From 7ff45b170dd521901fed35aa10c924ada6730cbd Mon Sep 17 00:00:00 2001 From: Folfy Date: Fri, 20 Dec 2024 15:42:07 +0000 Subject: [PATCH] setpoint calibration - round by step instead of fixed value (#1475) --- custom_components/better_thermostat/calibration.py | 4 ++-- custom_components/better_thermostat/climate.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/custom_components/better_thermostat/calibration.py b/custom_components/better_thermostat/calibration.py index 4820eb31..55a88b20 100644 --- a/custom_components/better_thermostat/calibration.py +++ b/custom_components/better_thermostat/calibration.py @@ -157,6 +157,7 @@ def calculate_calibration_setpoint(self, entity_id) -> Union[float, None]: _cur_external_temp = self.cur_temp _cur_target_temp = self.bt_target_temp + _trv_temp_steps = 1 / ( self.real_trvs[entity_id]["target_temp_step"] or 0.5 ) if None in (_cur_target_temp, _cur_external_temp, _cur_trv_temp_s): return None @@ -196,8 +197,7 @@ def calculate_calibration_setpoint(self, entity_id) -> Union[float, None]: if _cur_external_temp >= _cur_target_temp: _calibrated_setpoint -= (_cur_external_temp - _cur_target_temp) * 10.0 - # TODO: round down to half degree step -> replace with rounding to step size - _calibrated_setpoint = round_by_steps(_calibrated_setpoint, 2) + _calibrated_setpoint = round_by_steps(_calibrated_setpoint, _trv_temp_steps) # limit new setpoint within min/max of the TRV's range t_min = self.real_trvs[entity_id]["min_temp"] diff --git a/custom_components/better_thermostat/climate.py b/custom_components/better_thermostat/climate.py index e8ef78de..dc3548e1 100644 --- a/custom_components/better_thermostat/climate.py +++ b/custom_components/better_thermostat/climate.py @@ -827,7 +827,7 @@ async def startup(self): ) self.real_trvs[trv]["target_temp_step"] = convert_to_float( str( - self.hass.states.get(trv).attributes.get("target_temp_step", 1) + self.hass.states.get(trv).attributes.get("target_temp_step", 0.5) ), self.device_name, "startup",