Python with colorpicker

Python and python framework

Moderator: leecollings

Post Reply
elgringo
Posts: 96
Joined: Thursday 18 May 2017 8:08
Target OS: Raspberry Pi / ODroid
Domoticz version: Left
Contact:

Python with colorpicker

Post by elgringo »

I am busy developing a plugin to control Hyperion and a second one to control a Ledenet (UFOlight) device. I created python script to control both devices. However I want to create a plugin with has a colorpicker attached to it, instead of a on/off switch a color. Is this possible via Python?

I noticed the site: http://www.domoticz.com/wiki/Plugins/PlayBulb Here the colors ar split per channel, not with a single colorpicker.

I hope it is possible within python if this is not the case, will it be possible in C++?
mutley
Posts: 9
Joined: Tuesday 16 May 2017 18:01
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python with colorpicker

Post by mutley »

Yes it's possible in both c++ and python plugin. It's also possible using a "Virtual Censor" but I don;t think there is a way to get the RGB / HSL values with the virtual censor.

This will do it for python plugin
Domoticz.Device(Name="RGB Light", Unit=1, Type=241, Subtype=2, Switchtype=7).Create()

For c++ look at the source
https://github.com/domoticz/domoticz/bl ... itless.cpp
elgringo
Posts: 96
Joined: Thursday 18 May 2017 8:08
Target OS: Raspberry Pi / ODroid
Domoticz version: Left
Contact:

Re: Python with colorpicker

Post by elgringo »

If the plugin will be a python plugin

What does this do?

Code: Select all

Domoticz.Device(Name="RGB Light", Unit=1, Type=241, Subtype=2, Switchtype=7).Create()
And what are all the type/subtype/switchtype parameters? Is there a list with all possible options?

I only find virtual sensor with the JSON part:

Code: Select all

/json.htm?type=command&param=setcolbrightnessvalue&idx=99&hue=274&brightness=40&iswhite=false
And I miss the saturation part of it.
mutley
Posts: 9
Joined: Tuesday 16 May 2017 18:01
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python with colorpicker

Post by mutley »

elgringo wrote:If the plugin will be a python plugin

What does this do?

Code: Select all

Domoticz.Device(Name="RGB Light", Unit=1, Type=241, Subtype=2, Switchtype=7).Create()
And what are all the type/subtype/switchtype parameters? Is there a list with all possible options?

I only find virtual sensor with the JSON part:

Code: Select all

/json.htm?type=command&param=setcolbrightnessvalue&idx=99&hue=274&brightness=40&iswhite=false
And I miss the saturation part of it.
For Python plugin, the switch parameters are in one of the C++ header files, I have not found any documentation on that. You'll need to go through some examples to understand it fully, but the Domoticz.Device(bla bla bla).Create() command will create you a device that has the appropriate RGB color picker.
From this file
https://github.com/domoticz/domoticz/bl ... aretypes.h
Type 241 is pTypeLimitlessLights. (0xF1 = 241)
Subtype 2 is sTypeLimitlessRGB (0x02)

As for the virtual sensor, that's why I said you probably won't be able to control it correctly, even though it has the appropriate color picker there seem no way to get or set the appropriate RGB / HSL / HSV / HSB values.
elgringo
Posts: 96
Joined: Thursday 18 May 2017 8:08
Target OS: Raspberry Pi / ODroid
Domoticz version: Left
Contact:

Re: Python with colorpicker

Post by elgringo »

I ntoiced the device send mulltiple commands:
  • Set Level [0-100]
  • Set White [0-???]
  • Set Brightness [0-100]
  • Set Color [0-255]
  • On
  • Off
Brightness and Color come from the color picker
On/off from the buttons
Level from the slider below. What is the usage for this?
White. I dunno how to trigger this one.

If I use color/brightness/level it is possible to create HSB values.
mutley
Posts: 9
Joined: Tuesday 16 May 2017 18:01
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python with colorpicker

Post by mutley »

I don't think you'll get what you want without modifying the source code. I've played with this, and it's basically junk. There seems to be no way to actually get any useful values.

Set Color [0-255] is actually the Hue, so multiply that by ~1.4 to get a 0-360 range.
Set Brightness and Set Level I assume were supposed to be Saturation and (Lightness or Value). But they don't act that way at all, either from the color slider, or from dumping values in from URL / MQTT / Lua_script. So at the moment, I don't see a way to get RGB/HSL or HSV that gives you the full spectrum of colors. If you fix saturation to be a constant, then you can get some basic colors.

There is source code for Phillips Hue & Limitless devices, so I'm about to start sifting through that to see what's going on. But a few posts I've red on here about the Limitless, seems that it doesn't support the full color range.
poudenes
Posts: 667
Joined: Wednesday 08 March 2017 9:42
Target OS: Linux
Domoticz version: 3.8993
Location: Amsterdam
Contact:

Re: Python with colorpicker

Post by poudenes »

Read this article.

I using Mipow RGBW Bulbs. Someone have created a plugin.py to let them work within Domoticz. Now im try to modify and let them work correct.
He build 2 plugins: RGBW and Colorpicker. The RGBW creates 4 devices for Red, Green, Blue and White. Works great !!! in old Stable Domoticz.
It is not working fully in latest stable Domoticz. Crash all the time on 1 specific type of Mipow Bulb.

The Colorpicker never worked in old stable Domoticz. But work great in latest stable Domoticz all bulbs working. But the colorpicker itself is not working how it has to be.

Im now try to play around with the code (im not a programmer) and have now the option to select color and de slider below gives the brightness of the color. (For how it has to be) the 2 buttons for on and off i don't know. Must this give white color and turn white color off? Because when i use it the bulb goes into white and when i turn it off it gives me the color back i selected.

Also this plugin create a status device to turn on and off the bulb.
I hope the developer will work on this plugin and let it work at least the RGBW version, that one is usable also into scenes. The colorpicker is not working in scenes
RPi3 B+, Debain Stretch, Domoticz, Homebridge, Dashticz, RFLink, Milight, Z-Wave, Fibaro, Nanoleaf, Nest, Harmony Hub, Now try to understand pass2php
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 1 guest