Merge pull request #75 from claytonjn/dev

Merge dev into master
This commit is contained in:
Clayton Nummer 2020-03-07 10:14:12 -05:00 committed by GitHub
commit 70f2f3a8ae
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 11 deletions

View file

@ -48,7 +48,7 @@ from homeassistant.util.dt import utcnow as dt_utcnow, as_local
from datetime import datetime, timedelta
VERSION = '1.0.10b'
VERSION = '1.0.11b'
_LOGGER = logging.getLogger(__name__)

View file

@ -45,6 +45,7 @@ CONF_SLEEP_CT = 'sleep_colortemp'
CONF_SLEEP_BRIGHT = 'sleep_brightness'
CONF_DISABLE_ENTITY = 'disable_entity'
CONF_DISABLE_STATE = 'disable_state'
CONF_INITIAL_TRANSITION = 'initial_transition'
DEFAULT_INITIAL_TRANSITION = 1
PLATFORM_SCHEMA = vol.Schema({
@ -66,7 +67,9 @@ PLATFORM_SCHEMA = vol.Schema({
vol.Optional(CONF_SLEEP_BRIGHT):
vol.All(vol.Coerce(int), vol.Range(min=1, max=100)),
vol.Optional(CONF_DISABLE_ENTITY): cv.entity_id,
vol.Optional(CONF_DISABLE_STATE): cv.string
vol.Optional(CONF_DISABLE_STATE): cv.string,
vol.Optional(CONF_INITIAL_TRANSITION, default=DEFAULT_INITIAL_TRANSITION):
vol.All(vol.Coerce(int), vol.Range(min=1, max=1000))
})
def setup_platform(hass, config, add_devices, discovery_info=None):
@ -87,10 +90,11 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
sleep_brightness = config.get(CONF_SLEEP_BRIGHT)
disable_entity = config.get(CONF_DISABLE_ENTITY)
disable_state = config.get(CONF_DISABLE_STATE)
initial_transition = config.get(CONF_INITIAL_TRANSITION)
cs = CircadianSwitch(hass, cl, name, lights_ct, lights_rgb, lights_xy, lights_brightness,
disable_brightness_adjust, min_brightness, max_brightness,
sleep_entity, sleep_state, sleep_colortemp, sleep_brightness,
disable_entity, disable_state)
disable_entity, disable_state, initial_transition)
add_devices([cs])
def update(call=None):
@ -107,7 +111,7 @@ class CircadianSwitch(SwitchDevice, RestoreEntity):
def __init__(self, hass, cl, name, lights_ct, lights_rgb, lights_xy, lights_brightness,
disable_brightness_adjust, min_brightness, max_brightness,
sleep_entity, sleep_state, sleep_colortemp, sleep_brightness,
disable_entity, disable_state):
disable_entity, disable_state, initial_transition):
"""Initialize the Circadian Lighting switch."""
self.hass = hass
self._cl = cl
@ -129,6 +133,7 @@ class CircadianSwitch(SwitchDevice, RestoreEntity):
self._sleep_brightness = sleep_brightness
self._disable_entity = disable_entity
self._disable_state = disable_state
self._initial_transition = initial_transition
self._attributes = {}
self._attributes['hs_color'] = self._hs_color
self._attributes['brightness'] = None
@ -195,7 +200,7 @@ class CircadianSwitch(SwitchDevice, RestoreEntity):
self._state = True
# Make initial update
self.update_switch(DEFAULT_INITIAL_TRANSITION)
self.update_switch(self._initial_transition)
self.schedule_update_ha_state()
@ -331,7 +336,7 @@ class CircadianSwitch(SwitchDevice, RestoreEntity):
try:
_LOGGER.debug(entity_id + " change from " + str(from_state) + " to " + str(to_state))
if to_state.state == 'on' and from_state.state != 'on':
self.adjust_lights([entity_id], DEFAULT_INITIAL_TRANSITION)
self.adjust_lights([entity_id], self._initial_transition)
except:
pass
@ -339,7 +344,7 @@ class CircadianSwitch(SwitchDevice, RestoreEntity):
try:
_LOGGER.debug(entity_id + " change from " + str(from_state) + " to " + str(to_state))
if to_state.state == self._sleep_state or from_state.state == self._sleep_state:
self.update_switch(DEFAULT_INITIAL_TRANSITION)
self.update_switch(self._initial_transition)
except:
pass
@ -347,6 +352,6 @@ class CircadianSwitch(SwitchDevice, RestoreEntity):
try:
_LOGGER.debug(entity_id + " change from " + str(from_state) + " to " + str(to_state))
if from_state.state == self._disable_state:
self.update_switch(DEFAULT_INITIAL_TRANSITION)
self.update_switch(self._initial_transition)
except:
pass
pass

View file

@ -1,7 +1,7 @@
{
"circadian_lighting": {
"updated_at": "2020-02-12",
"version": "1.0.10b",
"updated_at": "2020-02-21",
"version": "1.0.11b",
"local_location": "/custom_components/circadian_lighting/__init__.py",
"remote_location": "https://raw.githubusercontent.com/claytonjn/hass-circadian_lighting/master/custom_components/circadian_lighting/__init__.py",
"visit_repo": "https://github.com/claytonjn/hass-circadian_lighting",