I have a button. Pressing it initiates the opening of the gate. I don’t have any sensors, pressing the only thing it does is open (while closing, it interrupts closing and opens again).
What I have now only shows
closed. What should I write in
value_template to show something different depending on the elapsed time?
- platform: template
friendly_name: "Main gate"
- service: switch.turn_on
- service: switch.turn_off
I would like it to show
opening from pressing for 15s, then 30s
open, then 15s
What you should do is place a $5 sensor on the door and use that in the value template. Or better yet two of them (one for open, one for closed).
Any door/window contact sensor will do.
If you want to do it without a sensor, you’d have to build the logic. If you just want an assumed state (without opening/closing for 15 seconds) remove the value_template.
@tom_l this is the entrance gate to the estate, it is outside the range of my network.
@petro If I remove
value_template, the gate will always be open after opening. Even when it closes after some time, it still shows as open.
Can I add some kind of countdown in
value_template so that it shows closed again after some time after opening?
No, you have to build the logic yourself if you want any complex timing for state changes. You’d build it by using a helper entity that stores what you currently want, and your open_cover / close_cover action sections would need to handle all the state changes on the helper entity. Lastly, your value_template would pull the state of the helper entity. There is no way around this.
How are you controlling it?
@tom_l there is a pair of wires common to each house. Its short circuit gives the signal for the gate to open.