Skip to content

Commit b004369

Browse files
committed
Add input-check as suggested
1 parent bba62b5 commit b004369

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

plugwise/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,9 @@ async def set_switch_state(
406406
- False when switched to state off,
407407
- the unchanged state when the switch is for instance locked.
408408
"""
409+
if state not in (STATE_ON, STATE_OFF):
410+
raise PlugwiseError("Invalid state supplied to set_switch_state")
411+
409412
try:
410413
return await self._smile_api.set_switch_state(
411414
appl_id, members, model, state

plugwise/constants.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
PRESET_AWAY: Final = "away"
2424
PRESSURE_BAR: Final = "bar"
2525
SIGNAL_STRENGTH_DECIBELS_MILLIWATT: Final = "dBm"
26+
STATE_OFF: Final = "off"
2627
STATE_ON: Final = "on"
2728
TEMP_CELSIUS: Final = "°C"
2829
TEMP_KELVIN: Final = "°K"

0 commit comments

Comments
 (0)