diff --git a/custom_components/adaptive_lighting/__init__.py b/custom_components/adaptive_lighting/__init__.py index dd3988e9..c4085dd9 100755 --- a/custom_components/adaptive_lighting/__init__.py +++ b/custom_components/adaptive_lighting/__init__.py @@ -26,53 +26,14 @@ Technical notes: I had to make a lot of assumptions when writing this app * The component doesn't calculate a true "Blue Hour" -- it just sets the lights to 2700K (warm white) until your hub goes into Night mode """ -import asyncio -import logging -from datetime import timedelta -import voluptuous as vol +import logging import homeassistant.helpers.config_validation as cv -import homeassistant.util.dt as dt_util -from homeassistant.components.light import ( - ATTR_BRIGHTNESS_PCT, - ATTR_COLOR_TEMP, - ATTR_RGB_COLOR, - ATTR_TRANSITION, -) -from homeassistant.components.light import DOMAIN as LIGHT_DOMAIN -from homeassistant.components.light import ( - SUPPORT_BRIGHTNESS, - SUPPORT_COLOR, - SUPPORT_COLOR_TEMP, - SUPPORT_TRANSITION, - VALID_TRANSITION, - is_on, -) -from homeassistant.components.switch import SwitchEntity +import voluptuous as vol +from homeassistant.components.light import VALID_TRANSITION from homeassistant.config_entries import SOURCE_IMPORT -from homeassistant.const import ( - ATTR_ENTITY_ID, - CONF_NAME, - SERVICE_TURN_ON, - STATE_ON, - SUN_EVENT_SUNRISE, - SUN_EVENT_SUNSET, -) -from homeassistant.helpers.entity import Entity -from homeassistant.helpers.event import ( - async_track_state_change, - async_track_time_interval, -) -from homeassistant.helpers.restore_state import RestoreEntity -from homeassistant.helpers.sun import get_astral_location -from homeassistant.util import slugify -from homeassistant.util.color import ( - color_RGB_to_xy, - color_temperature_kelvin_to_mired, - color_temperature_to_rgb, - color_xy_to_hs, -) +from homeassistant.const import CONF_NAME from .const import ( CONF_DISABLE_BRIGHTNESS_ADJUST, @@ -94,8 +55,6 @@ from .const import ( CONF_SUNRISE_TIME, CONF_SUNSET_OFFSET, CONF_SUNSET_TIME, - CONF_NAME, - DEFAULT_NAME, CONF_TRANSITION, DEFAULT_DISABLE_BRIGHTNESS_ADJUST, DEFAULT_INITIAL_TRANSITION, @@ -105,6 +64,7 @@ from .const import ( DEFAULT_MAX_COLOR_TEMP, DEFAULT_MIN_BRIGHTNESS, DEFAULT_MIN_COLOR_TEMP, + DEFAULT_NAME, DEFAULT_ONLY_ONCE, DEFAULT_SLEEP_BRIGHTNESS, DEFAULT_SLEEP_COLOR_TEMP, @@ -112,20 +72,8 @@ from .const import ( DEFAULT_SUNSET_OFFSET, DEFAULT_TRANSITION, DOMAIN, - ICON, - SUN_EVENT_MIDNIGHT, - SUN_EVENT_NOON, ) - -_SUPPORT_OPTS = { - "brightness": SUPPORT_BRIGHTNESS, - "color_temp": SUPPORT_COLOR_TEMP, - "color": SUPPORT_COLOR, - "transition": SUPPORT_TRANSITION, -} - - _LOGGER = logging.getLogger(__name__) diff --git a/custom_components/adaptive_lighting/switch.py b/custom_components/adaptive_lighting/switch.py index 31b07e40..aedb91f0 100755 --- a/custom_components/adaptive_lighting/switch.py +++ b/custom_components/adaptive_lighting/switch.py @@ -1,42 +1,11 @@ -""" -Adaptive Lighting Component for Home-Assistant. - -This component calculates color temperature and brightness to synchronize -your color changing lights with perceived color temperature of the sky throughout -the day. This gives your environment a more natural feel, with cooler whites during -the midday and warmer tints near twilight and dawn. - -In addition, the component sets your lights to a nice warm white at 1% in "Sleep" mode, -which is far brighter than starlight but won't reset your adaptive rhythm or break down -too much rhodopsin in your eyes. - -Human circadian rhythms are heavily influenced by ambient light levels and -hues. Hormone production, brainwave activity, mood and wakefulness are -just some of the cognitive functions tied to cyclical natural light. -http://en.wikipedia.org/wiki/Zeitgeber - -Here's some further reading: - -http://www.cambridgeincolour.com/tutorials/sunrise-sunset-calculator.htm -http://en.wikipedia.org/wiki/Color_temperature - -Technical notes: I had to make a lot of assumptions when writing this app -* There are no considerations for weather or altitude, but does use your - hub's location to calculate the sun position. -* The component doesn't calculate a true "Blue Hour" -- it just sets the - lights to 2700K (warm white) until your hub goes into Night mode -""" +"""Adaptive Lighting Component for Home-Assistant.""" import asyncio import bisect import logging from datetime import timedelta -import voluptuous as vol - -import homeassistant.helpers.config_validation as cv import homeassistant.util.dt as dt_util -from custom_components import adaptive_lighting from homeassistant.components.light import ( ATTR_BRIGHTNESS_PCT, ATTR_COLOR_TEMP, @@ -55,7 +24,6 @@ from homeassistant.components.switch import SwitchEntity from homeassistant.const import ( ATTR_ENTITY_ID, CONF_NAME, - CONF_PLATFORM, SERVICE_TURN_ON, STATE_ON, SUN_EVENT_SUNRISE,