For the life of me, I just can not get this to work. Can anyone see what’s wrong with it?
- name: last_assistant
unique_id: last_assistant
state: >
{{
expand(label_entities('Jarvis')) |
sort(attribute='last_changed') |
map(attribute='entity_id') |
list |
last |
area_name()
}}
attributes:
area_id: >
{{
expand(label_entities('Jarvis')) |
sort(attribute='last_changed') |
map(attribute='entity_id') |
list |
last |
area_id()
}}
The configuration looks fine, so the two remaining common failure points are:
- You don’t have any entities labelled “Jarvis”. Double check the spelling.
- The configuration has been pasted into the wrong place. Please describe where you have placed this configuration.
I just copied his code here, the entity is fine (I have changed it in my setup).
I’ve placed it under template sensors. So it should look as follows (sorry for not including in the first example)
- platform: template
sensors:
- name: last_assistant
unique_id: last_assistant
state: >
{{
expand(label_entities('Jarvis')) |
sort(attribute='last_changed') |
map(attribute='entity_id') |
list |
last |
area_name()
}}
attributes:
area_id: >
{{
expand(label_entities('Jarvis')) |
sort(attribute='last_changed') |
map(attribute='entity_id') |
list |
last |
area_id()
}}
Now that I’ve looked at his code again, he’s said that it should go under
template:
- sensor:
Could I be right in thinking that he’s intentionally leaving mistakes in the code so that you’ll have to join his site and then get the actual code? Maybe I’m being paranoid, it’s also possible I’m losing my mind. I’m sort of housebound currently due to a broken leg …
No, he is using the current format which is placed under the top-level key template
and uses different configuration keys. You have pasted it where it would go if you were using the legacy format.
If you are going to set it up in the legacy format it would be configured under the top-level key sensor
and be:
- platform: template
sensors:
last_assistant:
friendly_name: "Last Assistant"
value_template: >
{{
expand(label_entities('Jarvis')) |
sort(attribute='last_changed') |
map(attribute='entity_id') |
list |
last |
area_name()
}}
attribute_templates:
area_id: >
{{
expand(label_entities('Jarvis')) |
sort(attribute='last_changed') |
map(attribute='entity_id') |
list |
last |
area_id()
}}
ah! Fair enough. My system has been going for over 6 years, so there’s probably a lot of legacy code in there. One of these days, I’m going to have to take a look at that. Hopefully this solves it, as I’ve been spinning my wheels for a few hours now.
Hmm, I did a quick configuration check prior to reloading the yaml config, and it won’t complete … which is strange, and not something I’ve come across before. So obviously I won’t be reloading until I can solve this one … ugh
I think the -
before last_assistant:
is incorrect (it’s been a while since I used that format), I’ve corrected it in the previous post.
I caught that, and removed it. So that’s not the problem. I’ve no doubt the problem is on my end somewhere … it usually is. I’ll figure it out at some point. It’s just frustrating that he gives two examples of doing the same thing, but in his automation he only uses one example (the one that’s currently not working for me …)