mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Use core constants for switcher_kis (#46507)
This commit is contained in:
parent
c76758f775
commit
854504cccc
@ -8,7 +8,7 @@ from aioswitcher.bridge import SwitcherV2Bridge
|
|||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components.switch import DOMAIN as SWITCH_DOMAIN
|
from homeassistant.components.switch import DOMAIN as SWITCH_DOMAIN
|
||||||
from homeassistant.const import EVENT_HOMEASSISTANT_STOP
|
from homeassistant.const import CONF_DEVICE_ID, EVENT_HOMEASSISTANT_STOP
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import callback
|
||||||
from homeassistant.helpers import config_validation as cv
|
from homeassistant.helpers import config_validation as cv
|
||||||
from homeassistant.helpers.discovery import async_load_platform
|
from homeassistant.helpers.discovery import async_load_platform
|
||||||
@ -20,7 +20,6 @@ _LOGGER = logging.getLogger(__name__)
|
|||||||
|
|
||||||
DOMAIN = "switcher_kis"
|
DOMAIN = "switcher_kis"
|
||||||
|
|
||||||
CONF_DEVICE_ID = "device_id"
|
|
||||||
CONF_DEVICE_PASSWORD = "device_password"
|
CONF_DEVICE_PASSWORD = "device_password"
|
||||||
CONF_PHONE_ID = "phone_id"
|
CONF_PHONE_ID = "phone_id"
|
||||||
|
|
||||||
@ -48,7 +47,6 @@ CONFIG_SCHEMA = vol.Schema(
|
|||||||
|
|
||||||
async def async_setup(hass: HomeAssistantType, config: Dict) -> bool:
|
async def async_setup(hass: HomeAssistantType, config: Dict) -> bool:
|
||||||
"""Set up the switcher component."""
|
"""Set up the switcher component."""
|
||||||
|
|
||||||
phone_id = config[DOMAIN][CONF_PHONE_ID]
|
phone_id = config[DOMAIN][CONF_PHONE_ID]
|
||||||
device_id = config[DOMAIN][CONF_DEVICE_ID]
|
device_id = config[DOMAIN][CONF_DEVICE_ID]
|
||||||
device_password = config[DOMAIN][CONF_DEVICE_PASSWORD]
|
device_password = config[DOMAIN][CONF_DEVICE_PASSWORD]
|
||||||
|
@ -62,7 +62,6 @@ async def async_setup_platform(
|
|||||||
|
|
||||||
async def async_set_auto_off_service(entity, service_call: ServiceCallType) -> None:
|
async def async_set_auto_off_service(entity, service_call: ServiceCallType) -> None:
|
||||||
"""Use for handling setting device auto-off service calls."""
|
"""Use for handling setting device auto-off service calls."""
|
||||||
|
|
||||||
async with SwitcherV2Api(
|
async with SwitcherV2Api(
|
||||||
hass.loop,
|
hass.loop,
|
||||||
device_data.ip_addr,
|
device_data.ip_addr,
|
||||||
@ -76,7 +75,6 @@ async def async_setup_platform(
|
|||||||
entity, service_call: ServiceCallType
|
entity, service_call: ServiceCallType
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Use for handling turning device on with a timer service calls."""
|
"""Use for handling turning device on with a timer service calls."""
|
||||||
|
|
||||||
async with SwitcherV2Api(
|
async with SwitcherV2Api(
|
||||||
hass.loop,
|
hass.loop,
|
||||||
device_data.ip_addr,
|
device_data.ip_addr,
|
||||||
@ -133,7 +131,6 @@ class SwitcherControl(SwitchEntity):
|
|||||||
@property
|
@property
|
||||||
def is_on(self) -> bool:
|
def is_on(self) -> bool:
|
||||||
"""Return True if entity is on."""
|
"""Return True if entity is on."""
|
||||||
|
|
||||||
return self._state == SWITCHER_STATE_ON
|
return self._state == SWITCHER_STATE_ON
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -144,7 +141,6 @@ class SwitcherControl(SwitchEntity):
|
|||||||
@property
|
@property
|
||||||
def device_state_attributes(self) -> Dict:
|
def device_state_attributes(self) -> Dict:
|
||||||
"""Return the optional state attributes."""
|
"""Return the optional state attributes."""
|
||||||
|
|
||||||
attribs = {}
|
attribs = {}
|
||||||
|
|
||||||
for prop, attr in DEVICE_PROPERTIES_TO_HA_ATTRIBUTES.items():
|
for prop, attr in DEVICE_PROPERTIES_TO_HA_ATTRIBUTES.items():
|
||||||
@ -157,7 +153,6 @@ class SwitcherControl(SwitchEntity):
|
|||||||
@property
|
@property
|
||||||
def available(self) -> bool:
|
def available(self) -> bool:
|
||||||
"""Return True if entity is available."""
|
"""Return True if entity is available."""
|
||||||
|
|
||||||
return self._state in [SWITCHER_STATE_ON, SWITCHER_STATE_OFF]
|
return self._state in [SWITCHER_STATE_ON, SWITCHER_STATE_OFF]
|
||||||
|
|
||||||
async def async_added_to_hass(self) -> None:
|
async def async_added_to_hass(self) -> None:
|
||||||
@ -188,7 +183,6 @@ class SwitcherControl(SwitchEntity):
|
|||||||
|
|
||||||
async def _control_device(self, send_on: bool) -> None:
|
async def _control_device(self, send_on: bool) -> None:
|
||||||
"""Turn the entity on or off."""
|
"""Turn the entity on or off."""
|
||||||
|
|
||||||
response: SwitcherV2ControlResponseMSG = None
|
response: SwitcherV2ControlResponseMSG = None
|
||||||
async with SwitcherV2Api(
|
async with SwitcherV2Api(
|
||||||
self.hass.loop,
|
self.hass.loop,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user