riko
(Rik)
1
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!
kCologne
(Michael Kraft)
2
'{{states.climate.homeland.attributes.system_mode_status.mode}}
Should work.
M.
2 Likes
tom_l
3
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
riko
(Rik)
4
Thanks for the quick reply, unfortunately both solutions do not work?
tom_l
5
What does this return in the template editor:
{{ state_attr('climate.homeland', 'system_mode_status') }}
riko
(Rik)
6
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
tom_l
7
"{{ state_attr('climate.homeland', 'status').system_mode_status.mode }}"
1 Like
riko
(Rik)
8
YES! Thats it. Thanks a lot
1 Like
tom_l
9
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
riko
(Rik)
10
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" }}
tom_l
11
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