Prechádzať zdrojové kódy

Remove extraneous code

Christopher Mullins 6 rokov pred
rodič
commit
33402bcaca

+ 27 - 9
lib/MQTT/HomeAssistantDiscoveryClient.cpp

@@ -65,36 +65,48 @@ void HomeAssistantDiscoveryClient::addConfig(const char* alias, const BulbId& bu
   JsonArray effects = config.createNestedArray(F("effect_list"));
   effects.add(MiLightCommandNames::NIGHT_MODE);
 
-  // These bulbs support RGB color
+  // These bulbs support switching between rgb/white, and have a "white_mode" command
   switch (bulbId.deviceType) {
     case REMOTE_TYPE_FUT089:
-    case REMOTE_TYPE_RGB:
     case REMOTE_TYPE_RGB_CCT:
     case REMOTE_TYPE_RGBW:
-      config[F("rgb")] = true;
+      effects.add("white_mode");
       break;
     default:
       break; //nothing
   }
 
-  // These bulbs support adjustable white values
+  // All bulbs except CCT have 9 modes.  FUT029 and RGB/FUT096 has 9 modes, but they
+  // are not selectable directly.  There are only "next mode" commands.
   switch (bulbId.deviceType) {
     case REMOTE_TYPE_CCT:
+    case REMOTE_TYPE_RGB:
+    case REMOTE_TYPE_FUT020:
+      break;
+    default:
+      addNumberedEffects(effects, 0, 8);
+      break;
+  }
+
+  // These bulbs support RGB color
+  switch (bulbId.deviceType) {
     case REMOTE_TYPE_FUT089:
-    case REMOTE_TYPE_FUT091:
+    case REMOTE_TYPE_RGB:
     case REMOTE_TYPE_RGB_CCT:
-      config[GroupStateFieldNames::COLOR_TEMP] = true;
+    case REMOTE_TYPE_RGBW:
+      config[F("rgb")] = true;
       break;
     default:
       break; //nothing
   }
 
-  // These bulbs support switching between rgb/white, and have a "white_mode" command
+  // These bulbs support adjustable white values
   switch (bulbId.deviceType) {
+    case REMOTE_TYPE_CCT:
     case REMOTE_TYPE_FUT089:
+    case REMOTE_TYPE_FUT091:
     case REMOTE_TYPE_RGB_CCT:
-    case REMOTE_TYPE_RGBW:
-      effects.add("white_mode");
+      config[GroupStateFieldNames::COLOR_TEMP] = true;
       break;
     default:
       break; //nothing
@@ -152,4 +164,10 @@ String HomeAssistantDiscoveryClient::bindTopicVariables(const String& topic, con
   boundTopic.replace(":group_id", String(bulbId.groupId));
 
   return boundTopic;
+}
+
+void HomeAssistantDiscoveryClient::addNumberedEffects(JsonArray& effectList, uint8_t start, uint8_t end) {
+  for (uint8_t i = start; i <= end; ++i) {
+    effectList.add(String(i));
+  }
 }

+ 1 - 0
lib/MQTT/HomeAssistantDiscoveryClient.h

@@ -20,4 +20,5 @@ private:
 
   String buildTopic(const BulbId& bulbId);
   String bindTopicVariables(const String& topic, const char* alias, const BulbId& bulbId);
+  void addNumberedEffects(JsonArray& effectList, uint8_t start, uint8_t end);
 };

+ 0 - 4
lib/Transitions/TransitionController.cpp

@@ -46,10 +46,6 @@ std::shared_ptr<Transition::Builder> TransitionController::buildFieldTransition(
 }
 
 std::shared_ptr<Transition::Builder> TransitionController::buildStatusTransition(const BulbId& bulbId, MiLightStatus status, uint8_t startLevel) {
-  uint16_t value = static_cast<uint16_t>(status);
-  uint16_t startValue = status == ON ? 0 : 100;
-  uint16_t endValue = status == ON ? 100 : 0;
-
   std::shared_ptr<Transition::Builder> transition;
 
   if (status == ON) {