From e787698df5d654a46ca9fc39acb843ef070a0082 Mon Sep 17 00:00:00 2001 From: Hans Oischinger Date: Sat, 12 Aug 2023 17:27:54 +0200 Subject: [PATCH] Use temp min/max/step from API Get rid of hardcoded values and use the data provided by the API --- custom_components/vicare/climate.py | 18 +++++------------- custom_components/vicare/water_heater.py | 18 +++++------------- 2 files changed, 10 insertions(+), 26 deletions(-) diff --git a/custom_components/vicare/climate.py b/custom_components/vicare/climate.py index 814348e..a9c4e35 100644 --- a/custom_components/vicare/climate.py +++ b/custom_components/vicare/climate.py @@ -24,12 +24,7 @@ HVACMode, ) from homeassistant.config_entries import ConfigEntry -from homeassistant.const import ( - ATTR_TEMPERATURE, - PRECISION_TENTHS, - PRECISION_WHOLE, - UnitOfTemperature, -) +from homeassistant.const import ATTR_TEMPERATURE, PRECISION_TENTHS, UnitOfTemperature from homeassistant.core import HomeAssistant from homeassistant.helpers import entity_platform import homeassistant.helpers.config_validation as cv @@ -75,9 +70,6 @@ VICARE_HOLD_MODE_HOME = "home" VICARE_HOLD_MODE_OFF = "off" -VICARE_TEMP_HEATING_MIN = 3 -VICARE_TEMP_HEATING_MAX = 37 - VICARE_HEATING_CURVE_SLOPE_MIN = 0.3 VICARE_HEATING_CURVE_SLOPE_MAX = 3.5 @@ -344,17 +336,17 @@ def hvac_action(self) -> HVACAction: @property def min_temp(self): """Return the minimum temperature.""" - return VICARE_TEMP_HEATING_MIN + return self._circuit.getActiveProgramMinTemperature() @property def max_temp(self): """Return the maximum temperature.""" - return VICARE_TEMP_HEATING_MAX + return self._circuit.getActiveProgramMaxTemperature() @property def target_temperature_step(self) -> float: - """Set target temperature step to wholes.""" - return PRECISION_WHOLE + """Get current stepping.""" + return self._circuit.getActiveProgramStepping def set_temperature(self, **kwargs: Any) -> None: """Set new target temperatures.""" diff --git a/custom_components/vicare/water_heater.py b/custom_components/vicare/water_heater.py index 49169f1..8d7e42f 100644 --- a/custom_components/vicare/water_heater.py +++ b/custom_components/vicare/water_heater.py @@ -15,12 +15,7 @@ WaterHeaterEntityFeature, ) from homeassistant.config_entries import ConfigEntry -from homeassistant.const import ( - ATTR_TEMPERATURE, - PRECISION_TENTHS, - PRECISION_WHOLE, - UnitOfTemperature, -) +from homeassistant.const import ATTR_TEMPERATURE, PRECISION_TENTHS, UnitOfTemperature from homeassistant.core import HomeAssistant from homeassistant.helpers.entity import DeviceInfo from homeassistant.helpers.entity_platform import AddEntitiesCallback @@ -38,9 +33,6 @@ VICARE_MODE_FORCEDNORMAL = "forcedNormal" VICARE_MODE_OFF = "standby" -VICARE_TEMP_WATER_MIN = 10 -VICARE_TEMP_WATER_MAX = 60 - OPERATION_MODE_ON = "on" OPERATION_MODE_OFF = "off" @@ -176,17 +168,17 @@ def set_temperature(self, **kwargs: Any) -> None: @property def min_temp(self): """Return the minimum temperature.""" - return VICARE_TEMP_WATER_MIN + return self._circuit.getActiveProgramMinTemperature() @property def max_temp(self): """Return the maximum temperature.""" - return VICARE_TEMP_WATER_MAX + return self._circuit.getActiveProgramMaxTemperature() @property def target_temperature_step(self) -> float: - """Set target temperature step to wholes.""" - return PRECISION_WHOLE + """Get current stepping.""" + return self._circuit.getActiveProgramStepping @property def current_operation(self):