fix triggers

This commit is contained in:
NP v/d Spek 2024-09-24 17:06:48 +02:00
parent 167dcef1e6
commit b6f53a6dba

View file

@ -11,6 +11,7 @@ ESPNowComponent = espnow_ns.class_("ESPNowComponent", cg.Component)
ESPNowListener = espnow_ns.class_("ESPNowListener") ESPNowListener = espnow_ns.class_("ESPNowListener")
ESPNowPacket = espnow_ns.class_("ESPNowPacket") ESPNowPacket = espnow_ns.class_("ESPNowPacket")
ESPNowPacketPtr = ESPNowPacket.operator("ptr")
ESPNowInterface = espnow_ns.class_( ESPNowInterface = espnow_ns.class_(
@ -93,21 +94,17 @@ async def to_code(config):
trigger = cg.new_Pvariable(conf[CONF_TRIGGER_ID], var) trigger = cg.new_Pvariable(conf[CONF_TRIGGER_ID], var)
await automation.build_automation( await automation.build_automation(
trigger, trigger,
[(cg.std_shared_ptr.template(ESPNowPacket), "packet"), (bool, "status")], [(ESPNowPacketPtr, "packet"), (bool, "status")],
conf, conf,
) )
for conf in config.get(CONF_ON_RECEIVE, []): for conf in config.get(CONF_ON_RECEIVE, []):
trigger = cg.new_Pvariable(conf[CONF_TRIGGER_ID], var) trigger = cg.new_Pvariable(conf[CONF_TRIGGER_ID], var)
await automation.build_automation( await automation.build_automation(trigger, [(ESPNowPacketPtr, "packet")], conf)
trigger, [(cg.std_shared_ptr.template(ESPNowPacket), "packet")], conf
)
for conf in config.get(CONF_ON_NEW_PEER, []): for conf in config.get(CONF_ON_NEW_PEER, []):
trigger = cg.new_Pvariable(conf[CONF_TRIGGER_ID], var) trigger = cg.new_Pvariable(conf[CONF_TRIGGER_ID], var)
await automation.build_automation( await automation.build_automation(trigger, [(ESPNowPacketPtr, "packet")], conf)
trigger, [(cg.std_shared_ptr.template(ESPNowPacket), "packet")], conf
)
for conf in config.get(CONF_PEERS, []): for conf in config.get(CONF_PEERS, []):
cg.add(var.add_peer(conf.as_hex)) cg.add(var.add_peer(conf.as_hex))
@ -160,7 +157,7 @@ async def send_action(config, action_id, template_arg, args):
@automation.register_action( @automation.register_action(
"espnow.new.peer", "espnow.peer.new",
NewPeerAction, NewPeerAction,
cv.maybe_simple_value( cv.maybe_simple_value(
{ {
@ -178,7 +175,7 @@ async def new_peer_action(config, action_id, template_arg, args):
@automation.register_action( @automation.register_action(
"espnow.del.peer", "espnow.peer.del",
DelPeerAction, DelPeerAction,
cv.maybe_simple_value( cv.maybe_simple_value(
{ {