Use timezone aware timestamp in flux_update (#5378)

This commit is contained in:
Tom Dickman 2017-01-17 00:55:05 -06:00 committed by Paulus Schoutsen
parent d62b1fc808
commit 65bf30643a

View File

@ -14,12 +14,11 @@ from homeassistant.components.light import is_on, turn_on
from homeassistant.components.sun import next_setting, next_rising
from homeassistant.components.switch import DOMAIN, SwitchDevice
from homeassistant.const import CONF_NAME, CONF_PLATFORM
from homeassistant.helpers.event import track_utc_time_change
from homeassistant.helpers.event import track_time_change
from homeassistant.util.color import (
color_temperature_to_rgb, color_RGB_to_xy,
color_temperature_kelvin_to_mired, HASS_COLOR_MIN, HASS_COLOR_MAX)
from homeassistant.util.dt import now as dt_now
from homeassistant.util.dt import as_local
import homeassistant.helpers.config_validation as cv
DEPENDENCIES = ['sun', 'light']
@ -137,8 +136,8 @@ class FluxSwitch(SwitchDevice):
if not self._state: # make initial update
self.flux_update()
self._state = True
self.unsub_tracker = track_utc_time_change(self.hass, self.flux_update,
second=[0, 30])
self.unsub_tracker = track_time_change(self.hass, self.flux_update,
second=[0, 30])
self.schedule_update_ha_state()
def turn_off(self, **kwargs):
@ -199,8 +198,7 @@ class FluxSwitch(SwitchDevice):
_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,
as_local(now))
percentage_complete * 100), time_state, now)
else:
# Convert to mired and clamp to allowed values
mired = color_temperature_kelvin_to_mired(temp)
@ -208,8 +206,7 @@ class FluxSwitch(SwitchDevice):
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, as_local(now))
round(percentage_complete * 100), time_state, now)
def find_start_time(self, now):
"""Return sunrise or start_time if given."""