How to use this strange type of attribute with indentation?

I am trying to retrieve an attribute state from a Evohome climate sensor, but I don’t recognise this type with indentation (or nested?):

I tried the solutions mentioned here: Working with nested attributes in a template?

But that doesn’t work:

Any suggestions? Thanks!

'{{states.climate.homeland.attributes.system_mode_status.mode}}
Should work.
M.

2 Likes

You should use the state_attr() method though, to prevent errors,

"{{ state_attr('climate.homeland', 'system_mode_status').mode }}"

See the warning box here: Templating - Home Assistant

Thanks for the quick reply, unfortunately both solutions do not work?


What does this return in the template editor:

{{ state_attr('climate.homeland', 'system_mode_status') }}

It returns None

This is the yaml, maybe that gives some clue?

hvac_modes:
  - 'off'
  - heat
min_temp: 7
max_temp: 35
preset_modes:
  - eco
  - Reset
  - away
  - home
  - Custom
current_temperature: 13.7
preset_mode: null
status:
  system_id: '6874715'
  active_system_faults: []
  system_mode_status:
    mode: Auto
    is_permanent: true
icon: mdi:thermostat
friendly_name: Homeland
supported_features: 16
"{{ state_attr('climate.homeland', 'status').system_mode_status.mode }}"
1 Like

YES! Thats it. Thanks a lot

1 Like

The lack of indentation in the dev-tools states display didn’t help!

Good call posting the formatted yaml.

I’ve set a bookmark to remind me to open a frontend issue about that.

1 Like

Another follow-up question, as I don’t really understand the notation of your solution: how can I use this in an if-then validation?

These are not working working

{{ is_state_attr('climate.homeland', 'status').system_mode_status.mode == "Auto" }}
{{ is_state_attr('climate.homeland', 'status').system_mode_status.mode, "Auto" }}

Because you are only accessing part of the attribute you cant use is_state_attr(), that returns the whole attribute. You have to do this:

  - if:
      - condition: template
        value_template: "{{ state_attr('climate.homeland', 'status').system_mode_status.mode == 'Auto' }}"
    then:
      - do something

Or using the condition template shorthand notation:

  - if:
      - "{{ state_attr('climate.homeland', 'status').system_mode_status.mode == 'Auto' }}"
    then:
      - do something

When the template resolves to true the then action is performed.

1 Like