Request: Icon change by dzvents in a selector switch
Posted: Monday 01 April 2019 11:48
I would like to change to icon of a selector switch by dzVents according to the level.
Open source Home Automation System
https://forum.domoticz.com/
Attached script works for me.
Code: Select all
-- Icon changer
return { on = {
devices = {1423}, -- change to your device
},
logging =
{
level = domoticz.LOG_DEBUG, -- switch to LOG_ERROR when OK
marker = 'setIcon'
},
execute = function(dz, item)
local icons = { -- level = iconNumber
[0] = 10,
[10] = 13,
[20] = 16,
[30] = 14,
[40] = 14,
[50] = 14,
[60] = 14,
}
local function setIcon(iconNumber)
local url = dz.settings['Domoticz url'] .. '/json.htm?type=setused&used=true&name=' .. dz.utils.urlEncode(item.name) ..
'&description=' .. dz.utils.urlEncode(item.description) .. -- Required. If not set it will be blanked out.
'&idx=' .. item.id ..
'&switchtype=' .. item.switchTypeValue ..
'&customimage=' .. iconNumber
return dz.openURL(url)
end
if item.level ~= item.lastLevel then
setIcon(icons[item.level])
else
dz.log('No Icon change necessary' .. item.id,dz.LOG_DEBUG)
end
end
}
sqlitebrowser does require a GUI to linux