mirror of
https://github.com/home-assistant/core.git
synced 2025-07-16 01:37:08 +00:00
Add tilt functionality to Velux covers (#43669)
This commit is contained in:
parent
73d2ae76a9
commit
fb527814f9
@ -4,6 +4,7 @@ from pyvlx.opening_device import Awning, Blind, GarageDoor, Gate, RollerShutter,
|
||||
|
||||
from homeassistant.components.cover import (
|
||||
ATTR_POSITION,
|
||||
ATTR_TILT_POSITION,
|
||||
DEVICE_CLASS_AWNING,
|
||||
DEVICE_CLASS_BLIND,
|
||||
DEVICE_CLASS_GARAGE,
|
||||
@ -11,9 +12,13 @@ from homeassistant.components.cover import (
|
||||
DEVICE_CLASS_SHUTTER,
|
||||
DEVICE_CLASS_WINDOW,
|
||||
SUPPORT_CLOSE,
|
||||
SUPPORT_CLOSE_TILT,
|
||||
SUPPORT_OPEN,
|
||||
SUPPORT_OPEN_TILT,
|
||||
SUPPORT_SET_POSITION,
|
||||
SUPPORT_SET_TILT_POSITION,
|
||||
SUPPORT_STOP,
|
||||
SUPPORT_STOP_TILT,
|
||||
CoverEntity,
|
||||
)
|
||||
from homeassistant.core import callback
|
||||
@ -69,13 +74,29 @@ class VeluxCover(CoverEntity):
|
||||
@property
|
||||
def supported_features(self):
|
||||
"""Flag supported features."""
|
||||
return SUPPORT_OPEN | SUPPORT_CLOSE | SUPPORT_SET_POSITION | SUPPORT_STOP
|
||||
supported_features = (
|
||||
SUPPORT_OPEN | SUPPORT_CLOSE | SUPPORT_SET_POSITION | SUPPORT_STOP
|
||||
)
|
||||
if self.current_cover_tilt_position is not None:
|
||||
supported_features |= (
|
||||
SUPPORT_OPEN_TILT
|
||||
| SUPPORT_CLOSE_TILT
|
||||
| SUPPORT_SET_TILT_POSITION
|
||||
| SUPPORT_STOP_TILT
|
||||
)
|
||||
return supported_features
|
||||
|
||||
@property
|
||||
def current_cover_position(self):
|
||||
"""Return the current position of the cover."""
|
||||
return 100 - self.node.position.position_percent
|
||||
|
||||
@property
|
||||
def current_cover_tilt_position(self):
|
||||
"""Return the current position of the cover."""
|
||||
if isinstance(self.node, Blind):
|
||||
return 100 - self.node.orientation.position_percent
|
||||
|
||||
@property
|
||||
def device_class(self):
|
||||
"""Define this cover as either awning, blind, garage, gate, shutter or window."""
|
||||
@ -118,3 +139,24 @@ class VeluxCover(CoverEntity):
|
||||
async def async_stop_cover(self, **kwargs):
|
||||
"""Stop the cover."""
|
||||
await self.node.stop(wait_for_completion=False)
|
||||
|
||||
async def async_close_cover_tilt(self, **kwargs):
|
||||
"""Close cover tilt."""
|
||||
await self.node.close_orientation(wait_for_completion=False)
|
||||
|
||||
async def async_open_cover_tilt(self, **kwargs):
|
||||
"""Open cover tilt."""
|
||||
await self.node.open_orientation(wait_for_completion=False)
|
||||
|
||||
async def async_stop_cover_tilt(self, **kwargs):
|
||||
"""Stop cover tilt."""
|
||||
await self.node.stop_orientation(wait_for_completion=False)
|
||||
|
||||
async def async_set_cover_tilt_position(self, **kwargs):
|
||||
"""Move cover tilt to a specific position."""
|
||||
if ATTR_TILT_POSITION in kwargs:
|
||||
position_percent = 100 - kwargs[ATTR_TILT_POSITION]
|
||||
orientation = Position(position_percent=position_percent)
|
||||
await self.node.set_orientation(
|
||||
orientation=orientation, wait_for_completion=False
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user