Hi folks. I’m a long time C software engineer but pretty novice with yaml. I’m very confused by certain states, state displays, and colors in HA/Lovelace.
I’m trying to use custom:button-card so I can change the icon for the gate and the garage door when it’s open or closed. FYI, I have an insteon TriggerLinc (door sensor) on the gate and an Insteon Garage Door Kit (IO-Linc switch and sensor) on the garage, both connected to ISY994i, exposed to HA through the ISY994 integration.
I think my problem is that the cover.garage_door returns state values open and closed, and the icon stays white. Strangely, the raw sensor for the gate TriggerLinc seems to return on and off, which changes the icon to the standard on and off colors in the theme. This is what I would like to get on the garage door icon.
I don’t want to necessarily set them to explicit colors because if I change the theme it’ll be all wrong. So I either have to get a state value that produces the right colors, or maybe extract the theme’s on and off color values? I’ve done all kinds of searches and I can’t figure out how to get colors from the theme.
Now, really strangely, my TriggerLinc gate sensor seems to return on/off state (given the “if” conditions), but the state shown in the custom:button-card state label is open/closed. This is what has me totally confused. The garage cover template seems to go to great length to return state values of open and closed in order for the state display to say the right thing.
Bottom Line: How can I get the Garage Door icon (pictured in the middle below) to change to the right colors?
Here are my cards, followed by my card code and template code.
type: horizontal-stack
cards:
- type: 'custom:button-card'
entity: binary_sensor.gate_triggerlinc_open
name: Driveway Gate
show_state: true
state:
- value: 'on'
icon: 'mdi:gate-arrow-right'
- value: 'off'
icon: 'mdi:gate'
- type: 'custom:button-card'
tap_action:
action: toggle
entity: cover.garage_door
show_state: true
state:
- value: open
icon: 'mdi:garage-open'
- value: closed
icon: 'mdi:garage'
- type: button
tap_action:
action: toggle
entity: cover.garage_door
name: Garage
show_state: true
hold_action:
action: more-info
icon: 'mdi:garage'
cover:
- platform: template
covers:
garage_door:
device_class: garage
friendly_name: "Garage Door"
open_cover:
service: switch.toggle
data:
entity_id: switch.garage_door
close_cover:
service: switch.toggle
data:
entity_id: switch.garage_door
icon_template: >-
{% if (states.cover.garage_door.state) == "closed" %}
mdi:garage-open
{% else %}
mdi:garage
{% endif %}