Browse Source

Switch to night light mode at low brightness in both white light and RGB mode.

pull/3/head
Maurice Makaay 3 years ago
parent
commit
9fa8aa42ff
1 changed files with 13 additions and 8 deletions
  1. +13
    -8
      yeelight_bs2_light_output.h

+ 13
- 8
yeelight_bs2_light_output.h View File

@ -75,11 +75,6 @@ namespace rgbww {
{
auto values = state->current_values;
ESP_LOGD(TAG, "write_state: STATE %f, RGB %f %f %f, BRI %f, TEMP %f",
values.get_state(),
values.get_red(), values.get_green(), values.get_blue(),
values.get_brightness(), values.get_color_temperature());
// Power down the light when its state is 'off'.
if (values.get_state() == 0)
{
@ -110,6 +105,19 @@ namespace rgbww {
previous_state_ = values.get_state();
#endif
// 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%),
// because the lowest brightness setting from Home Assistant
// turns up as 0.011765 in here (which is 3/255).
if (brightness < 0.012f) {
turn_on_in_night_light_mode_();
return;
}
// Leave it to the default tooling to figure out the basics.
// Because of color interlocking, there are two possible outcomes:
// - red, green, blue zero -> white light color temperature mode
@ -122,9 +130,6 @@ namespace rgbww {
turn_on_in_white_mode_(
values.get_color_temperature(), brightness);
}
else if (brightness < 0.012f) {
turn_on_in_night_light_mode_();
}
else {
turn_on_in_rgb_mode_(
values.get_red(), values.get_green(), values.get_blue(),


Loading…
Cancel
Save