I’m trying to do the following in an automation using templates but I’m not sure how exactly to do that So any help would be appreciated.
Automation to stop all the media players
- If presence changes from home to not_home
- Loop the media_player domain and find the players that have state playing
- Stop one by one the players with state playing
I guess the step 2 I can do it with a template sensor that returns that at least one player is active.
And probably I can iterate the media_player domain in the action of the automation and stop the ones that have state playing?
Of course there is also the alternative to have all the media_player one by one in the automation and stop them even if they are not active. But I’m trying to find a way that I don’t have to update an automation every time that I’m adding a new media_player.