Skip to content

Commit 0bd5cfd

Browse files
committed
Integrate set_temp_offset() in set_number_setpoint()
1 parent f6ad431 commit 0bd5cfd

File tree

1 file changed

+23
-14
lines changed

1 file changed

+23
-14
lines changed

plugwise/smile.py

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,17 @@ async def set_gateway_mode(self, mode: str) -> None:
182182

183183
await self._request(uri, method="put", data=data)
184184

185-
async def set_number_setpoint(self, key: str, temperature: float) -> None:
185+
async def set_number_setpoint(
186+
self,
187+
key: str,
188+
temperature: float,
189+
dev_id: str | None = None,
190+
) -> None:
186191
"""Set the max. Boiler or DHW setpoint on the Central Heating boiler."""
192+
if dev_id is not None:
193+
await set_temperature_offset(dev_id, temperature)
194+
return
195+
187196
temp = str(temperature)
188197
thermostat_id: str | None = None
189198
locator = f'appliance[@id="{self._heater_id}"]/actuator_functionalities/thermostat_functionality'
@@ -199,6 +208,19 @@ async def set_number_setpoint(self, key: str, temperature: float) -> None:
199208
data = f"<thermostat_functionality><setpoint>{temp}</setpoint></thermostat_functionality>"
200209
await self._request(uri, method="put", data=data)
201210

211+
async def set_temperature_offset(self, dev_id: str, offset: float) -> None:
212+
"""Set the Temperature offset for thermostats that support this feature."""
213+
if dev_id not in self.therms_with_offset_func:
214+
raise PlugwiseError(
215+
"Plugwise: this device does not have temperature-offset capability."
216+
)
217+
218+
value = str(offset)
219+
uri = f"{APPLIANCES};id={dev_id}/offset;type=temperature_offset"
220+
data = f"<offset_functionality><offset>{value}</offset></offset_functionality>"
221+
222+
await self._request(uri, method="put", data=data)
223+
202224
async def set_preset(self, loc_id: str, preset: str) -> None:
203225
"""Set the given Preset on the relevant Thermostat - from LOCATIONS."""
204226
if (presets := self._presets(loc_id)) is None:
@@ -410,16 +432,3 @@ async def set_temperature(self, loc_id: str, items: dict[str, float]) -> None:
410432
)
411433

412434
await self._request(uri, method="put", data=data)
413-
414-
async def set_temperature_offset(self, dev_id: str, offset: float) -> None:
415-
"""Set the Temperature offset for thermostats that support this feature."""
416-
if dev_id not in self.therms_with_offset_func:
417-
raise PlugwiseError(
418-
"Plugwise: this device does not have temperature-offset capability."
419-
)
420-
421-
value = str(offset)
422-
uri = f"{APPLIANCES};id={dev_id}/offset;type=temperature_offset"
423-
data = f"<offset_functionality><offset>{value}</offset></offset_functionality>"
424-
425-
await self._request(uri, method="put", data=data)

0 commit comments

Comments
 (0)