'Parse data sent by gateway.'

def parse_data(self, data):

    value = data.get(self._data_key)
    if (value is None):
        return False
    if (value == 0):
        if self._state:
            self._state = False
        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)
        return False
    rgbhex = bytes.fromhex(rgbhexstr)
    rgba = struct.unpack('BBBB', rgbhex)
    brightness = rgba[0]
    rgb = rgba[1:]
    self._brightness = int(((255 * brightness) / 100))
    self._rgb = rgb
    self._state = True
    return True
