Create "Jukebox" Dashboard with Album Art for Echo or Sonos Devices

So how do I get one tap on my dashboard to start playing on multiple Sonos devices in a group?

Unfortunately, neither Hubitat or SmartThings’ Sonos integration supports grouping natively.

If I remember correctly, you’re on Hubitat. Check out the posts in the following thread to see if they work for you. It sounds like some people are using the custom node-sonos-http-api, but this particular post about using a special setTrack() format in order to get existing players to join the group of another player (without other external code) seems particularly interesting:

2 Likes

Hi all, I am a new sharptools user. My amazon music setup is that I have 2 echo dots paired as left and right channels across the room from each other. I use voice commands to play music primarily from tune-in radio and amazon music. I came across a youtube video for “Creating a Smart Music Command Center | Sharptoold Dashboards” ( https://www.youtube.com/watch?v=Vz8bzMLz224&t=34s ). I liked the Idea of having presets to play my favorite music. After having difficulties getting it to work, I unpaired the speakers and I successfully setup the music center using 1 speaker.

I later found another video “Automate Multi-Room Music on Alexa Groups | SmartThings & SharpTools” ( https://www.youtube.com/watch?v=YcHr0L-UKwY&feature=youtu.be ). That gave me hope that I could at least use both speakers, even if not a stereo pair. This is not working out for me. I am hoping someone can help me solve this.

The difference in the rule is supposed to be as follows:

Single speaker rule

 (select Device = speaker1, select command = searchAmazonMusic, string = artist1)

Speaker Group rule

 (select Device = speaker1, select command = searchAmazonMusic, string = artist1 on group1)

Test1 = Orig working rule test1 says:

(select Device = speaker1, select command = searchAmazonMusic, string = artist1)

Results = sharptools reports exec rule / speaker lights up white / music plays

I then created speaker group using speaker1 and speaker2 called Group1

I Ran command vocally - play artist1 on Multigroup1

results = music plays on the group and alexa presents vol control for each speaker within the group.

Test2 = New rule test2 says:

 (select Device = speaker1, select command = searchAmazonMusic, string = artist1 on group1)

Results = sharptools reports exec rule / speaker does not respond.

Test3 = New rule test3 says:

  *  I added a trigger device  ( Virtual Switch 1 - switch changes to 'on') as presented in the 2nd video

 (select Device = speaker1, select command = searchAmazonMusic, string = artist1 on group1)

Results = sharptools reports exec rule / speaker does not respond.

Is anyone able to provide different results? Thx in advance.

Hi @johnm93359, welcome to the community and SharpTools family. Unfortunately, it appears Amazon Echo MRM (multi-room music) may have a weird out-of-sync issue when mixed using both group and individual echo music, even with the voice control. According to Anthony, the author of Echo Speaks, this MRM(multi-room music) can be observed in the native Alexa app as well.


That being said there is likely an issue with MRM itself, but I guess playing music using MGM, instead of mixing between single and MGM, may help better avoid the issue.

Thanks for the update. Now that you know, I think it might be a good idea to pin a note in the multiroom video. I spent over 8 hrs trying to understand and figure out why it worked in the video, but never for me. I had other concerns also. The volume buttons in the player seem to only be able to point to a single device. Also there would be global coding changes within the player needed to switch from one speaker group to another. My real desire wasnt really multiroom, it was for a speaker pair to give me stereo separation and additional volume. I still enjoyed the jukebox project and find it useful. I will default it to a single device (echo input) which I can then hardwire or bluetooth connect to my desired target speakers.

I’ve post the MRM issue note in my original MRM thread. I still think the MRM should work for you, and the out-of-sync issue should matter when Alexa was asked to play music on individual device and MRM after a few times. So I am curious why it doesn’t work for you at all.

Unfortunately, grouping is fundamentally not supported by SmartThings capability model. However, to adjust volume across to different devices, you may consider to use the Number variable, and a rule to set volumes on the desired devices using this Number variable, when this variable value changes. So the variable value can be adjusted in the dashboard, and populated to multiple devices’ volume level.

Hi James -

I’m trying to make this work. Hubitat hub user. The step about grabbing the uri: and referencing the “x-rincon-queue:RINCON…” string from the device view of the Sonos speaker I’m targeting and plugging that into the playTrack action doesn’t seem to have the desired result.

My desire is to have the rule execute a Spotify Playlist on that Sonos speaker. But, all I can get it to do is to simply continue playing an already chosen playlist on that speaker, and not even the one I want. If I use the native Sonos app and chose the Spotify playlist I want and begin playing it, then executing the rule will continue to play that playlist. But, if there is nothing playing in the queue on the speaker, executing the rule does nothing.

Any thoughts on how to program the rule to target a particular Spotify Playlist? Ideally the dashboard will have a few buttons that map to rules for playlist a, playlist b, playlist c, etc. and if I click the tile for playlist a, that playlist begins playing at the top of its list. Then if I click the tile for playlist b the playlist that was playing is blown away and replaced with playlist b.

Thanks for any thoughts.

There’s another trick you can use for playing Spotify playlists. Sonos supports a special format for playing Spotify content… let me see if I can find the notes from when I tested that…

Hi

I’m using the hyperlink + rule option to open a radio stream on my echo and it works really well.

Is there any way to have the tile function as a toggle? i.e.Tap to run rule and then tap to stop music?

Thanks

@Ronan_Ryan, there are a couple ways to do it. You can add a IF_Condition in the rule to check the current echo status. If the echo is not playing, then play the radio; otherwise, pause echo. (Please also note that you can just add the rule tile in the dashboard directly, instead of Hyperlink tile with the $runRule() syntax.)

The downside of this approach is you cannot tell the echo status by looking at the tile since rule or hyperlink tile doesn’t have “active/inactive” status.

The other approach is to create a True/False variable (or a virtual switch with a few more steps). Create a rule to play or pause echo based on the variable status, and another rule to sync echo’s status to the variable in case the echo is asked to play from somewhere else or via voice control. Then add this variable to the dashboard and change its tap action from toggle to hyperlink where you can do the $runRule() syntax like you did with the hyperlink tile, and customize the icon/color based on the variable value, so you can tell if echo is playing by looking the tile. See screenshots below for details:

Create a True/False variable.

Rule 1: Play or pause echo based on the variable status when this rule is executed from the dashboard

Rule 2: Sync variable status when echo status is changed

Add the variable to the dashboard and customize tap action, icon and color as desired.

1 Like

Hi Josh,
I’m not sure if I’m missing something here, but how do I connect to a spotify playlist I created to play on a specific sonos speaker? I can see how to do it with a song but not a playlist in spotify.
M

Hi @Mark_W, welcome to the community.
You will need to create a preset in Sonos and add your Spotify playlist in the Sonos preset, and use playPreset/playTrack command (depends on if you use SmartThings or Hubitat hub) to play this preset.
Please refer to how to create rule to change the playlist section in the original post for more details.

Thanks James - My presets only appear to be single tracks on media sources when I look in my Smartthings IDE. I created a Sonos playlist (called Gym IT) from the Spotify playlist (Gym), but in the IDE on the device it only ever shows singular track info. How do I create a Sonos Preset that is the playlist that I can reference when calling on with playPreset and the relevant ID?

@Mark_W, see below for the detailed steps:

  1. Open Sonos mobile app. Go to “Browse” from the bottom navigation tab, select Spotify, find the specific play lists (not just a single track), tap the Spotify playlist and hold until the menu pops.

  2. Select “Add Playlist to My Sonos”. Please note that only those playlists/stations added in “My Sonos” will be shown as presets in SmartThings IDE. If you just created the Sonos playlist, there won’t be a preset created for it in ST.

  3. Now go back to “My Sonos” from the bottom navigation tab, and you should be able to find this newly added playlist from Spotify.

  4. This preset should be shown in SmartThings IDE like this, and you can create rule to play this preset.

2 Likes

Unbelievable support. Thank you so much James! Adding it to “My Sonos” was the trick I missed and I’d never have gotten it without you.

2 Likes

Really having fun creating the “Jukebox” as described. Using Hubitat with Echo Speaks and Amazon Music as my music service. Have created Media Tiles with artists, playlists and stations that work beautifully to play on my Echo devices. The only problem I am having is that the album artwork does not change when the song changes. If I press the Music Player tile settings in the lower left corner and press refresh, the song title and album artwork change to the currently playing tract. How can I get my tiles to refresh automatically? Don’t know much about rules, but thinking that using that might solve my problem. Any suggestions?

If you watch the Current States section of the device details in your Hubitat admin UI, does the audioTrackData attribute update whenever the song changes?

If not, it sounds like something about the Echo Speaks integration isn’t working as expected as the attribute should automatically update when tracks are changed. If the device attributes aren’t updating when the track data changes, it would probably be best to post in the Hubitat Echo Speaks release thread.

@Bill_Findley, does the album art eventually change after a few moments if you don’t manual refresh as described? In my experience, echo responds reasonably quickly when commends are sent over SmartThings/Hubitat, Echo Speaks smart app and the Echo Speaks virtual server you host in Heroku, but sometimes it can take tens of seconds for the data updates to be reported in SmartThings/Hubitat, and that might be the reason why you didn’t see the album art changed. It seems the latency of track data update is significantly smaller if I press next few times in a row, but the latency is more obvious when I cold start to play something. I haven’t looked into the Echo Speaks sever code/config much, and am wondering if the Heroku server goes idle/sleep if no activities for a period so there’s a delay for the data to be updated to SmartThings/Hubitat in that case.

James & Josh…thank you! I realized that I might not have the most recent update to Echo Speaks and that seemed to do the trick.
I don’t think this is available for variables but now that I have created a “Jukebox” for one of my Echo devices it would very time consuming to create rules for the same artists, playlists, stations, etc for another Echo and link it to a different dashboard. I would like to be able to select my device with a tile and use the rule for Amazon music search selecting that device.
Then I could carry around my own jukebox on my phone and have the music play on the Amazon device that is currently in the room with me. Wouldn’t that be cool?
I like it because I can never remember the names of playlists and get tongue tied when asking Alexa to play one.
If not available, please consider it in the future.

1 Like

That is indeed a cool idea. Select device based on the variable value is not currently supported, so I will have to note it down and see the interests from other users. Meanwhile, while it is not quite the same and does require some work in rules, you can use few True/False variables - kitchenEcho, bedroomEcho, garageEcho for example, and add a few IF_Conditions in your music playlist rules to check these variables’ value and decide which device to send the play (music search) command. And create another rule to turn the other variables to False, when either of them is turned True. Then added these variables tiles to the dashboard, Tap one of them to select the device first, and then the playlist/artist rule tile so the music will be played to the specific device, and by looking at those variables in the dashboard, you know which device is already selected.

3 Likes