Author Topic: Sonos Luup Code: How to always play second song in Sonos playlist during scene?  (Read 1062 times)

Offline thecodas

  • Sr. Newbie
  • *
  • Posts: 41
  • Karma: +0/-3
Hi! I'm trying to figure out how to play a specific song when I hit a trigger. I know how to play a shuffled Sonos playlist in scene, but not always a specific song.

Any help would be appreciated.

Also, is there some kind of master list of Sonos luup actions that work with the plug-in [i.e. SetURIToPlay, Next, SetPlayMode, etc...]?

Offline ZW-Tom

  • Jr. Member
  • **
  • Posts: 52
  • Karma: +4/-1
Hi! I'm trying to figure out how to play a specific song when I hit a trigger. I know how to play a shuffled Sonos playlist in scene, but not always a specific song.

Any help would be appreciated.

Also, is there some kind of master list of Sonos luup actions that work with the plug-in [i.e. SetURIToPlay, Next, SetPlayMode, etc...]?
This is a great question. Did you ever get an answer? There is only 6,235 post on Sonos to read through. If you are lucky, in about 3 weeks you may find the answer.
Tom

Offline Isablend

  • Jr. Member
  • **
  • Posts: 87
  • Karma: +1/-3
Use the url

Go into your sonos app and select the individual track you want to play.   Once you've done that, enter the following URL in a browser on the LAN where the Vera is located (replacing Vera-IP with the actual IP address);

http://Vera-IP:3480/data_request?id=user_data2&output_format=xml

In the output find the definition for the Sonos device you just played the track you select earlier.   You should find a definition for the currentURI and there should be a string representing the path to the track in question. Something like;

<state service="urn:upnp-org:serviceId:AVTransport" variable="CurrentTrackURI" id="35" value="x-file-cifs://192.168.1.254/Music/iTunes/iTunes%20Media/Music/Pearl%20and%20Dean/Asteroid.m4a"/>

You can cut and paste the string into Lua code, such as;
luup.call_action("urn:micasaverde-com:serviceId:Sonos1", "PlayURI", {URIToPlay="x-file-cifs://192.168.1.254/Music/iTunes/iTunes%20Media/Music/Pearl%20and%20Dean/Asteroid.m4a", Volume=20}, 112)

The IP address in the path in this example is a USB mounted path off my router where I store all my music so its available across the LAN.  I use this to announce when I switch the home cinema on.  :)