More examples in your templating documentation
jer78 opened this issue · 3 comments
The current documentation doesn't provide great examples. How come something like this won't work?
subtitle: >
[[[
return 'Current Temp: ' + states.[sensor.master_bedroom_temperature].state;
]]]
Try removing the dot after states and use quotes for your sensor name. Like so:
subtitle: >
[[[
return 'Current Temp: ' + states["sensor.master_bedroom_temperature"].state;
]]]
Also, I agree that there isn't enough explanation about the templating feature.
...
[[[
return states["sensor.my_sensor"].state;
]]]
It works, but when you try to use other attributes (name, friendly_name, etc.) it doesn't work
PS. Ops... Need use:
return states['person.serge'].attributes.friendly_name;
return states['person.serge'].entity_id
But for some reason, not all 'State Objects' work...
I apologize for my incapacity for such 'specific' logic
Indeed, that's the way to do it.
A handy tip is to use console.log
to see the contents of the variables in the web dev console. That helps a ton to wrap your head around the internal structure used by the Home Assistant Frontend.
What do you mean by "state objects" not working?