Преглед на файлове

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 години
родител
ревизия
0b29ddc094
променени са 1 файла, в които са добавени 2 реда и са изтрити 2 реда
  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}