Răsfoiți Sursa

Avoid errors when migrating multiple entities of the same type.

If a user upgrades after multiple entity configs are available and has already
configured the same device (an earlier version without multiple entities
perhaps), an error will be raised when trying to migrate the second entity
due to the config already being popped off the options.  Give a default when
popping to avoid raising an error.
Jason Rumney 4 ani în urmă
părinte
comite
0b29ddc094
1 a modificat fișierele cu 2 adăugiri și 2 ștergeri
  1. 2 2
      custom_components/tuya_local/__init__.py

+ 2 - 2
custom_components/tuya_local/__init__.py

@@ -116,12 +116,12 @@ async def async_migrate_entry(hass, entry: ConfigEntry):
         }
         e = devcfg.primary_entity
         if e.config_id != e.entity:
-            newopts.pop(e.entity)
+            newopts.pop(e.entity, None)
             newopts[e.config_id] = opts[e.entity]
 
         for e in devcfg.secondary_entities():
             if e.config_id != e.entity:
-                newopts.pop(e.entity)
+                newopts.pop(e.entity, None)
                 newopts[e.config_id] = opts[e.entity]
 
         entry.options = {**newopts}