Explorar el Código

Merge branch 'v1.6.0' into state_persistence

Chris Mullins hace 8 años
padre
commit
a3ae55cac7
Se han modificado 1 ficheros con 14 adiciones y 13 borrados
  1. 14 13
      lib/Udp/V5MiLightUdpServer.cpp

+ 14 - 13
lib/Udp/V5MiLightUdpServer.cpp

@@ -16,7 +16,7 @@ void V5MiLightUdpServer::handleCommand(uint8_t command, uint8_t commandArg) {
     const MiLightStatus status = (command % 2) == 1 ? ON : OFF;
     const uint8_t groupId = (command - UDP_RGBW_GROUP_1_ON + 2)/2;
 
-    client->prepare(&FUT098Config, deviceId, groupId);
+    client->prepare(&FUT096Config, deviceId, groupId);
     client->updateStatus(status);
 
     this->lastGroup = groupId;
@@ -26,18 +26,6 @@ void V5MiLightUdpServer::handleCommand(uint8_t command, uint8_t commandArg) {
     client->prepare(&FUT096Config, deviceId, groupId);
     client->updateColorWhite();
     this->lastGroup = groupId;
-    // On/off for CCT
-  } else if (CctPacketFormatter::cctCommandIdToGroup(command) != 255) {
-    uint8_t cctGroup = CctPacketFormatter::cctCommandIdToGroup(command);
-    client->prepare(&FUT091Config, deviceId, cctGroup);
-    this->lastGroup = cctGroup;
-
-    // Night mode commands are same as off commands with MSB set
-    if ((command & 0x80) == 0x80) {
-      client->enableNightMode();
-    } else {
-      client->updateStatus(CctPacketFormatter::cctCommandToStatus(command));
-    }
   } else {
     client->prepare(&FUT096Config, deviceId, lastGroup);
     bool handled = true;
@@ -84,6 +72,19 @@ void V5MiLightUdpServer::handleCommand(uint8_t command, uint8_t commandArg) {
       return;
     }
 
+    uint8_t onOffGroup = CctPacketFormatter::cctCommandIdToGroup(command);
+
+    if (onOffGroup != 255) {
+      client->prepare(&FUT091Config, deviceId, onOffGroup);
+      // Night mode commands are same as off commands with MSB set
+      if ((command & 0x80) == 0x80) {
+        client->enableNightMode();
+      } else {
+        client->updateStatus(CctPacketFormatter::cctCommandToStatus(command));
+      }
+      return;
+    }
+
     client->prepare(&FUT091Config, deviceId, lastGroup);
 
     switch(command) {