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
|
return True
|
||||||
|
|
||||||
rgbhexstr = "%x" % value
|
rgbhexstr = "%x" % value
|
||||||
if len(rgbhexstr) == 7:
|
if len(rgbhexstr) > 8:
|
||||||
rgbhexstr = '0' + rgbhexstr
|
_LOGGER.error("Light RGB data error."
|
||||||
elif len(rgbhexstr) != 8:
|
" Can't be more than 8 characters. Received: %s",
|
||||||
_LOGGER.error('Light RGB data error.'
|
rgbhexstr)
|
||||||
' Must be 8 characters. Received: %s', rgbhexstr)
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
rgbhexstr = rgbhexstr.zfill(8)
|
||||||
rgbhex = bytes.fromhex(rgbhexstr)
|
rgbhex = bytes.fromhex(rgbhexstr)
|
||||||
rgba = struct.unpack('BBBB', rgbhex)
|
rgba = struct.unpack('BBBB', rgbhex)
|
||||||
brightness = rgba[0]
|
brightness = rgba[0]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue