Add support for setting RGB and RGBW values for Twinkly lights#62337
Add support for setting RGB and RGBW values for Twinkly lights#62337pvizeli merged 14 commits intohome-assistant:devfrom
Conversation
|
Hey there @dr1rrb, mind taking a look at this pull request as it has been labeled with an integration ( |
|
Nice. Is also possible to read effect and let them choose with the library? |
|
Maybe...to set fixed color mode "movie" is used with 1 single frame with a fixed color. There is a mode "effect", but I didn't test that yet. I did forget one thing by the way when submitting this PR, there is twinkly RGB, RGBW and AWW. I need to add that it reads the available mode and set color_mode accordingly. |
@RobBie1221 😍😍😍
@pvizeli From my last investigations last year, unfortunately not really: effects are not stored on the device, they are sent by the app each time. And when you "group" and "map" multiple devices together, effects are "computed" by the app before being sent, so it's not a mater of capturing all of them statically and embed them in the component. The single option I see would be to have a "listening mode" which would somehow act as a "an in the middle" to capture effects sent by the app, store them on HA and then expose them as "light effects" in HA ... |
|
Hey @RobBie1221 does the (BTW when ready I do have RGB and RGBW devices, I will be more than happy to test it) |
Don't know, need to check that.
I do have RGBW, but don't have RGB, so it would be good to have someone who can test that. |
|
Yeah, twinkly integration with home assistant presents at least two difficult challenges:
I'm not saying these should be resolved right now (this PR has already improved twinkly situation significantly as it resolves the brightness changing killing playlist), I just want to bring them to your attention since we appear to have a new Twinkly maintainer. |
Great idea
My idea for this was to add a basic flag/switch to disable the polling for a given time (like 20 min). Then we could also add some basic logic like when we get a 401 we automatically enable that flag, and when we have a "real" command from HA we auto-disable it. But this year there is a new setting in the Twinkly App which sounds promising: you can make your device discoverable to homekit. I would assume that we would be able to avoid the "auth conflict" issue. |
Can I ask why it'd be preferable doing this over using the "color" mode? |
What color mode? These I know off: |
I got it from here: I used these successfully with my RGBW and ended up creating a PR for twinkly-client. Then I found this PR haha "oops". |
|
I think that API is new. Anyway it would take major redesign to get it working like that. The integration works at the moment that "on" means set mode "movie". If we are going to support multiple modes, we need a design to incorporate that. The simplicity of this solution is that nothing changes to which modes are set. I think in the end it may be nicer to use the "color" mode, but that needs more work. Also it needs to be in a library. Perhaps you can make a PR against the ttls library, that one seems to get regular updates. |
I see. I just got my twinkly last week, so that's when I started to look around for options and libs. I saw some ppl playing with xled and xled_plus, and then focused on twinkly-client since that's the one used by HA. I completely missed ttls though 🙄
I agree, this should get merged, given that it's a major improvement over the current implementation and ppl (including myself) want this stuff asap 😄 . Meanwhile I'll try to play around with ttls and see if I can add color mode to it 👍 |
| self._attr_supported_color_modes = {COLOR_MODE_RGBW} | ||
| self._attr_color_mode = COLOR_MODE_RGBW | ||
| self._attr_rgbw_color = (255, 255, 255, 0) |
There was a problem hiding this comment.
Well not all support RGBW, we should handle it dynamic and only show the support if they are present over an property
There was a problem hiding this comment.
Yep, you're right. It got burried a bit over the numerous comments. It's on my list to adjust.
|
All comments have to stop now, by side of the code review. Feel free to open a forum topic or an issue for future discussion. |
pvizeli
left a comment
There was a problem hiding this comment.
You can also remove line 132 - 141 - That is wrong extra_state_attributes
I noticed that there is still a lot of review comments open on the initial PR for the integration, which I think also adresses this. Maybe make a separate PR to cleanup those comments? |
@pvizeli No problem with removing that, but isn't that a breaking change for people using that? Shouldn't we do that in a separate pull? |
efa44c7 to
6032433
Compare
|
I reworked it a bit:
|
|
Looks a lot better as that code before :D |
MartinHjelmare
left a comment
There was a problem hiding this comment.
Nice! All my comments pertain to code that was already there from earlier contributions. Just noting them again, to help with possible future clean up efforts. ❤️
|
I'll make a follow up PR :) |
Breaking change
Proposed change
Change library from twinkly-client to ttls. It covers same functionality and more and has required functions to set RGBW values.
Add support in the light entity for setting RGBW values.
Update all tests.
Type of change
Additional information
Checklist
black --fast homeassistant tests)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest.requirements_all.txt.Updated by running
python3 -m script.gen_requirements_all..coveragerc.The integration reached or maintains the following Integration Quality Scale:
To help with the load of incoming pull requests: