Climate state and cards

I’ve got a Google Nest thermostat that works great, the state can be either ‘heat’ or ‘off’. With my setup it never changes to off because it remains on heat when the temperature is reached and then becomes idle.

I’m trying to setup a card that changes when the heating is on but can’t seem to get it to work, it must be possible because the customer mushroom climate card does exactly that but I can’t figure out what it is using to identify the difference between heating and idle.

Any pointers would be greatly apprecaited.

You want to use hvac_action: as an attribute in your IF statement.

For example…

card_mod:
 style: |
   ha-card {
    background: {{ 'orange' if state_attr('climate.living_room', 'hvac_action') ==
      'heating' else ' black' }}
1 Like

That worked great, thanks.

Thank you for this information. I had been searching for days to figure out how to do this. However, I have one small question (I hope): can I use a hex color code instead of the color name?

Just use the hex code vs the color name.

card_mod:
 style: |
   ha-card {
    background: {{ '#FF0000' if state_attr('climate.living_room', 'hvac_action') ==
      'heating' else '#00FF00' }}
1 Like

Funny, I had tried this before, but apparently I had forgotten the apostrophe. It’s clear that I haven’t fully recovered from the New Year yet.

1 Like