mirror of
https://github.com/esphome/esphome.git
synced 2026-05-12 10:08:47 +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":
|
||||
cg.add(var.set_listen_address(listen_address))
|
||||
cg.add(var.set_addresses([str(addr) for addr in config[CONF_ADDRESSES]]))
|
||||
if on_receive := config.get(CONF_ON_RECEIVE):
|
||||
on_receive = on_receive[0]
|
||||
trigger_id = cg.new_Pvariable(on_receive[CONF_TRIGGER_ID])
|
||||
trigger = await automation.build_automation(
|
||||
trigger_id, trigger_argtype, on_receive
|
||||
)
|
||||
for conf in config.get(CONF_ON_RECEIVE, []):
|
||||
trigger_id = cg.new_Pvariable(conf[CONF_TRIGGER_ID])
|
||||
trigger = await automation.build_automation(trigger_id, trigger_argtype, conf)
|
||||
trigger_lambda = await cg.process_lambda(
|
||||
trigger.trigger(
|
||||
cg.std_vector.template(cg.uint8)(
|
||||
@@ -146,6 +143,7 @@ async def to_code(config):
|
||||
listener_argtype,
|
||||
)
|
||||
cg.add(var.add_listener(trigger_lambda))
|
||||
if config.get(CONF_ON_RECEIVE):
|
||||
cg.add(var.set_should_listen())
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user