I don’t need the actual color of the device, and I think that’s what ‘state_color’ would provide?
I’ve hit upon this as a solution:
- entity: light.pillars
icon: mdi:pillar
card_mod:
style: |
:host {
--card-mod-icon-color: {% if is_state(config.entity, 'on') %} rgb(var(--rgb-state-switch-color)) {% else %} var(--state-icon-color) {% endif %};
}
It’s checking the state of the device, if it’s on or anything else (which assumes off) and then using the page variables of rgb-state-switch-color for the on icon color, and state-icon-color for off. Note, the text in the variable rgb-state-switch-color is a triplet, thus the rgb() wrapper. The text in state-icon-color is a #hex color and thus needs no wrapper to convert it.
My question now is are these the ‘correct’ variables to be using here? Or are there some other variables set as part of the theme used to create the page?