Skip to content

Commit e875c4a

Browse files
committed
Update the common set-functions
1 parent 9471b6a commit e875c4a

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

plugwise/__init__.py

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -318,36 +318,38 @@ async def set_schedule_state(
318318
name: str | None = None,
319319
) -> None:
320320
"""Activate/deactivate the Schedule, with the given name, on the relevant Thermostat."""
321-
await self._smile_api.set_schedule_state(loc_id, new_state, name)
321+
try:
322+
await self._smile_api.set_schedule_state(loc_id, new_state, name)
323+
except PlugwiseError as exc:
324+
raise exc
322325

323326
async def set_preset(self, loc_id: str, preset: str) -> None:
324327
"""Set the given Preset on the relevant Thermostat."""
325-
await self._smile_api.set_preset(loc_id, preset)
328+
try:
329+
await self._smile_api.set_preset(loc_id, preset)
330+
except PlugwiseError as exc:
331+
raise exc
326332

327333
async def set_temperature(self, loc_id: str, items: dict[str, float]) -> None:
328334
"""Set the given Temperature on the relevant Thermostat."""
329335
try:
330336
await self._smile_api.set_temperature(loc_id, items)
331337
except PlugwiseError as exc:
332-
raise PlugwiseError(
333-
"Plugwise: failed setting temperature: no valid input provided"
334-
) from exc
338+
raise exc
335339

336340
async def set_number_setpoint(self, key: str, _: str, temperature: float) -> None:
337341
"""Set the max. Boiler or DHW setpoint on the Central Heating boiler."""
338342
try:
339343
await self._smile_api.set_number_setpoint(key, temperature)
340344
except PlugwiseError as exc:
341-
raise PlugwiseError(f"Plugwise: cannot change setpoint, {key} not found.") from exc
345+
raise exc
342346

343347
async def set_temperature_offset(self, _: str, dev_id: str, offset: float) -> None:
344348
"""Set the Temperature offset for thermostats that support this feature."""
345349
try:
346350
await self._smile_api.set_temperature_offset(dev_id, offset)
347351
except PlugwiseError as exc:
348-
raise PlugwiseError(
349-
"Plugwise: this device does not have temperature-offset capability."
350-
) from exc
352+
raise exc
351353

352354
async def set_switch_state(
353355
self, appl_id: str, members: list[str] | None, model: str, state: str
@@ -356,28 +358,28 @@ async def set_switch_state(
356358
try:
357359
await self._smile_api.set_switch_state(appl_id, members, model, state)
358360
except PlugwiseError as exc:
359-
raise PlugwiseError("Plugwise: the locked Relay was not switched.") from exc
361+
raise exc
360362

361363
async def set_gateway_mode(self, mode: str) -> None:
362364
"""Set the gateway mode."""
363365
try:
364366
await self._smile_api.set_gateway_mode(mode)
365367
except PlugwiseError as exc:
366-
raise PlugwiseError("Plugwise: invalid gateway mode.") from exc
368+
raise exc
367369

368370
async def set_regulation_mode(self, mode: str) -> None:
369371
"""Set the heating regulation mode."""
370372
try:
371373
await self._smile_api.set_regulation_mode(mode)
372374
except PlugwiseError as exc:
373-
raise PlugwiseError("Plugwise: invalid regulation mode.") from exc
375+
raise exc
374376

375377
async def set_dhw_mode(self, mode: str) -> None:
376378
"""Set the domestic hot water heating regulation mode."""
377379
try:
378380
await self._smile_api.set_dhw_mode(mode)
379381
except PlugwiseError as exc:
380-
raise PlugwiseError("Plugwise: invalid dhw mode.") from exc
382+
raise exc
381383

382384
async def delete_notification(self) -> None:
383385
"""Delete the active Plugwise Notification."""

0 commit comments

Comments
 (0)