diff --git a/CHANGELOG.md b/CHANGELOG.md index 81f77b84d..f62626b08 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 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) + ## v1.14.0 - Include both old and new entities for a step-wise introduction of water_heaters in HA via PR [#895](https://github.com/plugwise/python-plugwise/pull/895): diff --git a/fixtures/m_adam_cooling/data.json b/fixtures/m_adam_cooling/data.json index da02a5282..508fbbb54 100644 --- a/fixtures/m_adam_cooling/data.json +++ b/fixtures/m_adam_cooling/data.json @@ -25,7 +25,7 @@ "select_dhw_mode": "eco", "sensors": { "intended_boiler_temperature": 17.5, - "water_temperature": 43.0 + "water_temperature": 19.0 }, "switches": { "dhw_cm_switch": false diff --git a/fixtures/m_anna_heatpump_cooling/data.json b/fixtures/m_anna_heatpump_cooling/data.json index 2caf94cca..5a902c45d 100644 --- a/fixtures/m_anna_heatpump_cooling/data.json +++ b/fixtures/m_anna_heatpump_cooling/data.json @@ -52,13 +52,13 @@ "model": "Generic heater/cooler", "name": "OpenTherm", "sensors": { - "dhw_temperature": 46.3, + "dhw_temperature": 41.5, "intended_boiler_temperature": 0.0, "modulation_level": 40, "outdoor_air_temperature": 28.0, "return_temperature": 23.8, "water_pressure": 1.57, - "water_temperature": 29.1 + "water_temperature": 22.7 }, "switches": { "dhw_cm_switch": false diff --git a/fixtures/m_anna_heatpump_idle/data.json b/fixtures/m_anna_heatpump_idle/data.json index c41b5b7d7..652d1591f 100644 --- a/fixtures/m_anna_heatpump_idle/data.json +++ b/fixtures/m_anna_heatpump_idle/data.json @@ -52,13 +52,13 @@ "model": "Generic heater/cooler", "name": "OpenTherm", "sensors": { - "dhw_temperature": 46.3, + "dhw_temperature": 41.5, "intended_boiler_temperature": 18.0, "modulation_level": 0, "outdoor_air_temperature": 28.2, "return_temperature": 22.0, "water_pressure": 1.57, - "water_temperature": 29.1 + "water_temperature": 22.7 }, "switches": { "dhw_cm_switch": false diff --git a/plugwise/__init__.py b/plugwise/__init__.py index fe8a9470e..3fff9be68 100644 --- a/plugwise/__init__.py +++ b/plugwise/__init__.py @@ -362,7 +362,7 @@ async def set_select( ) -> None: """Set the selected option for the applicable Select.""" try: - await self._smile_api.set_select(key, loc_id, option, state) + await self._smile_api.set_select(key, loc_id, option, state=state) except ConnectionFailedError as exc: raise ConnectionFailedError( f"Failed to set select option '{option}': {str(exc)}" @@ -371,12 +371,12 @@ async def set_select( async def set_schedule_state( self, loc_id: str, - state: str | None, name: str | None = None, + state: str | None = None, ) -> None: """Activate/deactivate the Schedule, with the given name, on the relevant Thermostat.""" try: - await self._smile_api.set_schedule_state(loc_id, state, name) + await self._smile_api.set_schedule_state(loc_id, name=name, state=state) except ConnectionFailedError as exc: # pragma no cover raise ConnectionFailedError( f"Failed to set schedule state: {str(exc)}" @@ -462,12 +462,19 @@ async def set_regulation_mode(self, mode: str) -> None: ) from exc # pragma no cover async def set_dhw_mode( - self, key: str, location: str, length: int, mode: str + self, + key: str, + location: str, + mode: str, + length: int, ) -> None: """Set the domestic hot water heating regulation mode.""" try: # pragma no cover await self._smile_api.set_dhw_mode( - key, location, length, mode + key, + location, + mode, + 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 419f2fde9..6b4399b54 100644 --- a/plugwise/legacy/smile.py +++ b/plugwise/legacy/smile.py @@ -132,7 +132,11 @@ async def reboot_gateway(self) -> None: """Set-function placeholder for legacy devices.""" async def set_dhw_mode( - self, key: str, location: str, length: int, mode: str + self, + key: str, + location: str, + mode: str, + length: int, ) -> None: """Set-function placeholder for legacy devices.""" @@ -170,14 +174,21 @@ async def set_regulation_mode(self, mode: str) -> None: """Set-function placeholder for legacy devices.""" async def set_select( - self, key: str, loc_id: str, option: str, state: str | None + self, + _: str, + loc_id: str, + option: str, + state: str | None = None, ) -> None: """Set the thermostat schedule option.""" # schedule name corresponds to select option - await self.set_schedule_state("dummy", state, option) + await self.set_schedule_state("loc_id", option, state=state) async def set_schedule_state( - self, _: str, state: str | None, name: str | None + self, + _: str, + name: str | None = None, + state: str | None = None, ) -> None: """Activate/deactivate the Schedule. diff --git a/plugwise/smile.py b/plugwise/smile.py index 39deea4ce..02508701a 100644 --- a/plugwise/smile.py +++ b/plugwise/smile.py @@ -232,7 +232,11 @@ async def set_preset(self, loc_id: str, preset: str) -> None: await self.call_request(uri, method="put", data=data) async def set_select( - self, key: str, appl_or_loc_id: str, option: str, state: str | None + self, + key: str, + appl_or_loc_id: str, + option: str, + state: str | None = None, ) -> None: """Set a dhw/gateway/regulation mode or the thermostat schedule option.""" match key: @@ -247,13 +251,13 @@ async def set_select( case "select_schedule": # The schedule name corresponds to the select option # Location id is passed - await self.set_schedule_state(appl_or_loc_id, state, option) + await self.set_schedule_state(appl_or_loc_id, option, state=state) case "select_zone_profile": # Location id is passed await self.set_zone_profile(appl_or_loc_id, option) async def set_dhw_mode( - self, key: str, appl_id: str, length: int, mode: str + self, key: str, appl_id: str, mode: str, length: int ) -> None: """Set the domestic hot water mode. @@ -266,7 +270,7 @@ async def set_dhw_mode( match length: case 2: - await self.set_select(key, appl_id, mode, None) + await self.set_select(key, appl_id, mode) case _: data = ( "" @@ -342,10 +346,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, - new_state: str | None, - name: str | None, + self, loc_id: str, name: str | None = None, state: str | None = None ) -> None: """Activate/deactivate the Schedule, with the given name, on the relevant Thermostat. @@ -353,17 +354,19 @@ async def set_schedule_state( Used in HA Core to set the hvac_mode: in practice switch between schedule on - off. """ # Input checking - if new_state not in (STATE_OFF, STATE_ON): + if state is None: + state = STATE_ON + elif state not in (STATE_OFF, STATE_ON): raise PlugwiseError("Plugwise: invalid schedule state.") # Translate selection of Off-schedule-option to disabling the active schedule if name == OFF: - new_state = STATE_OFF + state = STATE_OFF # Handle no schedule-name / schedule-off requested: find the active schedule if name is None or name == OFF: _, name = self._schedules(loc_id) - if name == OFF: # no active schedule found, nothing to do + if name in (NONE, OFF): # no active schedule found, nothing to do return schedule_rule = self._rule_ids_by_name(name, loc_id) @@ -372,7 +375,7 @@ async def set_schedule_state( raise PlugwiseError("Plugwise: no schedule with this name available.") # If no state change is requested, do nothing - if new_state == self._schedule_old_states[loc_id][name]: + if state == self._schedule_old_states[loc_id][name]: return schedule_rule_id: str = next(iter(schedule_rule)) @@ -384,7 +387,7 @@ async def set_schedule_state( template_id = self._domain_objects.find(locator).get("id") template = f'