NEW frontpage.html - request comments

Moderator: leecollings

HansLe
Posts: 25
Joined: Wednesday 13 January 2016 21:12
Target OS: Raspberry Pi / ODroid
Domoticz version: V2.3530
Location: Netherlands
Contact:

Re: NEW frontpage.html - request comments

Post 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 ;)
Raspberry Pi B+ | Domoticz v3.4834 | RFXtrx433E | Action sockets and remote control (a cheap solution to start with)
Sonos device: control via Action remote control and EasySonos (via Domoticz scripts)
2 x Chresta TX320, Kaku sensoren, D-link camera
User avatar
G3rard
Posts: 669
Joined: Wednesday 04 March 2015 22:15
Target OS: -
Domoticz version: No
Location: The Netherlands
Contact:

Re: NEW frontpage.html - request comments

Post 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.
Not using Domoticz anymore
trekker25
Posts: 40
Joined: Tuesday 26 May 2015 10:50
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: NEW frontpage.html - request comments

Post 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 :D :D
Kohen
Posts: 23
Joined: Monday 12 October 2015 12:05
Target OS: NAS (Synology & others)
Domoticz version:
Location: Veldhoven, The Netherlands
Contact:

Re: NEW frontpage.html - request comments

Post 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

:D :D after I got my raspberry restart it works

Top Thanks for your help

Now again I can continue, I am happy with it :D :D

Can you share your doorbell action script? Like to try it too.
Synology NAS 412+, Aeotec stick V5, Aeotec recessed door sensor, Aeotec micro double smart switch, Fibaro Dimmer, iPad 2 with own 3d printed wall mount.
HansLe
Posts: 25
Joined: Wednesday 13 January 2016 21:12
Target OS: Raspberry Pi / ODroid
Domoticz version: V2.3530
Location: Netherlands
Contact:

Re: NEW frontpage.html - request comments

Post by HansLe »

@G3rard. I have a problem to define my Sonos device. There seems to be a problem with line 290 in frontpage.js.

Code: Select all

var vs2 = JSON.parse(vs2);	
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 ;)
Raspberry Pi B+ | Domoticz v3.4834 | RFXtrx433E | Action sockets and remote control (a cheap solution to start with)
Sonos device: control via Action remote control and EasySonos (via Domoticz scripts)
2 x Chresta TX320, Kaku sensoren, D-link camera
User avatar
G3rard
Posts: 669
Joined: Wednesday 04 March 2015 22:15
Target OS: -
Domoticz version: No
Location: The Netherlands
Contact:

Re: NEW frontpage.html - request comments

Post 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.

Code: Select all

var vs2 = JSON.parse(vs2);	
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.
Not using Domoticz anymore
luckydoggie
Posts: 9
Joined: Friday 29 January 2016 18:43
Target OS: Raspberry Pi / ODroid
Domoticz version: Stable
Location: Netherlands
Contact:

Re: NEW frontpage.html - request comments

Post 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
HansLe
Posts: 25
Joined: Wednesday 13 January 2016 21:12
Target OS: Raspberry Pi / ODroid
Domoticz version: V2.3530
Location: Netherlands
Contact:

Re: NEW frontpage.html - request comments

Post 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.
Raspberry Pi B+ | Domoticz v3.4834 | RFXtrx433E | Action sockets and remote control (a cheap solution to start with)
Sonos device: control via Action remote control and EasySonos (via Domoticz scripts)
2 x Chresta TX320, Kaku sensoren, D-link camera
luckydoggie
Posts: 9
Joined: Friday 29 January 2016 18:43
Target OS: Raspberry Pi / ODroid
Domoticz version: Stable
Location: Netherlands
Contact:

Re: NEW frontpage.html - request comments

Post 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.
User avatar
G3rard
Posts: 669
Joined: Wednesday 04 March 2015 22:15
Target OS: -
Domoticz version: No
Location: The Netherlands
Contact:

Re: NEW frontpage.html - request comments

Post 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
Not using Domoticz anymore
luckydoggie
Posts: 9
Joined: Friday 29 January 2016 18:43
Target OS: Raspberry Pi / ODroid
Domoticz version: Stable
Location: Netherlands
Contact:

Re: NEW frontpage.html - request comments

Post 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
Capture.JPG (62.71 KiB) Viewed 3905 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
Capture2.JPG (92.91 KiB) Viewed 3905 times
It seems that there is a problem in the frontpage.js sonos code.
User avatar
G3rard
Posts: 669
Joined: Wednesday 04 March 2015 22:15
Target OS: -
Domoticz version: No
Location: The Netherlands
Contact:

Re: NEW frontpage.html - request comments

Post 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?
Not using Domoticz anymore
luckydoggie
Posts: 9
Joined: Friday 29 January 2016 18:43
Target OS: Raspberry Pi / ODroid
Domoticz version: Stable
Location: Netherlands
Contact:

Re: NEW frontpage.html - request comments

Post 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.
User avatar
G3rard
Posts: 669
Joined: Wednesday 04 March 2015 22:15
Target OS: -
Domoticz version: No
Location: The Netherlands
Contact:

Re: NEW frontpage.html - request comments

Post by G3rard »

Those are indeed the right values.
Does it work on the frontpage as well?
Not using Domoticz anymore
luckydoggie
Posts: 9
Joined: Friday 29 January 2016 18:43
Target OS: Raspberry Pi / ODroid
Domoticz version: Stable
Location: Netherlands
Contact:

Re: NEW frontpage.html - request comments

Post by luckydoggie »

Volume up, Volume down, Stop and Play work. I can't check the others because the frontpage does not show these.
User avatar
G3rard
Posts: 669
Joined: Wednesday 04 March 2015 22:15
Target OS: -
Domoticz version: No
Location: The Netherlands
Contact:

Re: NEW frontpage.html - request comments

Post by G3rard »

Did you set show_sonos_volume to true in frontpage_settings.js?
Not using Domoticz anymore
luckydoggie
Posts: 9
Joined: Friday 29 January 2016 18:43
Target OS: Raspberry Pi / ODroid
Domoticz version: Stable
Location: Netherlands
Contact:

Re: NEW frontpage.html - request comments

Post 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.
User avatar
G3rard
Posts: 669
Joined: Wednesday 04 March 2015 22:15
Target OS: -
Domoticz version: No
Location: The Netherlands
Contact:

Re: NEW frontpage.html - request comments

Post by G3rard »

I thought that it worked after you added the IP address to the VolumeSonos, MediaInfoSonos and PositionInfoSonos functions :geek:

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?
Not using Domoticz anymore
luckydoggie
Posts: 9
Joined: Friday 29 January 2016 18:43
Target OS: Raspberry Pi / ODroid
Domoticz version: Stable
Location: Netherlands
Contact:

Re: NEW frontpage.html - request comments

Post 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.
User avatar
G3rard
Posts: 669
Joined: Wednesday 04 March 2015 22:15
Target OS: -
Domoticz version: No
Location: The Netherlands
Contact:

Re: NEW frontpage.html - request comments

Post 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.
Not using Domoticz anymore
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest