mirror of
https://github.com/home-assistant/core.git
synced 2025-07-07 21:37:07 +00:00
fixed wrong check for valid range of 'rgb' values (#12132)
This commit is contained in:
parent
65f22b09ae
commit
ad24cbddcc
@ -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…
x
Reference in New Issue
Block a user