Hello,
I am trying to get my garage door icon to change with the status of open/closed. I have done this successfully with battery icons but the same code format is not working with my garage door. The only difference is that the garage door is already an entity (cover.garage_door) and I am not creating my own sensor from the data.
Battery Icon Code (this works):
- platform: template sensors: garage_door_battery: friendly_name: "Battery" value_template: "{{states.cover.garage_door.attributes.battery_level | round (0)}}" unit_of_measurement: '%' icon_template: '{% if (states.sensor.garage_door_battery.state) == "100" %} mdi:battery {% elif (states.sensor.garage_door_battery.state) >= "90" %} mdi:battery-90 {% elif (states.sensor.garage_door_battery.state) >= "80" %} mdi:battery-80 {% elif (states.sensor.garage_door_battery.state) >= "70" %} mdi:battery-70 {% elif (states.sensor.garage_door_battery.state) >= "60" %} mdi:battery-60 {% elif (states.sensor.garage_door_battery.state) >= "50" %} mdi:battery-50 {% elif (states.sensor.garage_door_battery.state) >= "40" %} mdi:battery-40 {% elif (states.sensor.garage_door_battery.state) >= "30" %} mdi:battery-30 {% elif (states.sensor.garage_door_battery.state) >= "20" %} mdi:battery-20 {% elif (states.sensor.garage_door_battery.state) >= "10" %} mdi:battery-10 {% else %} mdi:battery-alert {% endif %}'
Code in my covers.yaml:
- platform: template covers: garage_door: icon_template: '{% if (states.cover.garage_door.state) == "closed" %} mdi:garage {% else %} mdi:garage-open {% endif %}'
Enitity:
Front End: