change icon when data switch with text changes

Dashticz, alternative dashboard based on HTML, CSS, jQuery

Moderators: leecollings, htilburgs, robgeerts

Post Reply
pvklink
Posts: 822
Joined: Wednesday 12 November 2014 15:01
Target OS: Raspberry Pi / ODroid
Domoticz version: latest b
Contact:

change icon when data switch with text changes

Post by pvklink »

Hi, i like to change the icon of a switch (text switch filled with info from a weathersite)

This is the blockinfo (that works ok)
blocks[1285] = {}
blocks[1285]['title'] = 'Weer';
blocks[1285]['icon'] = 'fas fa-cloud-sun-rain';
blocks[1285]['hide_data'] = true;
blocks[1285]['width'] = 4;
blocks[1285]['switch'] =true;

And this is the first try of my first js script
Dont now how to change the icon :roll:

custom.js
function afterGetDevices(){
if (alldevices[1285].Data == 'bewolkt') {
blocks['1285']['icon'] = 'fa fa-cloud-rain';
}
elseif (alldevices[1285].Data == 'regen') {
blocks['1285']['icon'] = 'fa fa-cloud';
}
else {
blocks['1285']['icon'] = 'fa fa-cloud-rain';
}
}
Raspberry (raspbian on rpi 3) , Domoticz Beta, dzVents , RFXtrx433e, P1, Hue, Yeelight, Zwave+, X10, ESP(easy), MQTT,Weather Underground, System Alive Checker, Domoticz Remote Server to RPI with Google Assistant,
Jablotron connection, Ikea
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest