From eb8da2e46b08c5060f105fbf8e8303604ea0992d Mon Sep 17 00:00:00 2001 From: Bas Nijholt Date: Sun, 6 Sep 2020 11:54:32 +0200 Subject: [PATCH] initial implementation of profiles --- custom_components/circadian_lighting/__init__.py | 8 ++++++-- custom_components/circadian_lighting/const.py | 1 + custom_components/circadian_lighting/switch.py | 1 + 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/custom_components/circadian_lighting/__init__.py b/custom_components/circadian_lighting/__init__.py index 48cb5f85..9784868c 100755 --- a/custom_components/circadian_lighting/__init__.py +++ b/custom_components/circadian_lighting/__init__.py @@ -57,7 +57,7 @@ from homeassistant.util.color import ( color_xy_to_hs, ) -from .const import _PROFILE_SCHEMA, CONF_PROFILE +from .const import _PROFILE_SCHEMA, CONF_PROFILES _LOGGER = logging.getLogger(__name__) @@ -96,7 +96,7 @@ CONFIG_SCHEMA = vol.Schema( vol.Optional( ATTR_TRANSITION, default=DEFAULT_TRANSITION ): VALID_TRANSITION, - vol.Optional(CONF_PROFILE): vol.Schema( + vol.Optional(CONF_PROFILES): vol.Schema( {cv.string: vol.Schema(_PROFILE_SCHEMA)} ), } @@ -122,6 +122,7 @@ def setup(hass, config): elevation=conf.get(CONF_ELEVATION, hass.config.elevation), interval=conf.get(CONF_INTERVAL), transition=conf.get(ATTR_TRANSITION), + profiles=conf.get(CONF_PROFILES, {}), ) load_platform(hass, "sensor", DOMAIN, {}, config) @@ -145,6 +146,7 @@ class CircadianLighting: elevation, interval, transition, + profiles, ): self.hass = hass self._min_colortemp = min_colortemp @@ -157,6 +159,8 @@ class CircadianLighting: self._longitude = longitude self._elevation = elevation self._transition = transition + self._profiles = profiles + _LOGGER.debug("profiles: %s", self._profiles) self._percent = self.calc_percent() self._colortemp = self.calc_colortemp() diff --git a/custom_components/circadian_lighting/const.py b/custom_components/circadian_lighting/const.py index 9dab2828..19253342 100644 --- a/custom_components/circadian_lighting/const.py +++ b/custom_components/circadian_lighting/const.py @@ -5,6 +5,7 @@ from homeassistant.components.light import VALID_TRANSITION # Switch and profile settings CONF_PROFILE = "profile" +CONF_PROFILES = "profiles" CONF_DISABLE_BRIGHTNESS_ADJUST = "disable_brightness_adjust" CONF_MIN_BRIGHT, DEFAULT_MIN_BRIGHT = "min_brightness", 1 CONF_MAX_BRIGHT, DEFAULT_MAX_BRIGHT = "max_brightness", 100 diff --git a/custom_components/circadian_lighting/switch.py b/custom_components/circadian_lighting/switch.py index 70b2eb2b..f811763e 100755 --- a/custom_components/circadian_lighting/switch.py +++ b/custom_components/circadian_lighting/switch.py @@ -72,6 +72,7 @@ PLATFORM_SCHEMA = vol.Schema( vol.Optional(CONF_LIGHTS_RGB): cv.entity_ids, vol.Optional(CONF_LIGHTS_XY): cv.entity_ids, vol.Optional(CONF_LIGHTS_BRIGHT): cv.entity_ids, + vol.Optional(CONF_PROFILE): cv.string, **_PROFILE_SCHEMA, } )