I need to turn off all media players but one in particular. How would you, guys, go about it? So far I have this simple service call and it works just fine. How would I add an exception?
This is how I do it. I use a get-entities node and then iterate over the array. By using the state is playing, I only get media players that are actually playing.
For your use case, you could just add a switch node after the spliter and if the msg.topic is the one you don’t want to stop, just skip over it.
sweet, thanks, @code-in-progress ! but how do i populate the downstream service call enity_id field so I have all media players that are being passed along from the switch node?
that’s precisely what I have but I get API error Here’s the whole thing - https://pastebin.com/0fbnc8c0
Not all media players support the turn_off service. Try it with the media_player.media_stop service and see what happens. None of my Sonos speakers support turn_off, for instance.
That’s not likely to be the problem because I had no issues originally with just the trigger_state->call service nodes, turn_off all media players was called without any problems. Now I get this:
Call-service API error. Error Message: not a valid value for dictionary value @ data['entity_id']
I’m confused as the switch node catches and passes on nicely an entity_id:
…it’s as if the service call node get an ill-formatted parameter for the entity filed
Ok, had to import your flow. You’re missing the splitter node. get-entities returns an array and that’s what is being passed in and causing the call-service api error.
You want your flow to look like this:
you da man! it works fine now, thanks so much!
Glad to be of help!