Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions tinytuya/BulbDevice.py
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,9 @@ def set_white_percentage(self, brightness=100, colourtemp=0, nowait=False):
if err:
raise ValueError( 'set_white_percentage: %s percentage needs to be between 0 and 100.' % err[1:])

if not self.bulb_configured:
self.detect_bulb(nowait=nowait)

b = int(self.dpset['value_max'] * brightness // 100)
c = int(self.dpset['value_max'] * colourtemp // 100)

Expand Down Expand Up @@ -656,6 +659,8 @@ def set_brightness_percentage(self, brightness=100, nowait=False):
"""
if not 0 <= brightness <= 100:
raise ValueError('set_brightness_percentage: The brightness needs to be between 0 and 100.')
if not self.bulb_configured:
self.detect_bulb(nowait=nowait)
b = int(self.dpset['value_max'] * brightness // 100)
return self.set_brightness(b, nowait=nowait)

Expand Down Expand Up @@ -704,6 +709,8 @@ def set_colourtemp_percentage(self, colourtemp=100, nowait=False):
"""
if not 0 <= colourtemp <= 100:
raise ValueError( 'set_colourtemp_percentage: Colourtemp percentage needs to be between 0 and 100.')
if not self.bulb_configured:
self.detect_bulb(nowait=nowait)
c = int(self.dpset['value_max'] * colourtemp // 100)
return self.set_colourtemp( c, nowait=nowait )

Expand Down
Loading