Sonos playTrackAndRestore() missing?

Is playTrackAndRestore() not supported by the built-in Sonos driver?

I'm porting BigTalker from ST and a beta tester is reporting the following error:
errorjava.lang.IllegalArgumentException: Command 'playTrackAndRestore' is not support by device. on line 3593 (pageTalkNow)

Line 3593 (pageTalkNow) is related to BigTalker calling the expected playTrackAndRestore function for a musicPlayer device.
The actual called code in BigTalker is
device.playTrackAndRestore("uri" :uri, "duration" :duration, volume)

Raw code to the parent app where this is called is here:

playTrackAndRestore as well as playTextAndRestore are not part of the music player capability.

That was unexpected. Every musicPlayer device that I have come across has included this function, including the ST Sonos device handler

Everything listed as a command in that handler is a custom command, ie not part of the capability.
There's another reason I chose not to impement it in the sonos handler that being the json_object parameter is not suficiently defined, as such I have no control over what gets sent to it.
I can look at adding this in the future, but it's not been a high priority item so far.

I'm just trying to port BigTalker. I have testers with Samsung M3s and M6s that work but they also have Sonos which isn't working and if included breaks it from functioning. I also have VLCThing (also ported) which also includes this function and I can use it to play TTS mp3's as well.

Do you have suggestions for working around this for the Sonos driver? I really hate to code the app for specific devices. I'd like to continue coding for capabilities (musicPlayer or speechSynthesis) and send the required commands to make TTS happen for those. It's never been an issue before so I suspected that these functions were standard for musicPlayer devices across the board.

I saw in another thread that playTrackAndRestore as well as playTrackAndResume had been implemented into the Hubitat firmware for the Sonos driver.

I'm getting a report stating the following error from a user that says they are on the latest Hubitat Firmware:

errorjava.lang.IllegalArgumentException: Command 'playTrackAndRestore' is not supported by device.

@mike.maxwell Any update to @rayzurbock question surrounding the Sonos driver not working correctly? I have both a Samsung M3 and many Sonos Play 1's and the playTrackAndRestore is not working correctly. The M3 works flawlessly.

@mike.maxwell any updates on this?

Hubitat 1.1.5 release notes (released 10/3/18) mention:

  • Sonos driver now supports playTrackAndResume

It doesn't mention playTrackAndRestore though.

@mike.maxwell Can you describe what parameters the built-in Sonos driver supports in regards to playTrackAndRestore and playTrackAndResume?

For example does it support:

playTrackAndRestore(url, volume)
playTrackAndRestore(url, duration, volume)
playTrackAndRestore(url, duration, volume, [delay: xxxx])  //delay = ms
playTrackAndRestore("uri" :url, "duration" :duration, "volume": volume)

Are the same parameters supported for other built-in musicPlayer devices? Are there specific parameters supported by all in this call (for example, perhaps they do not all support duration, but do (url,volume) or perhaps (url) only?

playTrackAndRestore(uri,volume = null)
Sonos is the only musicPlayer device we currently support.

1 Like

I am a new user, and I am trying to use playTrackAndRestore(uri,volume = null)

When I send:

or musicplayer.playTrackAndRestore("https://IPADDRESS/radiometro/Audio2.mp3",0)
my sonos reproduce the 2 different audios, perfecly

But if I load a variable, like:
state.url1Data = ---> i am obtaining the value from a web service...

and after try musicplayer.playTrackAndRestore(state.url1Data,0)

The audio does not change... it continues playing the previous audio...

what I am doing wrong

Thank you!!

Insert a log.debug("URL=${state.url1Data}") and see what is being cast to playTrackAndRestore. Perhaps it's not formatted correctly or is not the url that you think it should be.

Thank you @rayzurbock

Here are the results

app:8712020-02-19 10:15:11.829 pm debugRADIO - URL=https://IPADDRESS/radio/Metro-20-02-19-07-00.mp3

The symptom is the audio restart but always with the last audio and not the one I am indicating...

My code:

My URL is coming from a Webservice...

state.url1Data =
log.debug("RADIO - URL=${state.url1Data}")

I tried:


Always the same behavior.

Could be a problem of the set of characters I am receiving from the webservice? like is not a simple text?

I found the solution, add .trim() to the end

state.url1Data =

1 Like

Glad I could help you find it!

Anyone know what the best way to do this would be in RM?
I'm not seeing a playTrackAndRestore() equivalent in the RM options.


Thank you!!

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