moroen / IKEA-Tradfri-plugin

A Python plugin for Domoticz to controll IKEA Gateway
68 stars 23 forks source link

Setting color on a lamp also changes the dim #101

Closed Logonz closed 3 years ago

Logonz commented 4 years ago

Hello! It seems that using the dzVents scripting and then setting the color of the color device also changes the brightness to a corresponding value

example:


        local light = domoticz.devices('Ikea Trådfri - Lamp1')
        local color = domoticz.devices('Ikea Trådfri - Lamp1- Color')
        color.setState("Set Level 10") --Either or
        color.switchSelector("Blue") --Either or

It works and it actually switches the color, but it also changes the brightness of the bulb to 10 (which is blue)

However changing the color in the Switches menu on the website does not change the brightness...

Any ideas on how to fix? If you can point me in the right direction i could probably code a fix for it as well if that is needed.

moroen commented 4 years ago

I've never used dzVents, since I do all my scripting in python, so I have no idea of which commands are sent from domoticz when dzVents is used to set a color. The light (dimmer) and color is actually two different devices, with different IDX in the domoticz device list, so I have no idea why dzVents sends a command to two different devices...

It might have something to do (and I'm just speculating here), how dzVents maps the name of a device used in a script to the actual IDX used by domoticz. The first thing I would try is to rename the color selector to something entirely different than the name of the light, and then try to set the color from dzVents... Let me know how it goes!

Regards, M

windmillert commented 3 years ago

Hi, This behavior is still there in version 0.10.5, so I did some experiments. If you issue a set color level command for a "CWS" type bulb, this is directly followed by a set dim level command where the color number is evaluated to a value between 0 an 254. After a look into the plugin code I saw that the if/then/else setup in the Command == "Set Level" part is causing this behavior: If the bulb is a CWS type, not only line 680 will be executed but also line 688. And by the way, limiting the value of Level to 100 is cutting of the last 10 colors of the CWS bulb, leaving me with 11 possibilities to select the color "Lime". Regards WM

moroen commented 3 years ago

Then we're lucky that "Lime" is such a nice color, especially the Ikea CWS bulb's version of "Lime"...

Jesting aside, thanks for pointing this out, version 0.10.6 just released should address both these issues...

Regards, M

windmillert commented 3 years ago

Thanks, that solved the problem(s). Lime indeed is a very nice color, but on my desk I prefere "Sunrise" ;-))

moroen commented 3 years ago

Glad it worked out! Closing issue, reopoen if needed!