Skip to content
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

Initial support for new Wyze Color Bulbs #35

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

mda590
Copy link

@mda590 mda590 commented Apr 4, 2021

This PR adds support for new Wyze Color Bulbs to this Homebridge plug-in.

A few things of note:

  • The color bulbs seems to use a new API endpoint for updating properties - where all of the other accessories seem to use the set_property endpoint, the new color bulbs use a run_action_list endpoint.
  • In order to support color changing in HomeKit, there is color translation that needs to be done between HSL (used by HomeKit) and Hex values (used by Wyze). I found these resources helpful for understanding HSL and doing color math.
  • One of the biggest challenges is that Hue and Saturation on HomeKit are separate - so when you set the color from HomeKit, Homebridge actually gets 2 calls - 1 for setting Hue and 1 for setting Saturation. I had a hard time figuring out how to handle this the best way, but l luckily I found another plugin which handles this using caching. I implemented this and it seems to work very well so far.
  • I am not a Javascript developer at all, so please excuse any sort of Javascript best practices I have broken - happy for any feedback.

I would love others to test this out and see if there is some kind of edge case I overlooked - and even to help contribute any fixes. It doesn't look like this project is very active any more so we will see if we can get this merged or if we need to branch out and create our own.

At the end of the day, the bulb shows up in the Home app and allows me to control all aspects of the bulb:
image
image
image

@mda590 mda590 mentioned this pull request Apr 4, 2021
@dejaloomer
Copy link

Thanks for this. One comment... I'm getting pretty strange results when trying to set color. If brightness is 100% the rgb value is computed as white. Online converters confirm that's expected...so I replaced hsl calculations with hsv and hardcode v to 100% . I don't see homekit ever sending brightness when changing colors so I suspect it's not meant to be used in the rgb calc. I'm brand new to colorspace conversion though...so might be wrong...but it at least seems to be working.

@mda590
Copy link
Author

mda590 commented Apr 7, 2021

@dejaloomer can you share the changes you made? I had a lot of issues with this part, as well, and your change to HSV makes sense based on everything I read! I would be interested to get that put into this PR (if you want to do a PR against my fork, I can merge that).

@InstigatorX
Copy link

@dejaloomer can you share the changes you made? I had a lot of issues with this part, as well, and your change to HSV makes sense based on everything I read! I would be interested to get that put into this PR (if you want to do a PR against my fork, I can merge that).

I noticed the odd behavior at 100% brightness as well. You might consider using https://www.npmjs.com/package/colorsys to standardize on the calcs/method.

@mda590
Copy link
Author

mda590 commented Apr 7, 2021 via email

@mda590
Copy link
Author

mda590 commented Apr 7, 2021

@dejaloomer @InstigatorX - this is updated to use HSV and the colorsys package now. This seems to work much better, especially when brightness is at 100. Let me know if you notice any issues after the change.

@InstigatorX
Copy link

Oh wow, great find! I'll work on incorporating that into the code.

Sent from my iPhone
________________________________ From: InstigatorX @.> Sent: Wednesday, April 7, 2021 5:08:44 PM To: misenhower/homebridge-wyze-connected-home @.> Cc: Matt Adorjan @.>; Author @.> Subject: Re: [misenhower/homebridge-wyze-connected-home] Initial support for new Wyze Color Bulbs (#35) @dejaloomerhttps://github.com/dejaloomer can you share the changes you made? I had a lot of issues with this part, as well, and your change to HSV makes sense based on everything I read! I would be interested to get that put into this PR (if you want to do a PR against my fork, I can merge that). I noticed the odd behavior at 100% brightness as well. You might consider using https://www.npmjs.com/package/colorsys to standardize on the calcs/method. — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub<#35 (comment)>, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ABBECJLYKM7632FYPIEGSULTHTJWZANCNFSM42LNQ2RA.

@dejaloomer @InstigatorX - this is updated to use HSV and the colorsys package now. This seems to work much better, especially when brightness is at 100. Let me know if you notice any issues after the change.

Yeah man! Works much better now. Only weirdness is setting TEMPERATURE in Home app. When you select something around the curve it changes the light color accordingly, but then jumps to another spot with the original color in the circle. Not sure how to explain it.

@dejaloomer
Copy link

I just pushed my changes to a fork in my repo. Unfortunately before I discovered your changes I had branched off off RMCob/homebridge-wyze-connected-home-op which seemed to have more recent support than misenhower. I used color-convert package and your wyze property list changes so we probably ended up with about the same solution. One thing I added that you might want to check out is that I batch multiple property-set requests into a single transaction. This seems to have fixed issues with bulbs getting out of sync when homekit uses scenes or groups to rapidly change a bunch of settings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants