Hi everyone.
I’ve read a number of threads trying to get my head around this, but struggling to find the right examples.
I have several Shelly switches around the house, integrated with Home Assistant using the Shelly integration (I haven’t ventured into MQTT yet but thinking I might have to in order to achieve what I’m aiming for…).
I’m using NodeRED for my automations and so far things are working fine for a single switch. Using an events:state node on each of my Shelly entities I have different devices and scenes firing. What I’d like to do now is if a switch is clicked twice quickly (that could be either on/off or off/on in quick succession) then a different action will be performed.
So far using a debug node I’m able to detect if the switch is on or off but not whether it’s a multi-click. I don’t know if this is something I can get out of the payload coming from the Shelly or if I need to build in some additional logic like:
- Fire with event:state
- Store the new state of the switch
- Wait 20 ms
- Check if switch is still in the new state
- if yes, then trigger the ‘single switch’ flow
- if no, trigger the ‘double switch’ flow on the assumption that the switch was flicked on and then off very quickly
This feels a bit clunky so I think I’m missing something and would appreciate any guidance anyone can provide.
Thanks in advance for your help!