Просмотр исходного кода

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 лет назад
Родитель
Сommit
44872a583d
1 измененных файлов с 2 добавлено и 2 удалено
  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}