diff --git a/CHANGELOG.md b/CHANGELOG.md index df83c6e16..5e7f78b49 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ - Change representation of no-thermostat-schedule-defined to a single `off` option via PR [#899](https://github.com/plugwise/python-plugwise/pull/899) +## v1.14.2 + +- Implement common typing in functions that are interacting. + ## v1.14.1 - 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) diff --git a/plugwise/__init__.py b/plugwise/__init__.py index 3fff9be68..f91308726 100644 --- a/plugwise/__init__.py +++ b/plugwise/__init__.py @@ -358,7 +358,7 @@ async def set_select( key: str, loc_id: str, option: str, - state: str | None = None, + state: int | str | None = None, ) -> None: """Set the selected option for the applicable Select.""" try: @@ -372,7 +372,7 @@ async def set_schedule_state( self, loc_id: str, name: str | None = None, - state: str | None = None, + state: int | str | None = None, ) -> None: """Activate/deactivate the Schedule, with the given name, on the relevant Thermostat.""" try: @@ -462,11 +462,7 @@ async def set_regulation_mode(self, mode: str) -> None: ) from exc # pragma no cover async def set_dhw_mode( - self, - key: str, - location: str, - mode: str, - length: int, + self, key: str, location: str, mode: str, length: int | str | None = None ) -> None: """Set the domestic hot water heating regulation mode.""" try: # pragma no cover @@ -474,7 +470,7 @@ async def set_dhw_mode( key, location, mode, - length, + length=length, ) # pragma: no cover except ConnectionFailedError as exc: # pragma no cover raise ConnectionFailedError( diff --git a/plugwise/legacy/smile.py b/plugwise/legacy/smile.py index 6b4399b54..4c5fbf7b7 100644 --- a/plugwise/legacy/smile.py +++ b/plugwise/legacy/smile.py @@ -136,7 +136,7 @@ async def set_dhw_mode( key: str, location: str, mode: str, - length: int, + length: int | str | None, ) -> None: """Set-function placeholder for legacy devices.""" @@ -178,7 +178,7 @@ async def set_select( _: str, loc_id: str, option: str, - state: str | None = None, + state: int | str | None = None, ) -> None: """Set the thermostat schedule option.""" # schedule name corresponds to select option @@ -188,7 +188,7 @@ async def set_schedule_state( self, _: str, name: str | None = None, - state: str | None = None, + state: int | str | None = None, ) -> None: """Activate/deactivate the Schedule. diff --git a/plugwise/smile.py b/plugwise/smile.py index 02508701a..e7a13aca7 100644 --- a/plugwise/smile.py +++ b/plugwise/smile.py @@ -236,7 +236,7 @@ async def set_select( key: str, appl_or_loc_id: str, option: str, - state: str | None = None, + state: int | str | None = None, ) -> None: """Set a dhw/gateway/regulation mode or the thermostat schedule option.""" match key: @@ -257,7 +257,7 @@ async def set_select( await self.set_zone_profile(appl_or_loc_id, option) async def set_dhw_mode( - self, key: str, appl_id: str, mode: str, length: int + self, key: str, appl_id: str, mode: str, length: int | str | None = None ) -> None: """Set the domestic hot water mode. @@ -265,8 +265,13 @@ async def set_dhw_mode( - 2 modes, comfort and off, representing the dhw comfort mode on and off switch states, - and the 5 modes available on the Loria. """ - if self._dhw_allowed_modes and mode not in self._dhw_allowed_modes: - raise PlugwiseError("Plugwise: invalid dhw mode.") + if ( + self._dhw_allowed_modes + and mode not in self._dhw_allowed_modes + or length is None + or not isinstance(length, int) + ): + raise PlugwiseError("Plugwise: invalid dhw mode or invalid dhw modes list.") match length: case 2: @@ -346,7 +351,7 @@ async def set_zone_profile(self, loc_id: str, profile: str) -> None: await self.call_request(uri, method="post", data=data) async def set_schedule_state( - self, loc_id: str, name: str | None = None, state: str | None = None + self, loc_id: str, name: str | None = None, state: int | str | None = None ) -> None: """Activate/deactivate the Schedule, with the given name, on the relevant Thermostat. diff --git a/pyproject.toml b/pyproject.toml index a1092e395..722cab0ab 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "plugwise" -version = "1.14.1" +version = "1.14.2" license = "MIT" description = "Plugwise Smile (Adam/Anna/P1) and Stretch module for Python 3." readme = "README.md"