mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 22:27:07 +00:00
Fix color mode in wiz light (#110328)
This commit is contained in:
parent
3b409b07e3
commit
6e4fd69326
@ -16,6 +16,7 @@ from homeassistant.components.light import (
|
|||||||
ColorMode,
|
ColorMode,
|
||||||
LightEntity,
|
LightEntity,
|
||||||
LightEntityFeature,
|
LightEntityFeature,
|
||||||
|
filter_supported_color_modes,
|
||||||
)
|
)
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.core import HomeAssistant, callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
@ -72,21 +73,24 @@ class WizBulbEntity(WizToggleEntity, LightEntity):
|
|||||||
"""Representation of WiZ Light bulb."""
|
"""Representation of WiZ Light bulb."""
|
||||||
|
|
||||||
_attr_name = None
|
_attr_name = None
|
||||||
|
_fixed_color_mode: ColorMode | None = None
|
||||||
|
|
||||||
def __init__(self, wiz_data: WizData, name: str) -> None:
|
def __init__(self, wiz_data: WizData, name: str) -> None:
|
||||||
"""Initialize an WiZLight."""
|
"""Initialize an WiZLight."""
|
||||||
super().__init__(wiz_data, name)
|
super().__init__(wiz_data, name)
|
||||||
bulb_type: BulbType = self._device.bulbtype
|
bulb_type: BulbType = self._device.bulbtype
|
||||||
features: Features = bulb_type.features
|
features: Features = bulb_type.features
|
||||||
self._attr_supported_color_modes: set[ColorMode | str] = set()
|
color_modes = {ColorMode.ONOFF}
|
||||||
if features.color:
|
if features.color:
|
||||||
self._attr_supported_color_modes.add(
|
color_modes.add(RGB_WHITE_CHANNELS_COLOR_MODE[bulb_type.white_channels])
|
||||||
RGB_WHITE_CHANNELS_COLOR_MODE[bulb_type.white_channels]
|
|
||||||
)
|
|
||||||
if features.color_tmp:
|
if features.color_tmp:
|
||||||
self._attr_supported_color_modes.add(ColorMode.COLOR_TEMP)
|
color_modes.add(ColorMode.COLOR_TEMP)
|
||||||
if not self._attr_supported_color_modes and features.brightness:
|
if features.brightness:
|
||||||
self._attr_supported_color_modes.add(ColorMode.BRIGHTNESS)
|
color_modes.add(ColorMode.BRIGHTNESS)
|
||||||
|
self._attr_supported_color_modes = filter_supported_color_modes(color_modes)
|
||||||
|
if len(self._attr_supported_color_modes) == 1:
|
||||||
|
# If the light supports only a single color mode, set it now
|
||||||
|
self._attr_color_mode = next(iter(self._attr_supported_color_modes))
|
||||||
self._attr_effect_list = wiz_data.scenes
|
self._attr_effect_list = wiz_data.scenes
|
||||||
if bulb_type.bulb_type != BulbClass.DW:
|
if bulb_type.bulb_type != BulbClass.DW:
|
||||||
kelvin = bulb_type.kelvin_range
|
kelvin = bulb_type.kelvin_range
|
||||||
@ -117,8 +121,6 @@ class WizBulbEntity(WizToggleEntity, LightEntity):
|
|||||||
elif ColorMode.RGBW in color_modes and (rgbw := state.get_rgbw()) is not None:
|
elif ColorMode.RGBW in color_modes and (rgbw := state.get_rgbw()) is not None:
|
||||||
self._attr_rgbw_color = rgbw
|
self._attr_rgbw_color = rgbw
|
||||||
self._attr_color_mode = ColorMode.RGBW
|
self._attr_color_mode = ColorMode.RGBW
|
||||||
else:
|
|
||||||
self._attr_color_mode = ColorMode.BRIGHTNESS
|
|
||||||
self._attr_effect = state.get_scene()
|
self._attr_effect = state.get_scene()
|
||||||
super()._async_update_attrs()
|
super()._async_update_attrs()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user