I created adevice which shows we the air quality index (LKI), which varies from 1 to 11.
Depending on the value I want the icon and text to change colour. I added the following in custom.js:
Code: Select all
function getStatus_Luchtkwaliteit(block) {
var device=block.device;
if(device['Data']<4) {
block.addClass='alertnormal';
}
else if (device['Data']<6) {
block.addClass='alertlight';
}
else if (device['Data']<8) {
block.addClass='alertmedium';
}
else if (device['Data']<10) {
block.addClass='alerthigh';
}
else {
block.addClass='alertcritical';
}
}
Code: Select all
.alertnormal .col-icon {
color: green !important;
}
.alertlight .col-icon {
color: yellow !important;
}
.alertmedium .col-icon {
color: orange !important;
}
.alerthigh .col-icon {
color: orangered !important;
}
.alertcritical .col-icon {
color: red !important;
}
Jeroen