I am using cad-mod and have the following styling that changes the background when on.
Is it possible to assign the entity as variable that can be used in the styling as I want to use this across all light buttons and don’t want to have to retype the entity name each time.
Or… maybe there is a better way.
Thanks in advance.
type: custom:mushroom-light-card
entity: light.terrace_front_door_left
use_light_color: true
show_brightness_control: true
collapsible_controls: false
fill_container: false
secondary_info: state
tap_action:
action: toggle
hold_action:
action: more-info
card_mod:
style: |
ha-card {
background: {% if is_state('light.terrace_front_door_left', 'on') %}
{% set r = state_attr('light.terrace_front_door_left', 'rgb_color')[0] %}
{% set g = state_attr('light.terrace_front_door_left', 'rgb_color')[1] %}
{% set b = state_attr('light.terrace_front_door_left', 'rgb_color')[2] %}
rgba({{r}}, {{g}}, {{b}}, 0.4) !important
{% else %}
var(--card-background-color)
{% endif %};
}