Browse Source

Config flow: when testing connection, only pause/resume active devices

Issue #2288
Jason Rumney 1 year ago
parent
commit
0c641e89d0
1 changed files with 2 additions and 2 deletions
  1. 2 2
      custom_components/tuya_local/config_flow.py

+ 2 - 2
custom_components/tuya_local/config_flow.py

@@ -617,7 +617,7 @@ def create_test_device(hass: HomeAssistant, config: dict):
 async def async_test_connection(config: dict, hass: HomeAssistant):
     domain_data = hass.data.get(DOMAIN)
     existing = domain_data.get(get_device_id(config)) if domain_data else None
-    if existing:
+    if existing and existing.get("device"):
         _LOGGER.info("Pausing existing device to test new connection parameters")
         existing["device"].pause()
         await asyncio.sleep(5)
@@ -634,7 +634,7 @@ async def async_test_connection(config: dict, hass: HomeAssistant):
         _LOGGER.warning("Connection test failed with %s %s", type(e), e)
         retval = None
 
-    if existing:
+    if existing and existing.get("device"):
         _LOGGER.info("Restarting device after test")
         existing["device"].resume()