Page 42 of 66

Re: NEW frontpage.html - request comments

Posted: Sunday 03 January 2016 14:58
by G3rard
FutureCow wrote:I'm trying to move the FrontPage to my own webserver (on the same server as Domoticz)
I have copied al the folders from domoticz/www/ to /var/www/

When i'm opening the FrontPage, everything look gooed, but the switches aren't working! When i'm pusing a switch, i hear the sounds and also see the "inschakelen" on the webpage. But the switch stays "UIT".

Is this a problem with owner/chmod?
I already tried a couple of things, but nothing is working.
Check your frontpage.js file and look for the functions. The URL part has to start with $.domoticzurl+"/. See the example below for function SwitchToggle.

Code: Select all

url: $.domoticzurl+"/json.htm?type=command&param=switchlight" + "&idx=" + idx + "&switchcmd=" + switchcmd,
Add the $.domoticzurl+"/ for all functions and it should work.

Re: NEW frontpage.html - request comments

Posted: Sunday 03 January 2016 16:23
by FutureCow
G3rard wrote:
FutureCow wrote:I'm trying to move the FrontPage to my own webserver (on the same server as Domoticz)
I have copied al the folders from domoticz/www/ to /var/www/

When i'm opening the FrontPage, everything look gooed, but the switches aren't working! When i'm pusing a switch, i hear the sounds and also see the "inschakelen" on the webpage. But the switch stays "UIT".

Is this a problem with owner/chmod?
I already tried a couple of things, but nothing is working.
Check your frontpage.js file and look for the functions. The URL part has to start with $.domoticzurl+"/. See the example below for function SwitchToggle.

Code: Select all

url: $.domoticzurl+"/json.htm?type=command&param=switchlight" + "&idx=" + idx + "&switchcmd=" + switchcmd,
Add the $.domoticzurl+"/ for all functions and it should work.
Thanks, that worked!
Last question (for now):
Is it possible to use another FrontPage.js for the day and night? (FrontpageDay.js and FrontPageNight.js) i'm using different weather icons for my day and night screen. And the link to the icons are inside the FrontPage.js

Or is it possible to change the page at a certain time:
go to FrontPage.html:
if time is before sunset --> FrontPageDay.html
if time is after sunset --> FrontPageNight.html

Re: NEW frontpage.html - request comments

Posted: Sunday 03 January 2016 21:56
by G3rard
FutureCow wrote:
Thanks, that worked!
Last question (for now):
Is it possible to use another FrontPage.js for the day and night? (FrontpageDay.js and FrontPageNight.js) i'm using different weather icons for my day and night screen. And the link to the icons are inside the FrontPage.js

Or is it possible to change the page at a certain time:
go to FrontPage.html:
if time is before sunset --> FrontPageDay.html
if time is after sunset --> FrontPageNight.html
My frontpage uses a Domoticz virtual switch to check whether it is day or night and changes the CSS to that. Also the code in frontpage.js used that to show different icons.
See https://github.com/gerard33/frontpage/b ... ontpage.js on line 444 and further.

Re: NEW frontpage.html - request comments

Posted: Thursday 07 January 2016 13:48
by Minglarn
Love this frontpage! Have been poking around and really love the easiness behind it! Great job to you all!

Two questions...
If I create a third page , would it bee to much for the Rasp PI2 & Domoticz to handle. I've already added an extra row to both of the pages, but I feel I need a 3 page.
And I dont seem to make a switch with custom icons "switchable" ...

I've added this to frontpage_settings.js:

Code: Select all

var idx_Motor = '62'; 
['62','Status',				'cell2_8',	'Motorvärmare','1','0'],
And this in frontpage.js:

Code: Select all

case idx_Motor:
if (vdata == txt_on) {
vdata = '<img src=icons/engine_on.png onclick="bleep.play();SwitchToggle('+item.idx+', \'On\');">';
} else {
vdata = '<img src=icons/engine_off.png onclick="bleep.play();SwitchToggle('+item.idx+', \'Off\');">';									
 }
break;	

Re: NEW frontpage.html - request comments

Posted: Thursday 07 January 2016 14:38
by jannl
I also need a third page, sensors and more (virtual) switches keep being added.

The work/cpu time for building the page is done on the tablet (mostly javascript). I use 2 json calls to get the data from Domoticz, the rest is done on the tablet by the browser. Because I read floorplan 0, I already have every switch etc present.

Re: NEW frontpage.html - request comments

Posted: Thursday 07 January 2016 20:31
by Minglarn
Good to hear that!

Any help regarding the switch?
Seems that if it locked it uses my icons but when it's unlocked its standard icon. Must be something I'm missing.


