State label wont use my if statement for color

Hi I’m currently trying to get a state label to change the color inside a picture element
Have tried multiple different solutions from the forum, with no success

Does anyone have any suggestions?

Have tried the logic in the Template editor, and it works there

The color just stays white no matter what the output of the if statement

  - type: state-label
    entity: sensor.floor_thermostat_air_temperature_2
    tap_action:
      action: navigate
      navigation_path: /heat-living-room
    style:
      color: |-
        {% if state_attr('climate.floor_thermostat_6', 'hvac_action') ==
        "heating" %}
          red 
        {% else %} 
          green
        {% endif %}
      top: 50%
      left: 75%

Templates not supported here.
Your possible solution could be using card-mod to define a variable with a template, then use this variable for the “color” option.
Example.

Here is the final code

type: picture-elements
style: >-
  ha-card {
  --bathroom_heat: {% if state_attr('climate.floor_thermostat_6', 'hvac_action') =="heating" %} red {% else %} green {% endif %}
  }
elements:
  - type: state-label
    entity: sensor.floor_thermostat_air_temperature_2
    style:
      top: 50%
      left: 50%
      transform: scale(6)
      color: var(--bathroom_heat)
image: /local/photos/layout.png