fixed wrong check for valid range of 'rgb' values (#12132)

This commit is contained in:
Paul Annekov 2018-02-02 15:02:11 +02:00 committed by Daniel Høyer Iversen
parent 65f22b09ae
commit ad24cbddcc

View file

@ -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]