plugin framework, how to control rgb devices
Posted: Tuesday 17 January 2023 9:26
Hi,
I built my own wordclock and attached it to domoticz. It is using rgb leds, so i have 3 colors to control (foregroundcolor, backgroundcolor, secondscolor)
I am now trying contol this colors using domiticz with a python plugin. but can't get it correct.
this is the code i use:
- switch it on : Devices[UnitID].Update(nValue=1,sValue=str(level))
- switch it off : Devices[UnitID].Update(nValue=0,sValue=str(Devices[UnitID].LastLevel))
- change the brightness: Devices[UnitID].Update(nValue=1,sValue=str(level))
- change the color: Devices[UnitID].Update(nValue=1,sValue=str(level),Color=str(Color))
Using this code: what works is:
- set the brightness,
- switch off
- change the color.
- switch on (but see remark below)
However i am doing something wrong, cause when the virtual device is set to "off" and then switched back on again, i loose the color setting and it's back to white/grey/black (depending on brightness setting).
So what are the correct update statements for a RGB device using a python plugin, so it will remember the color when switching back on?
I built my own wordclock and attached it to domoticz. It is using rgb leds, so i have 3 colors to control (foregroundcolor, backgroundcolor, secondscolor)
I am now trying contol this colors using domiticz with a python plugin. but can't get it correct.
this is the code i use:
- switch it on : Devices[UnitID].Update(nValue=1,sValue=str(level))
- switch it off : Devices[UnitID].Update(nValue=0,sValue=str(Devices[UnitID].LastLevel))
- change the brightness: Devices[UnitID].Update(nValue=1,sValue=str(level))
- change the color: Devices[UnitID].Update(nValue=1,sValue=str(level),Color=str(Color))
Using this code: what works is:
- set the brightness,
- switch off
- change the color.
- switch on (but see remark below)
However i am doing something wrong, cause when the virtual device is set to "off" and then switched back on again, i loose the color setting and it's back to white/grey/black (depending on brightness setting).
So what are the correct update statements for a RGB device using a python plugin, so it will remember the color when switching back on?