Skip to content

Commit

Permalink
Removed old_internal and old_external temperatur
Browse files Browse the repository at this point in the history
check/set from calibration, resulting in more eager
calibration adjustment also on hvac_mode change
  • Loading branch information
xX7 committed Dec 5, 2023
1 parent 8892924 commit 5675cf7
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 22 deletions.
18 changes: 1 addition & 17 deletions custom_components/better_thermostat/calibration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down
2 changes: 0 additions & 2 deletions custom_components/better_thermostat/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down
2 changes: 0 additions & 2 deletions custom_components/better_thermostat/events/trv.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion custom_components/better_thermostat/utils/controlling.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 5675cf7

Please sign in to comment.