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 play/queue playlist
#21
Hi Ruben,

Adjust group address and image size in the parameter section and run this script once, it creates a albumart.html file in the image folder.

Create a image frame in your visu and use this as url:  /scada/resources/img/albumart.html

This should give you the Sonos albumart image for local sources

BR,

Erwin

Attached Files
.lua   Create Albumart HTML.lua (Size: 158.66 KB / Downloads: 54)
Reply
#22
(05.03.2016, 13:01)Erwin van der Zwart Wrote: Try this script, the explanation is added into the script. Its still in development and the only thing i need to add is getting albumart URI for streaming content.

Hello Erwin,

I'm getting errors like this,when adjusting volume:
Code:
Line 463: attempt to call field 'tonumber' (a nil value)
Line 485: attempt to call field 'tonumber' (a nil value)
Seems that the volume variable is somehow cleared after FOR loop.

The volume feedback is correct. Start/stop is working, prev/next didn't tried yet.

Using the latest RC firmware (20160714). Copy/paste attempted with chrome, firefox, file download - then open with notepad, notepad++, same behaviour.

Attached Files Thumbnail(s)
   
Reply
#23
Replace lmcore.tonumber with tonumber everywhere and it should work. This function has been removed in RC firmware.
Reply
#24
Thanks,
I'll try it tomorrow.
Reply
#25
Just a little hijack;

When removing lmcore in a different script, the function inttohex and hextoint is not recognised. Gives me errors. Can´t find a reference to these functions anywhere. Could you elaborate further?
Reply
#26
Hi,

You only need to remove it on the tonumber as the command
is a default LUA command, inttohex is a custom command so
there lmcore. is needed.

To see a list of commands you can use press CTRL+space in
the script editor.

BR,

Erwin
Reply
#27
Hello, I'm trying it into a HomeLynk and works all fine within AlbumArt. The Album Art scrip creates a html image but all the time it appears like a NO ALBUM ART image, I can meke something to arrange this? Thank you veruy much.
Reply
#28
Hi Josep,

Can you give some more details?

What FW do you run?

What script version do you use to read the Sonos?

Is there a (valid) albumart URL visable  on the object that is set inside the Albumart.html file?

BR,

Erwin
Reply
#29
Hello Erwin,

The Homelynk is a 1.5.1 version.

The Script that I use is the Script that you upload to trhis forum post, the version is 1.1

The URL album art that I can see inside 1/1/18 adress is this, for example:
example 1 (tunein Radio) :x-rincon-mp3radio://streaming3.radiocat.net/
example 2 (Apple Music Album) /getaa?s=1&u=x-sonos-http%3asong%253a639380945.mp4%3fsid%3d204%26flags%3d8224%26sn%3d1

THX

Josep
Reply
#30
Hi Josep,

I think this version does not support streaming album art, as i already wrote in the post 09-03-2016:

Albumart URL should work now with local content, i'm still searching for a good solution for streaming content album art, but that's a hard one to tackle, when i solved it i let you know.

We created a app for Sonos that is still in development (we have it running on several sites for beta testing), in this app i solved the issue (puzzle) with streaming art.

Or you wait for the app or i must prepare a new version script for you..
 
BR,

Erwin
Reply
#31
Hello Erwin,

This app that you prepare it working in HomeLynk or only in LogicMachine? Can I try the beta version?

Thankyou very much.
Reply
#32
Hi Josep,