Sent from space using an app.

Re: NEW frontpage.html - request comments

Posted: Thursday 07 January 2016 21:55
by jannl
Here the toggle function is not in the vdata. Vdata contains the text or icon to show.
Please check the frontpage.js.
Looks like this here:

Code: Select all

if (typeof vattr == 'undefined') {
            if (item.Protected == true) {
                            $('#'+vlabel).html('<div onClick="lightbox_open(\'protected\', '+switch_protected_timeout+', '+txt_switch_protected+');" style='+alarmcss+'>'+vdata+'</div>');
            } else {
                            $('#'+vlabel).html('<div '+switchclick+' style='+alarmcss+'>'+vdata+'</div>');
            }
}
else if (item.Protected == true) {
            $('#'+vlabel).html( '<div onClick="lightbox_open(\'protected\', '+switch_protected_timeout+ ', '+txt_switch_protected+');" style='+vattr+alarmcss+'>'+vdata+'</div>');
} else {
            $('#'+vlabel).html( '<div '+switchclick+' style='+vattr+alarmcss+'>'+vdata+'</div>');
}


Re: NEW frontpage.html - request comments

Posted: Thursday 07 January 2016 22:52
by Minglarn
Dont quite follow you....

I've a swich. I added custom icons for it. But when I set the switch as non protected it does not use the custom icons.
However, when the switch is protected the icons show up. But now I cant change the status because it protected... :(

Re: NEW frontpage.html - request comments

Posted: Friday 08 January 2016 7:34
by jannl
Check the javascript. There is a difference between protected and not protected.

Re: NEW frontpage.html - request comments

Posted: Friday 08 January 2016 8:07
by Minglarn
jannl wrote:Here the toggle function is not in the vdata. Vdata contains the text or icon to show.
Please check the frontpage.js.
Looks like this here:

Code: Select all

if (typeof vattr == 'undefined') {
            if (item.Protected == true) {
                            $('#'+vlabel).html('<div onClick="lightbox_open(\'protected\', '+switch_protected_timeout+', '+txt_switch_protected+');" style='+alarmcss+'>'+vdata+'</div>');
            } else {
                            $('#'+vlabel).html('<div '+switchclick+' style='+alarmcss+'>'+vdata+'</div>');
            }
}
else if (item.Protected == true) {
            $('#'+vlabel).html( '<div onClick="lightbox_open(\'protected\', '+switch_protected_timeout+ ', '+txt_switch_protected+');" style='+vattr+alarmcss+'>'+vdata+'</div>');
} else {
            $('#'+vlabel).html( '<div '+switchclick+' style='+vattr+alarmcss+'>'+vdata+'</div>');
}

Interesting... This code appears to be not implemented in mine... :(

Re: NEW frontpage.html - request comments

Posted: Friday 08 January 2016 8:10
by jannl
the protected part obviously is, otherwise you could not get that message.

Re: NEW frontpage.html - request comments

Posted: Friday 08 January 2016 8:52
by Minglarn
obviously =)

But, as a noob i cant figure out what to search for...
I simply want to change icon for a specific cell with a ON icon and OFF icon wich seems to work when the cell is protected. BUT i want the cell to act as a button. How in earth do I accomplish that =)

Re: NEW frontpage.html - request comments

Posted: Friday 08 January 2016 9:14
by jannl
you can start with searching for protected in the js file.
The unprotected part is either in the else or a default setting, which makes it harder to find.

When you enable debugging in your browser, you can add console.log messages to see where the code is and what the contents of values are.

Before frontpage I did not know much of javascript either (but can read programming languages).

Luckily google is a big friend...

Re: NEW frontpage.html - request comments

Posted: Friday 08 January 2016 9:52
by Minglarn
Thanks! I finally made it!
Added this code to frontpage_settings.js

Code: Select all

var idx_Motor = '62';
var txt_Motor_on = '<img src=icons/engine_On.gif>';
var txt_Motor_off = '<img src=icons/engine_Off.gif>';
And this code to frontpage.js

Code: Select all

//						MOTOR Image
						if (item.idx == idx_Motor && vdata == txt_off){
                        //	vdata=new String(vdata).replace( "Off", "Open");
                            vdata=txt_Motor_off;
                        //    alarmcss=color_off;
                        }
						if (item.idx == idx_Motor && vdata == txt_on){
                        //	vdata=new String(vdata).replace( "Off", "Open");
                            vdata=txt_Motor_on;
                        //    alarmcss=color_off;
                        }
So when the engine heater is on i get this flashing icon:
engine_On.gif
engine_On.gif (1.42 KiB) Viewed 2480 times

Re: NEW frontpage.html - request comments

