Skip to content

Commit ccd5387

Browse files
authored
Merge pull request #914 from plugwise/fix-178699
Fix Core Issue #178699
2 parents 607ac48 + 429ae0a commit ccd5387

5 files changed

Lines changed: 42 additions & 28 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## v1.14.6
4+
5+
- Bugfixes: fix domestic hot water comfort switching, dhw modes selection issues reported in Core issue [#178699](https://github.com/home-assistant/core/issues/178699) via PR [#914](https://github.com/plugwise/python-plugwise/pull/914)
6+
37
## v1.14.5
48

59
- Rename dict-keys: `max_dhw_temperature` to `dhw_temperature`, `maximum_boiler_temperature` to `boiler_temperature` via PR [#908](https://github.com/plugwise/python-plugwise/pull/908)

plugwise/helper.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -271,10 +271,12 @@ def _collect_dhw_modes(self, appliance: etree.Element) -> None:
271271
appliance, "domestic_hot_water_mode_control_functionality"
272272
)
273273
# Determine the dhw modes from the domestic_hot_water_comfort_mode toggle
274-
if not self._dhw_allowed_modes:
275-
self._get_toggle_state(
276-
appliance, "domestic_hot_water_comfort_mode", "dhw_cm_switch", {}
277-
)
274+
if self._dhw_allowed_modes:
275+
return
276+
277+
self._get_toggle_state(
278+
appliance, "domestic_hot_water_comfort_mode", "dhw_cm_switch", {}
279+
)
278280

279281
def _appl_gateway_info(self, appl: Munch, appliance: etree.Element) -> Munch:
280282
"""Helper-function for _appliance_info_finder()."""
@@ -508,7 +510,10 @@ def _get_toggle_state(
508510
if "switches" in data:
509511
data["switches"][name] = state.text == "on"
510512
self._count += 1
511-
if toggle == "domestic_hot_water_comfort_mode":
513+
if (
514+
not self._dhw_allowed_modes
515+
and toggle == "domestic_hot_water_comfort_mode"
516+
):
512517
self._dhw_allowed_modes = ["comfort", "eco"]
513518

514519
def _get_plugwise_notifications(self) -> None:

plugwise/legacy/smile.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -157,15 +157,15 @@ async def set_offset(self, dev_id: str, offset: float) -> None:
157157
async def set_preset(self, _: str, preset: str) -> None:
158158
"""Set the given Preset on the relevant Thermostat - from DOMAIN_OBJECTS."""
159159
if not (presets := self._presets()):
160-
raise PlugwiseError("Plugwise: no presets available.") # pragma: no cover
160+
raise PlugwiseError("Plugwise: no presets available") # pragma: no cover
161161
if preset not in list(presets):
162-
raise PlugwiseError("Plugwise: invalid preset.")
162+
raise PlugwiseError(f"Plugwise: invalid preset {preset}")
163163

164164
locator = f'rule/directives/when/then[@icon="{preset}"].../.../...'
165165
if (rule := self._domain_objects.find(locator)) is None:
166-
raise PlugwiseError("Plugwise: no preset rule found.") # pragma: no cover
166+
raise PlugwiseError("Plugwise: no preset rule found") # pragma: no cover
167167
if (rule_id := rule.get("id")) is None:
168-
raise PlugwiseError("Plugwise: no preset id found.") # pragma: no cover
168+
raise PlugwiseError("Plugwise: no preset id found") # pragma: no cover
169169

170170
data = f"<rules><rule id='{rule_id}'><active>true</active></rule></rules>"
171171
await self.call_request(RULES, method="put", data=data)
@@ -196,7 +196,7 @@ async def set_schedule_state(
196196
Used in HA Core to set the hvac_mode: in practice switch between schedule on - off.
197197
"""
198198
if state not in (STATE_OFF, STATE_ON):
199-
raise PlugwiseError("Plugwise: invalid schedule state.")
199+
raise PlugwiseError(f"Plugwise: invalid schedule state {state}")
200200

201201
# Handle no schedule-name / Off-schedule provided
202202
if name is None or name == OFF:
@@ -210,7 +210,7 @@ async def set_schedule_state(
210210

211211
if schedule_rule_id is None:
212212
raise PlugwiseError(
213-
"Plugwise: no schedule with this name available."
213+
f"Plugwise: no schedule with name {name} available"
214214
) # pragma: no cover
215215

216216
new_state = "false"

plugwise/smile.py

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def model_to_switch_items(model: str, state: str, switch: Munch) -> tuple[str, M
4343
Helper function for set_switch_state().
4444
"""
4545
match model:
46-
case "select_dhw_mode" | "dhw_mode":
46+
case "select_dhw_mode" | "dhw_mode" | "dhw_cm_switch":
4747
switch.device = switch.func_type = "toggle"
4848
switch.act_type = "domestic_hot_water_comfort_mode"
4949
case "cooling_ena_switch":
@@ -189,7 +189,7 @@ async def set_number(
189189
thermostat_id = th_func.get("id")
190190

191191
if thermostat_id is None:
192-
raise PlugwiseError(f"Plugwise: cannot change setpoint, {key} not found.")
192+
raise PlugwiseError(f"Plugwise: cannot change setpoint, {key} not found")
193193

194194
data = (
195195
"<thermostat_functionality>"
@@ -203,7 +203,7 @@ async def set_offset(self, dev_id: str, offset: float) -> None:
203203
"""Set the Temperature offset for thermostats that support this feature."""
204204
if dev_id not in self.therms_with_offset_func:
205205
raise PlugwiseError(
206-
"Plugwise: this device does not have temperature-offset capability."
206+
"Plugwise: this device does not have temperature-offset capability"
207207
)
208208

209209
value = str(offset)
@@ -214,9 +214,9 @@ async def set_offset(self, dev_id: str, offset: float) -> None:
214214
async def set_preset(self, loc_id: str, preset: str) -> None:
215215
"""Set the given Preset on the relevant Thermostat - from LOCATIONS."""
216216
if (presets := self._presets(loc_id)) is None:
217-
raise PlugwiseError("Plugwise: no presets available.") # pragma: no cover
217+
raise PlugwiseError("Plugwise: no presets available") # pragma: no cover
218218
if preset not in list(presets):
219-
raise PlugwiseError("Plugwise: invalid preset.")
219+
raise PlugwiseError(f"Plugwise: invalid preset {preset}")
220220

221221
current_location = self._domain_objects.find(f'location[@id="{loc_id}"]')
222222
location_name = current_location.find("name").text
@@ -268,12 +268,13 @@ async def set_dhw_mode(
268268
- and the 5 modes available on the Loria.
269269
"""
270270
if (
271-
self._dhw_allowed_modes
272-
and mode not in self._dhw_allowed_modes
271+
mode not in self.gw_entities.get(appl_id, {}).get("dhw_modes", [])
273272
or length is None
274273
or not isinstance(length, int)
275274
):
276-
raise PlugwiseError("Plugwise: invalid dhw mode or invalid dhw modes list.")
275+
raise PlugwiseError(
276+
f"Plugwise: invalid dhw mode {mode} or invalid length {length}"
277+
)
277278

278279
match length:
279280
case 2:
@@ -291,8 +292,10 @@ async def set_dhw_mode(
291292

292293
async def set_gateway_mode(self, mode: str) -> None:
293294
"""Set the gateway mode."""
294-
if mode not in self._gw_allowed_modes:
295-
raise PlugwiseError("Plugwise: invalid gateway mode.")
295+
if mode not in self.gw_entities.get(self.gateway_id, {}).get(
296+
"gateway_modes", []
297+
):
298+
raise PlugwiseError(f"Plugwise: invalid gateway mode {mode}")
296299

297300
end_time = "2037-04-21T08:00:53.000Z"
298301
valid = ""
@@ -323,8 +326,10 @@ async def set_gateway_mode(self, mode: str) -> None:
323326

324327
async def set_regulation_mode(self, mode: str) -> None:
325328
"""Set the heating regulation mode."""
326-
if mode not in self._reg_allowed_modes:
327-
raise PlugwiseError("Plugwise: invalid regulation mode.")
329+
if mode not in self.gw_entities.get(self.gateway_id, {}).get(
330+
"regulation_modes", []
331+
):
332+
raise PlugwiseError(f"Plugwise: invalid regulation mode {mode}")
328333

329334
duration = ""
330335
if "bleeding" in mode:
@@ -342,7 +347,7 @@ async def set_regulation_mode(self, mode: str) -> None:
342347
async def set_zone_profile(self, loc_id: str, profile: str) -> None:
343348
"""Set the Adam thermoszone heating profile."""
344349
if profile not in ALLOWED_ZONE_PROFILES:
345-
raise PlugwiseError("Plugwise: invalid zone profile.")
350+
raise PlugwiseError(f"Plugwise: invalid zone profile {profile}")
346351

347352
data = (
348353
"<thermostat_functionality>"
@@ -364,7 +369,7 @@ async def set_schedule_state(
364369
if state is None:
365370
state = STATE_ON
366371
elif state not in (STATE_OFF, STATE_ON):
367-
raise PlugwiseError("Plugwise: invalid schedule state.")
372+
raise PlugwiseError(f"Plugwise: invalid schedule state {state}")
368373

369374
# Translate selection of Off-schedule-option to disabling the active schedule
370375
if name == OFF:
@@ -379,7 +384,7 @@ async def set_schedule_state(
379384
schedule_rule = self._rule_ids_by_name(name, loc_id)
380385
# Raise an error when the schedule name does not exist
381386
if not schedule_rule or schedule_rule is None:
382-
raise PlugwiseError("Plugwise: no schedule with this name available.")
387+
raise PlugwiseError(f"Plugwise: no schedule with name {name} available")
383388

384389
# If no state change is requested, do nothing
385390
if state == self._schedule_old_states[loc_id][name]:
@@ -526,7 +531,7 @@ async def set_temperature(self, loc_id: str, items: dict[str, float]) -> None:
526531

527532
if setpoint is None:
528533
raise PlugwiseError(
529-
"Plugwise: failed setting temperature: no valid input provided"
534+
f"Plugwise: failed setting temperature: setpoint {setpoint} provided"
530535
) # pragma: no cover"
531536

532537
temperature = str(setpoint)

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.5"
7+
version = "1.14.6"
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)