1 """Support for Velux covers."""
3 from __future__
import annotations
5 from typing
import Any, cast
7 from pyvlx
import OpeningDevice, Position
8 from pyvlx.opening_device
import Awning, Blind, GarageDoor, Gate, RollerShutter, Window
21 from .const
import DOMAIN
22 from .entity
import VeluxEntity
28 hass: HomeAssistant, config: ConfigEntry, async_add_entities: AddEntitiesCallback
30 """Set up cover(s) for Velux platform."""
31 module = hass.data[DOMAIN][config.entry_id]
34 for node
in module.pyvlx.nodes
35 if isinstance(node, OpeningDevice)
40 """Representation of a Velux cover."""
45 def __init__(self, node: OpeningDevice, config_entry_id: str) ->
None:
46 """Initialize VeluxCover."""
47 super().
__init__(node, config_entry_id)
49 if isinstance(node, Awning):
51 if isinstance(node, Blind):
54 if isinstance(node, GarageDoor):
56 if isinstance(node, Gate):
58 if isinstance(node, RollerShutter):
60 if isinstance(node, Window):
65 """Flag supported features."""
66 supported_features = (
67 CoverEntityFeature.OPEN
68 | CoverEntityFeature.CLOSE
69 | CoverEntityFeature.SET_POSITION
70 | CoverEntityFeature.STOP
73 supported_features |= (
74 CoverEntityFeature.OPEN_TILT
75 | CoverEntityFeature.CLOSE_TILT
76 | CoverEntityFeature.SET_TILT_POSITION
77 | CoverEntityFeature.STOP_TILT
79 return supported_features
83 """Return the current position of the cover."""
84 return 100 - self.
nodenode.position.position_percent
88 """Return the current position of the cover."""
90 return 100 - cast(Blind, self.
nodenode).orientation.position_percent
95 """Return if the cover is closed."""
96 return self.
nodenode.position.closed
100 """Return if the cover is opening or not."""
101 return self.
nodenode.is_opening
105 """Return if the cover is closing or not."""
106 return self.
nodenode.is_closing
109 """Close the cover."""
110 await self.
nodenode.close(wait_for_completion=
False)
113 """Open the cover."""
114 await self.
nodenode.
open(wait_for_completion=
False)
117 """Move the cover to a specific position."""
118 position_percent = 100 - kwargs[ATTR_POSITION]
120 await self.
nodenode.set_position(
121 Position(position_percent=position_percent), wait_for_completion=
False
125 """Stop the cover."""
126 await self.
nodenode.stop(wait_for_completion=
False)
129 """Close cover tilt."""
130 await cast(Blind, self.
nodenode).close_orientation(wait_for_completion=
False)
133 """Open cover tilt."""
134 await cast(Blind, self.
nodenode).open_orientation(wait_for_completion=
False)
137 """Stop cover tilt."""
138 await cast(Blind, self.
nodenode).stop_orientation(wait_for_completion=
False)
141 """Move cover tilt to a specific position."""
142 position_percent = 100 - kwargs[ATTR_TILT_POSITION]
143 orientation = Position(position_percent=position_percent)
144 await cast(Blind, self.
nodenode).set_orientation(
145 orientation=orientation, wait_for_completion=
False
int|None current_cover_tilt_position(self)
current_cover_tilt_position
CoverEntityFeature supported_features(self)
None async_close_cover_tilt(self, **Any kwargs)
None async_open_cover(self, **Any kwargs)
None async_set_cover_position(self, **Any kwargs)
None async_stop_cover(self, **Any kwargs)
None async_open_cover_tilt(self, **Any kwargs)
None __init__(self, OpeningDevice node, str config_entry_id)
int|None current_cover_tilt_position(self)
None async_close_cover(self, **Any kwargs)
None async_set_cover_tilt_position(self, **Any kwargs)
None async_stop_cover_tilt(self, **Any kwargs)
None open(self, **Any kwargs)
None async_setup_entry(HomeAssistant hass, ConfigEntry config, AddEntitiesCallback async_add_entities)