Sonos "Set Track Name"

I am trying to create a rule in rule machine that will play a favorite station on my Sonos speaker. In the device itself I can past a URI and it will play just as I expect. In rule machine I select control music player-> select player command "Play Track" -> I then enter the URI into the track name field but it doesn't work. It stops the music and in the Sonos app changes to no music selected.

How can I select a favorite station in Rule machine?

1 Like

Can you post a screenshot?
I'm doing this today for a specific song (I believe hosted on SoundCloud) like this.

I played with it over the weekend some more. All of my SONOS URI's have % characters in them and this forces a null value.
When I enter the play track string as: x-sonosapi-radio:SF%3a16722%3a3336487?sid=236&flags=8300&sn=3
It becomes
x-sonosapi-radio:SFnull3a3336487?sid=236&flags=8300&sn=3

I have tried putting the string in Quotes (") but no avail.
Here is the screen shot:

One additional note. In your example you have a single % character which doesn't force that behavior, it is only when the string has two % characters that the % and everything between them become null.

It looks like it is treating the %text% like an undefined variable. What happens if you create a local variable called 3a16722 as a string with a value of %3a16722%? Or even just store the entire URI as a string variable.

More of a work around than a fix, but it might work.

Oh... and BTW... Welcome to the community!

I tried to create a variable and had the same results. Created two variables and combined them, also same results. As soonas there are two "%" in the string things convert to null.

I checked the HE documentation but couldn't find an answer for this. Tagging @bravenel to see if he can shed some light on how to format strings that include % symbols.

This problem has to do with pairs of % symbols, which are used to represent special values such as variables, %device% etc. A stand-alone % works as expected.

To get a pair of percents into a string, create a local variable of type String, and set it to %. Use that local variable in the string to be used, like this:

1 Like

Thanks very much. This makes perfect sense, I really appreciate your assistance.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.