@@ -58,19 +58,13 @@ def update_for_cooling(self, device: DeviceData) -> DeviceData:
5858 if self ._cooling_present :
5959 thermostat = device ["thermostat" ]
6060 sensors = device ["sensors" ]
61- max_setpoint = MAX_SETPOINT
62- min_setpoint = MIN_SETPOINT
63- if device ["selected_schedule" ] != "None" :
64- max_setpoint = self ._sched_setpoints [1 ]
65- min_setpoint = self ._sched_setpoints [0 ]
66-
6761 temp_dict : ActuatorData = {
6862 "setpoint_low" : thermostat ["setpoint" ],
69- "setpoint_high" : max_setpoint ,
63+ "setpoint_high" : MAX_SETPOINT ,
7064 }
7165 if self ._cooling_enabled :
7266 temp_dict = {
73- "setpoint_low" : min_setpoint ,
67+ "setpoint_low" : MIN_SETPOINT ,
7468 "setpoint_high" : thermostat ["setpoint" ],
7569 }
7670 thermostat .pop ("setpoint" )
@@ -683,14 +677,26 @@ async def set_preset(self, loc_id: str, preset: str) -> None:
683677 async def set_temperature (self , loc_id : str , items : dict [str , float ]) -> None :
684678 """Set the given Temperature on the relevant Thermostat."""
685679 setpoint : float | None = None
680+
686681 if "setpoint" in items :
687682 setpoint = items ["setpoint" ]
683+
688684 if self ._cooling_present :
689- if "setpoint_low" in items :
690- setpoint = items ["setpoint_low" ]
691- if self ._cooling_active :
692- if "setpoint_high" in items :
693- setpoint = items ["setpoint_high" ]
685+ if "setpoint_high" in items :
686+ tmp_setpoint_high = items ["setpoint_high" ]
687+ tmp_setpoint_low = items ["setpoint_low" ]
688+ if self ._cooling_enabled : # in cooling mode
689+ setpoint = tmp_setpoint_high
690+ if tmp_setpoint_low != MIN_SETPOINT :
691+ raise PlugwiseError (
692+ "Plugwise: heating setpoint cannot be changed when in cooling mode!"
693+ )
694+ else : # in heating mode
695+ setpoint = tmp_setpoint_low
696+ if tmp_setpoint_high != MAX_SETPOINT :
697+ raise PlugwiseError (
698+ "Plugwise: cooling setpoint cannot be changed when in heating mode!"
699+ )
694700
695701 if setpoint is None :
696702 raise PlugwiseError (
0 commit comments