From 6ef544950e53568a50c4babe549f5dbd51e8c45b Mon Sep 17 00:00:00 2001 From: donfrensis <79254375+donfrensis@users.noreply.github.com> Date: Mon, 11 Nov 2024 10:48:24 +0100 Subject: [PATCH] Update config_flow.py Fixed connection test logic in configuration flow Improved connection test reliability during device setup --- custom_components/intesishome_local/config_flow.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/custom_components/intesishome_local/config_flow.py b/custom_components/intesishome_local/config_flow.py index 5479fae..39565e6 100644 --- a/custom_components/intesishome_local/config_flow.py +++ b/custom_components/intesishome_local/config_flow.py @@ -29,11 +29,11 @@ async def _test_device_connection(self, host: str) -> bool: try: async with async_timeout.timeout(2): async with aiohttp.request('HEAD', f"http://{host}", raise_for_status=False) as response: - if response.status != 200: - _LOGGER.error("Device at %s is not responding (HTTP %s)", host, response.status) + if response.status == 200: + _LOGGER.info("Successfully connected to device at %s", host) + return True + _LOGGER.error("Device at %s is not responding (HTTP %s)", host, response.status) return False - _LOGGER.info("Successfully connected to device at %s", host) - return True except Exception as ex: _LOGGER.error("Failed to connect to device at %s: %s", host, str(ex)) return False