However I now need another automation to notify some days before the birthday. However, since states are always string, I cannot use arithmetic operators inside the selectattr.
Thus, I used map to extract the state and convert to int, before filtering.
Howerer, this gives me an array of state integer values, while a need the entire entities list instead.
I was wondering if there is a way to get this as a list directly, or at least to have a boolean array with [true, false] values to use then to filter the starting group instead.
You’re making this more complicated than it needs to be. There have been a few additions to the available template filters that make it even easier than shown in that prior post. Now we can just select items whose state attribute is in the list ['0', '1', '2', '3'] by using the is_state test.
If you wanted to check against a larger range of sequential numerical values, you can use a little trick to turn a range into a list of number strings, so you don’t have to type them all. A 10 day range would be as follows:
{% set my_range = range(0,11) | map('string') | list %}
{{ state_attr('sensor.faimily_birthdays', 'entity_id')
| select('is_state', my_range) | expand | list }}