Przeglądaj źródła

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 lat temu
rodzic
commit
4651a348eb
1 zmienionych plików z 2 dodań i 2 usunięć
  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