Request: Icon change by dzvents in a selector switch [Solved]
Moderator: leecollings
Request: Icon change by dzvents in a selector switch
I would like to change to icon of a selector switch by dzVents according to the level.
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Request: Icon change by dzvents in a selector switch
Attached script works for me.
The icon Numbers can be found by changing the icon manually using the GUI and peek in the database to see the result in the custom image field. Could be there is an easier way to get these ?
I don't think this function will make it as a native dzVents command but if it's useful for you and you want to use it for multiple devices and and if you experience no side effects, you can implement it as a global helper function.
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
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Re: Request: Icon change by dzvents in a selector switch
Perfect, TNX. I try it to morrow.
Re: Request: Icon change by dzvents in a selector switch
Tnx again. It works perfectly. Now hunting for nice icons which fit my purpose.
-
- Posts: 65
- Joined: Friday 18 March 2016 10:11
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2020.2
- Location: Netherlands
- Contact:
Re: Request: Icon change by dzvents in a selector switch
Which program is the best way to see what the IconNumber is in the DB?
Raspberry 4 - USB boot Domoticz /|\ Raspberry 2B - Dashticz /|\ Tasmota device's /|\ Philips Hue & Yeelight
- erem
- Posts: 230
- Joined: Tuesday 27 March 2018 12:11
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2021.1
- Location: Amsterdam/netherlands
- Contact:
Re: Request: Icon change by dzvents in a selector switch
@Larsoss
i use sqlitebrowser (sudo apt-get install sqlitebrowser) on buster.
Works well.
i use sqlitebrowser (sudo apt-get install sqlitebrowser) on buster.
Works well.
Regards,
Rob
Rob
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Request: Icon change by dzvents in a selector switch [Solved]
sqlitebrowser does require a GUI to linux
Any sqlite db browser will do. I mostly use sqlite3 on Linux. Look for CustomImage field in DeviceStatus table.
Using dzVents you can set the icon on devicetypes for which it is allowed with the setIcon function.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Who is online
Users browsing this forum: Bing [Bot] and 1 guest