Selectattr or rejectattr based on a integration?

Hello,

i try to filter my results by a integration, i dont want the entiy_ids from the “Alexa Media Player” Integration.

my try was

| rejectattr('entity_id', 'in', integration['alexa_media_player'])

or

|rejectattr('entity_id', 'in', integration_entities('alexa_media_player'))

but got no success, is it not possible to filter with integration?

:thinking:

| rejectattr('integration', '==', 'alexa_media_player')

or

| rejectattr('integration', 'in', ['alexa_media_player'])

okay thank you, but my problem is i dont know the correct name of the integration, its a custom integration from hacs.

Unbenannt

i tried

“Alexa Media Player”
“alexa media player”
“alexa_media_player”
“Alexa_Media_player”

but get no entites with

{{ integration_entities('integration_name') }} 

i get it to work, its the name of the folder that hacs create of the integration, in my example

{{ integration_entities('alexa_media') }} 

In the screenshot you posted, you obscured the integration’s actual name (for privacy). Whatever it is, that’s the name you should use in the integration_entities() function.

{{ states.media_player
  | rejectattr('entity_id', 'in', integration_entities('The Name You Obscured In Your Screenshot'))
  | map(attribute='entity_id')
  | list
}}

For example, if I use Wemo it works but not if I use Belkin WeMo.

Screenshot_20221231-101041~2

3 Likes

thats a good hint, but the folder name from hacs integration works well too. But for all other integrations it must be the name, your way is really better to understand!
here is a code example that work.

|rejectattr('entity_id', 'in', integration_entities('[LG] webOS TV UM7050PLA'))

How would this look like to reject multiple integrations? Not just one.

It would look like this:

{{ states.media_player
  | rejectattr('entity_id', 'in', integration_entities('first integration') + integration_entities('second integration') + integration_entities('third integration'))
  | map(attribute='entity_id')
  | list
}}
1 Like