-
-
Notifications
You must be signed in to change notification settings - Fork 7
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
Added support for lightbulbs that require color temperature updates via percent #9
base: master
Are you sure you want to change the base?
Conversation
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.
Would love the idea of http-lightbulb becoming more versatile. Would like some changes to happen regarding code cleanup and still have some questions regarding design decisions.
Though, thanks for the contribution already 👍
index.js
Outdated
@@ -940,6 +945,8 @@ HTTP_LIGHTBULB.prototype = { | |||
|
|||
if (this.colorTemperature.unit === TemperatureUnit.KELVIN) | |||
colorTemperature = Math.round(1000000 / colorTemperature); // converting Kelvin to mired | |||
if (this.colorTemperature.unit === TemperatureUnit.PERCENT) | |||
colorTemperature = Math.round(400 - (3.5 * colorTemperature)); // converting percent to mired |
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.
You are assuming a maxValue of 400 and a maxValue of 50 here. Would make more sense to make it dynamically adjust to the defined min/max values defined in the hap characteristic properties. 🤔
Also is there are particular reasons for the mapping 0% -> 400 (aka warm white) and 100% maps to cold white? Seems to be pretty arbitrary and dependent on the scenario, why would somebody not endorse are mapping in the other way around 🤔
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.
The lightbulb I'm testing with seems to respond to this mapping (0% to maxValue and 100% to minValue) and plays nicely with the Home app's color wheel. However I do realize that some bulbs may have the opposite behavior, in which case switching min and max would work. Currently, minValue > maxValue is not allowed (which makes total sense). However, I could introduce another config option (possibly as another united, say "PERCENT_ALT" to map 0% to minValue and 100% to maxValue. This way you wouldn't have to break existing code. Let me know if that makes sense.
…which must be provided in mired
Sorry, I'm currently pretty busy, trying to come back to this PR as soon as possible. |
Hey, was wondering if you had a chance to look at this. |
An example is the VeSyncESL100CW.
0% maps to 400 mired and 100% maps to 50 mired.
mired = 400 - (3.5 * percent)
"unit":"percent"
can be used as a key-value pair inconfig.json
to use percentages to upgrade color temperature