Преглед изворни кода

Allow config options to be truely optional.

They were listed in the schema as optional, but the way they were accessed
made them raise errors if missing.
Jason Rumney пре 4 година
родитељ
комит
a0b5b44fb1
1 измењених фајлова са 5 додато и 5 уклоњено
  1. 5 5
      custom_components/tuya_local/__init__.py

+ 5 - 5
custom_components/tuya_local/__init__.py

@@ -49,23 +49,23 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
     config = {**entry.data, **entry.options, "name": entry.title}
     setup_device(hass, config)
 
-    if config[CONF_CLIMATE] is True:
+    if config.get(CONF_CLIMATE, False) is True:
         hass.async_create_task(
             hass.config_entries.async_forward_entry_setup(entry, "climate")
         )
-    if config[CONF_DISPLAY_LIGHT] is True:
+    if config.get(CONF_DISPLAY_LIGHT, False) is True:
         hass.async_create_task(
             hass.config_entries.async_forward_entry_setup(entry, "light")
         )
-    if config[CONF_CHILD_LOCK] is True:
+    if config.get(CONF_CHILD_LOCK, False) is True:
         hass.async_create_task(
             hass.config_entries.async_forward_entry_setup(entry, "lock")
         )
-    if config[CONF_SWITCH] is True:
+    if config.get(CONF_SWITCH, False) is True:
         hass.async_create_task(
             hass.config_entries.async_forward_entry_setup(entry, "switch")
         )
-    if config[CONF_HUMIDIFIER] is True:
+    if config.get(CONF_HUMIDIFIER, False) is True:
         hass.async_create_task(
             hass.config_entries.async_forward_entry_setup(entry, "humidifier")
         )