This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Sonos radio control through KNX
#1
Hi,

I've tried to connect two sonos speakers into KNX with the Sonos app in LM app store which works. The thing I need to do is to control everything through scripting, to create sort of my own app inside visualization or mosaic. Is there a way to send command to sonos through KNX script to turn on particular radio? I've tried the command in the example, doesn't work even as shown in the example. Also in case the link itself in the example is simply dead, which formats can I send and play? 
-I've seen this one being m3u but there are more radio formats like .pls or .mp3, is it possible to use these? 
-Is there a way to send a command for a particular spotify playlist?
Reply
#2
Read this very long thread and everything should be clear.
https://forum.logicmachine.net/showthrea...01#pid2101
------------------------------
Ctrl+F5
Reply
#3
Hi,

I've read the whole thread but I'm still a bit confused since it's a bit old and a new version has came out. I don't know which stuff is actual and which is not. However i've gotten into a point, where I have few radio stations in Sonos APP in LM (favourites section). All I need now is a command to make speaker (or group of speakers) to play whatever is in the favourites, in this case a radio.
Reply
#4
There were two apps over time, old which use older Sonos API which might stop working and new app which use new Sonos API.
If you want to use new app via script you have to fallow this:
https://forum.logicmachine.net/showthrea...9#pid13969
Some features in new app are not possible so users still use the old libraries to use more features. To use old way you need to upload libraries manually: https://forum.logicmachine.net/showthrea...1#pid12301
If you use scripts provided make sure location of libraries are correct in the script.
------------------------------
Ctrl+F5
Reply
#5
I created this for Schneider Electric Germany, maybe it is what you are looking for..

Reply
#6
(09.07.2021, 16:57)Erwin van der Zwart Wrote: I created this for Schneider Electric Germany, maybe it is what you are looking for..

I've been using Erwin's script on a Schneider CBUS SHAC (which doesn't have the ability to run apps) with good results, however the old UPNP code doesn't seem to support loading of Apple Music Playlists into the Sonos queue -  I suspect because they have a media type of x-rincon-cpcontainer which the Sonos devices treat differently to other playlists or streams.

By chance would you know the the UPNP command to load this playlist type?   I've combed through the previously posted variants of the SONOS scripts here on the forum but haven't been able to find a solution.

I think it requires an extra condition here for the mediatype 'x-rincon-cpcontainer' but I'm not sure what the upnp data format is - I suspect a variant of below.

Code:
if mediatype == 'x-sonosapi-stream'then

upnpavcmd(SonosDetails.sonos_ipaddress, 1400, 'SetAVTransportURI', '<CurrentURI>' .. sanitize(FavoritesTable[FavoriteNr].trackuri) .. '</CurrentURI><CurrentURIMetaData>' .. FavoritesTable[FavoriteNr].trackurimetadata .. '</CurrentURIMetaData>')


Here is the URI and MetaData that sonos returns from the playlist / favourite

Code:
["mediatype"]
* string: x-rincon-cpcontainer

["trackuri"]
  * string: x-rincon-cpcontainer:1006206clibraryplaylist:p.vB5KhgB44v?sid=204&flags=8300&sn=2

["trackurimetadata"]
  * string: <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="1006206clibraryplaylist:p.vB5KhgB44v" parentID="00080024libraryfolder:f.4" restricted="true"><dc:title>Avici</dc:title><upnp:class>object.container.playlistContainer.#PlaylistView</upnp:class><desc id="cdudn" nameSpace="urn:schemas-rinconnetworks-com:metadata-1-0/">SA_RINCON52231_X_#Svc52231-0-Token</desc></item></DIDL-Lite>

["description"]
  * string: Apple Music Playlist

My attempted update the the code below doesn't work!

Code:
if mediatype == 'x-rincon-cpcontainer' then

upnpavcmd(SonosDetails.sonos_ipaddress, 1400, 'SetAVTransportURI', '<CurrentURI>' .. sanitize(FavoritesTable[FavoriteNr].trackuri) .. '</CurrentURI><CurrentURIMetaData>' .. FavoritesTable[FavoriteNr].trackurimetadata .. '</CurrentURIMetaData>')



Many thanks in advance

Kind Regards
James
Reply
#7
Not sure if will help but the second : in trackuri should be URL-encoded:
Code:
x-rincon-cpcontainer:1006206clibraryplaylist%3ap.vB5KhgB44v?sid=204&flags=8300&sn=2
Reply
#8
We're using Erwin's sanitize function to URL encode the data in the upnp command.  I've tried with both an encoded and normal : and it doesn't seem to change the outcome

Here the Illegal Mime Type error from the upnpavcmd post - I'm not sure how to resolve though.

Code:
* arg: 1
  * string: HTTP/1.1 500 Internal Server Error
CONTENT-LENGTH: 347
CONTENT-TYPE: text/xml; charset="utf-8"
EXT:
Server: Linux UPnP/1.0 Sonos/69.1-32100 (ZPS16)
Connection: close


<s:Envelope
xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<s:Body>
<s:Fault>
<faultcode>s:Client</faultcode>
<faultstring>UPnPError</faultstring>
<detail>
<UPnPError
xmlns="urn:schemas-upnp-org:control-1-0">
<errorCode>714</errorCode>
</UPnPError>
</detail>
</s:Fault>
</s:Body>
</s:Envelope>

Thanks again for any suggestions / help.

Kind Regards
James
Reply


Forum Jump: