Button with state of other entity (colour)

So,

  1. The card displays a sensor.
  2. Tapping → toggling some switch.
  3. You need to colorize the card’s icon dependently on this switch.

Since

  • the icon is for entity which is not a switch,
  • and you need to use a standard “button” card,

then your only possible option is card-mod:

  - type: button
    entity: sensor.xxx
    ...
    card_mod:
      style: |
        {% if is_state('switch.xxx','on') -%}
        ha-state-icon {
          color: var(--state-active-color) !important;
        } 
        {%- endif %}

Suggest to ask all card-mod related questions in the huge card-mod thread.

Or consider using other cards/solutions (like one posted above).

1 Like