mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Cleanup switcher_kis - move to consts (#51807)
This commit is contained in:
parent
49a943cc94
commit
a31e6716d9
@ -1,4 +1,4 @@
|
|||||||
"""Home Assistant Switcher Component."""
|
"""The Switcher integration."""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from asyncio import QueueEmpty, TimeoutError as Asyncio_TimeoutError, wait_for
|
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.event import async_track_time_interval
|
||||||
from homeassistant.helpers.typing import EventType
|
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__)
|
_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(
|
CONFIG_SCHEMA = vol.Schema(
|
||||||
{
|
{
|
||||||
DOMAIN: vol.Schema(
|
DOMAIN: vol.Schema(
|
||||||
|
28
homeassistant/components/switcher_kis/const.py
Normal file
28
homeassistant/components/switcher_kis/const.py
Normal file
@ -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"
|
@ -13,37 +13,27 @@ from aioswitcher.consts import (
|
|||||||
from aioswitcher.devices import SwitcherV2Device
|
from aioswitcher.devices import SwitcherV2Device
|
||||||
import voluptuous as vol
|
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.core import HomeAssistant, ServiceCall
|
||||||
from homeassistant.helpers import config_validation as cv, entity_platform
|
from homeassistant.helpers import config_validation as cv, entity_platform
|
||||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
|
||||||
from . import (
|
from .const import (
|
||||||
ATTR_AUTO_OFF_SET,
|
CONF_AUTO_OFF,
|
||||||
ATTR_ELECTRIC_CURRENT,
|
CONF_TIMER_MINUTES,
|
||||||
ATTR_REMAINING_TIME,
|
|
||||||
DATA_DEVICE,
|
DATA_DEVICE,
|
||||||
|
DEVICE_PROPERTIES_TO_HA_ATTRIBUTES,
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
|
SERVICE_SET_AUTO_OFF_NAME,
|
||||||
|
SERVICE_TURN_ON_WITH_TIMER_NAME,
|
||||||
SIGNAL_SWITCHER_DEVICE_UPDATE,
|
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 = {
|
SERVICE_SET_AUTO_OFF_SCHEMA = {
|
||||||
vol.Required(CONF_AUTO_OFF): cv.time_period_str,
|
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 = {
|
SERVICE_TURN_ON_WITH_TIMER_SCHEMA = {
|
||||||
vol.Required(CONF_TIMER_MINUTES): vol.All(
|
vol.Required(CONF_TIMER_MINUTES): vol.All(
|
||||||
cv.positive_int, vol.Range(min=1, max=150)
|
cv.positive_int, vol.Range(min=1, max=150)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user