This will set the light color based on a hex value

def set_color(self, light_id, hex_value, brightness=None):
        '''
        This will set the light color based on a hex value
        '''
        light = self.get_light(light_id)

        xy = get_xy_from_hex(hex_value)
        data = {
            'xy': [xy.x, xy.y],
        }

        if brightness is not None:
            data['bri'] = brightness

        return self.set_state(light.light_id, **data)