Sonos Grouping (zones) and playlist help

(John Watkins) #1

I have been working on creating a device handler (well, actually adding to the existing ST one) and smart app that groups all selected Sonos’ and play’s TTS (once it works again). I have the grouping and resume working fine (except for the annoying significant delay by ST.

However, I’m having a problem with playlists. I have the handler parser grabbing the current play list titles; and uri and sending an event . I can read the event in my smartapp, but the format is no longer in map format.

the debug shows for the handler shows:

7c17cce0-fdef-499d-bde2-bb05e88628ef 5:46:05 PM: debug PlayList: [[title:[A7X, All music, Good Songs, Sonos Playlist 1], res:[file:///jffs/settings/savedqueues.rsq#3, file:///jffs/settings/savedqueues.rsq#0, file:///jffs/settings/savedqueues.rsq#1, file:///jffs/settings/savedqueues.rsq#2]]]
7c17cce0-fdef-499d-bde2-bb05e88628ef 5:46:05 PM: debug res: [file:///jffs/settings/savedqueues.rsq#3, file:///jffs/settings/savedqueues.rsq#0, file:///jffs/settings/savedqueues.rsq#1, file:///jffs/settings/savedqueues.rsq#2]
7c17cce0-fdef-499d-bde2-bb05e88628ef 5:46:05 PM: debug title: [A7X, All music, Good Songs, Sonos Playlist 1]
7c17cce0-fdef-499d-bde2-bb05e88628ef 5:46:05 PM: trace Parsed PlayList xml: A7Xfile:///jffs/settings/savedqueues.rsq#3object.container.playlistContainerAll musicfile:///jffs/settings/savedqueues.rsq#0object.container.playlistContainerGood Songsfile:///jffs/settings/savedqueues.rsq#1object.container.playlistContainerSonos Playlist 1file:///jffs/settings/savedqueues.rsq#2object.container.playlistContainer

the smartapp shows (notice the equal rather than colon:
[{title=[A7X, All music, Good Songs, Sonos Playlist 1], res=[file:///jffs/settings/savedqueues.rsq#3, file:///jffs/settings/savedqueues.rsq#0, file:///jffs/settings/savedqueues.rsq#1, file:///jffs/settings/savedqueues.rsq#2]}]

device handler parser:

//PlayList update
node = msg.xml.Body.BrowseResponse

	if (node.size()) {
	log.trace "Extracting PlayList"
	def xml1 = parseXml(node.Result.text())
           log.trace "Parsed PlayList xml: $xml1"
          state.title = []
          state.res = []
          def playListValue = []
          xml1.children().each {
              state.title << it.title
              state.res << it.res
            playListValue << [
		title: state.title,
          	res: state.res,

       results << sendEvent(name: "playListData",
		value: playListValue,
		descriptionText: playListValue,
                    displayed: false,
		isStateChange: isDataStateChange


SmartApp code:

def loadPlayList() {
state.playList = []

settings.sonos.each() {
      state.playList = it.currentState("playListData")
      log.debug "playList: $state.playList" //returns physicalgraph.device.cassandra.DeviceStateCache error
       log.debug "${it.value}" // returns the example above, but not in map format


(John Watkins) #2

don’t laugh too hard at my code. :smile: I’m a noob…