Closed jghaanstra closed 6 years ago
This is a really good idea, and I would be happy to have this functionality in this library. Unfortunately, I don't have the necessary setup to adequately test it at the moment. I could try to add necessary methods based on the python code alone, but I would not be able to verify that they actually did what they're supposed to.
I also don't have time to work on this library at the moment, so this request will need to stay unfulfilled for at least a few weeks (except you or someone else implements it instead).
Ok, that was actually a lot easier than I thought. Here is the PR: https://github.com/jangxx/node-magichome/pull/6
Okay, I cleaned up your code a bit, merged your PR and published the changes to npm. Thanks a lot :+1:
With cleaning up the code you actually broke the functionality. The warm white level is an integer between 0 and 100 in the Magic Home smartphone app but it needs to be normalized to a 0 - 255 range for the command. Using the following math gives the right value:
ww = (clamp(ww, lower_bound, 100) * 255) / 100;
Do you want me to submit a new PR?
I think we can just leave it as is it for now. The controllers take a value from 0 to 255, so the method works as intended. If you want to have value from 0 to 100, or 0 to 1, or any other arbitrary range, you can just calculate the value in your application.
RGBW and RGBWW LED strips can also change the (warm) white of the LED strip. The Python library which was used to create this library supports a "set warm white mode" function but it seems this has not been ported to this nodejs library. I'd like to request this feature. I'd submit a PR myself but my programming skills are to limited.