Skip to content

Commit

Permalink
setpoint calibration - round by step instead of fixed value (#1475)
Browse files Browse the repository at this point in the history
  • Loading branch information
folfy committed Dec 20, 2024
1 parent 663a509 commit 7ff45b1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions custom_components/better_thermostat/calibration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"]
Expand Down
2 changes: 1 addition & 1 deletion custom_components/better_thermostat/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 7ff45b1

Please sign in to comment.