I’ve been trying to get a MagiQuest wand to send an IR signal to an Atom Lite with an attached IR receiver/transmitter. My end goal is to turn a light on/off in Home Assistant when the IR receiver receives a signal from the wand. Here is the yaml I have so far:
remote_receiver:
pin:
number: GPIO32
inverted: true
dump: magiquest
binary_sensor:
- platform: remote_receiver
name: 'Green Wand'
magiquest:
wand_id: 0x02xxxxxx
I see the wand/IR events in the ESPHome logs for the device:
[10:42:54][D][binary_sensor:036]: 'Green Wand': Sending state ON
[10:42:54][D][binary_sensor:036]: 'Green Wand': Sending state OFF
I am not sure where to go from here though to get the above binary_sensor state into Home Assistant. I’m also not sure if it will pose a problem that the state is changed to ON, then immediately OFF? Any guidance would be appreciated, thank you!
Have you added the device to HA via the integrations page?
You could also try setting the internal: false flag.
And there’s the delayed off to change the momentary behaviour or debounce it.
I think the delayed_off filter is what I was missing, thank you! I forgot to mention that I did add the device in HA via the integrations page. I also see the state change from off to on to off in the Dev Tools in HA.
What is an appropriate value to start with for delayed_off? I have tried 1s, 5s, and 100ms, but it just delays sending the OFF state because ON is received first? I also tried using delayed_on and delayed_on_off with various values, but was not getting the expected result, which is persisting the on state. Thanks!
Do you know the lights true state? Or do you rely on the ir code having worked?
Should the code toggle the light or is there a separate code for on/off?
If you don’t want a momentary binary sensor you may be better off with a template switch with assumed_state and optimistic_mode.
Yes, HA knows the lights state if that’s what you mean.
TBH I’m not sure if the code should toggle the light or if there is separate code for it, but I’m willing to implement whatever works best. I’m not real well versed in coding yet, I’m picking up bits as I move along. I have used templates in frontend cards, if a template switch is similar.
Perhaps as a next step you just implement an automation in HA:
Trigger is the binary sensor changes from off to on.
Action is toggle the light.
Get that working and see if it functions as you like?
You know, I didn’t even think about reversing my logic to go from off to on and just using a toggle. I put it all together this morning, and it worked.
Thank you for walking through this with me!
1 Like