Page 45 of 66
Re: NEW frontpage.html - request comments
Posted: Friday 29 January 2016 23:27
by HansLe
I´ve not tested yet but you are using a selector. G3rard describes to use a switch (
https://github.com/gerard33/frontpage).
I see you are using the default Mediaplayer icon. On this page (
https://drive.google.com/folderview?id= ... sp=sharing) you can find a beautiful Sonos icon

Re: NEW frontpage.html - request comments
Posted: Saturday 30 January 2016 20:46
by G3rard
@luckydoggie, indeed use a normal on/off switch. The js code is looking for an On status, which the selector button doesn't have, so you won't see the buttons in the cell.
Re: NEW frontpage.html - request comments
Posted: Monday 01 February 2016 10:46
by trekker25
just letting you know:
android tablet + motion detector + automagic + boatbrowser is running for weeks perfectly without crashes/reboots. And my walltablet always turns on perfectly when i walk by

Re: NEW frontpage.html - request comments
Posted: Monday 01 February 2016 21:26
by Kohen
benotje wrote:G3rard wrote:@benotje, did you save the LUA as a Device in the Event page?
The pulldown on the right top now probably says All. Change that to Device and save the LUA script.
No I did not but this does not help
I can not specify LUA IDX: 104

after I got my raspberry restart it works
Top Thanks for your help
Now again I can continue, I am happy with it

Can you share your doorbell action script? Like to try it too.
Re: NEW frontpage.html - request comments
Posted: Tuesday 02 February 2016 0:04
by HansLe
@G3rard. I have a problem to define my Sonos device. There seems to be a problem with line 290 in frontpage.js.
However I can see the error message "Uncaught SyntaxError: Unexpected token <" I don't know how to solve this. I don't know how to inspect a variable with inspect. Your advise please

Re: NEW frontpage.html - request comments
Posted: Tuesday 02 February 2016 22:10
by G3rard
HansLe wrote:@G3rard. I have a problem to define my Sonos device. There seems to be a problem with line 290 in frontpage.js.
However I can see the error message "Uncaught SyntaxError: Unexpected token <" I don't know how to solve this. I don't know how to inspect a variable with inspect. Your advise please

Sent you a PM for some more details.
Re: NEW frontpage.html - request comments
Posted: Thursday 04 February 2016 22:14
by luckydoggie
Hi,
I think I know what the problem is. I executed the sonos commands from the /var/www path because this is were PHP5 is installed, but in frontpage.js it points to the sonos folder inside the domoticz's www path. Unfortunately I can't get PHP to run from the domoticz location.
So, I previously run the commands from the
http://192.168.0.124/sonos/index.php?zone=7&action=Play (which worked).
Now I need to run it from
http://192.168.0.124:8080/sonos/index.p ... ction=Play (it think, which doesn't work).
In the first it just plays the radio station it was paused on. In the second it only displays the index.php text.
Does someone know how to run PHP5 from the domoticz location or did I do something wrong?
Greetings,
Tom
Re: NEW frontpage.html - request comments
Posted: Saturday 06 February 2016 0:19
by HansLe
@Luckydogg, that's indeed the problem. I got it working today. See for example the following changed functions in frontpage.js.
Code: Select all
//Volume up of Sonos
function ChangeVolumeUp(idx)
{
var url = "http://172.16.0.12/" + "sonos/index.php?zone=" + idx + "&action=VolumeUp";
console.log(url);
$.ajax({
url: url,
async: true,
dataType: 'html', //was json but that always gave an error although it's working
success: function(){
console.log('Volume up');
},
error: function(){
console.log('ERROR');
}
});
RefreshData();
}
//Volume down of Sonos
function ChangeVolumeDown(idx)
{
var url = "http://172.16.0.12/" + "sonos/index.php?zone=" + idx + "&action=VolumeDown";
console.log(url);
$.ajax({
url: url,
async: true,
dataType: 'html',
success: function(){
console.log('Volume down');
},
error: function(){
console.log('ERROR');
}
});
RefreshData();
}
As you can see I made an url variabele where I've added the IP address (without the port number). This works fine for me. I think this will solve your problem to. Be aware that you have to do this for all the Sonos function calls.
Re: NEW frontpage.html - request comments
Posted: Sunday 07 February 2016 11:13
by luckydoggie
@HansLe
Great! Got it working, thanks! Next problem is that if I enable the show_sonos_volume it doesn't work anymore. Do you got this working?
#Edit: With not working I mean that there are two lines at the frontpage where the data should be. All calls to the sonos that are necessary are working in browser.
Re: NEW frontpage.html - request comments
Posted: Sunday 07 February 2016 14:00
by G3rard
luckydoggie wrote:@HansLe
Great! Got it working, thanks! Next problem is that if I enable the show_sonos_volume it doesn't work anymore. Do you got this working?
#Edit: With not working I mean that there are two lines at the frontpage where the data should be. All calls to the sonos that are necessary are working in browser.
Did you change to an on/off switch?
http://www.domoticz.com/forum/viewtopic ... 900#p72647
Re: NEW frontpage.html - request comments
Posted: Sunday 07 February 2016 14:21
by luckydoggie
Yes I did. If I disable the show_sonos_volume variable it shows the plus and minus buttons and they also work, see image.

- Capture.JPG (62.71 KiB) Viewed 4039 times
But if I enable the variable the page crashes and doesn't show the controls at all including some of the other functions.

- Capture2.JPG (92.91 KiB) Viewed 4039 times
It seems that there is a problem in the frontpage.js sonos code.
Re: NEW frontpage.html - request comments
Posted: Sunday 07 February 2016 14:38
by G3rard
@luckydoggie
In the top of the frontpage.js file are also some functions for Sonos called
- VolumeSonos
- MediaInfoSonos
- PositionInfoSonos
Please add the IP address in the URL just as you did in ChangeVolumeUp and ChangeVolumeDown.
Does it work then?
Re: NEW frontpage.html - request comments
Posted: Sunday 07 February 2016 16:22
by luckydoggie
Volume returns an integer.
MediaInfo returns:
{"CurrentURI":"x-sonosapi-stream:s6707?sid=254&flags=32&sn=0","CurrentURIMetaData":"NPO 3FM Serious Radio<\/dc:title>object.item.audioItem.audioBroadcast<\/upnp:class>SA_RINCON65031_<\/desc><\/item><\/DIDL-Lite>","title":"NPO 3FM Serious Radio"}
PositionInfo returns:
{"position":"0:01:05","RelTime":"0:01:05","duration":"","TrackDuration":"","URI":"x-rincon-mp3radio:\/\/icecast.omroep.nl\/3fm-bb-mp3","TrackURI":"x-rincon-mp3radio:\/\/icecast.omroep.nl\/3fm-bb-mp3","artist":"","title":"3fm-bb-mp3","album":"","albumArtURI":"","albumArtist":"","albumTrackNumber":"","streamContent":"HAEVN - FINDING OUT MORE #SERIOUSTALENT","trackURI":"","Track":"1"}
So these are the right values I think.
I did alter the functions by putting the IP of the raspberry in front of the url like this:
<!-- Check volume of Sonos -->
function VolumeSonos(idx) {
return $.ajax({
url: "
http://192.168.0.124/" + "sonos/index.php?zone=" + idx + "&action=GetVolume",
type: 'get',
dataType: 'html',
async: false
}).responseText
}
This was because I could not get PHP to run on domoticz so I installed NGINX to run from the domoticz's www.
Re: NEW frontpage.html - request comments
Posted: Sunday 07 February 2016 17:20
by G3rard
Those are indeed the right values.
Does it work on the frontpage as well?
Re: NEW frontpage.html - request comments
Posted: Sunday 07 February 2016 17:45
by luckydoggie
Volume up, Volume down, Stop and Play work. I can't check the others because the frontpage does not show these.
Re: NEW frontpage.html - request comments
Posted: Sunday 07 February 2016 17:50
by G3rard
Did you set show_sonos_volume to true in frontpage_settings.js?
Re: NEW frontpage.html - request comments
Posted: Sunday 07 February 2016 18:12
by luckydoggie
That's the point. If I do that the page crashes and doesn't show anything. If I leave it at false the page loads correctly only I cant see what the current volume is and what is playing.
Re: NEW frontpage.html - request comments
Posted: Sunday 07 February 2016 19:17
by G3rard
I thought that it worked after you added the IP address to the VolumeSonos, MediaInfoSonos and PositionInfoSonos functions
Please set the show_sonos_volume to true and find these lines in frontpage.js
Code: Select all
var vs1 = myTrim(VolumeSonos(item.idx)); //show volume
var vs2 = myTrim(MediaInfoSonos(item.idx)); //show what's playing - radio
var vs3 = myTrim(PositionInfoSonos(item.idx)); //show what's playing - albums
var vs2 = JSON.parse(vs2); //show what's playing to array
var vs3 = JSON.parse(vs3); //show what's playing to array
and add the console log lines to it
Code: Select all
var vs1 = myTrim(VolumeSonos(item.idx)); //show volume
console.log('volume: ' + vs1)
var vs2 = myTrim(MediaInfoSonos(item.idx)); //show what's playing - radio
console.log('vs2 part1: ' + vs2)
var vs3 = myTrim(PositionInfoSonos(item.idx)); //show what's playing - albums
console.log('vs3 part1: ' + vs3)
var vs2 = JSON.parse(vs2); //show what's playing to array
console.log('vs2 part2: ' + vs2)
var vs3 = JSON.parse(vs3); //show what's playing to array
console.log('vs3 part2: ' + vs3)
What is the console showing?
Re: NEW frontpage.html - request comments
Posted: Sunday 07 February 2016 20:31
by luckydoggie
The console shows:
XMLHttpRequest cannot load
http://192.168.0.124/sonos/index.php?zo ... =GetVolume. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin '
http://192.168.0.124:8080' is therefore not allowed access.
send @ jquery.min.js:6
x.extend.ajax @ jquery.min.js:6
VolumeSonos @ frontpage.js:23
(anonymous function) @ frontpage.js:287
x.extend.each @ jquery.min.js:4
(anonymous function) @ frontpage.js:92
c @ jquery.min.js:4
p.fireWith @ jquery.min.js:4
k @ jquery.min.js:6
r @ jquery.min.js:6
and:
Uncaught TypeError: Cannot read property 'replace' of undefined
So the error lies because there is a cross-domain request?
In that case I have to figure out how to get PHP to run on the domoticz server.
Re: NEW frontpage.html - request comments
Posted: Sunday 07 February 2016 22:05
by G3rard
Yes that's indeed the problem. I have Domoticz and the frontpage both running on my NAS, so don't have that problem.
See this link for a fix
http://stackoverflow.com/questions/7564 ... low-origin.