| 
		
	
	
	
		
	Posts: 1807 
	Threads: 7 
	Joined: Jul 2015
	
 Reputation: 
121 
	
		
		
		14.01.2017, 12:49 
(This post was last modified: 15.01.2017, 12:30 by Erwin van der Zwart.)
		
	 
		 (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
 
 
		
	 
	
	
	
		
	Posts: 57 
	Threads: 7 
	Joined: Jul 2016
	
 Reputation: 
1 
	
	
		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
 
		
	 
	
	
	
		
	Posts: 1807 
	Threads: 7 
	Joined: Jul 2015
	
 Reputation: 
121 
	
		
		
		15.02.2017, 19:19 
(This post was last modified: 15.02.2017, 19:23 by Erwin van der Zwart.)
		
	 
		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
 
		
	 
	
	
	
		
	Posts: 57 
	Threads: 7 
	Joined: Jul 2016
	
 Reputation: 
1 
	
	
		 (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
	 
		
	 
	
	
	
		
	Posts: 8410 
	Threads: 45 
	Joined: Jun 2015
	
 Reputation: 
481 
	
	
		Erwin, gsub on line 273 should be moved inside "if" on line 277, otherwise it can trigger the above error   
		
	 
	
	
	
		
	Posts: 57 
	Threads: 7 
	Joined: Jul 2016
	
 Reputation: 
1 
	
	
		 (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
	 
		
	 
	
	
	
		
	Posts: 1807 
	Threads: 7 
	Joined: Jul 2015
	
 Reputation: 
121 
	
		
		
		15.02.2017, 19:34 
(This post was last modified: 15.02.2017, 19:38 by Erwin van der Zwart.)
		
	 
		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
 
		
	 
	
	
	
		
	Posts: 8410 
	Threads: 45 
	Joined: Jun 2015
	
 Reputation: 
481 
	
	
		Bart, try updating the Sonos app now
	 
		
	 
	
	
	
		
	Posts: 57 
	Threads: 7 
	Joined: Jul 2016
	
 Reputation: 
1 
	
	
		 (15.02.2017, 19:34)admin Wrote:  Bart, try updating the Sonos app now 
You guys are the best - works again! 
Thanks, Bart
	 
		
	 
	
	
	
		
	Posts: 92 
	Threads: 31 
	Joined: Feb 2016
	
 Reputation: 
0 
	
	
		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!
 
		
	 
	
	
	
		
	Posts: 1807 
	Threads: 7 
	Joined: Jul 2015
	
 Reputation: 
121 
	
		
		
		23.02.2017, 23:05 
(This post was last modified: 23.02.2017, 23:20 by Erwin van der Zwart.)
		
	 
		Hi Josep, 
You can get feedback info from Sonos App API by using this:
 Code: -- Load modulesrequire('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
	
		
	 
	
	
	
		
	Posts: 92 
	Threads: 31 
	Joined: Feb 2016
	
 Reputation: 
0 
	
	
		 (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 modulesrequire('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.
	 
		
	 
	
	
	
		
	Posts: 1807 
	Threads: 7 
	Joined: Jul 2015
	
 Reputation: 
121 
	
		
		
		24.02.2017, 09:26 
(This post was last modified: 24.02.2017, 09:32 by Erwin van der Zwart.)
		
	 
		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
 
		
	 
	
	
	
		
	Posts: 92 
	Threads: 31 
	Joined: Feb 2016
	
 Reputation: 
0 
	
	
		 (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!!!
	 
		
	 
	
	
	
		
	Posts: 8410 
	Threads: 45 
	Joined: Jun 2015
	
 Reputation: 
481 
	
	
		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.
	 
		
	 
	
	
	
		
	Posts: 92 
	Threads: 31 
	Joined: Feb 2016
	
 Reputation: 
0 
	
	
		Hi, 
My Idea is put Sonos control into this visualization page, all my questions is about view Sonos feedbacks in this page... THX
  
		
	 
	
	
	
		
	Posts: 92 
	Threads: 31 
	Joined: Feb 2016
	
 Reputation: 
0 
	
	
		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
 
		
	 
	
	
	
		
	Posts: 1807 
	Threads: 7 
	Joined: Jul 2015
	
 Reputation: 
121 
	
	
		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
 
		
	 
	
	
	
		
	Posts: 92 
	Threads: 31 
	Joined: Feb 2016
	
 Reputation: 
0 
	
		
		
		24.02.2017, 14:26 
(This post was last modified: 24.02.2017, 14:34 by josep.)
		
	 
		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
 
		
	 
	
	
	
		
	Posts: 1807 
	Threads: 7 
	Joined: Jul 2015
	
 Reputation: 
121 
	
		
		
		25.02.2017, 09:28 
(This post was last modified: 25.02.2017, 15:25 by Erwin van der Zwart.)
		
	 
		Hi Josep, 
Yes you can update only on changed value like this:
 Code: -- Update objectscurrentvalue = 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
 
BR,
 
Erwin
	
		
	 |