Change Switch Icon if On?

I have two workshop hanging lights controlled by MQTT wifi smart plugs. These are grouped together currently.

group:
  workshop_lights:
    name:  Workshop Lights
    entities:
      - switch.workshop_east_hanging_lights
      - switch.workshop_west_hanging_light
    icon: mdi:ceiling-light

On my dashboard, I have these showing where I can switch them on and off, but I’d also like the icon to change when turned on to be yellow like the “lights” that are on. Is there a way to do this?

Use the state_color option in your Lovelace entities card:

entities:
  - entity: group.workshop_lights
    state_color: true
  - etc...

Ok, when I do:

entities:
  - entity: light.living_room_lights
  - entity: light.front_patio_lights
  - entity: switch.jasco_products_12722_on_off_relay_switch_switch
  - entity: light.jason_office_lights
  - entity: group.workshop_lights
    state_color: true
  - entity: switch.jasco_products_12720_outdoor_smart_switch_switch
title: Lights / Power
type: entities

I get:

Expected a value of type {entity,name,icon} | entity-id for entities.4.state_color but received true.

Ok, along that path I changed it to:

entities:
  - entity: light.living_room_lights
  - entity: light.front_patio_lights
  - entity: switch.jasco_products_12722_on_off_relay_switch_switch
  - entity: light.jason_office_lights
  - entity: group.workshop_lights
  - entity: switch.jasco_products_12720_outdoor_smart_switch_switch
title: Lights / Power
state_color: true
type: entities

This still gets an error: Expected a value of type undefined for state_color but received true.

The weird thing is that some devices that didn’t change color before now do, but this one doesn’t. :face_with_raised_eyebrow:

I suspect this is a bug.

How about a light group instead, might behave differently?

You’d need to make the switches lights as well, presumably.

I don’t think I can make these into lights as they are smart plugs. I believe they were discovered as switches automatically.

That does look like a bug.

You can make light entities based on switches:

Are you using the GUI? If yes, this is a warning (yellow = warning) not an error. You’ll notice that your switches will now be yellow when on.

They are not.

what version are you on?

Working on latest on an entities card

Yours is using a switch entity directly. Mine was using a group. There appears to be a bug with groups not updating the state_color.

BTW, I made light entities out of the switches, grouped them as a light group, and it works great now.

Groups have more than on/off states, they have never worked with state_color. Groups can have home, not_home, sensor values, zone names, on, off, as states.