|
@ -11,14 +11,15 @@ public: |
|
|
bool set_light_color_values(light::LightColorValues v) { |
|
|
bool set_light_color_values(light::LightColorValues v) { |
|
|
// This class can handle the GPIO outputs for the night light mode. |
|
|
// This class can handle the GPIO outputs for the night light mode. |
|
|
// |
|
|
// |
|
|
// At the lowest brightness setting, switch to night light mode. |
|
|
|
|
|
// In the Yeelight integration in Home Assistant, this feature is |
|
|
|
|
|
// exposed trough a separate switch. I have found that the switch |
|
|
|
|
|
// is both confusing and made me run into issues when automating |
|
|
|
|
|
// the lights. |
|
|
|
|
|
|
|
|
// At the lowest brightness setting, switch to night light mode. In |
|
|
|
|
|
// the Yeelight integration in Home Assistant, this feature is |
|
|
|
|
|
// exposed trough a separate switch. I have found that the switch is |
|
|
|
|
|
// both confusing and made me run into issues when automating the |
|
|
|
|
|
// lights. |
|
|
|
|
|
// |
|
|
// I don't simply check for a brightness at or below 0.01 (1%), |
|
|
// I don't simply check for a brightness at or below 0.01 (1%), |
|
|
// because the lowest brightness setting from Home Assistant |
|
|
|
|
|
// turns up as 0.011765 in here (which is 3/255). |
|
|
|
|
|
|
|
|
// because the lowest brightness setting from Home Assistant turns |
|
|
|
|
|
// up as 0.011765 in here (which is 3/255). |
|
|
if (v.get_brightness() >= 0.012f) { |
|
|
if (v.get_brightness() >= 0.012f) { |
|
|
return false; |
|
|
return false; |
|
|
} |
|
|
} |
|
@ -34,13 +35,13 @@ public: |
|
|
blue = 0.972f; |
|
|
blue = 0.972f; |
|
|
white = 0.0f; |
|
|
white = 0.0f; |
|
|
} |
|
|
} |
|
|
// In RGB mode, the selected color is used to give the night light |
|
|
|
|
|
// a specific color, instead of the default. This is a nice extra |
|
|
|
|
|
// for this firmware, as the original firmware does not support it. |
|
|
|
|
|
|
|
|
// In RGB mode, the selected color is used to give the night light a |
|
|
|
|
|
// specific color, instead of the default. This is a nice extra for |
|
|
|
|
|
// this firmware, as the original firmware does not support it. |
|
|
else { |
|
|
else { |
|
|
red = 0.9997f - v.get_red() * (0.9997f - 0.9680f); |
|
|
red = 0.9997f - v.get_red() * (0.9997f - 0.9680f); |
|
|
green = 0.9997f - v.get_green() * (0.9997f - 0.9680f); |
|
|
green = 0.9997f - v.get_green() * (0.9997f - 0.9680f); |
|
|
auto blue_on = 0.9720f + (0.9680f - 0.9720f) * (1.0f - (v.get_red() + v.get_green())/2.0f); |
|
|
|
|
|
|
|
|
auto blue_on = 0.9720f + (0.9640f - 0.9720f) * (1.0f - (v.get_red() + v.get_green())/2.0f); |
|
|
blue = 0.9997f - v.get_blue() * (0.9997f - blue_on); |
|
|
blue = 0.9997f - v.get_blue() * (0.9997f - blue_on); |
|
|
white = 0.0f; |
|
|
white = 0.0f; |
|
|
} |
|
|
} |
|
|