-
Notifications
You must be signed in to change notification settings - Fork 535
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"Color" feature depends on "Brightness" feature #1057
Comments
Good news for anyone else who buys these - frankly disappointing - RGB christmas lights. I can get it to work without any code changes on localtuya 64dcb15. You must set the following DPs for RGB mode to work correctly:
This clears all the hurdles needed to get In case anyone (including future me) wants to take a crack at it, I'll leave my notes here:
So I think this is pretty user-hostile because I'm fairly sure you could accidentally get into this situation with a supported bulb just by plugging in some DPs but not all when configuring the device? But anyway what I think the code should do in order to do it's best:
|
I've managed to hit this same case with a Galaxy Projector lamp. It's weird as nothing in the Smart Life app seems to allow changing back to that "white" colour mode (and it doesn't really make sense with what the device exposes). Changing the brightness in Smart Life changes the colour mode to "color" then the entity becomes available again. Going to take a look at your suggestion as there is definitely something weird in that bit of logic. |
The problem
My wife bought these "RGB" christmas lights, they're Mirabella Genio 200 LED "Colour Wheel Fairly Lights". They mostly work, the configuration modes for the various scenes are a pain and they play a bit fast+loose with the definition of "RGB" (despite the fact that they're specified in HTML style hex-triplets, you're limited to about 7 specific colors in the scenes), but my main concern is that the "set any single color" mode doesn't work, and I believe this is because of an incorrect assumption in localtuya.
Namely, that
SUPPORT_COLOR
being enabled impliesSUPPORT_BRIGHTNESS
, but these lights do not follow that - they don't have a brightness datapoint, but they do have a color one. See attached later.Environment
Steps to reproduce
set_dp
service without issue.light.py
to force brightness to some level if it's not present, the color picker works correctly.Configuration
configuration.yaml
orconfig_flow
Not sure what config to put in here, I didn't configure anything manually it's all done via the HA front-end.
DP dump
Provide Home Assistant taceback/logs
Additional information
Here's a diff of the changes I made that make the color wheel mode work, but are obviously not the correct way to handle it. I originally wrapped it in a try/except because of the TypeError, but doing so throws an exception elsewhere because
self._brightness
is packed into the values.So this patch isn't applicable, it's just showing my thought process for below.
So I'm not sure how to fix this, it seems like
SUPPORT_COLOR
needs decoupling fromSUPPORT_BRIGHTNESS
, and some arbitrary value picked for brightness if polling it is unavailable or if the DP isn't configured. At the very least not having it throw an exception so the device still works and doesn't go unavailable if the color DP is set and the brightness one isn't seems appropriate. Unfortunately either of these solutions is probably beyond my abilities at the moment, but I'll take a look at it if no one smarter has a better idea.I'm thinking that maybe in
map_range
it should check ifself._brightness
isNone
(and not just zero), and if so it should maybe assume a value (maybe upper_brightness?), that'd probably get the device working without breaking a bunch of stuff, but I'm not sure of that.Any suggestions are welcome.
The text was updated successfully, but these errors were encountered: