-
Notifications
You must be signed in to change notification settings - Fork 579
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
Add support for HSV encoded color lights #90
Conversation
Here I am, |
Would be great with a tester for this 👍 Do you have bulbs configured via RGB as well? |
Hi i do have multiple lights with different settings:
I have something almost fully working here https://github.com/ultratoto14/localtuya-homeassistant/tree/rgbw_update. Be kind, i'm not a python developer, many things can be done differently What is not working in mine:
|
Thanks @ultratoto14, I will a greater look. I think I have implemented most things in a similar manner, not RGB though. But I can take some inspiration from your code for that. One change I'm planning is to use a single option for color values, as HSV or RGB can be deduced from length of the value. Color temperature is a different matter, related of course. Should be simple enough to implement (there is also an issue about it: #91). I intend to add two options to allow custom values for lower and upper range, specified in Kelvin and converted to mired internally. |
I used the set_dps you introduced, i fixed the unneeded value and put the corresponding in common.py My full list of devices:
They are from different manufacturers and all the one in HSV are using this 1000 range where the RGB_HSV are using the 255 range. |
;-) my question was not clear. Do you know tuya lights that uses HSV coding for the color and 255 range for brightness and color_temp ? Because if you deduce the kind of color from the length, you can then also deduce the max value for brightness and color_temp. |
Ah, yes, then I understand. No, I don't know about that and I would expect that to not exist either. They however seem to use the same brightness range for white and color, so no distinction needs to be made there. Color temperature uses a different range based on mirad/kelvin range of the lamp and has to be entered separately. |
5d510a4
to
722aa70
Compare
Tested and only needs review before merging! |
Just tested it, two main remarks:
|
@ultratoto14 Thanks for testing! Color temperature will be dealt with in #91. Regarding the icon, not sure how that works. Will have to look into that, thanks for reporting! |
@ultratoto14 Pushed an update now, can you try if icon works as expected? |
@postlund Icon is now working as expected. |
@ultratoto14 Brilliant, thanks! 🎉 |
@postlund, i found a remaining small bug about the consistency of the brightness setting.
|
@ultratoto14 Ok, that's interesting. Maybe I should set white and color brightness at the same time to keep them in sync. I guess we could try that. |
@ultratoto14 Loong-shot here, but please try the latest commit and see if it works as expected (or at all). |
Hi @postlund, sorry for the delay. I still have a couple of hours to test before being unavailable for 3 days. |
Hi guys, I hadn't noticed this pull request so I added this feature by myself on my fork. Working:
Please take a look if that helps! (another set of eyes/ideas). lapy@7d76d91 Thank you, |
Hi @postlund, tried to find the problem and it seems that the update and turn on are competing. if not self._is_white_mode:
await self._device.set_dp(self._brightness, self._config.get(CONF_BRIGHTNESS))
await self._device.set_dp("white", self._config.get(CONF_COLOR_MODE)) You need to apply the brightness first because of the status updated. |
@ultratoto14 Seems like @lapy has come a longer way than I have (especially since I haven't prioritized this recently), maybe you can try his commit and see it if works better? At the end of the day I would love to see someone else implement this so I can focus on core stuff instead 🙃 |
@lapy Send a PR, I can review it for inclusion here and @ultratoto14 can probably test it. |
Hi @postlund , Which version are you testing? |
Hi, Thank you, |
OK! Thanks |
Hi @postlund , I was also testing this version # 90, I configured a light bulb via config flow and I could also test the colors and they work correctly and in real time. GREAT! You just have to fix the color temperature and then you have reached perfection :-) Thanks |
@ultratoto14 Got your email, will respond here so we can decide on how to move forward. From my point-of-view, it doesn't really matter if we go with my solution or the one by @lapy. I do feel that it'a a bit problematic to not have a steady maintainer behind the code we merge. So I need your input, based on what we have. Should we merge this and continue adding RGB support from @ultratoto14 as well as what else is missing in additional steps? Or should we go with @lapy? I'm up for anything, we just need to increase the pace a bit and get something merged that we can extend upon. |
@postlund, I totally agree with you. I just want to have this included to ensure i can work with it without implementing RGB each time because it's not yet supported. @lapy said he returned his bulb, so he will not maintain the code. |
Sounds good to me 👍 Let's merge this and continue with additional PRs and writing issues for bugs. @rospogrigio You can review this now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just one comment, for the rest I think it's ok.
@@ -219,6 +219,8 @@ async def async_added_to_hass(self): | |||
"""Subscribe localtuya events.""" | |||
await super().async_added_to_hass() | |||
|
|||
_LOGGER.debug("Adding %s with configuration: %s", self.entity_id, self._config) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really want to keep this debug message?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do like this debug print as it will tell us if a certain option is configured or not (it helps when a user thinks a he/she configured an option, but actually didn't).
@ultratoto14 This is merged now. You can rebase your changes on top of |
@postlund, @rospogrigio, @SmartM-ui the PR120 is created |
Thanks, I'll try now |
This PR adds support for light bulbs with colors encoded in HSV format. Brightness is supported as well (since it's embedded in the color data).
@rospogrigio This PR is ready for review, but it should not be merged before #92 and a final test by user.