Page 1 of 1

change icon when data switch with text changes

Posted: Saturday 08 June 2019 19:43
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';
}
}