From 1db304659d32202f6d007c68638bcfefaf6419f6 Mon Sep 17 00:00:00 2001 From: Arjen Bos <1064589+arjenbos@users.noreply.github.com> Date: Thu, 2 Nov 2023 14:38:17 +0100 Subject: [PATCH] Report error when room is not ok and small bug fix --- custom_components/alpha_innotec/climate.py | 4 ++-- custom_components/alpha_innotec/coordinator.py | 3 +++ custom_components/alpha_innotec/sensor.py | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/custom_components/alpha_innotec/climate.py b/custom_components/alpha_innotec/climate.py index f237842..2714109 100644 --- a/custom_components/alpha_innotec/climate.py +++ b/custom_components/alpha_innotec/climate.py @@ -93,12 +93,12 @@ def _handle_coordinator_update(self) -> None: @property def current_temperature(self) -> float | None: """Return the current temperature.""" - return self.thermostat.current_temperature if isinstance(self.thermostat.current_temperature, float) else None + return self.thermostat.current_temperature if isinstance(self.thermostat.current_temperature, (float, int)) else None @property def target_temperature(self) -> float: """Return the temperature we try to reach.""" - return self.thermostat.desired_temperature if isinstance(self.thermostat.desired_temperature, float) else None + return self.thermostat.desired_temperature if isinstance(self.thermostat.desired_temperature, (float, int)) else None async def async_set_temperature(self, **kwargs) -> None: """Set new target temperature.""" diff --git a/custom_components/alpha_innotec/coordinator.py b/custom_components/alpha_innotec/coordinator.py index bed0613..744662e 100644 --- a/custom_components/alpha_innotec/coordinator.py +++ b/custom_components/alpha_innotec/coordinator.py @@ -54,6 +54,9 @@ async def _async_update_data(self) -> dict[str, list[Valve | Thermostat]]: current_temperature = module_details["currentTemperature"] battery_percentage = module_details["battery"] + if room.get('status', 'problem') == 'problem': + _LOGGER.error("According to the API there is a problem with: %s", room['name']) + thermostat = Thermostat( identifier=room_id, name=room['name'], diff --git a/custom_components/alpha_innotec/sensor.py b/custom_components/alpha_innotec/sensor.py index ca2677f..4ef05f1 100644 --- a/custom_components/alpha_innotec/sensor.py +++ b/custom_components/alpha_innotec/sensor.py @@ -76,7 +76,7 @@ def name(self) -> str | UndefinedType | None: @property def native_value(self): - return self.thermostat.battery_percentage if self.thermostat.battery_percentage != "unknown" else None + return self.thermostat.battery_percentage if isinstance(self.thermostat.battery_percentage, (float, int)) else None @callback def _handle_coordinator_update(self) -> None: