1 """Support for Vera lights."""
3 from __future__
import annotations
7 import pyvera
as veraApi
22 from .common
import ControllerData, get_controller_data
23 from .entity
import VeraEntity
29 async_add_entities: AddEntitiesCallback,
31 """Set up the sensor config entry."""
36 for device
in controller_data.devices[Platform.LIGHT]
43 """Representation of a Vera Light, including dimmable."""
46 _attr_hs_color: tuple[float, float] |
None =
None
47 _attr_brightness: int |
None =
None
50 self, vera_device: veraApi.VeraDimmer, controller_data: ControllerData
52 """Initialize the light."""
53 VeraEntity.__init__(self, vera_device, controller_data)
58 """Return the color mode of the light."""
59 if self.vera_device.is_dimmable:
62 return ColorMode.BRIGHTNESS
63 return ColorMode.ONOFF
67 """Flag supported color modes."""
71 """Turn the light on."""
73 rgb = color_util.color_hs_to_RGB(*kwargs[ATTR_HS_COLOR])
74 self.vera_device.set_color(rgb)
75 elif ATTR_BRIGHTNESS
in kwargs
and self.vera_device.is_dimmable:
76 self.vera_device.set_brightness(kwargs[ATTR_BRIGHTNESS])
78 self.vera_device.switch_on()
84 """Turn the light off."""
85 self.vera_device.switch_off()
90 """Call to update state."""
93 if self.vera_device.is_dimmable:
97 rgb = self.vera_device.get_color()
98 self.
_attr_hs_color_attr_hs_color = color_util.color_RGB_to_hs(*rgb)
if rgb
else None
ColorMode|str|None color_mode(self)
None turn_on(self, **Any kwargs)
ColorMode color_mode(self)
None turn_off(self, **Any kwargs)
None __init__(self, veraApi.VeraDimmer vera_device, ControllerData controller_data)
set[ColorMode] supported_color_modes(self)
None schedule_update_ha_state(self, bool force_refresh=False)
ControllerData get_controller_data(HomeAssistant hass, ConfigEntry config_entry)
None async_setup_entry(HomeAssistant hass, ConfigEntry entry, AddEntitiesCallback async_add_entities)