Skip to content

Commit

Permalink
Data validation (#109)
Browse files Browse the repository at this point in the history
  • Loading branch information
lwis authored and Patrik committed Nov 12, 2017
1 parent ec6d395 commit 3898172
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions pytradfri/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,11 +191,8 @@ def set_dimmer(self, dimmer, *, index=0, transition_time=None):
dimmer: Integer between 0..254
transition_time: Integer representing tenth of a second (default None)
"""
# Set bounds for safety.
if dimmer < 0:
dimmer = 0
elif dimmer > 254:
dimmer = 254
if dimmer < 0 or dimmer > 254:
raise ValueError('Dimmer value must be between 0 and 254.')

values = {
ATTR_LIGHT_DIMMER: dimmer
Expand Down

0 comments on commit 3898172

Please sign in to comment.