Posted: Friday 08 January 2016 20:32
by Triangle
I'm trying to display the pressure trend. I have the trend in a text sensor from yahoo with a python script (arrow up, down, or same). I'd like to put this trend arrow in front of the pressure number in HPA. So I have to combine the two sensors (text sensor and Temp+Humidity+Baro sensor) in one cell. I can't get my head around how to do this. Is it possible and how would I achieve this? I'm a noob in programming, but I like to fiddle and learn :)

edit: after a good night of sleep, I think I just have to make an extra div and matching changes for the concerning cell, not?

Re: NEW frontpage.html - request comments

Posted: Friday 08 January 2016 23:54
by G3rard
Minglarn wrote:Love this frontpage! Have been poking around and really love the easiness behind it! Great job to you all!
I saw you implemented a min and max temperature on the frontpage. Can you share the code for that?

Re: NEW frontpage.html - request comments

Posted: Saturday 09 January 2016 0:08
by Minglarn
Of course... Here come my small contribution to your frontpage...

It's a bit rough but it works and should be easy to implement if you follow these steps...
I use BLOCKY, 2 dummy TEMP sensors and own made PHP scripts as I don't like lua...

Blocky handles the comparison and checks if actual min temp is lower than registered value... See below:
UTE is the outside sensor.
Skärmklipp2.PNG
Skärmklipp2.PNG (13.68 KiB) Viewed 2424 times
If actual value is below registered value it runs the php script. My script even notifies me via PROWL...
set_min.php code:

Code: Select all

<?PHP
//PROWL Class to include
include "class.prowl.php";

// Get UTE temp. IDX: 9
$json_string = file_get_contents("http://192.168.1.236:8080/json.htm?type=devices&rid=9");
$parsed_json = json_decode($json_string, true);
$parsed_json = $parsed_json['result'][0];
$temp = $parsed_json['Temp'];
$today = date("Y-m-d")."Temp: ".$temp;

// Send PROWL -->
$prowl = new Prowl("XXXXX", "XXXXXX", "Temperatur uppdatering!!");
$result = $prowl->send("Ny MIN Temp!", $temp."°C");

// Set new MAX temp to virtual sensor no: 514 using $ute
$ute = "http://192.168.1.236:8080/json.htm?type=command&param=udevice&idx=514&nvalue=0&svalue=".$temp;
$json_string = file_get_contents($ute);
// -----------------------------------------------
?>
set_max.php code:

Code: Select all

<?PHP
//PROWL Class to include
include "class.prowl.php";


// Get UTE temp. IDX: 9
$json_string = file_get_contents("http://192.168.1.236:8080/json.htm?type=devices&rid=9");
$parsed_json = json_decode($json_string, true);
$parsed_json = $parsed_json['result'][0];
$temp = $parsed_json['Temp'];
$today = date("Y-m-d")."Temp: ".$temp;

$ute = "http://192.168.1.236:8080/json.htm?type=command&param=udevice&idx=513&nvalue=0&svalue=".$temp;


// Send PROWL -->

$prowl = new Prowl("XXXXX", "XXXXXX", "Temperatur uppdatering!!");
$result = $prowl->send("Ny MAX Temp!", $temp."°C");

// Set new MAX temp to virtual sensor no: 513 using $ute
$json_string = file_get_contents($ute);
// -----------------------------------------------
?>
As seen in the PHP code I update the virtual TEMP sensors whit the actual TEMP and the result is this:

Re: NEW frontpage.html - request comments

Posted: Saturday 09 January 2016 0:49
by G3rard
Nice, I am going to use that solution :) .

Re: NEW frontpage.html - request comments

Posted: Saturday 09 January 2016 8:17
by Minglarn
Glad I could help...

But I need some assistance with 2 issues....

1.Trying to add a switch wich. In domotics it is a group containing switches for my outside and garden lights. Cant get it to work...

Code: Select all

	$.PageArray_Scenes = [
		['1','Status', 	'cell4_22',			'Utebelysning'],
Do I need to add something else?

2. Want to make the temperature color RED incase it gets to hot. Have added this to the cell i want to monitor

Code: Select all

		['14','Temp',				'cell7',	'Biorummet','1','0'],
Where do I add the alarm threshold?

Re: NEW frontpage.html - request comments

Posted: Saturday 09 January 2016 12:53
by erske
Hallå Minglarn.
Nice to have a fellow Swede here. :)

Since it's -29 degrees outside, i was going to implement my engineheater today, and i saw your loving blinkin Icon for it. I wonder if you can share both the "off" and "on" Icons for that, it would make my day so much easier.

Tack på förhand. / Erik