1 """Support for Velux lights."""
3 from __future__
import annotations
7 from pyvlx
import Intensity, LighteningDevice
14 from .const
import DOMAIN
15 from .entity
import VeluxEntity
21 hass: HomeAssistant, config: ConfigEntry, async_add_entities: AddEntitiesCallback
23 """Set up light(s) for Velux platform."""
24 module = hass.data[DOMAIN][config.entry_id]
28 for node
in module.pyvlx.nodes
29 if isinstance(node, LighteningDevice)
34 """Representation of a Velux light."""
36 _attr_supported_color_modes = {ColorMode.BRIGHTNESS}
37 _attr_color_mode = ColorMode.BRIGHTNESS
39 node: LighteningDevice
43 """Return the current brightness."""
44 return int((100 - self.
nodenode.intensity.intensity_percent) * 255 / 100)
48 """Return true if light is on."""
49 return not self.
nodenode.intensity.off
and self.
nodenode.intensity.known
52 """Instruct the light to turn on."""
53 if ATTR_BRIGHTNESS
in kwargs:
54 intensity_percent =
int(100 - kwargs[ATTR_BRIGHTNESS] / 255 * 100)
55 await self.
nodenode.set_intensity(
56 Intensity(intensity_percent=intensity_percent),
57 wait_for_completion=
True,
60 await self.
nodenode.
turn_on(wait_for_completion=
True)
63 """Instruct the light to turn off."""
None async_turn_off(self, **Any kwargs)
None async_turn_on(self, **Any kwargs)
None turn_off(self, **Any kwargs)
None turn_on(self, **Any kwargs)
None async_setup_entry(HomeAssistant hass, ConfigEntry config, AddEntitiesCallback async_add_entities)