I have an mqtt switch working on home assistant. The mqtt switch publishes a message with payload On and Off by watching a push button. So typically home assistant receives on immediately followed by off.
I’m now trying to do something on a long press AND short press. Is this possible? I know I can use an automation with a delay for the configuration of my long press but this will also trigger my short press even if I only want to trigger the long press.
I do this but I get ESPeasy to work out the long or short press, then send mqtt to Home Assistant.
Basically the initial press starts a timer.
If after the timer has finished, the button is no longer pressed : short press.
If the button is still pressed : long press.
The solution would be to create an automation with the trigger being that mqtt topic with payload ‘on’.
Your first action would be a 1 second delay ( so any press greater than 1 second is long ), then probably a templated ‘if’ looking to see if the payload is still ‘on’.
Sorry I can’t give you a better example but I’m away from my laptop ATM.
PS : That IOT module looks like a very fancy AND expensive piece of equipment. Any reason you are using that instead of something like a Wemos ?
This isn’t TASMOTA by any chance is it? By setting the following commands in my TASMOTA console, I got it to work: You have to have a “fire-on-release” type of push button rather than “fire-on-press”. All these commands are detailed here: https://github.com/arendst/Sonoff-Tasmota/wiki/Commands
switchtopic 0
switchmode 5
setoption1 1
setoption11 1
setoption32 20
rule on switch1#state=3 do publish [HOLD_MQTT_TOPIC] [HOLD_PAYLOAD] endon
rule 1
Then you can do whatever you want in HA with that new MQTT topic.
I don’t think the IoT module is a Tasmota (does Tasmota have something like the IoT module I posted? I could be wrong).
And @jivesinger: yes, it may be a bit pricey but I like the fact that it is a DIN module and that it’s wired by ethernet. Also, I still need to get my electricity certified, and I think the authorities will give me a hard time if I use a custom Wemos with some relays.
The notifier was easily integrated thanks to mqtt. For the relay module I had to create a custom component to control it but that was easy and I’m happy to share it if you want.
For the long press: it works but the short press is also fired.