Is_state_attribute never returning true

Hi,

I’m trying to add a condition to a template based on a nested state attribute and it simply isn’t working. I’m not sure what I’m doing wrong. The entity is:

hvac_modes:
  - 'off'
  - heat
min_temp: 4
max_temp: 28
preset_modes:
  - activity
  - boost
current_temperature: 18.9
temperature: 4
hvac_action: 'off'
preset_mode: null
status:
  type: radiator
  mode: override
  temperature: 18.860000610351562
  occupied: false
  override:
    duration: 360
    setpoint: 18
friendly_name: Kitchen
icon: 'mdi:radiator'
supported_features: 17

The template shows that the value can be found:

{{state_attr('climate.kitchen', 'status').mode }}

override

But the if statement isn’t returning true:

{% if is_state_attr('climate.kitchen','status.mode', 'override' )%}
override
{% else %}
not override
{% endif %}

not override

Where am I going wrong?

Many thanks,

Matt

You can’t get a nested attribute lile this with state_attr.

Try this:

{% if state_attr('climate.kitchen','status')['mode'] == 'override' %}
1 Like

Superb! Thank you very much, it’s been puzzling me for days and your code works a treat.