From e969d364e67a40020fe103bee59fef461f597bbe Mon Sep 17 00:00:00 2001 From: Eugene Prystupa Date: Sun, 14 Jun 2020 07:59:49 -0400 Subject: [PATCH] Refactor plum_lightpad (#36761) --- homeassistant/components/plum_lightpad/__init__.py | 8 +++----- homeassistant/components/plum_lightpad/const.py | 3 +++ homeassistant/components/plum_lightpad/light.py | 4 ++-- 3 files changed, 8 insertions(+), 7 deletions(-) create mode 100644 homeassistant/components/plum_lightpad/const.py diff --git a/homeassistant/components/plum_lightpad/__init__.py b/homeassistant/components/plum_lightpad/__init__.py index bfdf67a0f400..a995d1a816ae 100644 --- a/homeassistant/components/plum_lightpad/__init__.py +++ b/homeassistant/components/plum_lightpad/__init__.py @@ -10,9 +10,9 @@ from homeassistant.helpers import discovery from homeassistant.helpers.aiohttp_client import async_get_clientsession import homeassistant.helpers.config_validation as cv -_LOGGER = logging.getLogger(__name__) +from .const import DOMAIN -DOMAIN = "plum_lightpad" +_LOGGER = logging.getLogger(__name__) CONFIG_SCHEMA = vol.Schema( { @@ -26,8 +26,6 @@ CONFIG_SCHEMA = vol.Schema( extra=vol.ALLOW_EXTRA, ) -PLUM_DATA = "plum" - async def async_setup(hass, config): """Plum Lightpad Platform initialization.""" @@ -35,7 +33,7 @@ async def async_setup(hass, config): conf = config[DOMAIN] plum = Plum(conf[CONF_USERNAME], conf[CONF_PASSWORD]) - hass.data[PLUM_DATA] = plum + hass.data[DOMAIN] = plum def cleanup(event): """Clean up resources.""" diff --git a/homeassistant/components/plum_lightpad/const.py b/homeassistant/components/plum_lightpad/const.py new file mode 100644 index 000000000000..efea35d0a7a9 --- /dev/null +++ b/homeassistant/components/plum_lightpad/const.py @@ -0,0 +1,3 @@ +"""Constants for the Plum Lightpad component.""" + +DOMAIN = "plum_lightpad" diff --git a/homeassistant/components/plum_lightpad/light.py b/homeassistant/components/plum_lightpad/light.py index 2fea14474bb9..0dffa4c966c2 100644 --- a/homeassistant/components/plum_lightpad/light.py +++ b/homeassistant/components/plum_lightpad/light.py @@ -8,7 +8,7 @@ from homeassistant.components.light import ( ) import homeassistant.util.color as color_util -from . import PLUM_DATA +from .const import DOMAIN async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): @@ -16,7 +16,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= if discovery_info is None: return - plum = hass.data[PLUM_DATA] + plum = hass.data[DOMAIN] entities = []