bierlaagh wrote:ericjuh wrote:
Seems like its still wrong in the gerard33 release i downloaded yesterday. Because the status is still calculated by the switch, but i see code getting the sunrise and sunset values.
I just can't get it to work.
I also use the release of G3rard
and I have a dark CSS when the sun has set and a day CSS when we have sunrise
As far as I know you have to create a virtual switch (is donker of is dark) The IDS of that switch should be in the FrontPage_Settings.js (somewhere near line 51)
you also need to make a blocky as discribed here:
http://www.domoticz.com/forum/viewtopic ... 120#p36615
I just tested it and disabled the blocky, so i could manualy switch the is donker and when isdonker is on i have the night css if it is off you have the Day CSS.
Thanks for your reply. I got it working. It seems there is some code missing.
What i did:
I added this in frontpage_settings.js. NOTE!! day.jpg and night.jpg are files i made and not default. See attachment. I put the files in \css\images
Code: Select all
var bg_day = 'day.jpg'; // Create variable with backgroundimage day
var bg_night = 'night.jpg'; // Create variable with backgroundimage day
var bg_size = 'cover'; // Create variable with value to fill background
I disabled the stringreplace at line 49 and 55 in frontpage.js. Not sure why G3rard added this part and why he didt a substring and removed the last 3 characters. Because the sunrise and sunset is a time, like:
"Sunrise" : "06:55",
"Sunset" : "20:11",
If you remove the last 3 characters you only get the hours. But maybe it was the idea to not look at the minutes.
Code: Select all
function(data) {
if (typeof data != 'undefined') {
$.each(data, function(i,item){
if ( i == 'Sunrise' ) {
//console.log("Sunrise: ", item);
var_sunrise = item;
//remove seconds from time
//var_sunrise = var_sunrise.substring(0, var_sunrise.length - 3);
}
else if ( i == 'Sunset' ) {
//console.log("Sunset: ", item);
var_sunset = item;
//remove seconds from time
//var_sunset = var_sunset.substring(0, var_sunset.length - 3);
}
});
I then replaced this code (start at line 151 and this code is looking for a virtual switch)
Code: Select all
// change CSS file, depending on sunset and sunrise using virtual switch named IsDonker and set the var IsNight
if(item.idx == idx_IsDonker && vdata == 'Off'){
document.getElementById('dark-styles').disabled = true; // day
IsNight = 'No';
}
if(item.idx == idx_IsDonker && vdata == 'On'){
document.getElementById('dark-styles').disabled = false; // night
IsNight = 'Yes';
}
with (tnx @vil1driver):
Code: Select all
var today=new Date();
var h1 = today.getHours();
var m1 = today.getMinutes();
var h2 = var_sunrise.substring(0, 2);
var m2 = var_sunrise.substring(3, 5);
var h3 = var_sunset.substring(0, 2);
var m3 = var_sunset.substring(3, 5);
h2 = parseInt(h2, 10);
m2 = parseInt(m2, 10);
h3 = parseInt(h3, 10);
m3 = parseInt(m3, 10);
var t1 = (60 * h1) + m1; // time
var t2 = (60 * h2) + m2; // sunrise
var t3 = (60 * h3) + m3; // sunset
if ( t1 < t3 && t1 > t2) {
// dag
IsNight = 'No';
document.body.style.background='black url(css/images/'+bg_day+') no-repeat top center fixed';
document.body.style.backgroundSize=bg_size;
} else {
// nacht
IsNight = 'Yes';
document.body.style.background='black url(css/images/'+bg_night+') no-repeat top center fixed';
document.body.style.backgroundSize=bg_size;
}
I have now only 1 problem.
When i keep the site active i have no problems and it keeps refreshing. But when i close it for a few minutes and i open it again i keep getting a error on this part of the code.
Code: Select all
//Check wether we want to add the last seen to the block
if (lastseen == '1') {
if (thisday == vdate) {
$('#ls_'+vlabel).html(convStringTime) // Show only the time if last change date = today
}
else {
$('#ls_'+vlabel).html(convStringTime+' | '+convStringDate) // Change this 'Last Seen' into something you like
}
}
if (lastseen == '2') {
$('#ls_'+vlabel).html(convStringTime) // Show only the time
}
It keeps saying that vdate isnt correct in this line: