From 457310e1afd2e918113b2c75d0efce800c93f149 Mon Sep 17 00:00:00 2001 From: donfrensis <79254375+donfrensis@users.noreply.github.com> Date: Sun, 10 Nov 2024 00:55:36 +0100 Subject: [PATCH] change for release 1.1.4 --- README.md | 2 +- custom_components/intesishome_local/climate.py | 8 +++++++- custom_components/intesishome_local/config_flow.py | 13 +++++++++++-- custom_components/intesishome_local/manifest.json | 2 +- 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 8f66fd2..853b836 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ Simplified fork of the IntesisHome integration for Home Assistant *This project is a simplified fork of the original IntesisHome integration by @jnimmo. The original version supported various Intesis devices, while this fork focuses exclusively on local HTTP control for selected devices.* -[![hacs_badge](https://img.shields.io/badge/HACS-Custom-41BDF5.svg?style=for-the-badge)](https://github.com/hacs/integration) +[![hacs_badge](https://img.shields.io/badge/HACS-Custom-41BDF5.svg)](https://github.com/hacs/integration) This custom version exclusively supports local control via HTTP for selected devices. diff --git a/custom_components/intesishome_local/climate.py b/custom_components/intesishome_local/climate.py index 347fd7c..47193e6 100644 --- a/custom_components/intesishome_local/climate.py +++ b/custom_components/intesishome_local/climate.py @@ -199,6 +199,7 @@ def __init__( self._attr_hvac_modes.extend(mode_list) self._attr_hvac_modes.append(HVACMode.OFF) + # Nel metodo async_added_to_hass async def async_added_to_hass(self): """Subscribe to event updates.""" _LOGGER.debug("Added climate device with state: %s", repr(self._ih_device)) @@ -206,8 +207,13 @@ async def async_added_to_hass(self): try: await self._controller.connect() - except IHConnectionError as ex: + except (IHConnectionError, TypeError) as ex: _LOGGER.error("Exception connecting to IntesisHome: %s", ex) + self._connected = False + return # Non solleviamo PlatformNotReady, permettiamo all'entità di esistere come non disponibile + + except Exception as ex: # Cattura altri errori inattesi + _LOGGER.error("Unexpected error connecting to IntesisHome: %s", ex) raise PlatformNotReady from ex @property diff --git a/custom_components/intesishome_local/config_flow.py b/custom_components/intesishome_local/config_flow.py index dc32303..47fff59 100644 --- a/custom_components/intesishome_local/config_flow.py +++ b/custom_components/intesishome_local/config_flow.py @@ -29,8 +29,17 @@ 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: - return response.status == 200 - except: + if response.status != 200: + _LOGGER.error("Device at %s is not responding (HTTP %s)", host, response.status) + return False + # Verifica aggiuntiva che sia un dispositivo Intesis + async with aiohttp.request('GET', f"http://{host}/info", raise_for_status=False) as info_response: + if info_response.status != 200: + _LOGGER.error("Device at %s is not responding as an Intesis device", host) + return False + return True + except Exception as ex: + _LOGGER.error("Failed to connect to device at %s: %s", host, str(ex)) return False async def async_step_user(self, user_input=None) -> FlowResult: diff --git a/custom_components/intesishome_local/manifest.json b/custom_components/intesishome_local/manifest.json index 2cbcf63..07fbb7a 100644 --- a/custom_components/intesishome_local/manifest.json +++ b/custom_components/intesishome_local/manifest.json @@ -9,5 +9,5 @@ "issue_tracker": "https://github.com/donfrensis/ha-intesishome-local/issues", "loggers": ["pyintesishome"], "requirements": ["pyintesishome==1.8.5"], - "version": "1.1.3" + "version": "1.1.4" } \ No newline at end of file