Closed tempse closed 6 years ago
That line is correct, ATTR_BRIGHTNESS is indeed 0..255.
This seems like a bug in the third party library. The HSV setter is documented to accept a percentage but actually converts from byte.
I don't know if this should be fixed in pyHS100 or Home Assistant. Probably @rytilahti can say more.
Unfortunately I don't really know much about those lights, nor do I have a test device. @tempse is the pyhs100 cli tool and it's hsv
command working as expected for you?
Thanks for your prompt answers, @amelchio and @rytilahti!
The strange behavior I originally observed in Home Assistant is indeed coming from the pyHS100 tool, where I can reproduce everything I reported above.
As you can see, I created a PR in the pyHS100 repository which should fix this bug. I will keep you posted regarding any updates on this matter.
I just released 0.3.3: https://github.com/GadgetReactor/pyHS100/releases/tag/0.3.3
Home Assistant release with the issue:
0.74.0
Last working Home Assistant release (if known): unknown
Operating environment (Hass.io/Docker/Windows/etc.):
Raspbian GNU/Linux 9 (stretch), installation of homeassistant via pip (Python 3.5.3)
Component/platform:
issue with the
tplink
light component: https://www.home-assistant.io/components/light.tplink/Description of problem: Tested device: TP-Link Bulb TP130. Every time the color of the bulb is changed from the Home Assistant Interface, the bulb brightness is reduced (in addition to the successful change of color). For example, starting from 100% brightness, switching to a different color results in the brightness being reduced to 39%. Changing color again, yields 15% brightness, etc... (see my remarks about these specific numbers at the end of this issue).
Problem-relevant
configuration.yaml
entries and (fill out even if it seems unimportant):Traceback (if applicable):
Additional information: My best guess for the cause of this problem is the following: The brightness can be given in percent or values between 1 and 255. Internally, only one of those two options (i.e, percent values) is used, if I read the source code correctly. Now, if at some point, one assumes the brightness to be in the wrong format and does the conversion, the brightness will be updated to wrong values. In the case of the brightness actually being in percent, but assumed as values between 1 and 255, this would result in brightness reductions to values of 100/255=39%, 39/255=15%, etc... - which is exactly the steps in brightness reduction I observe. Is it possible that the following lines cause this problem by assuming the brightness values to be in absolute 1..255 values (whereas they actually are in percent already)? https://github.com/home-assistant/home-assistant/blob/7bc2362e33f86d41769d753d1701a53ae60224d5/homeassistant/components/light/tplink.py#L96-L97 Thanks, and keep up the excellent work!