mirror of https://github.com/home-assistant/core
Add low speed Overkiz cover (#66750)
This commit is contained in:
parent
f30681dae7
commit
d25a46d68d
|
@ -1,5 +1,5 @@
|
|||
"""Support for Overkiz covers - shutters etc."""
|
||||
from pyoverkiz.enums import UIClass
|
||||
from pyoverkiz.enums import OverkizCommand, UIClass
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import Platform
|
||||
|
@ -10,7 +10,7 @@ from . import HomeAssistantOverkizData
|
|||
from .const import DOMAIN
|
||||
from .cover_entities.awning import Awning
|
||||
from .cover_entities.generic_cover import OverkizGenericCover
|
||||
from .cover_entities.vertical_cover import VerticalCover
|
||||
from .cover_entities.vertical_cover import LowSpeedCover, VerticalCover
|
||||
|
||||
|
||||
async def async_setup_entry(
|
||||
|
@ -31,4 +31,10 @@ async def async_setup_entry(
|
|||
if device.ui_class != UIClass.AWNING
|
||||
]
|
||||
|
||||
entities += [
|
||||
LowSpeedCover(device.device_url, data.coordinator)
|
||||
for device in data.platforms[Platform.COVER]
|
||||
if OverkizCommand.SET_CLOSURE_AND_LINEAR_SPEED in device.definition.commands
|
||||
]
|
||||
|
||||
async_add_entities(entities)
|
||||
|
|
|
@ -13,6 +13,7 @@ from homeassistant.components.cover import (
|
|||
SUPPORT_STOP,
|
||||
CoverDeviceClass,
|
||||
)
|
||||
from homeassistant.components.overkiz.coordinator import OverkizDataUpdateCoordinator
|
||||
|
||||
from .generic_cover import COMMANDS_STOP, OverkizGenericCover
|
||||
|
||||
|
@ -99,3 +100,37 @@ class VerticalCover(OverkizGenericCover):
|
|||
"""Close the cover."""
|
||||
if command := self.executor.select_command(*COMMANDS_CLOSE):
|
||||
await self.executor.async_execute_command(command)
|
||||
|
||||
|
||||
class LowSpeedCover(VerticalCover):
|
||||
"""Representation of an Overkiz Low Speed cover."""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
device_url: str,
|
||||
coordinator: OverkizDataUpdateCoordinator,
|
||||
) -> None:
|
||||
"""Initialize the device."""
|
||||
super().__init__(device_url, coordinator)
|
||||
self._attr_name = f"{self._attr_name} Low Speed"
|
||||
self._attr_unique_id = f"{self._attr_unique_id}_low_speed"
|
||||
|
||||
async def async_set_cover_position(self, **kwargs: Any) -> None:
|
||||
"""Move the cover to a specific position."""
|
||||
await self.async_set_cover_position_low_speed(**kwargs)
|
||||
|
||||
async def async_open_cover(self, **kwargs: Any) -> None:
|
||||
"""Open the cover."""
|
||||
await self.async_set_cover_position_low_speed(**{ATTR_POSITION: 100})
|
||||
|
||||
async def async_close_cover(self, **kwargs: Any) -> None:
|
||||
"""Close the cover."""
|
||||
await self.async_set_cover_position_low_speed(**{ATTR_POSITION: 0})
|
||||
|
||||
async def async_set_cover_position_low_speed(self, **kwargs: Any) -> None:
|
||||
"""Move the cover to a specific position with a low speed."""
|
||||
position = 100 - kwargs.get(ATTR_POSITION, 0)
|
||||
|
||||
await self.executor.async_execute_command(
|
||||
OverkizCommand.SET_CLOSURE_AND_LINEAR_SPEED, position, "lowspeed"
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue