Sonos Play Favourite Tracks

Hi,

I am going through my current devices and automation in preparation for the groovy switch off next month.

At the moment I have the original notification Smarthings smartapp that allows you to select a sound effect (in this case a door bell), so that when my Ring Doorbell is triggered it will play on my selected speaker, when in a certain mode, temporarily adjust the volume and then resume playback once done.

I think I can achieve most of the above without the smart app and routines, however I have hit a snag.

I have added a door bell to my favorite music library in Sonos. If I look in the groovy IDE I can see the current websocket integration supports selecting presets (which are the favorites in the Sonos App).

However, for the life of me I can not figure out how to play the track using routines. The standard actions allow pause/ resume, grouping etc, but no ability to select a favorite track or specific a stream URL.

Does anyone have a solution for this? It must be possible as the functionality is exposed to SmartThings, there just does not appear to be a way to trigger it.

Thanks in advance

I believe you can use SharpTools to do this. @tagging @joshua_lyon

Yes, you should be able to call the playPreset() command with the number of the preset in SharpTools. This is what one of the presets I use looks like:

2 Likes

Thanks for the info.

I’m assuming I will need to subscribe to Sharptools to have the HTTP request functionality?

The base Rule Engine is free and includes complex conditions, nested conditions, etc, but a subset of features like HTTP Triggers/Actions and Variables are part of the premium tier.

I might have missed some additional context, but HTTP Request wouldn’t be necessary for the Sonos preset if you are just triggering a rule based off of an event (eg. pressing a physical button, tapping a tile in a dashboard, time based).

Wonderful.

I really appreciate the help.

With the Groovy sun setting its becoming a real patchwork of things to get back some functionality.

I already use IFTT for some migrations, mainly to make a bulb blink which In introduced last year knowing that webcore would eventually be gone (assuming it is not updated to the new rule api).

Does Sharptools use the rule api, so come Oct 1st everything will still be running?

Yes, SharpTools uses the ‘new’ REST APIs and will continue to work after groovy shuts down.

1 Like

I have taken a look at the web version and i am impressed so far. Tested with a virtual switch to play the preset I want.

Now, I’d like the ability to resume the previous track being played once my preset has played (its a notification for the door bell).

I assume I would need to use PlayTrackandRestore, but what type of variable would I need to populate in each box that comes up to accomplish this?

Not sure if you saw this, and it may not address your question directly. But lots of good info:

1 Like

The capabilities documentation is usually a good reference too (should be under audioNotification if I remember correctly)

I’m away from my desk for the weekend on a family matter, otherwise I would try to test it out for you.

Appreciate the info @joshua_lyon.

I will see if i can figure it out from the doc in the next rew days. I now know what the variables mean, track uri and volume level, and i need to use PlayTrackandResume.

Just need to get my sound preset uri now and shoukd be good to go

1 Like

Hi,

So I have worked on this some more and although I have not got exactly what I want there is at least a working prototype.

I used the PlayTrackandResume method as mentioned above, although I could not figure out the syntax for send a preset to Sonos despite copying the details from the groovy ide for the preset.

Anyway, what I did instead was find a sound online from a public domain website, which allowed me to find the stream url of the file I wanted which I could then use as the sound effect.

Tested it, and the volume changes to the desired level (specified as between 1 and 100), the track plays and then it returns to the previous playing item.

I am sure there will be a way to send a variable which triggers the Sonos preset, just not worked it ouot thus far

1 Like