Skip to content

Commit

Permalink
Light: Report color mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Mat931 committed Feb 21, 2024
1 parent 96dc6bd commit 94858bc
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions custom_components/digitalstrom/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,18 +85,20 @@ def __init__(
self.entity_id = f"{DOMAIN}.{self.device.dsuid}_{brightness_channel.index}"
self._attr_name = self.device.name

self._attr_supported_color_modes = set()
color_modes = []
if self.dimmable:
if self.x_channel is not None and self.y_channel is not None:
self._attr_supported_color_modes.add(ColorMode.XY)
color_modes.append(ColorMode.XY)
elif self.hue_channel is not None and self.saturation_channel is not None:
self._attr_supported_color_modes.add(ColorMode.HS)
color_modes.append(ColorMode.HS)
if self.color_temp_channel is not None:
self._attr_supported_color_modes.add(ColorMode.COLOR_TEMP)
if len(self._attr_supported_color_modes) == 0:
self._attr_supported_color_modes.add(ColorMode.BRIGHTNESS)
color_modes.append(ColorMode.COLOR_TEMP)
if len(color_modes) == 0:
color_modes.append(ColorMode.BRIGHTNESS)
else:
self._attr_supported_color_modes.add(ColorMode.ONOFF)
color_modes.append(ColorMode.ONOFF)
self._attr_supported_color_modes = set(color_modes)
self._attr_color_mode = color_modes[0]

async def async_turn_on(self, **kwargs: Any) -> None:
"""Turn the entity on."""
Expand Down

0 comments on commit 94858bc

Please sign in to comment.