Needed help with using themes for value-based coloring

I am trying to use the theme mechanism so as to enforce a value-based color scheme on specific set of entities.

My yaml config files contains the following line:

frontend:
  themes: !include_dir_merge_named themes

I am defining my target theme as follows:

theme1:
  state-binary_sensor-door-open-color: "#FF0000"
  state-binary_sensor-door-closed-color: "#008000"
  state-binary_sensor-smoke-open-color: "#FF0000"
  state-binary_sensor-smoke-closed-color: "#008000"
  state-binary_sensor-gas-open-color: "#FF0000"
  state-binary_sensor-gas-closed-color: "#008000"
  state-cover-open-color: "#ff0000"
  state-cover-closed-color: "#008000"
  state-media_player-inactive-color: "#795548"

In order to inject that theme into my environment, I inserted the above theme1 code into a new file “theme1.yaml” that I placed into the “themes” directory referred to in my config file.

I then tried deploying my theme1 in the definition of some of my lovelace cards, as follows:

type: custom:popup-card
entity: binary_sensor.zones_alarme
title: Zones
dismissable: true
card:
  type: entities
  state_color: true
  theme: theme1
  entities:
    - entity: binary_sensor.fumee
      icon: mdi:smoke-detector-variant
      name: Fumée (dét. panneau)
      theme: theme1
    - entity: binary_sensor.fumee_zigbee_avec_defaut
      icon: mdi:smoke-detector-variant
      name: Fumée escalier (zigbee)
      assumed_state: true
      theme: theme1
    - entity: binary_sensor.fumee_bureau_fumee
      icon: mdi:smoke-detector-variant
      name: Fumée salle exercice (wifi)
      assumed_state: true
      theme: theme1

Unfortunately, my theme1 definitions fail to be enforced.

Your suggestions will be very welcome…

Binary sensor can be on\off.

Also, the “theme” option is supported on a card level, not per row.

Thanks a lot: I should have guessed that.

Now my colors are indeed shown according to the entity values. However, the change is affecting the icon only, not the value. Is is possible to color the value at the same or independently?

It is only possible with card-mod. Ask in the main card-mod thread.

Understood, thanks a lot!