mirror of
https://github.com/esphome/esphome.git
synced 2026-06-01 01:19:45 +08:00
[udp] Fix on_receive only processing first automation (#15538)
This commit is contained in:
@@ -130,12 +130,9 @@ async def to_code(config):
|
|||||||
if (listen_address := str(config[CONF_LISTEN_ADDRESS])) != "255.255.255.255":
|
if (listen_address := str(config[CONF_LISTEN_ADDRESS])) != "255.255.255.255":
|
||||||
cg.add(var.set_listen_address(listen_address))
|
cg.add(var.set_listen_address(listen_address))
|
||||||
cg.add(var.set_addresses([str(addr) for addr in config[CONF_ADDRESSES]]))
|
cg.add(var.set_addresses([str(addr) for addr in config[CONF_ADDRESSES]]))
|
||||||
if on_receive := config.get(CONF_ON_RECEIVE):
|
for conf in config.get(CONF_ON_RECEIVE, []):
|
||||||
on_receive = on_receive[0]
|
trigger_id = cg.new_Pvariable(conf[CONF_TRIGGER_ID])
|
||||||
trigger_id = cg.new_Pvariable(on_receive[CONF_TRIGGER_ID])
|
trigger = await automation.build_automation(trigger_id, trigger_argtype, conf)
|
||||||
trigger = await automation.build_automation(
|
|
||||||
trigger_id, trigger_argtype, on_receive
|
|
||||||
)
|
|
||||||
trigger_lambda = await cg.process_lambda(
|
trigger_lambda = await cg.process_lambda(
|
||||||
trigger.trigger(
|
trigger.trigger(
|
||||||
cg.std_vector.template(cg.uint8)(
|
cg.std_vector.template(cg.uint8)(
|
||||||
@@ -146,6 +143,7 @@ async def to_code(config):
|
|||||||
listener_argtype,
|
listener_argtype,
|
||||||
)
|
)
|
||||||
cg.add(var.add_listener(trigger_lambda))
|
cg.add(var.add_listener(trigger_lambda))
|
||||||
|
if config.get(CONF_ON_RECEIVE):
|
||||||
cg.add(var.set_should_listen())
|
cg.add(var.set_should_listen())
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user