Change background color of card depending of entity state

Does the ability to dynamically change background color of card depending of entity state?

I want to highlight several cards in critical states of linked entities.

You can change the background with card-modder. Create the same card twice with different colors and switch between them with the state-switch.

And then say thanks to @thomasloven :wink:

1 Like

Actually, It can be done without state-switch by using templates: https://github.com/thomasloven/lovelace-card-modder#templates

1 Like

Thanks for the help. Everything worked out.

But for some reason the card-modder does not see the card custom:vertical-stack-in-card. Instead of modifying it, it modifies the first card that included in it.

  - type: custom:card-modder
    style:
      background: "[[ sensor.nas_pool_pool1_health.attributes.card_bg_color ]]"
    card:
      type: custom:vertical-stack-in-card
      cards:
        - type: entities
          title: "NAS сервер"
          show_header_toggle: false
          entities:
            ...