Skip to content

Commit

Permalink
Move the weight to the requested_setpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexwijn committed Jan 21, 2025
1 parent 7b396da commit 824038e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
6 changes: 3 additions & 3 deletions custom_components/sat/area.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def update(self, current_outside_temperature: float) -> None:
if area.target_temperature is None:
continue

area.heating_curve.update(area.target_temperature * area.weight, current_outside_temperature)
area.heating_curve.update(area.target_temperature, current_outside_temperature)

class _PIDs:
def __init__(self, areas: list[Area]):
Expand All @@ -148,12 +148,12 @@ def __init__(self, areas: list[Area]):
def update(self, boiler_temperature: float) -> None:
for area in self.areas:
if area.error is not None:
area.pid.update(area.error * area.weight, area.heating_curve.value, boiler_temperature)
area.pid.update(area.error, area.heating_curve.value, boiler_temperature)

def update_reset(self) -> None:
for area in self.areas:
if area.error is not None:
area.pid.update_reset(area.error * area.weight, area.heating_curve.value)
area.pid.update_reset(area.error, area.heating_curve.value)

def reset(self) -> None:
"""Reset PID controllers for all areas."""
Expand Down
6 changes: 4 additions & 2 deletions custom_components/sat/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -507,16 +507,18 @@ def requested_setpoint(self) -> float:
The setpoint is determined primarily by the global heating curve and PID output.
If the system is in 'comfort mode' and a focus area is defined with higher priority (based on its error),
the setpoint will be overridden by the focus area's heating curve and PID output.
the setpoint will be overridden by the focus area's heating curve and PID output multiplied by its weight.
The setpoint is always constrained to be above the minimum allowable setpoint.
"""
# Default to global heating curve and PID output
weight = 1.0
pid_output = self.pid.output
heating_curve = self.heating_curve.value

# Override with focus area values in comfort mode
if self._heating_mode == HEATING_MODE_COMFORT and self.areas.focus is not None and self.areas.focus.error > self.error:
weight = self.areas.focus.weight
pid_output = self.areas.focus.pid.output
heating_curve = self.areas.focus.heating_curve.value

Expand All @@ -525,7 +527,7 @@ def requested_setpoint(self) -> float:
return MINIMUM_SETPOINT

# Calculate and constrain the setpoint to be no less than the minimum allowed value
return round(max(heating_curve + pid_output, MINIMUM_SETPOINT), 1)
return round(max((heating_curve + pid_output) * weight, MINIMUM_SETPOINT), 1)

@property
def valves_open(self) -> bool:
Expand Down

0 comments on commit 824038e

Please sign in to comment.