Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Sonos PlayFavorites
#1
Even though we are having some troubles with the driver, I was wanting to update my system with a command you added after I built my templates that allowed you to create a stringlist of Favorites stored and display them.  I already do that with Playlists.  The link here I thinks describes how kfly did it, but his photos are no longer visible:  

https://www.charmedquark.com/vb_forum/sh...718&page=3

The help was even more confusing (at least to me) as it looks like the same command to show Playlists is what is to be used as for Favorites.  I see in the string list that is returned that there are some entries at the end that are "SQ:2", "SQ:3", etc.  Are those the items that are the Favorites, or is the documentation below incorrect and there is a different command to show the Favorites.

In the end, what I want to know is how I can get the Sonos Favorites into a list browser?  I think I can handle the commands to invoke it.

Code:
Backdoor Commands

This driver supports some backdoor commands you can send via Devices::QueryDrvText:

Playlists

ID=ListQuery, Value=PLList
This query will return a pair of quoted comma lists, separated by a new line. You can use the SetDblBrowserList command on a static list browser to load this list up into a list browser widget. The first list is the one that will be visible and will be the names of the available playlists. The second list is stored in the background for each visible list item and holds the Sonos specific ids for the playlists. Be sure to use the "^1" formatter when you pass in the list to the list browser, i.e:


           Devices::QueryDrvText(MySonosMoniker, ListQuery, PLList, LVar:PLLists)
           MyListBrowser::SetDblBrowserList(%(LVar:PLLists, "^1"))
           
This insures that the newline that separates the two lists doesn't get messed up by the standard processing that is done to parameters. The ^1 indicates that the expanded variable's value should not be further processed on the way into the SetDlbBrowserList command.

Favorites


           ID=ListQuery, Value=PLList
           
This will return a single quoted command list, with the names of the currently configured favorites. Using the PlayFavorite command (of the InvokeCmd field below), you can pass back in one of these names to start a favorite playing. You can load up this list into a list browser to let the user make a selection.
Reply
#2
The reason it doesn't make any sense is that the doc is wrong. The two values for favorites are:

ID=ListQuery, Value=FavsList

Sorry about that. I've fixed that for the next drop, and added an example like the playlists one has.

That returns a single quoted comma list. So just call SetBrowserList on a static list browser and pass that returned list as the values to set. When the user selects one, in the OnSelect (I think it is), use the runtime value that has the text of the selected item. When you get back the list, pass that to the InvokeCmd field using the command that lets you play a favorite. So the value you write to InvokeCmd would be something like:

PlayFavorite : %(IntfRTV:ListItemText)

Of course you can right click in the action editor and use the popup menus to select runtime values so you don't have to have them memorized or anything.
Dean Roddey
Explorans limites defectum
Reply
#3
That was what I needed!  Thanks for the quick help
Reply
#4
I just wanted to give a final update after I used the FavList and PLList commands in my templates.  This greatly simplified my setup.  

What I do now is put all of my radio stations (Tune-In, Radio.com, and IHeartRadio) along with Pandora and Amazon radio stations in my Sonos Favorites and use the generated Item List browser to select and play the stations.

I use the Sonos Playlists for my locally stored music library playlists along with canned Amazon Playlists (i.e. 100 Greatest Classic Rock Songs).  Again I generate a Playlist Item List browser to select and play.  Thanks to Kevin (kfly) for helping with the playlists, as you must invoke a SetTransURI command for the playlists before playing it.  What I found is that it just has to be a valid one, not necessarily one that is the same as the playlist you're playing.  It then puts Sonos into a different mode and plays the Playlist.  To play items in your Favorites, this SetTransURI command is not needed.

One thing I was also able to fix was the issue with the SonosZP.ArtURL showing up initially and then disappearing, which only happens on some Radio Stations.   I put a trigger on the ArtURL field, and when it changes, I place that URL text into a Variables device driver.  It passes over the variables driver write if the name goes back to empty.  It ends up that the URL call is still available even if the name is empty in the ZonePlayer driver, and can still be displayed.
Reply
#5
So the ArtURL field is cleared out at some point before the song ends? Is there any pattern to that? I.e. some specific time into the song or something like that?
Dean Roddey
Explorans limites defectum
Reply
#6
(10-22-2018, 04:15 PM)Dean Roddey Wrote: So the ArtURL field is cleared out at some point before the song ends? Is there any pattern to that? I.e. some specific time into the song or something like that?

It is only the radio stations (TuneIn, Radko.com, IheartRadio) that do it.  They probably stay up 2 seconds, then go blank.  On Pandora and Amazon Radio Stations, they do not disappear, but in those cases they are showing Album Art, whereas the ones that disappear are just showing an Icon of the radio station which doesn't change.

Here is the trigger code I set up:

Code:
LocalVars::SetVariable
   P1=LVar:ArtURL
   P2=$(ZonePlayer.ArtURL)

If
System::StartsWith
   P1=%(LVar:ArtURL)
   P2=http

Devices::FieldWrite
   P1=SonosVars.CoverArt
   P2=%(LVar:ArtURL)
   P3=True

End
Reply
#7
If the URL field goes blank, then presumably we are getting a blank value. I'm not sure how we'd be expected to know to ignore that vs. when we should take it literally (i.e. we don't want to display the previous file/station's image just if the new one doesn't provide one and sends a blank.)
Dean Roddey
Explorans limites defectum
Reply
#8
(10-22-2018, 06:55 PM)Dean Roddey Wrote: If the URL field goes blank, then presumably we are getting a blank value. I'm not sure how we'd be expected to know to ignore that vs. when we should take it literally (i.e. we don't want to display the previous file/station's image just if the new one doesn't provide one and sends a blank.)

Agree - I just defined a state in the template where the cover art is displayed to be hidden if the PlayMode was set to Stop,   Maybe that is something that could be added to the driver, but what I am doing works fine for me.
Reply
#9
I don't know if that's a good thing to do or not. I guess it depends on Stop semantics. If Stop means the current track will not be picked up again if you hit play (unlike Pause), then it might work. But that's somewhat device specific. I think that the media renderers will treat stop as as the end of input for the current track, but I'd have to check that. If so, even if the device didn't do it, they would do a next track operation.
Dean Roddey
Explorans limites defectum
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Sonos Log Message karenlee 5 1,281 10-24-2021, 04:18 AM
Last Post: karenlee
  Sonos Zone Player - Win10 zra 9 3,889 09-26-2019, 10:00 AM
Last Post: zra
  SONOS Driver Question gReatAutomation 13 6,495 08-23-2019, 12:37 PM
Last Post: Dean Roddey
  Sonos - PlayFovorite command NightLight 22 7,505 05-10-2019, 09:32 PM
Last Post: kblagron
  Sonos batwater 4 2,316 01-24-2019, 05:20 AM
Last Post: batwater
  Sonos Update Error (Again) karenlee 39 14,972 12-04-2018, 10:15 PM
Last Post: Dean Roddey
  Sonos Driver zra 3 2,628 09-01-2018, 03:09 PM
Last Post: Dean Roddey
  Sonos stops after CQC restart batwater 1 1,826 05-18-2018, 10:12 AM
Last Post: Dean Roddey
  Sonos Driver with Sonos Connect Amp zra 5 4,003 05-05-2018, 09:43 AM
Last Post: Dean Roddey
  Sonos Drivers kjaerligkatt 66 29,033 02-15-2018, 06:06 PM
Last Post: jkmonroe

Forum Jump:


Users browsing this thread: 1 Guest(s)