diff --git a/homeassistant/components/group/light.py b/homeassistant/components/group/light.py index 671a471318a..96cad7a4914 100644 --- a/homeassistant/components/group/light.py +++ b/homeassistant/components/group/light.py @@ -24,6 +24,7 @@ from homeassistant.components.light import ( ATTR_RGBWW_COLOR, ATTR_SUPPORTED_COLOR_MODES, ATTR_TRANSITION, + ATTR_WHITE, ATTR_WHITE_VALUE, ATTR_XY_COLOR, COLOR_MODE_BRIGHTNESS, @@ -93,6 +94,7 @@ FORWARDED_ATTRIBUTES = frozenset( ATTR_RGBW_COLOR, ATTR_RGBWW_COLOR, ATTR_TRANSITION, + ATTR_WHITE, ATTR_WHITE_VALUE, ATTR_XY_COLOR, } diff --git a/tests/components/group/test_light.py b/tests/components/group/test_light.py index 74275cf0bd2..e7a862ee0ad 100644 --- a/tests/components/group/test_light.py +++ b/tests/components/group/test_light.py @@ -21,6 +21,7 @@ from homeassistant.components.light import ( ATTR_RGBWW_COLOR, ATTR_SUPPORTED_COLOR_MODES, ATTR_TRANSITION, + ATTR_WHITE, ATTR_WHITE_VALUE, ATTR_XY_COLOR, COLOR_MODE_BRIGHTNESS, @@ -29,6 +30,7 @@ from homeassistant.components.light import ( COLOR_MODE_ONOFF, COLOR_MODE_RGBW, COLOR_MODE_RGBWW, + COLOR_MODE_WHITE, DOMAIN as LIGHT_DOMAIN, SERVICE_TOGGLE, SERVICE_TURN_OFF, @@ -442,6 +444,62 @@ async def test_white_value(hass): assert state.attributes[ATTR_WHITE_VALUE] == 100 +async def test_white(hass, enable_custom_integrations): + """Test white reporting.""" + platform = getattr(hass.components, "test.light") + platform.init(empty=True) + + platform.ENTITIES.append(platform.MockLight("test1", STATE_ON)) + platform.ENTITIES.append(platform.MockLight("test2", STATE_ON)) + + entity0 = platform.ENTITIES[0] + entity0.supported_color_modes = {COLOR_MODE_HS, COLOR_MODE_WHITE} + entity0.color_mode = COLOR_MODE_WHITE + entity0.brightness = 255 + + entity1 = platform.ENTITIES[1] + entity1.supported_color_modes = {COLOR_MODE_HS, COLOR_MODE_WHITE} + entity1.color_mode = COLOR_MODE_WHITE + entity1.brightness = 128 + + assert await async_setup_component( + hass, + LIGHT_DOMAIN, + { + LIGHT_DOMAIN: [ + {"platform": "test"}, + { + "platform": DOMAIN, + "entities": ["light.test1", "light.test2"], + }, + ] + }, + ) + await hass.async_block_till_done() + await hass.async_start() + await hass.async_block_till_done() + + state = hass.states.get("light.light_group") + assert state.attributes[ATTR_COLOR_MODE] == "white" + assert state.attributes[ATTR_BRIGHTNESS] == 191 + assert state.attributes[ATTR_SUPPORTED_FEATURES] == 0 + assert state.attributes[ATTR_SUPPORTED_COLOR_MODES] == ["hs", "white"] + + await hass.services.async_call( + "light", + "turn_on", + {"entity_id": ["light.light_group"], ATTR_WHITE: 128}, + blocking=True, + ) + await hass.async_block_till_done() + + state = hass.states.get("light.light_group") + assert state.attributes[ATTR_COLOR_MODE] == "white" + assert state.attributes[ATTR_BRIGHTNESS] == 128 + assert state.attributes[ATTR_SUPPORTED_FEATURES] == 0 + assert state.attributes[ATTR_SUPPORTED_COLOR_MODES] == ["hs", "white"] + + async def test_color_temp(hass, enable_custom_integrations): """Test color temp reporting.""" platform = getattr(hass.components, "test.light") diff --git a/tests/testing_config/custom_components/test/light.py b/tests/testing_config/custom_components/test/light.py index 88ce04bdc92..1b33b1cafbf 100644 --- a/tests/testing_config/custom_components/test/light.py +++ b/tests/testing_config/custom_components/test/light.py @@ -66,3 +66,5 @@ class MockLight(MockToggleEntity, LightEntity): "white_value", ]: setattr(self, key, value) + if key == "white": + setattr(self, "brightness", value)