From 855850cd2f78803970d62b4af41ea62bd1577037 Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Thu, 27 Aug 2026 17:43:31 +0200 Subject: [PATCH] Report a color mode for WiZ bulbs that send no color values (#180420) --- homeassistant/components/wiz/light.py | 7 +++++++ tests/components/wiz/test_light.py | 18 +++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/wiz/light.py b/homeassistant/components/wiz/light.py index 3463091c4b33..0f5aedc69fec 100644 --- a/homeassistant/components/wiz/light.py +++ b/homeassistant/components/wiz/light.py @@ -116,6 +116,13 @@ class WizBulbEntity(WizToggleEntity, LightEntity): elif ColorMode.RGBW in color_modes and (rgbw := state.get_rgbw()) is not None: self._attr_color_mode = ColorMode.RGBW self._attr_rgbw_color = rgbw + elif len(color_modes) == 1: + self._attr_color_mode = next(iter(color_modes)) + else: + # The bulb reports none of the values a color mode is picked from, + # so with more than one to choose from it cannot be told which is + # active. + self._attr_color_mode = ColorMode.UNKNOWN self._attr_effect = effect = state.get_scene() if effect is not None: diff --git a/tests/components/wiz/test_light.py b/tests/components/wiz/test_light.py index be3625858501..b0cac285b97b 100644 --- a/tests/components/wiz/test_light.py +++ b/tests/components/wiz/test_light.py @@ -1,6 +1,6 @@ """Tests for light platform.""" -from pywizlight import PilotBuilder +from pywizlight import PilotBuilder, PilotParser from homeassistant.components.light import ( ATTR_BRIGHTNESS, @@ -10,6 +10,7 @@ from homeassistant.components.light import ( ATTR_RGBW_COLOR, ATTR_RGBWW_COLOR, DOMAIN as LIGHT_DOMAIN, + ColorMode, ) from homeassistant.const import ( ATTR_ENTITY_ID, @@ -27,6 +28,7 @@ from . import ( FAKE_RGBW_BULB, FAKE_RGBWW_BULB, FAKE_TURNABLE_BULB, + _mocked_wizlight, async_push_update, async_setup_integration, ) @@ -234,3 +236,17 @@ async def test_old_firmware_dimmable_light(hass: HomeAssistant) -> None: ) pilot: PilotBuilder = bulb.turn_on.mock_calls[0][1][0] assert pilot.pilot_params == {"dimming": 100} + + +async def test_light_without_any_color_state(hass: HomeAssistant) -> None: + """Test a light reporting no color values still reports a color mode.""" + bulb = _mocked_wizlight(None, None, FAKE_RGBWW_BULB) + # A bulb can report being on without any of the values the color mode is + # otherwise picked from, and there is no color mode to fall back on for a + # bulb that supports more than one. + bulb.state = PilotParser({"mac": FAKE_MAC, "state": True, "dimming": 100}) + await async_setup_integration(hass, wizlight=bulb, bulb_type=FAKE_RGBWW_BULB) + + state = hass.states.get("light.mock_title") + assert state.state == STATE_ON + assert state.attributes[ATTR_COLOR_MODE] == ColorMode.UNKNOWN