SONOS TTS - Go back to queue

Hi @bertabcd1234.

Sorry for all the updates I've done on this post. I've discovered a lot and that is why. :slight_smile:

1. The playTextAndRestore command did not work.
It behaves the same way as Play Text and Speak in this scenario.
If the speaker is already playing music the TTS will perform and the music will resume. But when the speaker is not playing the TTS will speak and the audioSource will be set to "Unknown" as the TTS is.

2. What I've learned
When a TTS is played on the sonos the audioSource of the trackData is set to Unknown and then provided with a link to the TTS.
So it looks like this:

trackData : {"audioSource":"Unknown"}
I need to switch the audioSource back to Sonos Q.
It looks like this:

trackData : {"audioSource":"Sonos Q","station":null,"name":"........."}
If i need to do it to my Sonos Playbar the audioSource mich be switched back to something similar to this:

trackData : {"audioSource":"Aux Input","station":null,"name":........."}
I cannot see the option to change audioSource as a part of the Device List Commands. Any suggestion?

3. Solution (I need help here)
We need to extract 2 fields from trackData under the Current Stats of the device:

  • uri. When this is extracted we use the command Set Track with the result [1].
  • trackNumber. After we use Set Track we make a loop that runs trackNumber - 1 and uses the command Next Track in the loop.

I don't know how to retrieve these numbers, since they are in an array in a variable. If you say where I can program it, I will try. But there is no easy with variable swapping.

[1] URI is also available under State Variables, but as Mike stated:

Link: Device State Variables Not Updating in UI - #2 by mike.maxwell

4 Likes