|
|
@@ -267,16 +267,23 @@ void MiLightClient::update(const JsonObject& request) {
|
|
|
uint8_t r = color["r"];
|
|
|
uint8_t g = color["g"];
|
|
|
uint8_t b = color["b"];
|
|
|
+ //If close to white
|
|
|
+ if( r > 256 - RGB_BOUNDARY && g > 256 - RGB_BOUNDARY && b > 256 - RGB_BOUNDARY)
|
|
|
+ {
|
|
|
+ this->updateColorWhite();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ double hsv[3];
|
|
|
+ RGBConverter converter;
|
|
|
+ converter.rgbToHsv(r, g, b, hsv);
|
|
|
|
|
|
- double hsv[3];
|
|
|
- RGBConverter converter;
|
|
|
- converter.rgbToHsv(r, g, b, hsv);
|
|
|
-
|
|
|
- uint16_t hue = round(hsv[0]*360);
|
|
|
- uint8_t saturation = round(hsv[1]*100);
|
|
|
+ uint16_t hue = round(hsv[0]*360);
|
|
|
+ uint8_t saturation = round(hsv[1]*100);
|
|
|
|
|
|
- this->updateHue(hue);
|
|
|
- this->updateSaturation(saturation);
|
|
|
+ this->updateHue(hue);
|
|
|
+ this->updateSaturation(saturation);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
if (request.containsKey("level")) {
|
|
|
@@ -298,11 +305,6 @@ void MiLightClient::update(const JsonObject& request) {
|
|
|
);
|
|
|
}
|
|
|
|
|
|
- //Homeassistant - Switch to white if white value is set
|
|
|
- if (request.containsKey("white_value")) {
|
|
|
- this->updateColorWhite();
|
|
|
- }
|
|
|
-
|
|
|
if (request.containsKey("mode")) {
|
|
|
this->updateMode(request["mode"]);
|
|
|
}
|