Template cover for one button garage door

Hi,
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?

cover:
  - platform: template
    covers:
      garage_door:
        device_class: gate
        friendly_name: "Main gate"
        unique_id: tplMainGate
        value_template: false
        open_cover:
          - service: switch.turn_on
            target:
              entity_id: switch.yi_lu_hong_kong_kai_guan_switch_1
        close_cover:
          - service: switch.turn_off
            target:
              entity_id: switch.yi_lu_hong_kong_kai_guan_switch_1

I would like it to show opening from pressing for 15s, then 30s open, then 15s closing.

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.

1 Like

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.