So i have a time trigger for a binary sensor.
I want to do different things depending on how long it’s pushed for, but i want to start at less the 1 second trigger time.
So is it possible to use milliseconds in the trigger field, or even .5 of a second ?
- alias: 'Touch Pad trigger less than 1 second'
trigger:
platform: state
entity_id: binary_sensor.esp2_touchpad
from: 'off'
to: 'on'
for:
seconds: <1
action:
- service: scene.turn_on
entity_id: scene.bedroomdance
or
- alias: 'Touch Pad trigger before bedtime 2 seconds'
trigger:
platform: state
entity_id: binary_sensor.esp2_touchpad
from: 'off'
to: 'on'
for:
seconds: 0.5
action:
- service: scene.turn_on
entity_id: scene.bedroomdance
Don’t think you can do it this way.
what do you need to monitor and why is the time condition so important?
You could try and use a template condition and or a script to check how long the button was pressed for, something like:
or maybe 2 automations, one that triggers on button pressed, one that triggers on button released, then get the time difference between the 2 automations being triggered, but seeing as we’re in the milliseconds world, I’m not sure how accurate this will be…
Its only cause i want to turn the lights on in normal mode if touched i.e. pressed for less than a second.
Turn on dance/disco mode if pressed for 1-5 seconds
do something else if pushed for longer the 5 seconds.
Agreed that ESP8266 over wifi wouldn’t be highly accurate in the milliseconds world, but prob enough to to tell between 0.5 and 1 seconds
I hadn’t thought of templates, i’ll have to dig into what u’ve posted (as they are above my knowledge at the mo)
So if you have an ESP8266 to run it, set your commands in there? How does the ESP talk to HA? Is it was MQTT? If so maybe change your code to have an effect set up when the button is pressed and help?
I meant define your touchpad as an MQTT light instead of binary_sensor, then you can have more than on/off status (by using effects that you set up in the ESP when posting the message on the topic)
Thanks for the praise
I would think this is slightly different here and I would put part/most of the logic on the ESP code, and from the link you provided it appears you can set min and max times for presses, so see if you can add an if-then-else or a switch/case in there to define a status (on/off) and a substatus (mode, like “bedroomdance”) then post on MQTT the status and the effect. you’ll probably need to define an effect for “no effecT” as in simply On…
Hope that makes sense…
I’m running Hassio 98.5 and I tried using 500 milliseconds to flash a light on and off.It worked but appeared more like 1 second. So I shortened it to 250 and nothing happened. I bumped it to 300 and it worked again. Not sure why 250 won’t work though but it could be the latency in the shelly switch I’m using.