fixed wrong check for valid range of 'rgb' values (#12132)
This commit is contained in:
parent
65f22b09ae
commit
ad24cbddcc
1 changed files with 5 additions and 5 deletions
|
@ -51,13 +51,13 @@ class XiaomiGatewayLight(XiaomiDevice, Light):
|
|||
return True
|
||||
|
||||
rgbhexstr = "%x" % value
|
||||
if len(rgbhexstr) == 7:
|
||||
rgbhexstr = '0' + rgbhexstr
|
||||
elif len(rgbhexstr) != 8:
|
||||
_LOGGER.error('Light RGB data error.'
|
||||
' Must be 8 characters. Received: %s', rgbhexstr)
|
||||
if len(rgbhexstr) > 8:
|
||||
_LOGGER.error("Light RGB data error."
|
||||
" Can't be more than 8 characters. Received: %s",
|
||||
rgbhexstr)
|
||||
return False
|
||||
|
||||
rgbhexstr = rgbhexstr.zfill(8)
|
||||
rgbhex = bytes.fromhex(rgbhexstr)
|
||||
rgba = struct.unpack('BBBB', rgbhex)
|
||||
brightness = rgba[0]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue