-
Notifications
You must be signed in to change notification settings - Fork 4
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 RGB light support #7
Conversation
Use device name for PlatformAccessory when available.
…Mode, rgbColor, etc.
Fix undefined colortemperature durng device discovery and cache color…
… only support color temp. change only, need a way to distinguish lights. Set colortemp range to 2000k to 6500k. Set brightness range to match Sengled encoding. Fix issue with updating existing contects. Fix issue retrieving cached device.
…, and saturation. Resolve issue with deserialized context not having object methods by creating an instanced accessory wrapper that now handles callbacks, etc. Seperate context data from brightness/color classes.
…Add firmware revision accessory information. Restore color context data on hue failure.
…e a match color wheel in home application
…es remaining on homebridge-lib. Did a pass through color routines to consistently use color objects. Add a .catch for getpowerstate as this method has been timing out.
@sammy1881 would appreciate if you could test with your lights to make sure this properly detects that they don't do RGB. I can switch to a table based approach if this auto-detect capabilities scheme fails. Also, I'm not familiar, is revising the package version and publishing something you'd do seperately? This change certainly grew larger than I thought it would when I started out, feedback welcome. |
Hi @RandyTidd, thanks for all the great work! Everything looks good in my testing and I was able to change colors. I've enabled auto-publish workflow so if you could please bump up the version in package.json file, I'll merge this PR and we should have the new version available. |
@sammy1881 I think I've updated the version in the package.json. Let me know if this isn't correct. Oh, I didn't realize you had rgb lights. Which lights do you have? |
Yeah, I have a few of there multicolored A19 bulbs and they work great with your change and I was able to choose colors. Thanks again for adding this feature. |
Yes, I’ve built it for Node 16, i’ll republish it for 14 too later. |
Add support for hue and saturation characteristics when bulbs support it. Light bulb support for brightness, color temperature, and hue/saturation are determined by the presence of the corresponding fields in the data retrieved from the Sengled service, but this has only been tested on E12-N1E which supports them all. If this approach doesn't work for lightbulbs that do not have some of these characteristics, it's easy to move to a table based approach for choosing capabilities.
The E12-N1E has a "white" light mode and a "color" light mode. This PR treats color temperature changes as switching to "white" light mode and setting of hue/saturation as switching into "color" light mode. When temperature is set, this change calculates hue and saturation values to update to homebridge so that the cursor in the home app on the color temperature tab appears to match the temperature rather than the hue saturation. This seems to result in some jumping around on the color temperature wheel, but this should only affect lights that support color temp and RGB.
Added an instanced SengledLightAccessory to handle callbacks and resolve some issues with state. Added a common method for updating homebridge context from sengled device state. As part of this, I removed the calls to addCharacteristc and a uuid argument to characteristic construction that didn't seem to do anything. It seems that calls to getCharacteristic add the optional characteristic if it's not there. Some callbacks for getters/setters were commented out. Enabled those and also fixed up some error reporting to be more consistent.
Color.js is added to help keep hue/sat in sync when in color temp mode, and handle the various color conversions.
Added firmware revision characteristic and plumbed through the value from sengled device data.
Modified brightness min/max to be 0-255 to match sengled encoding so scaling is no longer needed to map the ranges. Added a configuration option to set the min/max color temperature values based on matching product number. Only the E12-N1E has values here. Other bulbs will fall back to the previous homebridge defaults.
Client has an API added for setting RGB color. This has a quirk that it also turns on the light if it is off, which is inconsistent with setting color temp. For now, updating homekit power state when an RGB color is set.