Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 16 additions & 18 deletions homeassistant/components/wiz/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,8 @@
ATTR_EFFECT,
ATTR_RGBW_COLOR,
ATTR_RGBWW_COLOR,
COLOR_MODE_BRIGHTNESS,
COLOR_MODE_COLOR_TEMP,
COLOR_MODE_RGBW,
COLOR_MODE_RGBWW,
SUPPORT_EFFECT,
ColorMode,
LightEntity,
)
from homeassistant.config_entries import ConfigEntry
Expand All @@ -32,7 +29,7 @@
from .entity import WizToggleEntity
from .models import WizData

RGB_WHITE_CHANNELS_COLOR_MODE = {1: COLOR_MODE_RGBW, 2: COLOR_MODE_RGBWW}
RGB_WHITE_CHANNELS_COLOR_MODE = {1: ColorMode.RGBW, 2: ColorMode.RGBWW}


def _async_pilot_builder(**kwargs: Any) -> PilotBuilder:
Expand Down Expand Up @@ -79,14 +76,15 @@ def __init__(self, wiz_data: WizData, name: str) -> None:
super().__init__(wiz_data, name)
bulb_type: BulbType = self._device.bulbtype
features: Features = bulb_type.features
color_modes = set()
self._attr_supported_color_modes: set[ColorMode | str] = set()
if features.color:
color_modes.add(RGB_WHITE_CHANNELS_COLOR_MODE[bulb_type.white_channels])
self._attr_supported_color_modes.add(
RGB_WHITE_CHANNELS_COLOR_MODE[bulb_type.white_channels]
)
if features.color_tmp:
color_modes.add(COLOR_MODE_COLOR_TEMP)
if not color_modes and features.brightness:
color_modes.add(COLOR_MODE_BRIGHTNESS)
self._attr_supported_color_modes = color_modes
self._attr_supported_color_modes.add(ColorMode.COLOR_TEMP)
if not self._attr_supported_color_modes and features.brightness:
self._attr_supported_color_modes.add(ColorMode.BRIGHTNESS)
self._attr_effect_list = wiz_data.scenes
if bulb_type.bulb_type != BulbClass.DW:
kelvin = bulb_type.kelvin_range
Expand All @@ -104,21 +102,21 @@ def _async_update_attrs(self) -> None:
assert color_modes is not None
if (brightness := state.get_brightness()) is not None:
self._attr_brightness = max(0, min(255, brightness))
if COLOR_MODE_COLOR_TEMP in color_modes and (
if ColorMode.COLOR_TEMP in color_modes and (
color_temp := state.get_colortemp()
):
self._attr_color_mode = COLOR_MODE_COLOR_TEMP
self._attr_color_mode = ColorMode.COLOR_TEMP
self._attr_color_temp = color_temperature_kelvin_to_mired(color_temp)
elif (
COLOR_MODE_RGBWW in color_modes and (rgbww := state.get_rgbww()) is not None
ColorMode.RGBWW in color_modes and (rgbww := state.get_rgbww()) is not None
):
self._attr_rgbww_color = rgbww
self._attr_color_mode = COLOR_MODE_RGBWW
elif COLOR_MODE_RGBW in color_modes and (rgbw := state.get_rgbw()) is not None:
self._attr_color_mode = ColorMode.RGBWW
elif ColorMode.RGBW in color_modes and (rgbw := state.get_rgbw()) is not None:
self._attr_rgbw_color = rgbw
self._attr_color_mode = COLOR_MODE_RGBW
self._attr_color_mode = ColorMode.RGBW
else:
self._attr_color_mode = COLOR_MODE_BRIGHTNESS
self._attr_color_mode = ColorMode.BRIGHTNESS
self._attr_effect = state.get_scene()
super()._async_update_attrs()

Expand Down