plugin framework, how to control rgb devices

Python and python framework

Moderator: leecollings

Post Reply
akamming
Posts: 369
Joined: Friday 17 August 2018 14:03
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

plugin framework, how to control rgb devices

Post by akamming »

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?
User avatar
waltervl
Posts: 5853
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: plugin framework, how to control rgb devices

Post by waltervl »

Perhaps check zigbeeforDomoticz plugin:
https://github.com/zigbeefordomoticz/Do ... d.py#L1281
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
akamming
Posts: 369
Joined: Friday 17 August 2018 14:03
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: plugin framework, how to control rgb devices

Post by akamming »

waltervl wrote: Wednesday 18 January 2023 11:34 Perhaps check zigbeeforDomoticz plugin:
https://github.com/zigbeefordomoticz/Do ... d.py#L1281
tx.. will check!
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest