Garage Door State Shows as On/Off instead of Open/Closed

I have a cover template that used to work well but since around a month again I no longer see open/closed; instead it’s on/off.

Here’s the YAML in my configuration.yaml file. What’s interesting is that the icon template works fine so the icons are correct but for some reason it’s not using open/closed from the value template. Any idea what I’m doing wrong here?

cover:
  platform: template
  covers:
    left_garage_door:
      device_class: garage
      friendly_name: "Left Garage Door"
      value_template: >-
       {% if is_state('binary_sensor.left_garage_door_sensor_state_any','on') %}
         open
       {% else %}
         closed
       {% endif %}
      open_cover:
        service: switch.turn_on
        data:
          entity_id: switch.left_garage_door_switch_0
      close_cover:
        service: switch.turn_on
        data:
          entity_id: switch.left_garage_door_switch_0
      stop_cover:
        service: switch.turn_on
        data:
          entity_id: switch.left_garage_door_switch_0
      icon_template: >-
       {% if is_state('binary_sensor.left_garage_door_sensor_state_any ' , 'on') %}
         mdi:garage-open-variant
       {% else %}
         mdi:garage-variant
       {% endif %}

The translation of the state from on/off to open/closed comes from the device class. Not the value template.

As you have no position template the value template can be reduced to:

      value_template: "{{ is_state('binary_sensor.left_garage_door_sensor_state_any','on') }}"

Okay, so I replaced that and it’s still showing on/off instead of open/closed. I’m using button-card, by the way. I’m not sure if that matters. It shows correctly if I just create an entity card for the sensor.

cover:
  platform: template
  covers:
    left_garage_door:
      device_class: garage
      friendly_name: "Left Garage Door"
      value_template: "{{ is_state('binary_sensor.left_garage_door_sensor_state_any','on')}}"
      open_cover:
        service: switch.turn_on
        data:
          entity_id: switch.left_garage_door_switch_0
      close_cover:
        service: switch.turn_on
        data:
          entity_id: switch.left_garage_door_switch_0
      stop_cover:
        service: switch.turn_on
        data:
          entity_id: switch.left_garage_door_switch_0
      icon_template: >
        {% if is_state('binary_sensor.left_garage_door_sensor_state_any ' , 'on') %}
          mdi:garage-open-variant
        {% else %}
          mdi:garage-variant
        {% endif %}

Core or custom button card?

Sorry, custom button card.

As a third party frontend resource you will have to take that up with the developer, however that particular card has a lot of bugs and is no longer being actively maintained.

Hi.

I scraped together some code from a few posts to knock up this,
hopefully it’s of use. It shows ‘open’ and ‘closed’, and changes the icon colour and type

type: horizontal-stack
cards:
  - type: custom:mushroom-template-card
    primary: |
      {% set state=states('binary_sensor.lhs_garage_door_input') %}
      {% if state=='on' %}
      Open
      {% elif state=='off' %}
      Closed
      {% else %}
      ERROR
      {% endif %}
    secondary: Left Garage
    icon: |-
      {% set state=states('binary_sensor.lhs_garage_door_input') %}
      {% if state=='on' %}
      mdi:garage-open
      {% elif state=='off' %}
      mdi:garage
      {% else %}
      mdi:garage-alert
      {% endif %}
    entity: binary_sensor.lhs_garage_door_input
    icon_color: |-
      {% set state=states('binary_sensor.lhs_garage_door_input') %}
      {% if state=='off' %}
      green
      {% elif state=='on' %}
      red
      {% else %}
      yellow
      {% endif %}
    layout: vertical
    multiline_secondary: false
    tap_action:
      action: call-service
      service: switch.turn_on
      data: {}
      target:
        entity_id: switch.lhs_garage_door
  - type: custom:mushroom-template-card
    primary: |
      {% set state=states('binary_sensor.shelly1_xxxx_input') %}
      {% if state=='on' %}
      Open
      {% elif state=='off' %}
      Closed
      {% else %}
      ERROR
      {% endif %}
    secondary: Right Garage
    icon: |-
      {% set state=states('binary_sensor.shelly1_xxxx_input') %}
      {% if state=='on' %}
      mdi:garage-open
      {% elif state=='off' %}
      mdi:garage
      {% else %}
      mdi:garage-alert
      {% endif %}
    entity: binary_sensor.shelly1_xxxx_input
    icon_color: |-
      {% set state=states('binary_sensor.shelly1_xxxxx_input') %}
      {% if state=='off' %}
      green
      {% elif state=='on' %}
      red
      {% else %}
      yellow
      {% endif %}
    layout: vertical
    multiline_secondary: false
    tap_action:
      action: call-service
      service: switch.turn_on
      data: {}
      target:
        entity_id: switch.shelly1_xxxx

That’s great! Thank you very much!

Any change there is a way to change the size of the icon with this?

just stick it in its own card or something - this is the size in my WIP dash - those are standard chips to the right , HA seems to default to 3 columns total so these two take one column

Almost there. I just want to remove the border around the icon and add something for when the button is being pressed. I’ll keep playing around with this and see what I can work out. Here’s what I have so far, though.

image