I don't know if it's related to this subject, but i have also problem with status of an other object.
When the website loads or when there is a new update from the block the colors are right, but after a whole minute the block will go to its normal state (no colors)
See the screenshots below with also the code:
After website reload / new update from block like 0.1 mm to 0.2 mm.
After the whole minute, maybe the refresh of domoticz, no new update for the block (see screenshot of the block, now 0.0 because there is no rain anymore when i made the screenshot

)
custom.css
Code: Select all
.nultottwee {
background: rgba(228, 229, 255,1.0) !important;
background-clip: padding-box;
color: black;
}
custom.js
Only to change the block icon
Code: Select all
// regen
function getStatus_3962(block){
var idx = block.idx;
var device = block.device;
if(device['Data']!="Voorlopig blijft het droog!"){
block.icon = 'fas fa-cloud-rain'
}
else {
block.icon = 'fas fa-tint-slash'
}
}
Get the status of 9450, its a text value in domoticz and change the block to its color
Code: Select all
// geeft regenmelding een kleur op basis van aantal mm per uur
function getStatus_9450(block){
var Data = block.device.Data;
var idx = block.idx;
var device = block.device;
if(parseFloat(Data) > 100){
Dashticz.setBlock('3962', {addClass: 'bovendehonderd'});
}
else if(parseFloat(Data) >10){
Dashticz.setBlock('3962', {addClass: 'tientothonderd'});
}
else if(parseFloat(Data) >5){
Dashticz.setBlock('3962', {addClass: 'vijftottien'});
}
else if(parseFloat(Data) >2){
Dashticz.setBlock('3962', {addClass: 'tweetotvijf'});
}
else if(parseFloat(Data) >0){
Dashticz.setBlock('3962', {addClass: 'nultottwee'});
}
else {
Dashticz.setBlock('3962', {addClass: 'none'});
}
}
I put this script also between the "after get devices" code, but that didnt help.
Code: Select all
function afterGetDevices(){
var device9450 = alldevices[9450];
var device3962 = alldevices[3962];
function getStatus_9450(block){
var Data = block.device.Data;
var idx = block.idx;
var device = block.device;
if(parseFloat(Data) > 100){
Dashticz.setBlock('3962', {addClass: 'bovendehonderd'});
}
else if(parseFloat(Data) >10){
Dashticz.setBlock('3962', {addClass: 'tientothonderd'});
}
else if(parseFloat(Data) >5){
Dashticz.setBlock('3962', {addClass: 'vijftottien'});
}
else if(parseFloat(Data) >2){
Dashticz.setBlock('3962', {addClass: 'tweetotvijf'});
}
else if(parseFloat(Data) >0){
Dashticz.setBlock('3962', {addClass: 'nultottwee'});
}
else {
Dashticz.setBlock('3962', {addClass: 'none'});
}
} // einde afterGetDevices
Did i miss something in the code?