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

Use get with default of False when migrating options.

Issue #61
Some configs are missing entries for the entity altogether, so ensure they
do not raise an error during migration by assuming False.
This is maybe only happening for configs that have had entities added since
the user first installed.
Jason Rumney преди 4 години
родител
ревизия
4651a348eb
променени са 1 файла, в които са добавени 2 реда и са изтрити 2 реда
  1. 2 2
      custom_components/tuya_local/__init__.py

+ 2 - 2
custom_components/tuya_local/__init__.py

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