Sfoglia il codice sorgente

Setup: rethrow exceptions as ConfigEntryNotReady

For Home Assistant to retry setup, exceptions thrown from
async_entry_setup need to be a specific exception class.

This is required to handle devices that are offline at the time
Home Assistant boots (eg, HA comes up before the WiFi router
after a power outage, or a device gets switched off at the wall, and
turned on after HA is up).

Issue #1683
Jason Rumney 2 anni fa
parent
commit
4adb7d490e
1 ha cambiato i file con 5 aggiunte e 1 eliminazioni
  1. 5 1
      custom_components/tuya_local/__init__.py

+ 5 - 1
custom_components/tuya_local/__init__.py

@@ -311,7 +311,11 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
         get_device_id(entry.data),
     )
     config = {**entry.data, **entry.options, "name": entry.title}
-    setup_device(hass, config)
+    try:
+        setup_device(hass, config)
+    except Exception as e:
+        raise ConfigEntryNotReady("tuya-local device not ready") from e
+
     device_conf = get_config(entry.data[CONF_TYPE])
     if device_conf is None:
         _LOGGER.error(NOT_FOUND, config[CONF_TYPE])