Look at my avatar (: 

I'ts designed on a homeLYnk, but i see no reason why it doesn't work on a LM.

I'm still fixing a few found items, when done i let you know.

BR,

Erwin van der Zwart
Reply
#33
Big Grin

Thank you very much!

(P.D. some news about Homekit in Homelynk? I'm trying Thinka and it works fine)
Reply
#34
+1 for beta testing Wink
Reply
#35
(24.11.2015, 12:23)gjniewenhuijse Wrote:
(23.11.2015, 12:49)admin Wrote: We don't have any Sonos devices so what we can help with is limited.

You can use Node.js library with debug enabled to monitor which kind of requests are being sent and then implement the same thing in LM.

Some hints for your case:
- To find your playlist id (SQ:1 or similar), you need to get a list of all playlists and find it there
- Use RemoveAllTracksFromQueue to empty current queue
- Use SetPlayMode to set repeat / shuffle
- You don't have to add tracks one by one, you can load the whole playlist (stored queue) in one call

Yes.. it works.
I attached a little bit changed upnpavcmd function.

And two new functions:

Code:
-- find all playlist
function getPlaylists(ip, port)
cBrowse = '<ObjectID>SQ:</ObjectID>' ..
        '<BrowseFlag>BrowseDirectChildren</BrowseFlag>' ..
        '<Filter>*</Filter>' ..
        '<StartingIndex>0</StartingIndex>' ..
        '<RequestedCount>25</RequestedCount>' ..
        '<SortCriteria>*</SortCriteria>'
  res,err = upnpavcmd(ip, port, 'Browse', cBrowse)
  return res,err
end

-- add saved queue (playlist) to queue
function qPlaylist(pId)
uriprm = '<EnqueuedURI>file:///jffs/settings/savedqueues.rsq#'..pId..'</EnqueuedURI>' ..
'<EnqueuedURIMetaData></EnqueuedURIMetaData>' ..
'<DesiredFirstTrackNumberEnqueued>0</DesiredFirstTrackNumberEnqueued>' ..
'<EnqueueAsNext>1</EnqueueAsNext>'
  return uriprm
end

-- find all playlist (run once and note playlist id)
res,err = getPlaylists(ip, 1400)
log(res)

And then you can use:


Code:
-- clear current queue
upnpavcmd(ip, 1400, 'RemoveAllTracksFromQueue')

-- add playlist to queue
upnpavcmd(ip, 1400, 'AddURIToQueue', qPlaylist(2)) -- add the playlist id here

-- play
uri_queue = "x-rincon-queue:RINCON_B8E937A06A3E01400#0" -- add the right URI for the queue
upnpavcmd(ip, 1400, 'SetAVTransportURI', '<CurrentURI>'..uri_queue..'</CurrentURI><CurrentURIMetaData/>')
upnpavcmd(ip, 1400, 'Play', '<Speed>1</Speed>')

Hi Guy, 

how can i find the right URI? 
uri_queue = "x-rincon-queue:RINCON_<my macadress?>" -- add the right URI for the queue
Reply
#36
(24.11.2015, 12:23)gjniewenhuijse Wrote:
(23.11.2015, 12:49)admin Wrote: We don't have any Sonos devices so what we can help with is limited.

You can use Node.js library with debug enabled to monitor which kind of requests are being sent and then implement the same thing in LM.

Some hints for your case:
- To find your playlist id (SQ:1 or similar), you need to get a list of all playlists and find it there
- Use RemoveAllTracksFromQueue to empty current queue
- Use SetPlayMode to set repeat / shuffle
- You don't have to add tracks one by one, you can load the whole playlist (stored queue) in one call

Yes.. it works.
I attached a little bit changed upnpavcmd function.

And two new functions:

Code:
-- find all playlist
function getPlaylists(ip, port)
cBrowse = '<ObjectID>SQ:</ObjectID>' ..
        '<BrowseFlag>BrowseDirectChildren</BrowseFlag>' ..
        '<Filter>*</Filter>' ..
        '<StartingIndex>0</StartingIndex>' ..
        '<RequestedCount>25</RequestedCount>' ..
        '<SortCriteria>*</SortCriteria>'
  res,err = upnpavcmd(ip, port, 'Browse', cBrowse)
  return res,err
end

-- add saved queue (playlist) to queue
function qPlaylist(pId)
uriprm = '<EnqueuedURI>file:///jffs/settings/savedqueues.rsq#'..pId..'</EnqueuedURI>' ..
'<EnqueuedURIMetaData></EnqueuedURIMetaData>' ..
'<DesiredFirstTrackNumberEnqueued>0</DesiredFirstTrackNumberEnqueued>' ..
'<EnqueueAsNext>1</EnqueueAsNext>'
  return uriprm
end

-- find all playlist (run once and note playlist id)
res,err = getPlaylists(ip, 1400)
log(res)

And then you can use:


Code:
-- clear current queue
upnpavcmd(ip, 1400, 'RemoveAllTracksFromQueue')

-- add playlist to queue
upnpavcmd(ip, 1400, 'AddURIToQueue', qPlaylist(2)) -- add the playlist id here

-- play
uri_queue = "x-rincon-queue:RINCON_B8E937A06A3E01400#0" -- add the right URI for the queue
upnpavcmd(ip, 1400, 'SetAVTransportURI', '<CurrentURI>'..uri_queue..'</CurrentURI><CurrentURIMetaData/>')
upnpavcmd(ip, 1400, 'Play', '<Speed>1</Speed>')

Hi,

one question. Unfortunately I get an error message at the function: getPlaylists()

Error message:

Code:
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/48.2-61220 (ZPS14)
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>401</errorCode></UPnPError></detail></s:Fault></s:Body></s:Envelope>


and when I execute the command with various IDs and look in the app to see which playlist the ID could be, the playlists are somehow mixed, although I of course take them all out of the queue first. 

-- add playlist to queue
upnpavcmd(ip, 1400, 'AddURIToQueue', qPlaylist(2)) -- 
I can control unique playlists. I don't understand the problem.
Reply
#37
Have you tried the Sonos app from LM app store? This code is outdated and might not work with newer Sonos devices/firmwares.
Reply
#38
Thanks for your reply. What do you mean, have you try the sonos app from LM appstore?? I installed it, yes. But how do I get the corresponding playlists?

That's a pity when code expires.
Then I can never implement and sell the LM for customers?
Reply
#39
The error that you are getting for getPlaylists can be caused by using old upnpavcmd function. Try using the code attached to this post: https://forum.logicmachine.net/showthrea...601#pid601

As for outdated code I was referring to Sonos UPnP support which can change from version to version. Changes that break backward compatibility in LM happen rarely.
Reply
#40
(09.03.2016, 07:03)Erwin van der Zwart Wrote: Hi Ruben,

Sounds good, I would make que random to avoid listen to same music over and over (:

What commands from the original sonos script are missing in my version? I can add them..

BR,

Erwin

thanks for help admin. But now i get the following error message. :-(

Code:
* string: HTTP/1.1 500 Internal Server Error
Server: Linux UPnP/1.0 Sonos/48.2-61220 (ZPS12)
Connection: close
Reply


Forum Jump: