diff --git a/README.md b/README.md index cf89540..19b43a7 100644 --- a/README.md +++ b/README.md @@ -282,6 +282,9 @@ https://www.gnu.org/licenses/gpl-3.0.html - Keep looking to see if there is a time sync mechanism - Use the config ver and status ver check in simulator to make sure partial block updates are acceptable +## Done/Fixed in 1.0.10 + - Handle TempNotValid error + ## Done/Fixed in 1.0.9 - Fixed broken EcoMode switch that 1.0.8 introduced - Added pump and blower sensors to show P & BL device states because buttons now diff --git a/src/geckolib/_version.py b/src/geckolib/_version.py index e85f274..07007d1 100644 --- a/src/geckolib/_version.py +++ b/src/geckolib/_version.py @@ -1,3 +1,3 @@ """Single module version.""" -VERSION = "1.0.9" +VERSION = "1.0.10" diff --git a/src/geckolib/automation/heater.py b/src/geckolib/automation/heater.py index e7af005..25e4f96 100644 --- a/src/geckolib/automation/heater.py +++ b/src/geckolib/automation/heater.py @@ -2,8 +2,9 @@ from __future__ import annotations +import logging from abc import abstractmethod -from typing import TYPE_CHECKING +from typing import TYPE_CHECKING, Any from geckolib.automation.power import GeckoPower from geckolib.const import GeckoConstants @@ -13,6 +14,8 @@ if TYPE_CHECKING: from geckolib.automation.async_facade import GeckoAsyncFacade +_LOGGER = logging.getLogger(__name__) + class GeckoWaterHeaterAbstract(GeckoPower): """Abstract base for water heaters.""" @@ -71,6 +74,7 @@ def __init__(self, facade: GeckoAsyncFacade) -> None: self._cooling_action_sensor = None self._min_temp_sensor = None self._max_temp_sensor = None + self._temp_not_valid_sensor = None # Attempt to locate the various items needed from the spa accessors self._temperature_unit_accessor = self._spa.accessors[ @@ -126,6 +130,12 @@ def __init__(self, facade: GeckoAsyncFacade) -> None: self._spa.accessors[GeckoConstants.KEY_MAX_SETPOINT_G], self._temperature_unit_accessor, ) + if GeckoConstants.KEY_TEMP_NOT_VALID in self._spa.accessors: + self._temp_not_valid_sensor = GeckoSensor( + self.facade, + "Temp Not Valid", + self._spa.accessors[GeckoConstants.KEY_TEMP_NOT_VALID], + ) # Setup change observers for sensor in [ @@ -137,10 +147,13 @@ def __init__(self, facade: GeckoAsyncFacade) -> None: self._cooling_action_sensor, self._min_temp_sensor, self._max_temp_sensor, + self._temp_not_valid_sensor, ]: if sensor is not None: sensor.watch(self._on_change) + self._on_change(None, None, None) + @property def target_temperature_sensor(self) -> GeckoSensor: """Get the target temperature sensor object.""" @@ -262,6 +275,13 @@ def __str__(self) -> str: ) return f"{self.name}: Not present" + def _on_change( + self, sender: Any = None, old_value: Any = None, new_value: Any = None + ) -> None: + if self._temp_not_valid_sensor is not None: + self.set_availability(is_available=not self._temp_not_valid_sensor.state) + return super()._on_change(sender, old_value, new_value) + @property def monitor(self) -> str: """Get monitor string.""" diff --git a/src/geckolib/automation/sensors.py b/src/geckolib/automation/sensors.py index 6e96293..6128dac 100644 --- a/src/geckolib/automation/sensors.py +++ b/src/geckolib/automation/sensors.py @@ -157,3 +157,5 @@ def update_state( _LOGGER.debug("Error sensor state is %s", self.state) else: self._state = "None" + + self._on_change(None, None, None) diff --git a/src/geckolib/const.py b/src/geckolib/const.py index 24dcf6a..e042be4 100644 --- a/src/geckolib/const.py +++ b/src/geckolib/const.py @@ -48,6 +48,7 @@ class GeckoConstants: KEY_DISPLAYED_TEMP_G = "DisplayedTempG" KEY_HEATING = "Heating" KEY_COOLINGDOWN = "CoolingDown" + KEY_TEMP_NOT_VALID = "TempNotValid" KEY_PUMP_1 = "P1" KEY_PUMP_2 = "P2" KEY_PUMP_3 = "P3"