Hi,
I’m trying to filter out temperature
entities for one area. The documentations says it can be used as a filter:
area_entities(area_name_or_id)
returns the list of entity IDs tied to a given area ID or name. Can also be used as a filter.
Since the returned list is just a list of strings, not state objects, there doesn’t seem to be an easy way of filtering based on device_class
.
Anyone have a suggestion?
The closest I can come up with is
{% set entities = namespace(list=[]) %}
{% for entity in area_entities('Living room') if state_attr(entity.entity_id, 'device_class') == 'temperature' %}
{% set entitites.list = entities.list + [ entity.entity_id ]
{% endfor %}
{{ entities.list }}
But a one-liner using the selectattr
would be much cleaner and easier to maintain.