Jinjia question: how to filter a list of strings (entity_ids)

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:

ENTITY_IDS | selectattr('some_attribute','eq','some_value')

which seems to be not possible in this case since the ENTITY_IDS is a list of strings, not a list of objects.

{{ ENTITY_IDS | select('eq', 'somevalue') }}

This may be used to find by some entity_id:

{{ENTITY_IDS | select('eq','sensor.a') | list}}

which gives ‘sensor.a’.
What I need is to check an attribute.

Tried smth like

{{ ENTITY_IDS | select('state_attr','some_attribute','some_value') | list }}

with no success

{{ ENTITY_IDS | select('is_state_attr', 'someattr', 'somevalue') }}

Great, thank you!!

Is there any way to use “state_attr()” method here?
Just for educational purpose…

No, that’s only a filter. select requires a test as the first argument, so only tests will work as the first argument.

You can use map with state_attr, however it will then transform your list into the attributes values.

I do not understand properly how filters work.
This works:

{{ is_state_attr('sensor.a','some_attribute','some_value') }}

and this does NOT:

{{ 'sensor.a' | is_state_attr('some_attribute','some_value') }}

gives “TemplateAssertionError: No filter named ‘is_state_attr’.”

Same with this “person” entity:

{{ is_state('person.ildar','home') }}
{# {{ 'person.ildar' | is_state('home') }} #}

where the 2nd line does not work.

is_state_attr is a test, it’s not a filter, so it cannot be used like a filter. Same goes for is_state.

OK, thanks again! Need to learn it.