mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 03:07:37 +00:00
Refactor switcher kis (#114281)
* switcher: small refactoring * swithcer: Update switch.py * more refactoring * fix ruff
This commit is contained in:
parent
c21d508c2d
commit
4d27f4be51
@ -126,6 +126,6 @@ class SwitcherCoverEntity(
|
||||
"""Move the cover to a specific position."""
|
||||
await self._async_call_api(API_SET_POSITON, kwargs[ATTR_POSITION])
|
||||
|
||||
async def async_stop_cover(self, **_kwargs: Any) -> None:
|
||||
async def async_stop_cover(self, **kwargs: Any) -> None:
|
||||
"""Stop the cover."""
|
||||
await self._async_call_api(API_STOP)
|
||||
|
@ -34,6 +34,9 @@ from .const import (
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
API_CONTROL_DEVICE = "control_device"
|
||||
API_SET_AUTO_SHUTDOWN = "set_auto_shutdown"
|
||||
|
||||
SERVICE_SET_AUTO_OFF_SCHEMA = {
|
||||
vol.Required(CONF_AUTO_OFF): cv.time_period_str,
|
||||
}
|
||||
@ -141,13 +144,13 @@ class SwitcherBaseSwitchEntity(
|
||||
|
||||
async def async_turn_on(self, **kwargs: Any) -> None:
|
||||
"""Turn the entity on."""
|
||||
await self._async_call_api("control_device", Command.ON)
|
||||
await self._async_call_api(API_CONTROL_DEVICE, Command.ON)
|
||||
self.control_result = True
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def async_turn_off(self, **kwargs: Any) -> None:
|
||||
"""Turn the entity off."""
|
||||
await self._async_call_api("control_device", Command.OFF)
|
||||
await self._async_call_api(API_CONTROL_DEVICE, Command.OFF)
|
||||
self.control_result = False
|
||||
self.async_write_ha_state()
|
||||
|
||||
@ -181,11 +184,11 @@ class SwitcherWaterHeaterSwitchEntity(SwitcherBaseSwitchEntity):
|
||||
|
||||
async def async_set_auto_off_service(self, auto_off: timedelta) -> None:
|
||||
"""Use for handling setting device auto-off service calls."""
|
||||
await self._async_call_api("set_auto_shutdown", auto_off)
|
||||
await self._async_call_api(API_SET_AUTO_SHUTDOWN, auto_off)
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def async_turn_on_with_timer_service(self, timer_minutes: int) -> None:
|
||||
"""Use for turning device on with a timer service calls."""
|
||||
await self._async_call_api("control_device", Command.ON, timer_minutes)
|
||||
await self._async_call_api(API_CONTROL_DEVICE, Command.ON, timer_minutes)
|
||||
self.control_result = True
|
||||
self.async_write_ha_state()
|
||||
|
Loading…
x
Reference in New Issue
Block a user