Assume there is a list of entity_ids (not objects themselves):
- sensor.a
- sensor.b
- sensor.c
Some of these sensors have an attribute “some_attribute” with a “some_value” value.
I need to filter only these sensors.
I can do it like this (let’s just print each found entity_id for simplicity):
{% set ENTITY_IDS = ['sensor.a','sensor.b','sensor.c'] %}
{% for ENTITY_ID in ENTITY_IDS %}
{% if state_attr(ENTITY_ID,'some_attribute') == 'some_value' %}
{{ ENTITY_ID }}
{% endif %}
{% endfor %}
Surely, I need a list of these found entity_ids, not just a print out.
And this is NOT a problem, I may create a list and put each found entity_id into it.
The problem is - how to SIMPLIFY this code and use something like: