With the changes this PR introduced in 2022.4, if an operation is called for an entity that does not support it an error is raised. While this is obviously good from from a programming structure stand point, it is particularly problematic for media players.
I have a script that turns off all media players when I leave this house. I select which media players need to be turned off by iterating the states object to determine what media players are actually on, or playing.
{{ states.media_player|selectattr('state','in','on','home','idle','playing','paused','idle'])
|map(attribute='entity_id')|list }}
In this case, if a browser_mod media player happens to be playing, this script now will now raise an error because browser players do not support media_player.turn off.
We need to be able to filter out unsupported entities when calling an operation. In the case of media players, the supported operations are noted in the supported_features attribute which is a bitfield. but unfortunately there is no bitfield_and test (however, there is a bitwise_and filter).
As a workaround I have created custom attributes for all of my existing media players to indicate support for off, pause etc so I have something to filter the entities with. This is a kludgy workaround though - customized attributes must be updated every time a media player is added/removed.
This workaround is also limited in that the attributes are not dynamic. So for example, a chormecast supports media_pause most of the time when playing media, but if you are casting a dashboard it does not and will now fail if media_pause is called.
ERROR (MainThread) [homeassistant.components.automation.media_player_auto_pause] Error while executing automation automation.media_player_auto_pause: Entity media_player.living_room_chromecast does not support this service.
We need a bitwise_and test so we can reliable select media players the support the current operation without kludgy workarounds!
{{ states.media_player|selectattr('state','in','on','home','idle','playing','paused','idle'])
|selectattr('attributes.supported_features','bitwise_and',1)
|map(attribute='entity_id')|list }}