Kaynağa Gözat

Only turn bulbs off if they aren't already off

Christopher Mullins 6 yıl önce
ebeveyn
işleme
355645830d
1 değiştirilmiş dosya ile 9 ekleme ve 1 silme
  1. 9 1
      lib/MiLight/RgbwPacketFormatter.cpp

+ 9 - 1
lib/MiLight/RgbwPacketFormatter.cpp

@@ -96,7 +96,15 @@ void RgbwPacketFormatter::updateColorWhite() {
 void RgbwPacketFormatter::enableNightMode() {
   uint8_t button = STATUS_COMMAND(OFF, groupId);
 
-  command(button, 0);
+  // Bulbs must be OFF for night mode to work in RGBW.
+  // Turn it off if it isn't already off.
+  const GroupState* state = stateStore->get(deviceId, groupId, REMOTE_TYPE_RGBW);
+  if (state == NULL || state->getState() == MiLightStatus::ON) {
+    command(button, 0);
+  }
+
+  // Night mode command has 0x10 bit set, but is otherwise
+  // a repeat of the OFF command.
   command(button | 0x10, 0);
 }