stevemann
(Stephen Mann (YAML-challenged))
June 27, 2022, 2:46am
1
I am trying to use the template tool in Developer Tools to learn more about using templates.
If I enter:
Office light is on? {{ is_state(‘switch.officelight’, ‘on’) }}
It correctly returns True or False.
If I enter:
{{ light.steve_desk_light }}
I get:
UndefinedError: ‘light’ is undefined
Likewise:
sensor.disk_use_percent = {{sensor.disk_use_percent}}
returns:
UndefinedError: ‘dict object’ has no attribute ‘freezer_temperature_c’
Am I doing something wrong or does the template tool not have scope to my states?
tom_l
June 27, 2022, 2:49am
2
You can’t just supply the entity id and expect to get back the state. You need to ask for the state of the entity, like this:
{{ states('light.steve_desk_light') }}
Or ask for an attribute value, like this:
{{ state_attr('light.steve_desk_light', 'brightness') }}
Note that example will only work if the light is on.
stevemann
(Stephen Mann (YAML-challenged))
June 27, 2022, 3:18am
3
Thanks. I’ll stumble through more tomorrow…
tom_l
June 27, 2022, 3:47am
4