How do you use attribute for state_image in a picture-card?

Help please? I’m trying to show a different image if my generic thermostat is idle or heating. Those are attributes and I can’t seem to reference them.

Tried this - didn’t work

  - type: image
    variables:
     - 'states[''climate.thermostat_office''].attributes.hvac_action'
    entity: climate.thermostat_office
    image: /local/thermo/thermostat.png
    state_image:
      heating: /local/thermo/thermostatON.png
      idle: /local/thermo/thermostatOFF.png
    style:
      top: 28%
      left: 48.5%

Tried this and also didn’t work:

  - type: image
    entity: climate.thermostat_office.hvac_action
    image: /local/thermo/thermostat.png
    state_image:
      heating: /local/thermo/thermostatON.png
      idle: /local/thermo/thermostatOFF.png
    style:
      top: 28%
      left: 48.5%

@lkeays
What card are you using as type ‘image’ is not a good name?
You might try a picture glance card which has state_image controls.

If it is part of a Picture Elements card you would use this as per docs
https://www.home-assistant.io/lovelace/picture-elements/

state_image:
  "on": /local/living_room_on.jpg
  "off": /local/living_room_off.jpg

Hi,

Yes, it is indeed a picture elements. The trouble is not the state_image. It’s using the attribute “hvac_action” from “climate.thermostat_office” to set the state.
At the moment, I created a another sensor template based on the attribute I need but I find this is really going around the world to cross the road.

Hello, did you found a solution for this ? I face the same problem and try to find a good way? thx

Apologies for not being much helpful - I think I sticked with making the other sensor just to bring the status into the state. But it’s a bit of a while ago…