Skip to content

Commit 04f2491

Browse files
authored
Merge pull request #905 from plugwise/mypy-fix-2
Add v1.14.2 changes to main branch
2 parents f0a667a + 1e4aed1 commit 04f2491

5 files changed

Lines changed: 22 additions & 17 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44

55
- Change representation of no-thermostat-schedule-defined to a single `off` option via PR [#899](https://github.com/plugwise/python-plugwise/pull/899)
66

7+
## v1.14.2
8+
9+
- Implement common typing in functions that are interacting.
10+
711
## v1.14.1
812

913
- Improve manual fixtures script, reorder set_schedule_state() arguments for better compatibility with set_dhw_mode(), via PR[#897](https://github.com/plugwise/python-plugwise/pull/897)

plugwise/__init__.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ async def set_select(
358358
key: str,
359359
loc_id: str,
360360
option: str,
361-
state: str | None = None,
361+
state: int | str | None = None,
362362
) -> None:
363363
"""Set the selected option for the applicable Select."""
364364
try:
@@ -372,7 +372,7 @@ async def set_schedule_state(
372372
self,
373373
loc_id: str,
374374
name: str | None = None,
375-
state: str | None = None,
375+
state: int | str | None = None,
376376
) -> None:
377377
"""Activate/deactivate the Schedule, with the given name, on the relevant Thermostat."""
378378
try:
@@ -462,19 +462,15 @@ async def set_regulation_mode(self, mode: str) -> None:
462462
) from exc # pragma no cover
463463

464464
async def set_dhw_mode(
465-
self,
466-
key: str,
467-
location: str,
468-
mode: str,
469-
length: int,
465+
self, key: str, location: str, mode: str, length: int | str | None = None
470466
) -> None:
471467
"""Set the domestic hot water heating regulation mode."""
472468
try: # pragma no cover
473469
await self._smile_api.set_dhw_mode(
474470
key,
475471
location,
476472
mode,
477-
length,
473+
length=length,
478474
) # pragma: no cover
479475
except ConnectionFailedError as exc: # pragma no cover
480476
raise ConnectionFailedError(

plugwise/legacy/smile.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ async def set_dhw_mode(
136136
key: str,
137137
location: str,
138138
mode: str,
139-
length: int,
139+
length: int | str | None,
140140
) -> None:
141141
"""Set-function placeholder for legacy devices."""
142142

@@ -178,7 +178,7 @@ async def set_select(
178178
_: str,
179179
loc_id: str,
180180
option: str,
181-
state: str | None = None,
181+
state: int | str | None = None,
182182
) -> None:
183183
"""Set the thermostat schedule option."""
184184
# schedule name corresponds to select option
@@ -188,7 +188,7 @@ async def set_schedule_state(
188188
self,
189189
_: str,
190190
name: str | None = None,
191-
state: str | None = None,
191+
state: int | str | None = None,
192192
) -> None:
193193
"""Activate/deactivate the Schedule.
194194

plugwise/smile.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ async def set_select(
236236
key: str,
237237
appl_or_loc_id: str,
238238
option: str,
239-
state: str | None = None,
239+
state: int | str | None = None,
240240
) -> None:
241241
"""Set a dhw/gateway/regulation mode or the thermostat schedule option."""
242242
match key:
@@ -257,16 +257,21 @@ async def set_select(
257257
await self.set_zone_profile(appl_or_loc_id, option)
258258

259259
async def set_dhw_mode(
260-
self, key: str, appl_id: str, mode: str, length: int
260+
self, key: str, appl_id: str, mode: str, length: int | str | None = None
261261
) -> None:
262262
"""Set the domestic hot water mode.
263263
264264
Two options are known:
265265
- 2 modes, comfort and off, representing the dhw comfort mode on and off switch states,
266266
- and the 5 modes available on the Loria.
267267
"""
268-
if self._dhw_allowed_modes and mode not in self._dhw_allowed_modes:
269-
raise PlugwiseError("Plugwise: invalid dhw mode.")
268+
if (
269+
self._dhw_allowed_modes
270+
and mode not in self._dhw_allowed_modes
271+
or length is None
272+
or not isinstance(length, int)
273+
):
274+
raise PlugwiseError("Plugwise: invalid dhw mode or invalid dhw modes list.")
270275

271276
match length:
272277
case 2:
@@ -346,7 +351,7 @@ async def set_zone_profile(self, loc_id: str, profile: str) -> None:
346351
await self.call_request(uri, method="post", data=data)
347352

348353
async def set_schedule_state(
349-
self, loc_id: str, name: str | None = None, state: str | None = None
354+
self, loc_id: str, name: str | None = None, state: int | str | None = None
350355
) -> None:
351356
"""Activate/deactivate the Schedule, with the given name, on the relevant Thermostat.
352357

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "plugwise"
7-
version = "1.14.1"
7+
version = "1.14.2"
88
license = "MIT"
99
description = "Plugwise Smile (Adam/Anna/P1) and Stretch module for Python 3."
1010
readme = "README.md"

0 commit comments

Comments
 (0)