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

Added support for lightbulbs that require color temperature updates via percent #9

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

Conversation

adityasalapaka
Copy link

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 in config.json to use percentages to upgrade color temperature

Copy link
Owner

@Supereg Supereg left a 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 👍

README.md Outdated Show resolved Hide resolved
index.js Outdated Show resolved Hide resolved
index.js Outdated Show resolved Hide resolved
index.js Outdated Show resolved Hide resolved
index.js Outdated Show resolved Hide resolved
index.js Outdated Show resolved Hide resolved
index.js Outdated Show resolved Hide resolved
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
Copy link
Owner

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 🤔

Copy link
Author

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.

index.js Outdated Show resolved Hide resolved
index.js Outdated Show resolved Hide resolved
@Supereg
Copy link
Owner

Supereg commented Jun 27, 2020

Sorry, I'm currently pretty busy, trying to come back to this PR as soon as possible.

@adityasalapaka
Copy link
Author

Hey, was wondering if you had a chance to look at this.

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.

2 participants