Which filter should be added to this record to select those devices to which the area is assigned {{ states.light|selectattr('state','eq','on')|map(attribute='entity_id')| list }}
I should check what area_id(‘device_id’) in areas(), but I don’t see how to do it in a nice way.
Any solution on how to get a list of working lights (with assigned area) will also do.
Copy-paste the following template into the Template Editor and experiment with it.
{% set x = states.light
| selectattr('state', 'eq', 'on')
| map(attribute='entity_id')
| list %}
{% set y = x | map('area_name') | list %}
{{ zip(x, y) | list }}
If you want to display the results in a particular format then you’ll need to use a for-loop.
Perhaps my question was not worded accurately enough.
I will clarify the general task - to find out if there are switched on lights in the house, excluding various indicators to which no area is assigned ( A sub-variant of the task, the indicators are assigned an auxiliary area. And when checking, we exclude them based on that area).
Your example does not add any checks and returns objects without area