Skip to content

Commit

Permalink
Update config_flow.py
Browse files Browse the repository at this point in the history
Fixed connection test logic in configuration flow
Improved connection test reliability during device setup
  • Loading branch information
donfrensis committed Nov 11, 2024
1 parent 93fdfa5 commit 6ef5449
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions custom_components/intesishome_local/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6ef5449

Please sign in to comment.