'Update all the lights using flux.'

def flux_update(self, now=None):

    if (now is None):
        now = dt_now()
    sunset = get_astral_event_date(self.hass, 'sunset', now.date())
    start_time = self.find_start_time(now)
    stop_time = now.replace(hour=self._stop_time.hour, minute=self._stop_time.minute, second=0)
    if (start_time < now < sunset):
        time_state = 'day'
        temp_range = abs((self._start_colortemp - self._sunset_colortemp))
        day_length = int((sunset.timestamp() - start_time.timestamp()))
        seconds_from_start = int((now.timestamp() - start_time.timestamp()))
        percentage_complete = (seconds_from_start / day_length)
        temp_offset = (temp_range * percentage_complete)
        if (self._start_colortemp > self._sunset_colortemp):
            temp = (self._start_colortemp - temp_offset)
        else:
            temp = (self._start_colortemp + temp_offset)
    else:
        time_state = 'night'
        if ((now < stop_time) and (now > start_time)):
            now_time = now
        else:
            now_time = stop_time
        temp_range = abs((self._sunset_colortemp - self._stop_colortemp))
        night_length = int((stop_time.timestamp() - sunset.timestamp()))
        seconds_from_sunset = int((now_time.timestamp() - sunset.timestamp()))
        percentage_complete = (seconds_from_sunset / night_length)
        temp_offset = (temp_range * percentage_complete)
        if (self._sunset_colortemp > self._stop_colortemp):
            temp = (self._sunset_colortemp - temp_offset)
        else:
            temp = (self._sunset_colortemp + temp_offset)
    rgb = color_temperature_to_rgb(temp)
    (x_val, y_val, b_val) = color_RGB_to_xy(*rgb)
    brightness = (self._brightness if self._brightness else b_val)
    if self._disable_brightness_adjust:
        brightness = None
    if (self._mode == MODE_XY):
        set_lights_xy(self.hass, self._lights, x_val, y_val, brightness)
        _LOGGER.info('Lights    updated    to    x:%s    y:%s    brightness:%s,    %s%%    of    %s    cycle    complete    at    %s', x_val, y_val, brightness, round((percentage_complete * 100)), time_state, now)
    elif (self._mode == MODE_RGB):
        set_lights_rgb(self.hass, self._lights, rgb)
        _LOGGER.info('Lights    updated    to    rgb:%s,    %s%%    of    %s    cycle    complete    at    %s', rgb, round((percentage_complete * 100)), time_state, now)
    else:
        mired = color_temperature_kelvin_to_mired(temp)
        set_lights_temp(self.hass, self._lights, mired, brightness)
        _LOGGER.info('Lights    updated    to    mired:%s    brightness:%s,    %s%%    of    %s    cycle    complete    at    %s', mired, brightness, round((percentage_complete * 100)), time_state, now)
