Procházet zdrojové kódy

Save deleted group IDs so that they can be processed

Christopher Mullins před 6 roky
rodič
revize
eddda7f284
2 změnil soubory, kde provedl 11 přidání a 0 odebrání
  1. 10 0
      lib/Settings/Settings.cpp
  2. 1 0
      lib/Settings/Settings.h

+ 10 - 0
lib/Settings/Settings.cpp

@@ -165,6 +165,13 @@ std::map<String, BulbId>::const_iterator Settings::findAlias(MiLightRemoteType d
 
 void Settings::parseGroupIdAliases(JsonObject json) {
   JsonObject aliases = json["group_id_aliases"];
+
+  // Save group IDs that were deleted so that they can be processed by discovery
+  // if necessary
+  for (auto it = groupIdAliases.begin(); it != groupIdAliases.end(); ++it) {
+    deletedGroupIdAliases[it->second.getCompactId()] = it->second;
+  }
+
   groupIdAliases.clear();
 
   for (JsonPair kv : aliases) {
@@ -175,6 +182,9 @@ void Settings::parseGroupIdAliases(JsonObject json) {
       MiLightRemoteTypeHelpers::remoteTypeFromString(bulbIdProps[0].as<String>())
     };
     groupIdAliases[kv.key().c_str()] = bulbId;
+
+    // If added this round, do not mark as deleted.
+    deletedGroupIdAliases.erase(bulbId.getCompactId());
   }
 }
 

+ 1 - 0
lib/Settings/Settings.h

@@ -183,6 +183,7 @@ public:
   String wifiStaticIPGateway;
   size_t packetRepeatsPerLoop;
   std::map<String, BulbId> groupIdAliases;
+  std::map<uint32_t, BulbId> deletedGroupIdAliases;
   String homeAssistantDiscoveryPrefix;
 
 protected: