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 app
#41
(14.01.2017, 11:52)admin Wrote: All apps should use jQuery from /apps/js/jquery.js.gz, as the contents of visualization's jQuery package is not guaranteed (it uses velocity.js for animation instead of built-in).

Hi Admin,

I know, but app is originally made for HL/SL and the files in/apps/js are not available until next FW (:

I have HL beta FW with files now, so all apps i create now uses /apps/js files.

Thanks!

BR,

Erwin

Reply
#42
Hi guys,
Anyone seen the error 'Error in /www/apps/data/sonos/sonos.lp at line 273: attempt to index global 'zonename' (a nil value)'?
The sonos app runs, once on the schneider logo it moves to the "now playing screen" but returns to schneider logo, and so on...
Don't know what causes this - regular sonos app (ipad) works fine. I added multiple sonos-players since the first test/installation and also updated to the latest sonos version earlier this week. Result is that no sonos players can be found and be controlled.
Any ideas Erwin?
Thanks, Bart
Reply
#43
Hi Bart,

Can you try to enable the checkbox advanced settings and press the search sonos button?

I will update my Sonos in a minute and will check if something is changed, but i don't realy expect that..

BR,

Erwin
Reply
#44
(15.02.2017, 19:19)Erwin van der Zwart Wrote: Hi Bart,

Can you try to enable the checkbox advanced settings and press the search sonos button?

I will update my Sonos in a minute and will check if something is changed, but i don't realy expect that..

BR,

Erwin

Hi Erwin,
I can't hit the search button - it switches back to the schneider logo after fading to the screen - switching between the schneider logo and the 'now playing screen'. I does this indefinitively.
Bart
Reply
#45
Erwin, gsub on line 273 should be moved inside "if" on line 277, otherwise it can trigger the above error Wink
Reply
#46
(15.02.2017, 19:27)bmodeco Wrote:
(15.02.2017, 19:19)Erwin van der Zwart Wrote: Hi Bart,

Can you try to enable the checkbox advanced settings and press the search sonos button?

I will update my Sonos in a minute and will check if something is changed, but i don't realy expect that..

BR,

Erwin

Hi Erwin,
I can't hit the search button - it switches back to the schneider logo after fading to the screen - switching between the schneider logo and the 'now playing screen'. I does this indefinitively.
Bart

Just extra info: it is just the detection of the players that is not working.
When using the commands with the players ip-adr. - the commands do work
Bart
Reply
#47
Hi Admin,

There are so much lines of code in this app so i missed it (:

Are you going to modify this and update the app in the store or do you want a updated version? 

Erwin
Reply
#48
Bart, try updating the Sonos app now
Reply
#49
(15.02.2017, 19:34)admin Wrote: Bart, try updating the Sonos app now

You guys are the best - works again!
Thanks, Bart
Reply
#50
Hello Erwin,

How Can I save a feedback info from HTTP API into a group adress to use it into a custom visualization dessign? Thank you very much!
Reply
#51
Hi Josep,

You can get feedback info from Sonos App API by using this:

Code:
-- Load modules
require('socket.http')
require('json')

-- Set timout
socket.http.TIMEOUT = 5

-- Set SONOS IP
Sonos_Player_IP = '192.168.10.26'
reply = socket.http.request('http://127.0.0.1/apps/data/sonos/sonos.lp?action=getextendedstate&ip=' .. Sonos_Player_IP)

-- Set SONOS Name
--Sonos_Player_Name = 'Woonkamer'
--reply = socket.http.request('http://127.0.0.1/apps/data/sonos/sonos.lp?action=getextendedstate&name=' .. Sonos_Player_Name)

-- Get values from result table
replytable = json.pdecode(reply)
volume = replytable[1].volume or 0
mute = replytable[2].mute or 0
crossfade = replytable[3].crossfade or 0
playmode = replytable[4].playmode or ''
transport = replytable[5].transport or ''
trackuri = replytable[6].trackuri or ''
duration = replytable[7].duration or ''
playingtime = replytable[8].playingtime or ''
tracktitle = replytable[9].tracktitle or ''
creator = replytable[10].creator or ''
album = replytable[11].album or ''
albumart = replytable[12].albumart or ''
mediatype = replytable[13].mediatype or ''
trackuri = replytable[14].trackuri or ''
trackurimetadata = replytable[15].trackurimetadata or ''
albumartbase64 = replytable[16].albumartbase64 or ''
sonosplayerip = replytable[17].sonosplayerip or ''

-- Update objects
grp.update('1/1/5', volume)

There are 2 methodes in this sample, 1 by Player IP and 1 by Player name, you can pick 1 of them..

BR,

Erwin
Reply
#52
(23.02.2017, 23:05)Erwin van der Zwart Wrote: Hi Josep,

You can get feedback info from Sonos App API by using this:

Code:
-- Load modules
require('socket.http')
require('json')

-- Set timout
socket.http.TIMEOUT = 5

-- Set SONOS IP
Sonos_Player_IP = '192.168.10.26'
reply = socket.http.request('http://127.0.0.1/apps/data/sonos/sonos.lp?action=getextendedstate&ip=' .. Sonos_Player_IP)

-- Set SONOS Name
--Sonos_Player_Name = 'Woonkamer'
--reply = socket.http.request('http://127.0.0.1/apps/data/sonos/sonos.lp?action=getextendedstate&name=' .. Sonos_Player_Name)

-- Get values from result table
replytable = json.pdecode(reply)
volume = replytable[1].volume or 0
mute = replytable[2].mute or 0
crossfade = replytable[3].crossfade or 0
playmode = replytable[4].playmode or ''
transport = replytable[5].transport or ''
trackuri = replytable[6].trackuri or ''
duration = replytable[7].duration or ''
playingtime = replytable[8].playingtime or ''
tracktitle = replytable[9].tracktitle or ''
creator = replytable[10].creator or ''
album = replytable[11].album or ''
albumart = replytable[12].albumart or ''
mediatype = replytable[13].mediatype or ''
trackuri = replytable[14].trackuri or ''
trackurimetadata = replytable[15].trackurimetadata or ''
albumartbase64 = replytable[16].albumartbase64 or ''
sonosplayerip = replytable[17].sonosplayerip or ''

-- Update objects
grp.update('1/1/5', volume)

There are 2 methodes in this sample, 1 by Player IP and 1 by Player name, you can pick 1 of them..

BR,

Erwin

Hi Erwin,

I have two questions about this,

1.- How Can I read feedback cyclically without overload the LM CPU, for example I try to use a ciclally scrip to 1s to view play time in real time and this freeze the LM CPU

2.- How can I use the album Art URL into group address to use into visualization. 

THX very much.
Reply
#53
Hi Josep,

I think you update all the objects every loop (1 second) and this is what causes the CPU load to shoot in the air. When polling only the data to the controller without writng to objects you hardly notice a CPU increasement.

So i would poll slower and/or check first the old value before updating a object. This was the main reason for me to make a app to bypass the need of use KNX objects for this as there is a lot of data between controller and Sonos to be exchanged when you want real time data from Sonos... 

You can use the URL to album art together with some custom javascript to update a image container in your visu.

Anyway, i would strongly advice you to use the app for real time data and KNX only for control so you won't have to poll every second with a LOT of data to KNX objects..

BR,

Erwin
Reply
#54
(24.02.2017, 09:26)Erwin van der Zwart Wrote: Hi Josep,

I think you update all the objects every loop (1 second) and this is what causes the CPU load to shoot in the air. When polling only the data to the controller without writng to objects you hardly notice a CPU increasement.

So i would poll slower and/or check first the old value before updating a object. This was the main reason for me to make a app to bypass the need of use KNX objects for this as there is a lot of data between controller and Sonos to be exchanged when you want real time data from Sonos... 

You can use the URL to album art together with some custom javascript to update a image container in your visu.

Anyway, i would strongly advice you to use the app for real time data and KNX only for control so you won't have to poll every second with a LOT of data to KNX objects..

BR,

Erwin
Hi Erwin,

I use KNX addresses because it's the only way that I know to use the variables into the visualization. We are making a custom visualization to control all the things in one place and I'm very interested in use my visualization to control basic Sonos functions... Can I use some type of internal variables different that KNX group address to represent that values into my custom visu?

Can you show me an example to implementate the album art with JavaScript?

Thank you very much!!!
Reply
#55
There will be "virtual objects" in the next firmware. Virtual object address range is outside of standard KNX group address range, so virtual objects are not passed to KNX/IP or KNX/TP. Apart from that they will act absolutely the same.
Reply
#56
Hi,

My Idea is put Sonos control into this visualization page, all my questions is about view Sonos feedbacks in this page... THX

   
Reply
#57
Hi Erwin,

I'm trying to make an html resource into /img using your lua script (Create Albumart HTML.lua) but it doesn't work with my album cover adress and a frame into visu... everytime it appears like NOT COVER draw, Can you help me please?

THX
Reply
#58
Hi,

You must ignore this file, it was written for old FW, url's are changed in current FW and we have custom JavaScript now (:

I will try to upload a custom Javascript sample tonight.

BR,

Erwin
Reply
#59
Thank you very much!

Hi,

It's possible to update feedback values only when it changes and not ciclally? for example only write values into KNX adresses only when song title change, How Can I make this? Thank you

BR
Reply
#60
Hi Josep,

Yes you can update only on changed value like this:

Code:
-- Update objects
currentvalue = grp.getvalue('1/1/6')
if currentvalue ~= albumart then
    grp.update('1/1/6', albumart)
end

For albumart, create a image container and add a default image that must be showed on startup (noalbumart or something) and give it a additional class 'albumart' 

Add this to custom JavaScript to update the image on new URL (now linked to address 1/1/6):

Code:
$(function(){
 if (typeof grp != 'undefined') {
   grp.listen('1/1/6', function(object, state) {
     var value = object.value;
     if (state == 'value') {
       $(".albumart").find("img").attr('src', value);
     }
   }, true);
 }
});

That should do the trick.

Here is also a custom JavaScript that will perform feedback polling direct between API and client, so you don't need the LUA script and objects in the controller (:

Code:
$(function(){
 setInterval(function(){
   // Only poll if current page = 1
   //console.log(currentPlanId)
   if (currentPlanId == 1 ){
     // Request data from sonos API
     $.post("/apps/data/sonos/sonos.lp",
     { action: "getextendedstate", ip: "192.168.10.26" },
     function(data) {
     var res_parsed = JSON.parse(data);
     //console.log(res_parsed)

     // Update text label with additional class 'volume'
     $(".volume").html(res_parsed[0].volume);

     // Update text label with additional class 'mute'
       $(".mute").html(res_parsed[1].mute);

     // Update text label with additional class 'crossfade'
       $(".crossfade").html(res_parsed[2].crossfade);

     // Update text label with additional class 'playmode'    
     $(".playmode").html(res_parsed[3].playmode);

     // Update text label with additional class 'transport'
     $(".transport").html(res_parsed[4].transport);

     // Update text label with additional class 'trackuri'
     $(".trackuri").html(res_parsed[5].trackuri);

     // Update text label with additional class 'duration'
     $(".duration").html(res_parsed[6].duration);

     // Update text label with additional class 'playingtime'
     $(".playingtime").html(res_parsed[7].playingtime);

     // Update text label with additional class 'tracktitle'
     $(".tracktitle").html(res_parsed[8].tracktitle);

     // Update text label with additional class 'creator'
     $(".creator").html(res_parsed[9].creator);

     // Hide Album when mediatype = radio
     if (res_parsed[12].mediatype == 'radio'){
       $(".album").css( "display", "none" );
     } else {
       $(".album").css( "display", "block" );
       // Update text label with additional class 'album'
       $(".album").html(res_parsed[10].album);
     }

     // Update image container with additional class 'albumart'
     $(".albumart").find("img").attr('src', res_parsed[11].albumart);

      // Update text label with additional class 'mediatype'
     $(".mediatype").html(res_parsed[12].mediatype);
     //$(".trackuri").html(res_parsed[13].trackuri);
     //$(".trackurimetadata").html(res_parsed[14].trackurimetadata);
     //$(".albumartbase64").html(res_parsed[15].albumartbase64);
     //$(".sonosplayerip").html(res_parsed[16].sonosplayerip);
     }
   );
 }; }, 1000);
});

Note the pagenumber condition (on line 4) to poll only when the page with you sonos control is visible, make sure to use it like this to avoid polling when you don't need to.

I attached a sample page with elements you can use with above custom javascript

.tar   Vis-Custom_Sonos-homeLYnk-2017.02.25-15.44.tar (Size: 9 KB / Downloads: 37)

BR,

Erwin
Reply


Forum Jump: