Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ jobs:
if: failure()
run: |
. venv/bin/activate
ruff --fix plugwise/*py tests/*py
ruff check --fix plugwise/*py tests/*py
git config --global user.name 'autoruff'
git config --global user.email 'plugwise@users.noreply.github.com'
git remote set-url origin https://x-access-token:${{ secrets.PAT_CT }}@github.com/$GITHUB_REPOSITORY
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Ongoing

- Combine set_temperature_offset() with set_number()
- Fix typo in manual_fixtures.py script

## v0.37.3
Expand Down
13 changes: 7 additions & 6 deletions plugwise/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,13 +323,14 @@ async def set_temperature(self, loc_id: str, items: dict[str, float]) -> None:
"""Set the given Temperature on the relevant Thermostat."""
await self._smile_api.set_temperature(loc_id, items)

async def set_number_setpoint(self, key: str, _: str, temperature: float) -> None:
async def set_number(
self,
key: str,
temperature: float,
dev_id: str | None = None,
) -> None:
"""Set the max. Boiler or DHW setpoint on the Central Heating boiler."""
await self._smile_api.set_number_setpoint(key, temperature)

async def set_temperature_offset(self, _: str, dev_id: str, offset: float) -> None:
"""Set the Temperature offset for thermostats that support this feature."""
await self._smile_api.set_temperature_offset(dev_id, offset)
await self._smile_api.set_number(key, temperature, dev_id)

async def set_switch_state(
self, appl_id: str, members: list[str] | None, model: str, state: str
Expand Down
10 changes: 6 additions & 4 deletions plugwise/legacy/smile.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,12 @@ async def set_dhw_mode(self, mode: str) -> None:
async def set_gateway_mode(self, mode: str) -> None:
"""Set-function placeholder for legacy devices."""

async def set_number_setpoint(self, key: str, temperature: float) -> None:
async def set_number(
self,
key: str,
temperature: float,
dev_id: str | None,
) -> None:
"""Set-function placeholder for legacy devices."""

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

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

async def set_temperature_offset(self, dev_id: str, offset: float) -> None:
"""Set-function placeholder for legacy devices."""
39 changes: 24 additions & 15 deletions plugwise/smile.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,17 @@ async def set_gateway_mode(self, mode: str) -> None:

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

async def set_number_setpoint(self, key: str, temperature: float) -> None:
"""Set the max. Boiler or DHW setpoint on the Central Heating boiler."""
async def set_number(
self,
key: str,
temperature: float,
dev_id: str | None,
) -> None:
"""Set the maximum boiler- or DHW-setpoint on the Central Heating boiler or the temperature-offset on a Thermostat."""
if dev_id is not None:
await self.set_offset(dev_id, temperature)
return

temp = str(temperature)
thermostat_id: str | None = None
locator = f'appliance[@id="{self._heater_id}"]/actuator_functionalities/thermostat_functionality'
Expand All @@ -199,6 +208,19 @@ async def set_number_setpoint(self, key: str, temperature: float) -> None:
data = f"<thermostat_functionality><setpoint>{temp}</setpoint></thermostat_functionality>"
await self._request(uri, method="put", data=data)

async def set_offset(self, dev_id: str, offset: float) -> None:
"""Set the Temperature offset for thermostats that support this feature."""
if dev_id not in self.therms_with_offset_func:
raise PlugwiseError(
"Plugwise: this device does not have temperature-offset capability."
)

value = str(offset)
uri = f"{APPLIANCES};id={dev_id}/offset;type=temperature_offset"
data = f"<offset_functionality><offset>{value}</offset></offset_functionality>"

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

async def set_preset(self, loc_id: str, preset: str) -> None:
"""Set the given Preset on the relevant Thermostat - from LOCATIONS."""
if (presets := self._presets(loc_id)) is None:
Expand Down Expand Up @@ -410,16 +432,3 @@ async def set_temperature(self, loc_id: str, items: dict[str, float]) -> None:
)

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

async def set_temperature_offset(self, dev_id: str, offset: float) -> None:
"""Set the Temperature offset for thermostats that support this feature."""
if dev_id not in self.therms_with_offset_func:
raise PlugwiseError(
"Plugwise: this device does not have temperature-offset capability."
)

value = str(offset)
uri = f"{APPLIANCES};id={dev_id}/offset;type=temperature_offset"
data = f"<offset_functionality><offset>{value}</offset></offset_functionality>"

await self._request(uri, method="put", data=data)
2 changes: 1 addition & 1 deletion scripts/tests_and_coverage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ fi
if [ -z "${GITHUB_ACTIONS}" ] || [ "$1" == "linting" ] ; then
# Black first to ensure nothings roughing up ruff
echo "... ruff-ing ..."
ruff plugwise/ tests/
ruff check plugwise/ tests/

echo "... pylint-ing ..."
pylint plugwise/ tests/
Expand Down
5 changes: 2 additions & 3 deletions tests/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -873,11 +873,10 @@ async def tinker_regulation_mode(smile):
async def tinker_max_boiler_temp(smile):
"""Change max boiler temp setpoint to test functionality."""
new_temp = 60.0
dev_id = None
_LOGGER.info("- Adjusting temperature to %s", new_temp)
for test in ["maximum_boiler_temperature", "bogus_temperature"]:
try:
await smile.set_number_setpoint(test, dev_id, new_temp)
await smile.set_number(test, new_temp)
_LOGGER.info(" + tinker_max_boiler_temp worked as intended")
except pw_exceptions.PlugwiseError:
_LOGGER.info(" + tinker_max_boiler_temp failed as intended")
Expand All @@ -888,7 +887,7 @@ async def tinker_temp_offset(smile, dev_id):
new_offset = 1.0
_LOGGER.info("- Adjusting temperature offset to %s", new_offset)
try:
await smile.set_temperature_offset("dummy", dev_id, new_offset)
await smile.set_number("dummy", new_offset, dev_id=dev_id)
_LOGGER.info(" + tinker_temp_offset worked as intended")
return True
except pw_exceptions.PlugwiseError:
Expand Down