1 """Representation of an RGB light."""
3 from __future__
import annotations
7 from zwave_me_ws
import ZWaveMeData
20 from .
import ZWaveMeController
21 from .const
import DOMAIN, ZWaveMePlatform
22 from .entity
import ZWaveMeEntity
27 config_entry: ConfigEntry,
28 async_add_entities: AddEntitiesCallback,
30 """Set up the rgb platform."""
34 """Add a new device."""
35 controller = hass.data[DOMAIN][config_entry.entry_id]
45 hass, f
"ZWAVE_ME_NEW_{ZWaveMePlatform.RGB_LIGHT.upper()}", add_new_device
48 hass, f
"ZWAVE_ME_NEW_{ZWaveMePlatform.RGBW_LIGHT.upper()}", add_new_device
51 hass, f
"ZWAVE_ME_NEW_{ZWaveMePlatform.BRIGHTNESS_LIGHT.upper()}", add_new_device
56 """Representation of a ZWaveMe light."""
60 controller: ZWaveMeController,
63 """Initialize the device."""
64 super().
__init__(controller=controller, device=device)
65 if device.deviceType
in [ZWaveMePlatform.RGB_LIGHT, ZWaveMePlatform.RGBW_LIGHT]:
69 self._attr_supported_color_modes: set[ColorMode] = {self.
_attr_color_mode_attr_color_mode}
72 """Turn the device on."""
73 self.
controllercontroller.zwave_api.send_command(self.
devicedevice.id,
"off")
76 """Turn the device on."""
77 color = kwargs.get(ATTR_RGB_COLOR)
80 brightness = kwargs.get(ATTR_BRIGHTNESS)
81 if brightness
is None:
84 self.
controllercontroller.zwave_api.send_command(
85 self.
devicedevice.id, f
"exact?level={round(brightness / 2.55)}"
88 red, green, blue = color
if any(color)
else (255, 255, 255)
89 cmd = f
"exact?red={red}&green={green}&blue={blue}"
94 """Return true if the light is on."""
95 return self.
devicedevice.level ==
"on"
99 """Return the brightness of a device."""
100 return max(self.
devicedevice.color.values())
104 """Return the rgb color value [int, int, int]."""
105 rgb = self.
devicedevice.color
106 return rgb[
"r"], rgb[
"g"], rgb[
"b"]
None turn_on(self, **Any kwargs)
None __init__(self, ZWaveMeController controller, ZWaveMeData device)
None turn_off(self, **Any kwargs)
tuple[int, int, int] rgb_color(self)
None async_setup_entry(HomeAssistant hass, ConfigEntry config_entry, AddEntitiesCallback async_add_entities)
def add_new_device(new_device)
Callable[[], None] async_dispatcher_connect(HomeAssistant hass, str signal, Callable[..., Any] target)