From 5675cf76a6221ea145f7ec8487b8c5a165dfd0fd Mon Sep 17 00:00:00 2001 From: xX7 <5272979+xX7@users.noreply.github.com> Date: Tue, 5 Dec 2023 22:59:58 +0000 Subject: [PATCH] Removed old_internal and old_external temperatur check/set from calibration, resulting in more eager calibration adjustment also on hvac_mode change --- .../better_thermostat/calibration.py | 18 +----------------- custom_components/better_thermostat/climate.py | 2 -- .../better_thermostat/events/trv.py | 2 -- .../better_thermostat/utils/controlling.py | 2 +- 4 files changed, 2 insertions(+), 22 deletions(-) diff --git a/custom_components/better_thermostat/calibration.py b/custom_components/better_thermostat/calibration.py index 5cb232a0..0f75b20c 100644 --- a/custom_components/better_thermostat/calibration.py +++ b/custom_components/better_thermostat/calibration.py @@ -42,34 +42,18 @@ def calculate_calibration_local(self, entity_id) -> Union[float, None]: """ _context = "_calculate_calibration_local()" - if None in (self.cur_temp, self.bt_target_temp, self.old_internal_temp): + if None in (self.cur_temp, self.bt_target_temp): return None - _old_trv_temp_s = self.old_internal_temp _cur_trv_temp_s = self.real_trvs[entity_id]["current_temperature"] - _calibration_steps = self.real_trvs[entity_id]["local_calibration_steps"] - - _old_external_temp = self.old_external_temp _cur_external_temp = self.cur_temp - _cur_target_temp = self.bt_target_temp _cur_trv_temp_f = convert_to_float( str(_cur_trv_temp_s), self.name, _context ) - # check if we need to calculate - if ( - _cur_trv_temp_s == _old_trv_temp_s - and _cur_external_temp == _old_external_temp - ): - return None - - # Setting old variables - self.old_internal_temp = _cur_trv_temp_s - self.old_external_temp = _cur_external_temp - _current_trv_calibration = convert_to_float( str(self.real_trvs[entity_id]["last_calibration"]), self.name, _context ) diff --git a/custom_components/better_thermostat/climate.py b/custom_components/better_thermostat/climate.py index 4e5c4018..8dea6079 100644 --- a/custom_components/better_thermostat/climate.py +++ b/custom_components/better_thermostat/climate.py @@ -284,8 +284,6 @@ def __init__( self.heating_end_temp = None self.heating_end_timestamp = None self._async_unsub_state_changed = None - self.old_external_temp = 0 - self.old_internal_temp = 0 self.all_entities = [] self.devices_states = {} self.devices_errors = [] diff --git a/custom_components/better_thermostat/events/trv.py b/custom_components/better_thermostat/events/trv.py index c6f0bbc5..e2779033 100644 --- a/custom_components/better_thermostat/events/trv.py +++ b/custom_components/better_thermostat/events/trv.py @@ -102,8 +102,6 @@ async def trigger_trv_change(self, event): f"better_thermostat {self.name}: calibration accepted by TRV {entity_id}" ) _main_change = False - self.old_internal_temp = self.real_trvs[entity_id]["current_temperature"] - self.old_external_temp = self.cur_temp if self.real_trvs[entity_id]["calibration"] == 0: self.real_trvs[entity_id][ "last_calibration" diff --git a/custom_components/better_thermostat/utils/controlling.py b/custom_components/better_thermostat/utils/controlling.py index a95100c3..e3092147 100644 --- a/custom_components/better_thermostat/utils/controlling.py +++ b/custom_components/better_thermostat/utils/controlling.py @@ -113,7 +113,7 @@ async def control_trv(self, heater_entity_id=None): _temperature = _remapped_states.get("temperature", None) _calibration = _remapped_states.get("local_temperature_calibration", None) _calibration_mode = self.real_trvs[heater_entity_id]["advanced"].get( - "calibration_mode", CalibrationMode.DEFAULT + "calibration_mode", CalibrationMode.DEFAULT ) _new_hvac_mode = handle_window_open(self, _remapped_states)