1 """Support for Abode Security System lights."""
3 from __future__
import annotations
8 from jaraco.abode.devices.light
import Light
21 color_temperature_kelvin_to_mired,
22 color_temperature_mired_to_kelvin,
25 from .
import AbodeSystem
26 from .const
import DOMAIN
27 from .entity
import AbodeDevice
31 hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
33 """Set up Abode light devices."""
34 data: AbodeSystem = hass.data[DOMAIN]
38 for device
in data.abode.get_devices(generic_type=
"light")
43 """Representation of an Abode light."""
49 """Turn on the light."""
50 if ATTR_COLOR_TEMP
in kwargs
and self.
_device_device.is_color_capable:
51 self.
_device_device.set_color_temp(
56 if ATTR_HS_COLOR
in kwargs
and self.
_device_device.is_color_capable:
57 self.
_device_device.set_color(kwargs[ATTR_HS_COLOR])
60 if ATTR_BRIGHTNESS
in kwargs
and self.
_device_device.is_dimmable:
63 self.
_device_device.set_level(ceil(kwargs[ATTR_BRIGHTNESS] * 99 / 255.0))
69 """Turn off the light."""
70 self.
_device_device.switch_off()
74 """Return true if device is on."""
79 """Return the brightness of the light."""
80 if self.
_device_device.is_dimmable
and self.
_device_device.has_brightness:
81 brightness =
int(self.
_device_device.brightness)
84 return 255
if brightness == 100
else ceil(brightness * 255 / 99.0)
89 """Return the color temp of the light."""
90 if self.
_device_device.has_color:
95 def hs_color(self) -> tuple[float, float] | None:
96 """Return the color of the light."""
98 if self.
_device_device.has_color:
104 """Return the color mode of the light."""
105 if self.
_device_device.is_dimmable
and self.
_device_device.is_color_capable:
108 return ColorMode.COLOR_TEMP
109 if self.
_device_device.is_dimmable:
110 return ColorMode.BRIGHTNESS
111 return ColorMode.ONOFF
115 """Flag supported color modes."""
116 if self.
_device_device.is_dimmable
and self.
_device_device.is_color_capable:
117 return {ColorMode.COLOR_TEMP, ColorMode.HS}
118 if self.
_device_device.is_dimmable:
119 return {ColorMode.BRIGHTNESS}
120 return {ColorMode.ONOFF}
tuple[float, float]|None hs_color(self)
int|None color_temp(self)
None turn_off(self, **Any kwargs)
set[str]|None supported_color_modes(self)
None turn_on(self, **Any kwargs)
str|None color_mode(self)
int|None brightness(self)
tuple[float, float]|None hs_color(self)
None async_setup_entry(HomeAssistant hass, ConfigEntry entry, AddEntitiesCallback async_add_entities)
int color_temperature_mired_to_kelvin(float mired_temperature)
int color_temperature_kelvin_to_mired(float kelvin_temperature)