Skip to main content

Shortcut: Join Playing Sonos

I have Sonos speakers around my house and I like listening to music as I move around. For example, I'll often start listening to music in the shower (using the Sonos Move) and then want to continue listening in the living room after I'm done.

In order to avoid having to use the slow Sonos iOS app to join speakers, I've built a Shortcut powered by Home Assistant to quickly join a new speaker to the currently playing speaker.

To power it, I created a Home Assistant script called join_playing_sonos which identifies the currently playing Sonos speaker and then uses media_player.join in order to join in another speaker which is passed as input (a.k.a. a field) to the script.

Now that we have a way to easily make Home Assistant identify the currently playing speaker and group another speaker with it, we just need a way to run the script from Shortcuts. Fortunately the Home Assistant Companion app on iOS (and macOS) exposes a "Call Service" action which we can use.

Screen shot of Shortcuts action 'Call `script.join_playing_sonos` with data'

We just need to pass in the target media player as input JSON. Unfortunately I haven't found a really clean way to do this in Shortcuts: I tried setting variables in a Dictionary and passing them in as input, but for some reason that didn't work.

To tie it all together, I use "Choose from Menu" in order to create a dropdown of speakers and to call the service with the correct input for each speaker. It's a bit repetitive, but it's not so bad if you copy/paste the action over and over.