How to use state_color?

In version 0.105, they changed how icon colors are displayed. https://www.home-assistant.io/blog/2020/02/05/release-105/#icons-no-longer-change-color-based-on-state

It mentions something about a state_color. How to use it? I cannot find anything about it in the documentation.


(One example)

Are there only a few components where I can enable it? I want to enable it for MQTT switches and MQTT binary sensors. Apparently, they don’t support this attribute.

It goes in the card config, not the integration config.

1 Like
entities:
  - entity: binary_sensor.ping_raspberry_pi3_rasp_usb
  - entity: binary_sensor.ping_ubiquiti_unifi
  - entity: binary_sensor.ping_tv_samsung_red
  - entity: binary_sensor.ping_corei7asere
  - entity: binary_sensor.ping_iphone_wifi
  - entity: binary_sensor.ping_tablet_galaxytaba
show_header_toggle: false
state_color: true
theme: AMOLED Blue
title: Status Red
type: entities

1 Like

Apparently, I was still using the old UI, so I had to switch to Lovelace first. Now it works.

Hi,
I am only 5 months in HA and the rapid development is sometimes overwhelming.
Now I am trying to get the state_color in again for some entities.

Am I right, that the above code needs to go in the button card via lovelace UI / YAML editor?
My 1st approach looks like this ( I guess ‘theme’,‘title’, etc are not required):

entities:
  - entity: switch.gelbmuell
show_header_toggle: false
state_color: true
entity: switch.gelbmuell
hold_action:
  action: more-info
icon: 'mdi:trash-can-outline'
icon_height: 30px
name: Gelbmüll
show_icon: true
show_name: true
tap_action:
  action: toggle
type: button

[Sorry on german keyboard at my acer it sometimes works with the code tag - sometimes not. It really knocks be down - any germans here who can help for multi line code ?]

But that won’t work.
Any idea how I can approach that?

Regards,
Joerg

So after a couple hours of reading several threads about state_color, at the end of the day are you only able to go back to the yellow or black?

I am in the process of taking load off my Vera and moving away from iRule, so I’m wrapping up week 1 of HA.

Using the state_color: true command doesn’t do anything for me. Honestly, don’t care about yellow.

With the recent changes, is that your only option or can you still use commands like

binary_sensor.back_door_20:
  templates:
  icon: mdi:icon
  rgb_color: "if (state === 'Closed') return [13, 212, 112]; else return [191, 22, 10];"

I’m very interested in the multi-color for states.

Thanks!

jwb