With an automation itās reasonably straightforward to do what youāre asking there. In rough steps:
- Create a timer object
- Watch MQTT topic
hasp/[your plate name]/state/json
. A button press looks like this: {"event_type":"button_short_press","event":"p[1].b[5]","value":"ON"}
- condition template:
{{trigger.payload_json.event_type == "button_short_press"}}
- reset your timer
When the timer expires, you can issue the command to go to your idle page.
Soā¦ why donāt I have a blueprint that does this for you already?
First, blueprints cannot create a timer object, so a user would have to create one with the correct name first which isā¦ likely to break. I could make one and have the user create their own timer, and then enter the name, but thatās really clunky and Iād like to avoid people having to go edit configuration.yaml
if at all possible.
HOWEVER, there is another way to make this happen. Automation mode set to restart
will stop execution of an automation and restart it if triggered again. So, create a trigger like the one above, have the first action in the sequence be a delay (60sec or whatever), and then any additional incoming messages simply reset the entire automation. If it finally makes it past the delay without being reset, then switch to your default page.
Problem here is that without MQTT topic filters, itās going to catch a lot more things than just button presses from a single HASP. It will catch all messages from all HASPs instead. I expect the next release of Home Assistant is likely to include this PR, which will let me publish a solution that should work like youād expect.
Finally, Iāve also noticed the WiFi behavior and I canāt for the life of me figure out why. I can reset the device 10 times w/ the reset button, and one of those times it will not connect. Reset again and it connects right away. I am working on a cheap hack for this - attempt the first connection, if it fails, manually reset the radio, try to connect, if fail, repeat a few times, and then eventually give up. That approach appears to be working, if I run into whatever edge case is causing the initial connection to fail, resetting the radio allows it to connect the second time. Using the exact same sequence, but without resetting the radio, fails to connect no matter how many times you try.