I have some shutters which I do control by double relays.
At the moment I do use “delay” to automatically switch the relay off, after 30sec, otherwise it would be allways on until change of action.
switch:
- platform: gpio
id: open_relay
name: open ${device_name}
pin: 12
# interlock: [close_relay]
- platform: gpio
id: close_relay
name: close ${device_name}
pin: 14
# interlock: [open_relay]
# external switches
binary_sensor:
- platform: gpio
id: open_button
pin:
number: 4
inverted: true
on_click:
- min_length: 50ms # Short press
max_length: 500ms
then:
- switch.turn_off: close_relay
- switch.turn_on: open_relay
- delay: 30s # maximum time for open action plus some reserve
- switch.turn_off: open_relay
- min_length: 1000ms # Medium press / long
max_length: 5000ms
then:
- switch.turn_off: open_relay
- platform: gpio
id: close_button
pin:
number: 5
inverted: true
on_click:
- min_length: 50ms # Short press
max_length: 500ms
then:
- switch.turn_off: open_relay
- switch.turn_on: close_relay
- delay: 30s # maximum time for close action plus some reserve
- switch.turn_off: close_relay
- min_length: 1000ms # Medium press / long
max_length: 5000ms
then:
- switch.turn_off: close_relay
- platform: gpio
id: stop_button
pin:
number: 13
inverted: true
on_click:
then:
- switch.turn_off: close_relay
- switch.turn_off: open_relay
Probably you see, that I am a bloody beginner and that this ends up in a problem. Then after a few up/stop/down actions in a short timeframe it will send as well many stop actions, as well when they are not wanted.
now my question is:
Could someone please tell me a other possibility for a time limited action? (Maybe something with lambda?)
Or a possibility to reset the delay-timer, when the same action or a other action is triggered?
thanks in advance
(To control the shutter with “cover component” is no option for me. I did allready try this here, but the timing is absolutely useless if you do not open/close completely all the time.You end up with shutters stopping anywhere, but not where you want them)
The delay is fine, I’m not sure any other way is particularly better. The way I do it is to expose a number slider to let me dictate the delay and use a lambda to use that value in my delays, as such:
thanks a lot for your help.
I will try it with the “lambda code” and check, if there is any difference in the behavior of keeping the delayed stop-action after selecting “open/close” a few times in short time. But I´m afraid it stays the same.
How would this look as simple as possible only with a value directly in the lambda itself?
Another question:
Is there a command to interrupt “delay”?
Somebody on discourd gaved me the hint to put the actions to a script. And with the script parameters and actions ( mode: restart and stop.action) it is possible to reset and interrupt the delays.