Răsfoiți Sursa

Improve robustness of migration.

If options were never set, the migration would raise an error when popping
the old values off the options list.  Add a default value so pop won't raise
exceptions.
Jason Rumney 4 ani în urmă
părinte
comite
44872a583d
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

@@ -53,10 +53,10 @@ async def async_migrate_entry(hass, entry: ConfigEntry):
         }
         opts[CONF_TYPE] = config[CONF_TYPE]
         if CONF_CHILD_LOCK in config:
-            opts.pop(CONF_CHILD_LOCK)
+            opts.pop(CONF_CHILD_LOCK, False)
             opts[CONF_LOCK] = config[CONF_CHILD_LOCK]
         if CONF_DISPLAY_LIGHT in config:
-            opts.pop(CONF_DISPLAY_LIGHT)
+            opts.pop(CONF_DISPLAY_LIGHT, False)
             opts[CONF_LIGHT] = config[CONF_DISPLAY_LIGHT]
 
         entry.options = {**opts}