Skip to content

Commit 9f00ddc

Browse files
authored
Merge pull request #554 from plugwise/set_number_state
Combine set_temperature_offset() with set_number()
2 parents f6ad431 + 0d2f7b6 commit 9f00ddc

File tree

7 files changed

+42
-30
lines changed

7 files changed

+42
-30
lines changed

.github/workflows/verify.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ jobs:
102102
if: failure()
103103
run: |
104104
. venv/bin/activate
105-
ruff --fix plugwise/*py tests/*py
105+
ruff check --fix plugwise/*py tests/*py
106106
git config --global user.name 'autoruff'
107107
git config --global user.email '[email protected]'
108108
git remote set-url origin https://x-access-token:${{ secrets.PAT_CT }}@github.com/$GITHUB_REPOSITORY

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## Ongoing
44

5+
- Combine set_temperature_offset() with set_number()
56
- Fix typo in manual_fixtures.py script
67

78
## v0.37.3

plugwise/__init__.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -323,13 +323,14 @@ async def set_temperature(self, loc_id: str, items: dict[str, float]) -> None:
323323
"""Set the given Temperature on the relevant Thermostat."""
324324
await self._smile_api.set_temperature(loc_id, items)
325325

326-
async def set_number_setpoint(self, key: str, _: str, temperature: float) -> None:
326+
async def set_number(
327+
self,
328+
key: str,
329+
temperature: float,
330+
dev_id: str | None = None,
331+
) -> None:
327332
"""Set the max. Boiler or DHW setpoint on the Central Heating boiler."""
328-
await self._smile_api.set_number_setpoint(key, temperature)
329-
330-
async def set_temperature_offset(self, _: str, dev_id: str, offset: float) -> None:
331-
"""Set the Temperature offset for thermostats that support this feature."""
332-
await self._smile_api.set_temperature_offset(dev_id, offset)
333+
await self._smile_api.set_number(key, temperature, dev_id)
333334

334335
async def set_switch_state(
335336
self, appl_id: str, members: list[str] | None, model: str, state: str

plugwise/legacy/smile.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,12 @@ async def set_dhw_mode(self, mode: str) -> None:
154154
async def set_gateway_mode(self, mode: str) -> None:
155155
"""Set-function placeholder for legacy devices."""
156156

157-
async def set_number_setpoint(self, key: str, temperature: float) -> None:
157+
async def set_number(
158+
self,
159+
key: str,
160+
temperature: float,
161+
dev_id: str | None,
162+
) -> None:
158163
"""Set-function placeholder for legacy devices."""
159164

160165
async def set_preset(self, _: str, preset: str) -> None:
@@ -268,6 +273,3 @@ async def set_temperature(self, _: str, items: dict[str, float]) -> None:
268273
)
269274

270275
await self._request(uri, method="put", data=data)
271-
272-
async def set_temperature_offset(self, dev_id: str, offset: float) -> None:
273-
"""Set-function placeholder for legacy devices."""

plugwise/smile.py

Lines changed: 24 additions & 15 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:
186-
"""Set the max. Boiler or DHW setpoint on the Central Heating boiler."""
185+
async def set_number(
186+
self,
187+
key: str,
188+
temperature: float,
189+
dev_id: str | None,
190+
) -> None:
191+
"""Set the maximum boiler- or DHW-setpoint on the Central Heating boiler or the temperature-offset on a Thermostat."""
192+
if dev_id is not None:
193+
await self.set_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_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)

scripts/tests_and_coverage.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ fi
3636
if [ -z "${GITHUB_ACTIONS}" ] || [ "$1" == "linting" ] ; then
3737
# Black first to ensure nothings roughing up ruff
3838
echo "... ruff-ing ..."
39-
ruff plugwise/ tests/
39+
ruff check plugwise/ tests/
4040

4141
echo "... pylint-ing ..."
4242
pylint plugwise/ tests/

tests/test_init.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -873,11 +873,10 @@ async def tinker_regulation_mode(smile):
873873
async def tinker_max_boiler_temp(smile):
874874
"""Change max boiler temp setpoint to test functionality."""
875875
new_temp = 60.0
876-
dev_id = None
877876
_LOGGER.info("- Adjusting temperature to %s", new_temp)
878877
for test in ["maximum_boiler_temperature", "bogus_temperature"]:
879878
try:
880-
await smile.set_number_setpoint(test, dev_id, new_temp)
879+
await smile.set_number(test, new_temp)
881880
_LOGGER.info(" + tinker_max_boiler_temp worked as intended")
882881
except pw_exceptions.PlugwiseError:
883882
_LOGGER.info(" + tinker_max_boiler_temp failed as intended")
@@ -888,7 +887,7 @@ async def tinker_temp_offset(smile, dev_id):
888887
new_offset = 1.0
889888
_LOGGER.info("- Adjusting temperature offset to %s", new_offset)
890889
try:
891-
await smile.set_temperature_offset("dummy", dev_id, new_offset)
890+
await smile.set_number("dummy", new_offset, dev_id=dev_id)
892891
_LOGGER.info(" + tinker_temp_offset worked as intended")
893892
return True
894893
except pw_exceptions.PlugwiseError:

0 commit comments

Comments
 (0)