diff --git a/homeassistant/components/switcher_kis/__init__.py b/homeassistant/components/switcher_kis/__init__.py index 5483ad88c2d..6627e9d097c 100644 --- a/homeassistant/components/switcher_kis/__init__.py +++ b/homeassistant/components/switcher_kis/__init__.py @@ -1,4 +1,4 @@ -"""Home Assistant Switcher Component.""" +"""The Switcher integration.""" from __future__ import annotations from asyncio import QueueEmpty, TimeoutError as Asyncio_TimeoutError, wait_for @@ -17,21 +17,16 @@ from homeassistant.helpers.dispatcher import async_dispatcher_send from homeassistant.helpers.event import async_track_time_interval from homeassistant.helpers.typing import EventType +from .const import ( + CONF_DEVICE_PASSWORD, + CONF_PHONE_ID, + DATA_DEVICE, + DOMAIN, + SIGNAL_SWITCHER_DEVICE_UPDATE, +) + _LOGGER = logging.getLogger(__name__) -DOMAIN = "switcher_kis" - -CONF_DEVICE_PASSWORD = "device_password" -CONF_PHONE_ID = "phone_id" - -DATA_DEVICE = "device" - -SIGNAL_SWITCHER_DEVICE_UPDATE = "switcher_device_update" - -ATTR_AUTO_OFF_SET = "auto_off_set" -ATTR_ELECTRIC_CURRENT = "electric_current" -ATTR_REMAINING_TIME = "remaining_time" - CONFIG_SCHEMA = vol.Schema( { DOMAIN: vol.Schema( diff --git a/homeassistant/components/switcher_kis/const.py b/homeassistant/components/switcher_kis/const.py new file mode 100644 index 00000000000..da51fae4d1a --- /dev/null +++ b/homeassistant/components/switcher_kis/const.py @@ -0,0 +1,28 @@ +"""Constants for the Switcher integration.""" +from homeassistant.components.switch import ATTR_CURRENT_POWER_W + +DOMAIN = "switcher_kis" + +CONF_DEVICE_PASSWORD = "device_password" +CONF_PHONE_ID = "phone_id" + +DATA_DEVICE = "device" + +SIGNAL_SWITCHER_DEVICE_UPDATE = "switcher_device_update" + +ATTR_AUTO_OFF_SET = "auto_off_set" +ATTR_ELECTRIC_CURRENT = "electric_current" +ATTR_REMAINING_TIME = "remaining_time" + +CONF_AUTO_OFF = "auto_off" +CONF_TIMER_MINUTES = "timer_minutes" + +DEVICE_PROPERTIES_TO_HA_ATTRIBUTES = { + "power_consumption": ATTR_CURRENT_POWER_W, + "electric_current": ATTR_ELECTRIC_CURRENT, + "remaining_time": ATTR_REMAINING_TIME, + "auto_off_set": ATTR_AUTO_OFF_SET, +} + +SERVICE_SET_AUTO_OFF_NAME = "set_auto_off" +SERVICE_TURN_ON_WITH_TIMER_NAME = "turn_on_with_timer" diff --git a/homeassistant/components/switcher_kis/switch.py b/homeassistant/components/switcher_kis/switch.py index 8f7332162a9..343d4dd8b13 100644 --- a/homeassistant/components/switcher_kis/switch.py +++ b/homeassistant/components/switcher_kis/switch.py @@ -13,37 +13,27 @@ from aioswitcher.consts import ( from aioswitcher.devices import SwitcherV2Device import voluptuous as vol -from homeassistant.components.switch import ATTR_CURRENT_POWER_W, SwitchEntity +from homeassistant.components.switch import SwitchEntity from homeassistant.core import HomeAssistant, ServiceCall from homeassistant.helpers import config_validation as cv, entity_platform from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.entity_platform import AddEntitiesCallback -from . import ( - ATTR_AUTO_OFF_SET, - ATTR_ELECTRIC_CURRENT, - ATTR_REMAINING_TIME, +from .const import ( + CONF_AUTO_OFF, + CONF_TIMER_MINUTES, DATA_DEVICE, + DEVICE_PROPERTIES_TO_HA_ATTRIBUTES, DOMAIN, + SERVICE_SET_AUTO_OFF_NAME, + SERVICE_TURN_ON_WITH_TIMER_NAME, SIGNAL_SWITCHER_DEVICE_UPDATE, ) -CONF_AUTO_OFF = "auto_off" -CONF_TIMER_MINUTES = "timer_minutes" - -DEVICE_PROPERTIES_TO_HA_ATTRIBUTES = { - "power_consumption": ATTR_CURRENT_POWER_W, - "electric_current": ATTR_ELECTRIC_CURRENT, - "remaining_time": ATTR_REMAINING_TIME, - "auto_off_set": ATTR_AUTO_OFF_SET, -} - -SERVICE_SET_AUTO_OFF_NAME = "set_auto_off" SERVICE_SET_AUTO_OFF_SCHEMA = { vol.Required(CONF_AUTO_OFF): cv.time_period_str, } -SERVICE_TURN_ON_WITH_TIMER_NAME = "turn_on_with_timer" SERVICE_TURN_ON_WITH_TIMER_SCHEMA = { vol.Required(CONF_TIMER_MINUTES): vol.All( cv.positive_int, vol.Range(min=1, max=150)