Jinja: selectattr & map attribute

Hello,

Basically I would like to filter Twitch entities by “game”. Now I have the problem that I only get Undefined results with this example template:

{{ states
   |selectattr('entity_id','in', integration_entities('twitch'))
   |map(attribute='game')
   |list }}

When I remove the map line I can clearly see that the game attribute exists with a valid value. The same with any other attribute.

Originally I would like to achieve something like this

{{ states
   |selectattr('entity_id','in', integration_entities('twitch'))
   |selectattr('game','eq','Just Chatting')
   |count }}

What is wrong here?

{{ expand(integration_entities('twitch'))
   | selectattr('attributes.game', 'eq', 'Just Chatting')
   | list | count }}
2 Likes

Thank you!

The expand function seems very powerful. The solution was attributes.xxxxx.
Honostly I already didn’t got the difference between entity_id and a “real” attribute. And why selectATTR is not fetching “attributes” directly.
I still have to learn a lot. ^^

1 Like