Template and Sensors

I am having difficulty creating a sensor that tracks a cover entity despite studying the configuration pages and looking for examples. I only want this b/c I want to see “Open/Closed” on my dashboard similar to door/window sensors. I have a card that list several sensor entities and instead of a simple “Open/Closed” for the covers I get arrows indicating status of cover.

Here is the error I keep getting:

‘Invalid config for [template]: required key not provided @ data[‘trigger’]. Got None’

template:
  # Define state-based template entities
  - sensor:
      - name: "Matt Garage Door"
        state: >
          {% if is_state('states.cover.matt_garage_door', 'closed') %}
            closed
          {% elif is_state('states.cover.matt_garage_door', 'open') %}
            open
          {% else %}
            failed
          {% endif %}

You’ll get that error message if you are using an older version of Home Assistant (pre 2021.5.0) with that Template Sensor configuration. What version are you using?

oh man…I’ve been beating my head against the wall on this one…

core-2021.4.2.

I recently upgraded to 2021.6.2 but had to rollback b/c all my zwave.js stuff stopped working.

And that’s why you are seeing that message. That version only supported Trigger-based Template Sensors in the template configuration. The next version introduced support for non-Trigger-based Template Sensors.

@123 Thank you for the quick and helpful reply. I updated my core installation and after some config clean-up, everything was up and running.

For those interested, here is the final config I used

template:
  # Define state-based template entities
  - sensor:
      - name: "Matt Garage Door"
        state: >
          {% if is_state('cover.matt_garage_door', 'closed') %}
            Closed
          {% elif is_state('cover.matt_garage_door', 'open') %}
            Open
          {% else %}
            Alert
          {% endif %}
        icon: >
          {% if is_state('cover.matt_garage_door', 'closed') %}
            mdi:garage
          {% elif is_state('cover.matt_garage_door', 'open') %}
            mdi:garage-open
          {% else %}
            mdi:garage-alert
          {% endif %}

You’re welcome!

Please consider marking my post above with the Solution tag. It will automatically place a check-mark next to the topic’s title which signals to other users that this topic has been resolved. This helps users find answers to similar questions.