Cover template not updating state

I have a template which works fine in the developer tools, but when I open/close my garage door it does not update the state. I can’t seem for force the value template to re-evaluate. There are no errors in my log, and I see the correct state update when I watch the template in the developer tools. I had opening/closing states, but simplified it as the basic open/close doesn’t get updated when the contact switch changes.


cover:
  - platform: template
    covers:
      garage_door_right:
        friendly_name: "Garage Door Right"
        value_template: >
            {%- if is_state('binary_sensor.garage_door_right_contact', 'on') -%}
              open
            {%- elif is_state('binary_sensor.garage_door_right_contact', 'off') -%}
              closed
            {%- else -%}
              unknown
            {%- endif -%}
        open_cover:
          - wait_template: '{{ is_state("cover.garage_door_right", "closed") }}'
            timeout: '00:00:01'
            continue_on_timeout: 'false'
          - service: switch.turn_on
            entity_id: switch.garage_opener_right_2
        close_cover:
          - wait_template: '{{ is_state("cover.garage_door_right", "open") }}'
            timeout: '00:00:01'
            continue_on_timeout: 'false'
          - service: switch.turn_on
            entity_id: switch.garage_opener_right_2
        stop_cover:
          service: switch.turn_on
          entity_id: switch.garage_opener_right_2
        device_class: "garage"
        unique_id: "garage_door_right_ha"

I’m having the same issue, did you find anything useful?

I made a few updates, and it seems to be working now. If can get stuck in ‘closing’ state if the garage doesn’t actually close, which is almost a feature.

        friendly_name: "Garage Door Right"
        value_template: >
          {% set b_ts = now().timestamp() - as_timestamp(states.button.garage_door_right.last_changed) %}
          {% set s_ts = now().timestamp() - as_timestamp(states.binary_sensor.garage_door_right_access_control_window_door_is_open.last_changed) %}
          {%- if is_state('binary_sensor.garage_door_right_access_control_window_door_is_open', 'on') -%}
            {%- if s_ts < 12 -%}
               opening
            {%- elif b_ts < 12 -%}
               closing
            {%- else -%}
               open
            {%- endif -%}
          {%- else -%}
            closed
          {%- endif -%}
        open_cover:
          - wait_template: '{{ is_state("binary_sensor.garage_door_right_access_control_window_door_is_open", "off") }}'
            timeout: '00:00:01'
            continue_on_timeout: 'false'
          - service: button.press
            target:
              entity_id: button.garage_door_right
        close_cover:
          - wait_template: '{{ is_state("binary_sensor.garage_door_right_access_control_window_door_is_open", "on") }}'
            timeout: '00:00:01'
            continue_on_timeout: 'false'
          - service: button.press
            target:
              entity_id: button.garage_door_right
        stop_cover:
          service: button.press
          target:
            entity_id: button.garage_door_right
        device_class: "garage"

thank you. I finally got a decent cover working in esphome which is what i really wanted. I prefer having that fail safe if HA ever goes down. I’m curious though, what is b_ts? and s_ts? are those unique to your naming scheme or are they apart of timestamp function? I googled them with time stamp but didnt see anything from a quick search

I define them at the top of the template. Basically, after you press the button the door should be ‘opening’ or ‘closing’ as it’s neither ‘open’ or ‘closed’. My tilt sensor is at the top panel of the garage, so if it’s open 1 foot or more, then the sensor is ‘on’, but it may not be fully open yet.