Explorar el Código

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 hace 4 años
padre
commit
4651a348eb
Se han modificado 1 ficheros con 2 adiciones y 2 borrados
  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