Sonos track data


#1

How do you grab the track data as a variable i have tried everything i can think of and i just can’t get it :frowning:


#2

Any example of what that track data looks like? Is it a JSON? If so, use the Parse JSON task and then read the results via $json…


#3

Adjust the trigger on this one?
Works here if this is the info jo need.


#4

I may misunderstand what you’re asking but I get Sonos track data as follows:

[sonosdevice : trackDescription]


#5

It’s for these pistons I’m trying to store the playing track in a variable to then return the que or track to how it was.

Sure I have tried this one but will try again.

Edit: still didn’t work

Hi @Einars I don’t quite understand the piston what does it do?


#6

If you edit the trigger so something at yours trigger it. And you set your Sonos speaker as speaker. Then play something on your Sonos speaker and trigger the piston. You will then see the variables get filled with info from the Sonos.


#7

I don’t put it in a variable as I have no need, but no reason why it couldn’t.

Not sure if there is an easy way to extract the array data (short of doing the string search @Einars does). Does the native webcore array handling let you parse something like:

{
“station”: “RINCON_5CAAFD31629601400”,
“name”: null,
“artist”: null,
“album”: null,
“trackNumber”: “1”,
“status”: “playing”,
“level”: “”,
“uri”: “x-sonos-htastream:RINCON_5CAAFD31629601400:spdif”,
“trackUri”: “x-sonos-htastream:RINCON_5CAAFD31629601400:spdif”,
“transportUri”: “x-sonos-htastream:RINCON_5CAAFD31629601400:spdif”,
“enqueuedUri”: “”,
“metaData”: “<DIDL-Lite xmlns:dc=“http://purl.org/dc/elements/1.1/” xmlns:upnp=“urn:schemas-upnp-org:metadata-1-0/upnp/” xmlns:r=“urn:schemas-rinconnetworks-com:metadata-1-0/” xmlns=“urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/”><item id=“spdif-input” parentID=“0” restricted=“false”>dc:titleRINCON_5CAAFD31629601400</dc:title>upnp:classobject.item.audioItem</upnp:class><res protocolInfo=“spdif”>x-sonos-htastream:RINCON_5CAAFD31629601400:spdif”,
“trackMetaData”: “<DIDL-Lite xmlns:dc=“http://purl.org/dc/elements/1.1/” xmlns:upnp=“urn:schemas-upnp-org:metadata-1-0/upnp/” xmlns:r=“urn:schemas-rinconnetworks-com:metadata-1-0/” xmlns=“urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/”><item id=”-1" parentID="-1" restricted=“true”><res protocolInfo=“x-sonos-htastream:::*”>x-sonos-htastream:RINCON_5CAAFD31629601400:spdif<r:audioInputIcon></r:audioInputIcon><r:streamInfo>21</r:streamInfo>dc:title </dc:title>upnp:classobject.item</upnp:class>"
}


#8

There is a Parse JSON task that saves the parsed object into $json and then you can go through it using dot notation:

$json.station >>> RINCON_5CAAFD31629601400
$json.album >>> null
$json.uri >>> x-sonos-htastream:RINCON_5CAAFD31629601400:spdif

etc.


Looking for help parsing [[ and ]] out of a HTTP "Get" response
#9

Super, that would give me more confidence that even if other stuff changes in what is returning I would be checking the list element I cared about.

Thanks @ady624