diff --git a/custom_components/circadian_lighting/__init__.py b/custom_components/circadian_lighting/__init__.py index 715125c6..d4398cc8 100644 --- a/custom_components/circadian_lighting/__init__.py +++ b/custom_components/circadian_lighting/__init__.py @@ -57,9 +57,7 @@ VERSION = "1.0.13" _LOGGER = logging.getLogger(__name__) DOMAIN = "circadian_lighting" -CIRCADIAN_LIGHTING_PLATFORMS = ["sensor", "switch"] -CIRCADIAN_LIGHTING_UPDATE_TOPIC = "{}_update".format(DOMAIN) -DATA_CIRCADIAN_LIGHTING = "data_cl" +CIRCADIAN_LIGHTING_UPDATE_TOPIC = f"{DOMAIN}_update" CONF_MIN_CT = "min_colortemp" DEFAULT_MIN_CT = 2500 @@ -106,7 +104,7 @@ def setup(hass, config): conf = config[DOMAIN] load_platform(hass, "sensor", DOMAIN, {}, config) - hass.data[DATA_CIRCADIAN_LIGHTING] = CircadianLighting( + hass.data[DOMAIN] = CircadianLighting( hass, min_colortemp=conf.get(CONF_MIN_CT), max_colortemp=conf.get(CONF_MAX_CT), diff --git a/custom_components/circadian_lighting/sensor.py b/custom_components/circadian_lighting/sensor.py index dc6cd738..0d3016c1 100644 --- a/custom_components/circadian_lighting/sensor.py +++ b/custom_components/circadian_lighting/sensor.py @@ -12,7 +12,6 @@ from homeassistant.helpers.entity import Entity from custom_components.circadian_lighting import ( CIRCADIAN_LIGHTING_UPDATE_TOPIC, - DATA_CIRCADIAN_LIGHTING, DOMAIN, ) @@ -23,7 +22,7 @@ ICON = "mdi:theme-light-dark" def setup_platform(hass, config, add_devices, discovery_info=None): """Set up the Circadian Lighting sensor.""" - cl = hass.data.get(DATA_CIRCADIAN_LIGHTING) + cl = hass.data.get(DOMAIN) if cl: cs = CircadianSensor(hass, cl) add_devices([cs]) diff --git a/custom_components/circadian_lighting/switch.py b/custom_components/circadian_lighting/switch.py index e3b8f951..189c30fd 100644 --- a/custom_components/circadian_lighting/switch.py +++ b/custom_components/circadian_lighting/switch.py @@ -6,7 +6,6 @@ DEPENDENCIES = ["circadian_lighting", "light"] import logging from contextlib import suppress -from typing import Optional import homeassistant.helpers.config_validation as cv import voluptuous as vol @@ -40,7 +39,7 @@ from homeassistant.util.color import ( from custom_components.circadian_lighting import ( CIRCADIAN_LIGHTING_UPDATE_TOPIC, - DATA_CIRCADIAN_LIGHTING, + DOMAIN, ) try: @@ -107,9 +106,9 @@ PLATFORM_SCHEMA = vol.Schema( def setup_platform(hass, config, add_devices, discovery_info=None): """Set up the Circadian Lighting switches.""" - cl = hass.data.get(DATA_CIRCADIAN_LIGHTING) + cl = hass.data.get(DOMAIN) if cl: - cs = CircadianSwitch( + switch = CircadianSwitch( hass, cl, name=config.get(CONF_NAME), @@ -129,7 +128,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None): initial_transition=config.get(CONF_INITIAL_TRANSITION), once_only=config.get(CONF_ONCE_ONLY), ) - add_devices([cs]) + add_devices([switch]) return True else: