From 7d2363ad22e43cc20918655e4878ba0390586d61 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Tue, 26 Apr 2022 16:32:00 +0200 Subject: [PATCH] Use light enums in tests (#70801) --- tests/components/blebox/test_light.py | 9 +- tests/components/bond/test_light.py | 15 +- tests/components/deconz/test_light.py | 95 ++++++------- tests/components/dynalite/test_light.py | 9 +- tests/components/elgato/test_light.py | 13 +- .../components/evil_genius_labs/test_light.py | 10 +- tests/components/flux_led/test_light.py | 18 ++- tests/components/group/test_light.py | 131 +++++++++--------- .../homekit_controller/test_light.py | 22 ++- .../homematicip_cloud/test_light.py | 40 +++--- tests/components/hyperion/test_light.py | 10 +- tests/components/knx/test_light.py | 32 ++--- tests/components/kulersky/test_light.py | 20 +-- tests/components/myq/test_light.py | 7 +- tests/components/senseme/test_light.py | 17 +-- tests/components/switch/test_light.py | 7 +- tests/components/switch_as_x/test_light.py | 6 +- tests/components/template/test_light.py | 4 +- tests/components/zerproc/test_light.py | 18 +-- 19 files changed, 225 insertions(+), 258 deletions(-) diff --git a/tests/components/blebox/test_light.py b/tests/components/blebox/test_light.py index daa4902f7fe..a546424e14b 100644 --- a/tests/components/blebox/test_light.py +++ b/tests/components/blebox/test_light.py @@ -9,8 +9,7 @@ from homeassistant.components.light import ( ATTR_BRIGHTNESS, ATTR_RGBW_COLOR, ATTR_SUPPORTED_COLOR_MODES, - COLOR_MODE_BRIGHTNESS, - COLOR_MODE_RGBW, + ColorMode, ) from homeassistant.const import ( SERVICE_TURN_OFF, @@ -58,7 +57,7 @@ async def test_dimmer_init(dimmer, hass, config): assert state.name == "dimmerBox-brightness" color_modes = state.attributes[ATTR_SUPPORTED_COLOR_MODES] - assert color_modes == [COLOR_MODE_BRIGHTNESS] + assert color_modes == [ColorMode.BRIGHTNESS] assert state.attributes[ATTR_BRIGHTNESS] == 65 assert state.state == STATE_ON @@ -229,7 +228,7 @@ async def test_wlightbox_s_init(wlightbox_s, hass, config): assert state.name == "wLightBoxS-color" color_modes = state.attributes[ATTR_SUPPORTED_COLOR_MODES] - assert color_modes == [COLOR_MODE_BRIGHTNESS] + assert color_modes == [ColorMode.BRIGHTNESS] assert ATTR_BRIGHTNESS not in state.attributes assert state.state == STATE_UNKNOWN @@ -329,7 +328,7 @@ async def test_wlightbox_init(wlightbox, hass, config): assert state.name == "wLightBox-color" color_modes = state.attributes[ATTR_SUPPORTED_COLOR_MODES] - assert color_modes == [COLOR_MODE_RGBW] + assert color_modes == [ColorMode.RGBW] assert ATTR_BRIGHTNESS not in state.attributes assert ATTR_RGBW_COLOR not in state.attributes diff --git a/tests/components/bond/test_light.py b/tests/components/bond/test_light.py index 1e8b50be073..6556c25efe2 100644 --- a/tests/components/bond/test_light.py +++ b/tests/components/bond/test_light.py @@ -20,9 +20,8 @@ from homeassistant.components.light import ( ATTR_BRIGHTNESS, ATTR_COLOR_MODE, ATTR_SUPPORTED_COLOR_MODES, - COLOR_MODE_BRIGHTNESS, - COLOR_MODE_ONOFF, DOMAIN as LIGHT_DOMAIN, + ColorMode, ) from homeassistant.const import ( ATTR_ASSUMED_STATE, @@ -728,7 +727,7 @@ async def test_brightness_support(hass: core.HomeAssistant): state = hass.states.get("light.name_1") assert state.state == "off" assert ATTR_COLOR_MODE not in state.attributes - assert state.attributes[ATTR_SUPPORTED_COLOR_MODES] == [COLOR_MODE_BRIGHTNESS] + assert state.attributes[ATTR_SUPPORTED_COLOR_MODES] == [ColorMode.BRIGHTNESS] assert state.attributes[ATTR_SUPPORTED_FEATURES] == 0 with patch_bond_device_state(return_value={"light": 1, "brightness": 50}): @@ -737,8 +736,8 @@ async def test_brightness_support(hass: core.HomeAssistant): state = hass.states.get("light.name_1") assert state.state == "on" - assert state.attributes[ATTR_COLOR_MODE] == COLOR_MODE_BRIGHTNESS - assert state.attributes[ATTR_SUPPORTED_COLOR_MODES] == [COLOR_MODE_BRIGHTNESS] + assert state.attributes[ATTR_COLOR_MODE] == ColorMode.BRIGHTNESS + assert state.attributes[ATTR_SUPPORTED_COLOR_MODES] == [ColorMode.BRIGHTNESS] assert state.attributes[ATTR_SUPPORTED_FEATURES] == 0 @@ -754,7 +753,7 @@ async def test_brightness_not_supported(hass: core.HomeAssistant): state = hass.states.get("light.name_1") assert state.state == "off" assert ATTR_COLOR_MODE not in state.attributes - assert state.attributes[ATTR_SUPPORTED_COLOR_MODES] == [COLOR_MODE_ONOFF] + assert state.attributes[ATTR_SUPPORTED_COLOR_MODES] == [ColorMode.ONOFF] assert state.attributes[ATTR_SUPPORTED_FEATURES] == 0 with patch_bond_device_state(return_value={"light": 1}): @@ -763,8 +762,8 @@ async def test_brightness_not_supported(hass: core.HomeAssistant): state = hass.states.get("light.name_1") assert state.state == "on" - assert state.attributes[ATTR_COLOR_MODE] == COLOR_MODE_ONOFF - assert state.attributes[ATTR_SUPPORTED_COLOR_MODES] == [COLOR_MODE_ONOFF] + assert state.attributes[ATTR_COLOR_MODE] == ColorMode.ONOFF + assert state.attributes[ATTR_SUPPORTED_COLOR_MODES] == [ColorMode.ONOFF] assert state.attributes[ATTR_SUPPORTED_FEATURES] == 0 diff --git a/tests/components/deconz/test_light.py b/tests/components/deconz/test_light.py index 2405ed159e6..c3dbe79bb6e 100644 --- a/tests/components/deconz/test_light.py +++ b/tests/components/deconz/test_light.py @@ -1,5 +1,4 @@ """deCONZ light platform tests.""" - from unittest.mock import patch import pytest @@ -20,20 +19,14 @@ from homeassistant.components.light import ( ATTR_SUPPORTED_COLOR_MODES, ATTR_TRANSITION, ATTR_XY_COLOR, - COLOR_MODE_BRIGHTNESS, - COLOR_MODE_COLOR_TEMP, - COLOR_MODE_HS, - COLOR_MODE_ONOFF, - COLOR_MODE_XY, DOMAIN as LIGHT_DOMAIN, EFFECT_COLORLOOP, FLASH_LONG, FLASH_SHORT, SERVICE_TURN_OFF, SERVICE_TURN_ON, - SUPPORT_EFFECT, - SUPPORT_FLASH, - SUPPORT_TRANSITION, + ColorMode, + LightEntityFeature, ) from homeassistant.const import ( ATTR_ENTITY_ID, @@ -95,16 +88,16 @@ async def test_no_lights_or_groups(hass, aioclient_mock): ATTR_COLOR_TEMP: 375, ATTR_EFFECT_LIST: [EFFECT_COLORLOOP], ATTR_SUPPORTED_COLOR_MODES: [ - COLOR_MODE_COLOR_TEMP, - COLOR_MODE_HS, - COLOR_MODE_XY, + ColorMode.COLOR_TEMP, + ColorMode.HS, + ColorMode.XY, ], - ATTR_COLOR_MODE: COLOR_MODE_COLOR_TEMP, + ATTR_COLOR_MODE: ColorMode.COLOR_TEMP, ATTR_MIN_MIREDS: 153, ATTR_MAX_MIREDS: 500, - ATTR_SUPPORTED_FEATURES: SUPPORT_TRANSITION - | SUPPORT_FLASH - | SUPPORT_EFFECT, + ATTR_SUPPORTED_FEATURES: LightEntityFeature.TRANSITION + | LightEntityFeature.FLASH + | LightEntityFeature.EFFECT, DECONZ_GROUP: False, }, }, @@ -145,19 +138,19 @@ async def test_no_lights_or_groups(hass, aioclient_mock): ATTR_MAX_MIREDS: 650, ATTR_EFFECT_LIST: [EFFECT_COLORLOOP], ATTR_SUPPORTED_COLOR_MODES: [ - COLOR_MODE_COLOR_TEMP, - COLOR_MODE_HS, - COLOR_MODE_XY, + ColorMode.COLOR_TEMP, + ColorMode.HS, + ColorMode.XY, ], - ATTR_COLOR_MODE: COLOR_MODE_XY, + ATTR_COLOR_MODE: ColorMode.XY, ATTR_BRIGHTNESS: 254, ATTR_HS_COLOR: (29.691, 38.039), ATTR_RGB_COLOR: (255, 206, 158), ATTR_XY_COLOR: (0.427, 0.373), DECONZ_GROUP: False, - ATTR_SUPPORTED_FEATURES: SUPPORT_TRANSITION - | SUPPORT_FLASH - | SUPPORT_EFFECT, + ATTR_SUPPORTED_FEATURES: LightEntityFeature.TRANSITION + | LightEntityFeature.FLASH + | LightEntityFeature.EFFECT, }, }, ), @@ -188,16 +181,16 @@ async def test_no_lights_or_groups(hass, aioclient_mock): "state": STATE_ON, "attributes": { ATTR_EFFECT_LIST: [EFFECT_COLORLOOP], - ATTR_SUPPORTED_COLOR_MODES: [COLOR_MODE_HS], - ATTR_COLOR_MODE: COLOR_MODE_HS, + ATTR_SUPPORTED_COLOR_MODES: [ColorMode.HS], + ATTR_COLOR_MODE: ColorMode.HS, ATTR_BRIGHTNESS: 25, ATTR_HS_COLOR: (294.938, 55.294), ATTR_RGB_COLOR: (243, 113, 255), ATTR_XY_COLOR: (0.357, 0.188), DECONZ_GROUP: False, - ATTR_SUPPORTED_FEATURES: SUPPORT_TRANSITION - | SUPPORT_FLASH - | SUPPORT_EFFECT, + ATTR_SUPPORTED_FEATURES: LightEntityFeature.TRANSITION + | LightEntityFeature.FLASH + | LightEntityFeature.EFFECT, }, }, ), @@ -231,12 +224,13 @@ async def test_no_lights_or_groups(hass, aioclient_mock): "attributes": { ATTR_MIN_MIREDS: 153, ATTR_MAX_MIREDS: 454, - ATTR_SUPPORTED_COLOR_MODES: [COLOR_MODE_COLOR_TEMP], - ATTR_COLOR_MODE: COLOR_MODE_COLOR_TEMP, + ATTR_SUPPORTED_COLOR_MODES: [ColorMode.COLOR_TEMP], + ATTR_COLOR_MODE: ColorMode.COLOR_TEMP, ATTR_BRIGHTNESS: 254, ATTR_COLOR_TEMP: 396, DECONZ_GROUP: False, - ATTR_SUPPORTED_FEATURES: SUPPORT_TRANSITION | SUPPORT_FLASH, + ATTR_SUPPORTED_FEATURES: LightEntityFeature.TRANSITION + | LightEntityFeature.FLASH, }, }, ), @@ -258,11 +252,12 @@ async def test_no_lights_or_groups(hass, aioclient_mock): "entity_id": "light.hue_filament", "state": STATE_ON, "attributes": { - ATTR_SUPPORTED_COLOR_MODES: [COLOR_MODE_BRIGHTNESS], - ATTR_COLOR_MODE: COLOR_MODE_BRIGHTNESS, + ATTR_SUPPORTED_COLOR_MODES: [ColorMode.BRIGHTNESS], + ATTR_COLOR_MODE: ColorMode.BRIGHTNESS, ATTR_BRIGHTNESS: 254, DECONZ_GROUP: False, - ATTR_SUPPORTED_FEATURES: SUPPORT_TRANSITION | SUPPORT_FLASH, + ATTR_SUPPORTED_FEATURES: LightEntityFeature.TRANSITION + | LightEntityFeature.FLASH, }, }, ), @@ -284,8 +279,8 @@ async def test_no_lights_or_groups(hass, aioclient_mock): "entity_id": "light.simple_light", "state": STATE_ON, "attributes": { - ATTR_SUPPORTED_COLOR_MODES: [COLOR_MODE_ONOFF], - ATTR_COLOR_MODE: COLOR_MODE_ONOFF, + ATTR_SUPPORTED_COLOR_MODES: [ColorMode.ONOFF], + ATTR_COLOR_MODE: ColorMode.ONOFF, DECONZ_GROUP: False, ATTR_SUPPORTED_FEATURES: 0, }, @@ -706,8 +701,8 @@ async def test_configuration_tool(hass, aioclient_mock): "attributes": { ATTR_MIN_MIREDS: 153, ATTR_MAX_MIREDS: 500, - ATTR_SUPPORTED_COLOR_MODES: [COLOR_MODE_COLOR_TEMP, COLOR_MODE_XY], - ATTR_COLOR_MODE: COLOR_MODE_COLOR_TEMP, + ATTR_SUPPORTED_COLOR_MODES: [ColorMode.COLOR_TEMP, ColorMode.XY], + ATTR_COLOR_MODE: ColorMode.COLOR_TEMP, ATTR_BRIGHTNESS: 255, ATTR_EFFECT_LIST: [EFFECT_COLORLOOP], "all_on": False, @@ -726,15 +721,15 @@ async def test_configuration_tool(hass, aioclient_mock): "attributes": { ATTR_MIN_MIREDS: 153, ATTR_MAX_MIREDS: 500, - ATTR_SUPPORTED_COLOR_MODES: [COLOR_MODE_COLOR_TEMP, COLOR_MODE_XY], - ATTR_COLOR_MODE: COLOR_MODE_COLOR_TEMP, + ATTR_SUPPORTED_COLOR_MODES: [ColorMode.COLOR_TEMP, ColorMode.XY], + ATTR_COLOR_MODE: ColorMode.COLOR_TEMP, ATTR_BRIGHTNESS: 50, ATTR_EFFECT_LIST: [EFFECT_COLORLOOP], "all_on": False, DECONZ_GROUP: True, - ATTR_SUPPORTED_FEATURES: SUPPORT_TRANSITION - | SUPPORT_FLASH - | SUPPORT_EFFECT, + ATTR_SUPPORTED_FEATURES: LightEntityFeature.TRANSITION + | LightEntityFeature.FLASH + | LightEntityFeature.EFFECT, }, }, ), @@ -748,16 +743,16 @@ async def test_configuration_tool(hass, aioclient_mock): "attributes": { ATTR_MIN_MIREDS: 153, ATTR_MAX_MIREDS: 500, - ATTR_SUPPORTED_COLOR_MODES: [COLOR_MODE_COLOR_TEMP, COLOR_MODE_XY], - ATTR_COLOR_MODE: COLOR_MODE_XY, + ATTR_SUPPORTED_COLOR_MODES: [ColorMode.COLOR_TEMP, ColorMode.XY], + ATTR_COLOR_MODE: ColorMode.XY, ATTR_HS_COLOR: (52.0, 100.0), ATTR_RGB_COLOR: (255, 221, 0), ATTR_XY_COLOR: (0.5, 0.5), "all_on": False, DECONZ_GROUP: True, - ATTR_SUPPORTED_FEATURES: SUPPORT_TRANSITION - | SUPPORT_FLASH - | SUPPORT_EFFECT, + ATTR_SUPPORTED_FEATURES: LightEntityFeature.TRANSITION + | LightEntityFeature.FLASH + | LightEntityFeature.EFFECT, }, }, ), @@ -1221,5 +1216,7 @@ async def test_verify_group_supported_features(hass, aioclient_mock): assert hass.states.get("light.group").state == STATE_ON assert ( hass.states.get("light.group").attributes[ATTR_SUPPORTED_FEATURES] - == SUPPORT_TRANSITION | SUPPORT_FLASH | SUPPORT_EFFECT + == LightEntityFeature.TRANSITION + | LightEntityFeature.FLASH + | LightEntityFeature.EFFECT ) diff --git a/tests/components/dynalite/test_light.py b/tests/components/dynalite/test_light.py index 17ce4dd5f53..b100cf8d3f6 100644 --- a/tests/components/dynalite/test_light.py +++ b/tests/components/dynalite/test_light.py @@ -1,12 +1,11 @@ """Test Dynalite light.""" - from dynalite_devices_lib.light import DynaliteChannelLightDevice import pytest from homeassistant.components.light import ( ATTR_COLOR_MODE, ATTR_SUPPORTED_COLOR_MODES, - COLOR_MODE_BRIGHTNESS, + ColorMode, ) from homeassistant.const import ( ATTR_FRIENDLY_NAME, @@ -36,10 +35,8 @@ async def test_light_setup(hass, mock_device): entity_state = hass.states.get("light.name") assert entity_state.attributes[ATTR_FRIENDLY_NAME] == mock_device.name assert entity_state.attributes["brightness"] == mock_device.brightness - assert entity_state.attributes[ATTR_COLOR_MODE] == COLOR_MODE_BRIGHTNESS - assert entity_state.attributes[ATTR_SUPPORTED_COLOR_MODES] == [ - COLOR_MODE_BRIGHTNESS - ] + assert entity_state.attributes[ATTR_COLOR_MODE] == ColorMode.BRIGHTNESS + assert entity_state.attributes[ATTR_SUPPORTED_COLOR_MODES] == [ColorMode.BRIGHTNESS] assert entity_state.attributes[ATTR_SUPPORTED_FEATURES] == 0 await run_service_tests( hass, diff --git a/tests/components/elgato/test_light.py b/tests/components/elgato/test_light.py index 63701721a1c..743abc1ad49 100644 --- a/tests/components/elgato/test_light.py +++ b/tests/components/elgato/test_light.py @@ -13,9 +13,8 @@ from homeassistant.components.light import ( ATTR_MAX_MIREDS, ATTR_MIN_MIREDS, ATTR_SUPPORTED_COLOR_MODES, - COLOR_MODE_COLOR_TEMP, - COLOR_MODE_HS, DOMAIN as LIGHT_DOMAIN, + ColorMode, ) from homeassistant.const import ( ATTR_ENTITY_ID, @@ -45,10 +44,10 @@ async def test_light_state_temperature( assert state.attributes.get(ATTR_BRIGHTNESS) == 54 assert state.attributes.get(ATTR_COLOR_TEMP) == 297 assert state.attributes.get(ATTR_HS_COLOR) == (27.316, 47.743) - assert state.attributes.get(ATTR_COLOR_MODE) == COLOR_MODE_COLOR_TEMP + assert state.attributes.get(ATTR_COLOR_MODE) == ColorMode.COLOR_TEMP assert state.attributes.get(ATTR_MIN_MIREDS) == 143 assert state.attributes.get(ATTR_MAX_MIREDS) == 344 - assert state.attributes.get(ATTR_SUPPORTED_COLOR_MODES) == [COLOR_MODE_COLOR_TEMP] + assert state.attributes.get(ATTR_SUPPORTED_COLOR_MODES) == [ColorMode.COLOR_TEMP] assert state.state == STATE_ON entry = entity_registry.async_get("light.frenck") @@ -90,10 +89,10 @@ async def test_light_state_color( assert state.attributes.get(ATTR_HS_COLOR) == (358.0, 6.0) assert state.attributes.get(ATTR_MIN_MIREDS) == 153 assert state.attributes.get(ATTR_MAX_MIREDS) == 285 - assert state.attributes.get(ATTR_COLOR_MODE) == COLOR_MODE_HS + assert state.attributes.get(ATTR_COLOR_MODE) == ColorMode.HS assert state.attributes.get(ATTR_SUPPORTED_COLOR_MODES) == [ - COLOR_MODE_COLOR_TEMP, - COLOR_MODE_HS, + ColorMode.COLOR_TEMP, + ColorMode.HS, ] assert state.state == STATE_ON diff --git a/tests/components/evil_genius_labs/test_light.py b/tests/components/evil_genius_labs/test_light.py index 746afa10785..9c304e47e98 100644 --- a/tests/components/evil_genius_labs/test_light.py +++ b/tests/components/evil_genius_labs/test_light.py @@ -6,8 +6,8 @@ import pytest from homeassistant.components.light import ( ATTR_COLOR_MODE, ATTR_SUPPORTED_COLOR_MODES, - COLOR_MODE_RGB, - SUPPORT_EFFECT, + ColorMode, + LightEntityFeature, ) from homeassistant.const import ATTR_SUPPORTED_FEATURES @@ -19,9 +19,9 @@ async def test_works(hass, setup_evil_genius_labs): assert state is not None assert state.state == "on" assert state.attributes["brightness"] == 128 - assert state.attributes[ATTR_COLOR_MODE] == COLOR_MODE_RGB - assert state.attributes[ATTR_SUPPORTED_COLOR_MODES] == [COLOR_MODE_RGB] - assert state.attributes[ATTR_SUPPORTED_FEATURES] == SUPPORT_EFFECT + assert state.attributes[ATTR_COLOR_MODE] == ColorMode.RGB + assert state.attributes[ATTR_SUPPORTED_COLOR_MODES] == [ColorMode.RGB] + assert state.attributes[ATTR_SUPPORTED_FEATURES] == LightEntityFeature.EFFECT @pytest.mark.parametrize("platforms", [("light",)]) diff --git a/tests/components/flux_led/test_light.py b/tests/components/flux_led/test_light.py index 67603544c5d..4ff827335a9 100644 --- a/tests/components/flux_led/test_light.py +++ b/tests/components/flux_led/test_light.py @@ -50,10 +50,8 @@ from homeassistant.components.light import ( ATTR_RGBWW_COLOR, ATTR_SUPPORTED_COLOR_MODES, ATTR_WHITE, - COLOR_MODE_RGB, - COLOR_MODE_RGBW, - COLOR_MODE_RGBWW, DOMAIN as LIGHT_DOMAIN, + ColorMode, ) from homeassistant.const import ( ATTR_ENTITY_ID, @@ -318,9 +316,9 @@ async def test_rgb_light_auto_on(hass: HomeAssistant) -> None: assert state.state == STATE_ON attributes = state.attributes assert attributes[ATTR_BRIGHTNESS] == 128 - assert attributes[ATTR_COLOR_MODE] == COLOR_MODE_RGB + assert attributes[ATTR_COLOR_MODE] == ColorMode.RGB assert attributes[ATTR_EFFECT_LIST] == bulb.effect_list - assert attributes[ATTR_SUPPORTED_COLOR_MODES] == [COLOR_MODE_RGB] + assert attributes[ATTR_SUPPORTED_COLOR_MODES] == [ColorMode.RGB] assert attributes[ATTR_HS_COLOR] == (0, 100) await hass.services.async_call( @@ -451,9 +449,9 @@ async def test_rgbw_light_auto_on(hass: HomeAssistant) -> None: assert state.state == STATE_ON attributes = state.attributes assert attributes[ATTR_BRIGHTNESS] == 128 - assert attributes[ATTR_COLOR_MODE] == COLOR_MODE_RGBW + assert attributes[ATTR_COLOR_MODE] == ColorMode.RGBW assert attributes[ATTR_EFFECT_LIST] == bulb.effect_list - assert attributes[ATTR_SUPPORTED_COLOR_MODES] == [COLOR_MODE_RGBW] + assert attributes[ATTR_SUPPORTED_COLOR_MODES] == [ColorMode.RGBW] assert attributes[ATTR_HS_COLOR] == (0.0, 83.529) await hass.services.async_call( @@ -586,9 +584,9 @@ async def test_rgbww_light_auto_on(hass: HomeAssistant) -> None: assert state.state == STATE_ON attributes = state.attributes assert attributes[ATTR_BRIGHTNESS] == 128 - assert attributes[ATTR_COLOR_MODE] == COLOR_MODE_RGBWW + assert attributes[ATTR_COLOR_MODE] == ColorMode.RGBWW assert attributes[ATTR_EFFECT_LIST] == bulb.effect_list - assert attributes[ATTR_SUPPORTED_COLOR_MODES] == [COLOR_MODE_RGBWW] + assert attributes[ATTR_SUPPORTED_COLOR_MODES] == [ColorMode.RGBWW] assert attributes[ATTR_HS_COLOR] == (3.237, 94.51) await hass.services.async_call( @@ -1304,7 +1302,7 @@ async def test_rgbcw_light(hass: HomeAssistant) -> None: await async_mock_device_turn_on(hass, bulb) state = hass.states.get(entity_id) assert state.state == STATE_ON - assert state.attributes[ATTR_COLOR_MODE] == COLOR_MODE_RGBWW + assert state.attributes[ATTR_COLOR_MODE] == ColorMode.RGBWW assert state.attributes[ATTR_BRIGHTNESS] == 1 await hass.services.async_call( diff --git a/tests/components/group/test_light.py b/tests/components/group/test_light.py index 0f125dd3e88..d5f7abedb44 100644 --- a/tests/components/group/test_light.py +++ b/tests/components/group/test_light.py @@ -27,14 +27,6 @@ from homeassistant.components.light import ( ATTR_WHITE, ATTR_WHITE_VALUE, ATTR_XY_COLOR, - COLOR_MODE_BRIGHTNESS, - COLOR_MODE_COLOR_TEMP, - COLOR_MODE_HS, - COLOR_MODE_ONOFF, - COLOR_MODE_RGB, - COLOR_MODE_RGBW, - COLOR_MODE_RGBWW, - COLOR_MODE_WHITE, DOMAIN as LIGHT_DOMAIN, SERVICE_TOGGLE, SERVICE_TURN_OFF, @@ -42,6 +34,7 @@ from homeassistant.components.light import ( SUPPORT_BRIGHTNESS, SUPPORT_COLOR, SUPPORT_COLOR_TEMP, + ColorMode, ) from homeassistant.const import ( ATTR_ENTITY_ID, @@ -185,8 +178,8 @@ async def test_brightness(hass, enable_custom_integrations): platform.ENTITIES.append(platform.MockLight("test2", STATE_OFF)) entity0 = platform.ENTITIES[0] - entity0.supported_color_modes = {COLOR_MODE_BRIGHTNESS} - entity0.color_mode = COLOR_MODE_BRIGHTNESS + entity0.supported_color_modes = {ColorMode.BRIGHTNESS} + entity0.color_mode = ColorMode.BRIGHTNESS entity0.brightness = 255 entity1 = platform.ENTITIES[1] @@ -255,8 +248,8 @@ async def test_color_hs(hass, enable_custom_integrations): platform.ENTITIES.append(platform.MockLight("test2", STATE_OFF)) entity0 = platform.ENTITIES[0] - entity0.supported_color_modes = {COLOR_MODE_HS} - entity0.color_mode = COLOR_MODE_HS + entity0.supported_color_modes = {ColorMode.HS} + entity0.color_mode = ColorMode.HS entity0.brightness = 255 entity0.hs_color = (0, 100) @@ -324,14 +317,14 @@ async def test_color_rgb(hass, enable_custom_integrations): platform.ENTITIES.append(platform.MockLight("test2", STATE_OFF)) entity0 = platform.ENTITIES[0] - entity0.supported_color_modes = {COLOR_MODE_RGB} - entity0.color_mode = COLOR_MODE_RGB + entity0.supported_color_modes = {ColorMode.RGB} + entity0.color_mode = ColorMode.RGB entity0.brightness = 255 entity0.rgb_color = (0, 64, 128) entity1 = platform.ENTITIES[1] - entity1.supported_color_modes = {COLOR_MODE_RGB} - entity1.color_mode = COLOR_MODE_RGB + entity1.supported_color_modes = {ColorMode.RGB} + entity1.color_mode = ColorMode.RGB entity1.brightness = 255 entity1.rgb_color = (255, 128, 64) @@ -396,14 +389,14 @@ async def test_color_rgbw(hass, enable_custom_integrations): platform.ENTITIES.append(platform.MockLight("test2", STATE_OFF)) entity0 = platform.ENTITIES[0] - entity0.supported_color_modes = {COLOR_MODE_RGBW} - entity0.color_mode = COLOR_MODE_RGBW + entity0.supported_color_modes = {ColorMode.RGBW} + entity0.color_mode = ColorMode.RGBW entity0.brightness = 255 entity0.rgbw_color = (0, 64, 128, 255) entity1 = platform.ENTITIES[1] - entity1.supported_color_modes = {COLOR_MODE_RGBW} - entity1.color_mode = COLOR_MODE_RGBW + entity1.supported_color_modes = {ColorMode.RGBW} + entity1.color_mode = ColorMode.RGBW entity1.brightness = 255 entity1.rgbw_color = (255, 128, 64, 0) @@ -468,14 +461,14 @@ async def test_color_rgbww(hass, enable_custom_integrations): platform.ENTITIES.append(platform.MockLight("test2", STATE_OFF)) entity0 = platform.ENTITIES[0] - entity0.supported_color_modes = {COLOR_MODE_RGBWW} - entity0.color_mode = COLOR_MODE_RGBWW + entity0.supported_color_modes = {ColorMode.RGBWW} + entity0.color_mode = ColorMode.RGBWW entity0.brightness = 255 entity0.rgbww_color = (0, 32, 64, 128, 255) entity1 = platform.ENTITIES[1] - entity1.supported_color_modes = {COLOR_MODE_RGBWW} - entity1.color_mode = COLOR_MODE_RGBWW + entity1.supported_color_modes = {ColorMode.RGBWW} + entity1.color_mode = ColorMode.RGBWW entity1.brightness = 255 entity1.rgbww_color = (255, 128, 64, 32, 0) @@ -582,13 +575,13 @@ async def test_white(hass, enable_custom_integrations): 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.supported_color_modes = {ColorMode.HS, ColorMode.WHITE} + entity0.color_mode = ColorMode.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.supported_color_modes = {ColorMode.HS, ColorMode.WHITE} + entity1.color_mode = ColorMode.WHITE entity1.brightness = 128 assert await async_setup_component( @@ -639,8 +632,8 @@ async def test_color_temp(hass, enable_custom_integrations): platform.ENTITIES.append(platform.MockLight("test2", STATE_OFF)) entity0 = platform.ENTITIES[0] - entity0.supported_color_modes = {COLOR_MODE_COLOR_TEMP} - entity0.color_mode = COLOR_MODE_COLOR_TEMP + entity0.supported_color_modes = {ColorMode.COLOR_TEMP} + entity0.color_mode = ColorMode.COLOR_TEMP entity0.brightness = 255 entity0.color_temp = 2 @@ -708,16 +701,16 @@ async def test_emulated_color_temp_group(hass, enable_custom_integrations): platform.ENTITIES.append(platform.MockLight("test3", STATE_OFF)) entity0 = platform.ENTITIES[0] - entity0.supported_color_modes = {COLOR_MODE_COLOR_TEMP} - entity0.color_mode = COLOR_MODE_COLOR_TEMP + entity0.supported_color_modes = {ColorMode.COLOR_TEMP} + entity0.color_mode = ColorMode.COLOR_TEMP entity1 = platform.ENTITIES[1] - entity1.supported_color_modes = {COLOR_MODE_COLOR_TEMP, COLOR_MODE_HS} - entity1.color_mode = COLOR_MODE_COLOR_TEMP + entity1.supported_color_modes = {ColorMode.COLOR_TEMP, ColorMode.HS} + entity1.color_mode = ColorMode.COLOR_TEMP entity2 = platform.ENTITIES[2] - entity2.supported_color_modes = {COLOR_MODE_HS} - entity2.color_mode = COLOR_MODE_HS + entity2.supported_color_modes = {ColorMode.HS} + entity2.color_mode = ColorMode.HS assert await async_setup_component( hass, @@ -774,8 +767,8 @@ async def test_min_max_mireds(hass, enable_custom_integrations): platform.ENTITIES.append(platform.MockLight("test2", STATE_OFF)) entity0 = platform.ENTITIES[0] - entity0.supported_color_modes = {COLOR_MODE_COLOR_TEMP} - entity0.color_mode = COLOR_MODE_COLOR_TEMP + entity0.supported_color_modes = {ColorMode.COLOR_TEMP} + entity0.color_mode = ColorMode.COLOR_TEMP entity0.color_temp = 2 entity0.min_mireds = 2 entity0.max_mireds = 5 @@ -950,10 +943,10 @@ async def test_supported_color_modes(hass, enable_custom_integrations): platform.ENTITIES.append(platform.MockLight("test3", STATE_OFF)) entity0 = platform.ENTITIES[0] - entity0.supported_color_modes = {COLOR_MODE_COLOR_TEMP, COLOR_MODE_HS} + entity0.supported_color_modes = {ColorMode.COLOR_TEMP, ColorMode.HS} entity1 = platform.ENTITIES[1] - entity1.supported_color_modes = {COLOR_MODE_RGBW, COLOR_MODE_RGBWW} + entity1.supported_color_modes = {ColorMode.RGBW, ColorMode.RGBWW} entity2 = platform.ENTITIES[2] entity2.supported_features = SUPPORT_BRIGHTNESS @@ -996,16 +989,16 @@ async def test_color_mode(hass, enable_custom_integrations): platform.ENTITIES.append(platform.MockLight("test3", STATE_OFF)) entity0 = platform.ENTITIES[0] - entity0.supported_color_modes = {COLOR_MODE_COLOR_TEMP, COLOR_MODE_HS} - entity0.color_mode = COLOR_MODE_COLOR_TEMP + entity0.supported_color_modes = {ColorMode.COLOR_TEMP, ColorMode.HS} + entity0.color_mode = ColorMode.COLOR_TEMP entity1 = platform.ENTITIES[1] - entity1.supported_color_modes = {COLOR_MODE_COLOR_TEMP, COLOR_MODE_HS} - entity1.color_mode = COLOR_MODE_COLOR_TEMP + entity1.supported_color_modes = {ColorMode.COLOR_TEMP, ColorMode.HS} + entity1.color_mode = ColorMode.COLOR_TEMP entity2 = platform.ENTITIES[2] - entity2.supported_color_modes = {COLOR_MODE_COLOR_TEMP, COLOR_MODE_HS} - entity2.color_mode = COLOR_MODE_HS + entity2.supported_color_modes = {ColorMode.COLOR_TEMP, ColorMode.HS} + entity2.color_mode = ColorMode.HS assert await async_setup_component( hass, @@ -1026,7 +1019,7 @@ async def test_color_mode(hass, enable_custom_integrations): await hass.async_block_till_done() state = hass.states.get("light.light_group") - assert state.attributes[ATTR_COLOR_MODE] == COLOR_MODE_COLOR_TEMP + assert state.attributes[ATTR_COLOR_MODE] == ColorMode.COLOR_TEMP await hass.services.async_call( "light", @@ -1036,7 +1029,7 @@ async def test_color_mode(hass, enable_custom_integrations): ) await hass.async_block_till_done() state = hass.states.get("light.light_group") - assert state.attributes[ATTR_COLOR_MODE] == COLOR_MODE_COLOR_TEMP + assert state.attributes[ATTR_COLOR_MODE] == ColorMode.COLOR_TEMP await hass.services.async_call( "light", @@ -1046,7 +1039,7 @@ async def test_color_mode(hass, enable_custom_integrations): ) await hass.async_block_till_done() state = hass.states.get("light.light_group") - assert state.attributes[ATTR_COLOR_MODE] == COLOR_MODE_COLOR_TEMP + assert state.attributes[ATTR_COLOR_MODE] == ColorMode.COLOR_TEMP await hass.services.async_call( "light", @@ -1056,7 +1049,7 @@ async def test_color_mode(hass, enable_custom_integrations): ) await hass.async_block_till_done() state = hass.states.get("light.light_group") - assert state.attributes[ATTR_COLOR_MODE] == COLOR_MODE_HS + assert state.attributes[ATTR_COLOR_MODE] == ColorMode.HS async def test_color_mode2(hass, enable_custom_integrations): @@ -1072,28 +1065,28 @@ async def test_color_mode2(hass, enable_custom_integrations): platform.ENTITIES.append(platform.MockLight("test6", STATE_ON)) entity = platform.ENTITIES[0] - entity.supported_color_modes = {COLOR_MODE_COLOR_TEMP} - entity.color_mode = COLOR_MODE_COLOR_TEMP + entity.supported_color_modes = {ColorMode.COLOR_TEMP} + entity.color_mode = ColorMode.COLOR_TEMP entity = platform.ENTITIES[1] - entity.supported_color_modes = {COLOR_MODE_BRIGHTNESS} - entity.color_mode = COLOR_MODE_BRIGHTNESS + entity.supported_color_modes = {ColorMode.BRIGHTNESS} + entity.color_mode = ColorMode.BRIGHTNESS entity = platform.ENTITIES[2] - entity.supported_color_modes = {COLOR_MODE_BRIGHTNESS} - entity.color_mode = COLOR_MODE_BRIGHTNESS + entity.supported_color_modes = {ColorMode.BRIGHTNESS} + entity.color_mode = ColorMode.BRIGHTNESS entity = platform.ENTITIES[3] - entity.supported_color_modes = {COLOR_MODE_ONOFF} - entity.color_mode = COLOR_MODE_ONOFF + entity.supported_color_modes = {ColorMode.ONOFF} + entity.color_mode = ColorMode.ONOFF entity = platform.ENTITIES[4] - entity.supported_color_modes = {COLOR_MODE_ONOFF} - entity.color_mode = COLOR_MODE_ONOFF + entity.supported_color_modes = {ColorMode.ONOFF} + entity.color_mode = ColorMode.ONOFF entity = platform.ENTITIES[5] - entity.supported_color_modes = {COLOR_MODE_ONOFF} - entity.color_mode = COLOR_MODE_ONOFF + entity.supported_color_modes = {ColorMode.ONOFF} + entity.color_mode = ColorMode.ONOFF assert await async_setup_component( hass, @@ -1121,7 +1114,7 @@ async def test_color_mode2(hass, enable_custom_integrations): await hass.async_block_till_done() state = hass.states.get("light.light_group") - assert state.attributes[ATTR_COLOR_MODE] == COLOR_MODE_COLOR_TEMP + assert state.attributes[ATTR_COLOR_MODE] == ColorMode.COLOR_TEMP await hass.services.async_call( "light", @@ -1131,7 +1124,7 @@ async def test_color_mode2(hass, enable_custom_integrations): ) await hass.async_block_till_done() state = hass.states.get("light.light_group") - assert state.attributes[ATTR_COLOR_MODE] == COLOR_MODE_BRIGHTNESS + assert state.attributes[ATTR_COLOR_MODE] == ColorMode.BRIGHTNESS async def test_supported_features(hass): @@ -1157,18 +1150,18 @@ async def test_supported_features(hass): assert state.attributes[ATTR_SUPPORTED_FEATURES] == 0 # SUPPORT_COLOR_TEMP = 2 - # SUPPORT_COLOR_TEMP = 2 will be blocked in favour of COLOR_MODE_COLOR_TEMP + # SUPPORT_COLOR_TEMP = 2 will be blocked in favour of ColorMode.COLOR_TEMP hass.states.async_set("light.test2", STATE_ON, {ATTR_SUPPORTED_FEATURES: 2}) await hass.async_block_till_done() state = hass.states.get("light.light_group") assert state.attributes[ATTR_SUPPORTED_FEATURES] == 0 - # SUPPORT_TRANSITION | SUPPORT_FLASH | SUPPORT_BRIGHTNESS = 41 - # SUPPORT_BRIGHTNESS = 1 will be translated to COLOR_MODE_BRIGHTNESS + # LightEntityFeature.TRANSITION | LightEntityFeature.FLASH | SUPPORT_BRIGHTNESS = 41 + # SUPPORT_BRIGHTNESS = 1 will be translated to ColorMode.BRIGHTNESS hass.states.async_set("light.test1", STATE_OFF, {ATTR_SUPPORTED_FEATURES: 41}) await hass.async_block_till_done() state = hass.states.get("light.light_group") - # SUPPORT_TRANSITION | SUPPORT_FLASH = 40 + # LightEntityFeature.TRANSITION | LightEntityFeature.FLASH = 40 assert state.attributes[ATTR_SUPPORTED_FEATURES] == 40 # Test that unknown feature 256 is blocked @@ -1178,7 +1171,7 @@ async def test_supported_features(hass): assert state.attributes[ATTR_SUPPORTED_FEATURES] == 40 -@pytest.mark.parametrize("supported_color_modes", [COLOR_MODE_HS, COLOR_MODE_RGB]) +@pytest.mark.parametrize("supported_color_modes", [ColorMode.HS, ColorMode.RGB]) async def test_service_calls(hass, enable_custom_integrations, supported_color_modes): """Test service calls.""" platform = getattr(hass.components, "test.light") diff --git a/tests/components/homekit_controller/test_light.py b/tests/components/homekit_controller/test_light.py index 51e11feda60..39e44c57cc5 100644 --- a/tests/components/homekit_controller/test_light.py +++ b/tests/components/homekit_controller/test_light.py @@ -6,9 +6,7 @@ from homeassistant.components.homekit_controller.const import KNOWN_DEVICES from homeassistant.components.light import ( ATTR_COLOR_MODE, ATTR_SUPPORTED_COLOR_MODES, - COLOR_MODE_BRIGHTNESS, - COLOR_MODE_COLOR_TEMP, - COLOR_MODE_HS, + ColorMode, ) from homeassistant.const import ATTR_SUPPORTED_FEATURES, STATE_UNAVAILABLE @@ -113,7 +111,7 @@ async def test_switch_read_light_state_dimmer(hass, utcnow): state = await helper.poll_and_get_state() assert state.state == "off" assert ATTR_COLOR_MODE not in state.attributes - assert state.attributes[ATTR_SUPPORTED_COLOR_MODES] == [COLOR_MODE_BRIGHTNESS] + assert state.attributes[ATTR_SUPPORTED_COLOR_MODES] == [ColorMode.BRIGHTNESS] assert state.attributes[ATTR_SUPPORTED_FEATURES] == 0 # Simulate that someone switched on the device in the real world not via HA @@ -126,8 +124,8 @@ async def test_switch_read_light_state_dimmer(hass, utcnow): ) assert state.state == "on" assert state.attributes["brightness"] == 255 - assert state.attributes[ATTR_COLOR_MODE] == COLOR_MODE_BRIGHTNESS - assert state.attributes[ATTR_SUPPORTED_COLOR_MODES] == [COLOR_MODE_BRIGHTNESS] + assert state.attributes[ATTR_COLOR_MODE] == ColorMode.BRIGHTNESS + assert state.attributes[ATTR_SUPPORTED_COLOR_MODES] == [ColorMode.BRIGHTNESS] assert state.attributes[ATTR_SUPPORTED_FEATURES] == 0 # Simulate that device switched off in the real world not via HA @@ -176,7 +174,7 @@ async def test_switch_read_light_state_hs(hass, utcnow): state = await helper.poll_and_get_state() assert state.state == "off" assert ATTR_COLOR_MODE not in state.attributes - assert state.attributes[ATTR_SUPPORTED_COLOR_MODES] == [COLOR_MODE_HS] + assert state.attributes[ATTR_SUPPORTED_COLOR_MODES] == [ColorMode.HS] assert state.attributes[ATTR_SUPPORTED_FEATURES] == 0 # Simulate that someone switched on the device in the real world not via HA @@ -192,8 +190,8 @@ async def test_switch_read_light_state_hs(hass, utcnow): assert state.state == "on" assert state.attributes["brightness"] == 255 assert state.attributes["hs_color"] == (4, 5) - assert state.attributes[ATTR_COLOR_MODE] == COLOR_MODE_HS - assert state.attributes[ATTR_SUPPORTED_COLOR_MODES] == [COLOR_MODE_HS] + assert state.attributes[ATTR_COLOR_MODE] == ColorMode.HS + assert state.attributes[ATTR_SUPPORTED_COLOR_MODES] == [ColorMode.HS] assert state.attributes[ATTR_SUPPORTED_FEATURES] == 0 # Simulate that device switched off in the real world not via HA @@ -245,7 +243,7 @@ async def test_switch_read_light_state_color_temp(hass, utcnow): state = await helper.poll_and_get_state() assert state.state == "off" assert ATTR_COLOR_MODE not in state.attributes - assert state.attributes[ATTR_SUPPORTED_COLOR_MODES] == [COLOR_MODE_COLOR_TEMP] + assert state.attributes[ATTR_SUPPORTED_COLOR_MODES] == [ColorMode.COLOR_TEMP] assert state.attributes[ATTR_SUPPORTED_FEATURES] == 0 # Simulate that someone switched on the device in the real world not via HA @@ -260,8 +258,8 @@ async def test_switch_read_light_state_color_temp(hass, utcnow): assert state.state == "on" assert state.attributes["brightness"] == 255 assert state.attributes["color_temp"] == 400 - assert state.attributes[ATTR_COLOR_MODE] == COLOR_MODE_COLOR_TEMP - assert state.attributes[ATTR_SUPPORTED_COLOR_MODES] == [COLOR_MODE_COLOR_TEMP] + assert state.attributes[ATTR_COLOR_MODE] == ColorMode.COLOR_TEMP + assert state.attributes[ATTR_SUPPORTED_COLOR_MODES] == [ColorMode.COLOR_TEMP] assert state.attributes[ATTR_SUPPORTED_FEATURES] == 0 diff --git a/tests/components/homematicip_cloud/test_light.py b/tests/components/homematicip_cloud/test_light.py index b01b999b447..8286acbb1d4 100644 --- a/tests/components/homematicip_cloud/test_light.py +++ b/tests/components/homematicip_cloud/test_light.py @@ -7,11 +7,9 @@ from homeassistant.components.light import ( ATTR_COLOR_MODE, ATTR_COLOR_NAME, ATTR_SUPPORTED_COLOR_MODES, - COLOR_MODE_BRIGHTNESS, - COLOR_MODE_HS, - COLOR_MODE_ONOFF, DOMAIN as LIGHT_DOMAIN, - SUPPORT_TRANSITION, + ColorMode, + LightEntityFeature, ) from homeassistant.const import ATTR_SUPPORTED_FEATURES, STATE_OFF, STATE_ON from homeassistant.setup import async_setup_component @@ -41,8 +39,8 @@ async def test_hmip_light(hass, default_mock_hap_factory): ) assert ha_state.state == STATE_ON - assert ha_state.attributes[ATTR_COLOR_MODE] == COLOR_MODE_ONOFF - assert ha_state.attributes[ATTR_SUPPORTED_COLOR_MODES] == [COLOR_MODE_ONOFF] + assert ha_state.attributes[ATTR_COLOR_MODE] == ColorMode.ONOFF + assert ha_state.attributes[ATTR_SUPPORTED_COLOR_MODES] == [ColorMode.ONOFF] assert ha_state.attributes[ATTR_SUPPORTED_FEATURES] == 0 service_call_counter = len(hmip_device.mock_calls) @@ -57,7 +55,7 @@ async def test_hmip_light(hass, default_mock_hap_factory): ha_state = hass.states.get(entity_id) assert ha_state.state == STATE_OFF assert ATTR_COLOR_MODE not in ha_state.attributes - assert ha_state.attributes[ATTR_SUPPORTED_COLOR_MODES] == [COLOR_MODE_ONOFF] + assert ha_state.attributes[ATTR_SUPPORTED_COLOR_MODES] == [ColorMode.ONOFF] assert ha_state.attributes[ATTR_SUPPORTED_FEATURES] == 0 await hass.services.async_call( @@ -87,8 +85,8 @@ async def test_hmip_notification_light(hass, default_mock_hap_factory): assert ha_state.state == STATE_OFF assert ATTR_COLOR_MODE not in ha_state.attributes - assert ha_state.attributes[ATTR_SUPPORTED_COLOR_MODES] == [COLOR_MODE_HS] - assert ha_state.attributes[ATTR_SUPPORTED_FEATURES] == SUPPORT_TRANSITION + assert ha_state.attributes[ATTR_SUPPORTED_COLOR_MODES] == [ColorMode.HS] + assert ha_state.attributes[ATTR_SUPPORTED_FEATURES] == LightEntityFeature.TRANSITION service_call_counter = len(hmip_device.mock_calls) # Send all color via service call. @@ -143,9 +141,9 @@ async def test_hmip_notification_light(hass, default_mock_hap_factory): assert ha_state.state == STATE_ON assert ha_state.attributes[ATTR_COLOR_NAME] == RGBColorState.PURPLE assert ha_state.attributes[ATTR_BRIGHTNESS] == 255 - assert ha_state.attributes[ATTR_COLOR_MODE] == COLOR_MODE_HS - assert ha_state.attributes[ATTR_SUPPORTED_COLOR_MODES] == [COLOR_MODE_HS] - assert ha_state.attributes[ATTR_SUPPORTED_FEATURES] == SUPPORT_TRANSITION + assert ha_state.attributes[ATTR_COLOR_MODE] == ColorMode.HS + assert ha_state.attributes[ATTR_SUPPORTED_COLOR_MODES] == [ColorMode.HS] + assert ha_state.attributes[ATTR_SUPPORTED_FEATURES] == LightEntityFeature.TRANSITION await hass.services.async_call( "light", "turn_off", {"entity_id": entity_id, "transition": 100}, blocking=True @@ -184,7 +182,7 @@ async def test_hmip_dimmer(hass, default_mock_hap_factory): assert ha_state.state == STATE_OFF assert ATTR_COLOR_MODE not in ha_state.attributes - assert ha_state.attributes[ATTR_SUPPORTED_COLOR_MODES] == [COLOR_MODE_BRIGHTNESS] + assert ha_state.attributes[ATTR_SUPPORTED_COLOR_MODES] == [ColorMode.BRIGHTNESS] assert ha_state.attributes[ATTR_SUPPORTED_FEATURES] == 0 service_call_counter = len(hmip_device.mock_calls) @@ -207,8 +205,8 @@ async def test_hmip_dimmer(hass, default_mock_hap_factory): ha_state = hass.states.get(entity_id) assert ha_state.state == STATE_ON assert ha_state.attributes[ATTR_BRIGHTNESS] == 255 - assert ha_state.attributes[ATTR_COLOR_MODE] == COLOR_MODE_BRIGHTNESS - assert ha_state.attributes[ATTR_SUPPORTED_COLOR_MODES] == [COLOR_MODE_BRIGHTNESS] + assert ha_state.attributes[ATTR_COLOR_MODE] == ColorMode.BRIGHTNESS + assert ha_state.attributes[ATTR_SUPPORTED_COLOR_MODES] == [ColorMode.BRIGHTNESS] assert ha_state.attributes[ATTR_SUPPORTED_FEATURES] == 0 await hass.services.async_call( @@ -242,7 +240,7 @@ async def test_hmip_light_measuring(hass, default_mock_hap_factory): assert ha_state.state == STATE_OFF assert ATTR_COLOR_MODE not in ha_state.attributes - assert ha_state.attributes[ATTR_SUPPORTED_COLOR_MODES] == [COLOR_MODE_ONOFF] + assert ha_state.attributes[ATTR_SUPPORTED_COLOR_MODES] == [ColorMode.ONOFF] assert ha_state.attributes[ATTR_SUPPORTED_FEATURES] == 0 service_call_counter = len(hmip_device.mock_calls) @@ -256,8 +254,8 @@ async def test_hmip_light_measuring(hass, default_mock_hap_factory): await async_manipulate_test_data(hass, hmip_device, "currentPowerConsumption", 50) ha_state = hass.states.get(entity_id) assert ha_state.state == STATE_ON - assert ha_state.attributes[ATTR_COLOR_MODE] == COLOR_MODE_ONOFF - assert ha_state.attributes[ATTR_SUPPORTED_COLOR_MODES] == [COLOR_MODE_ONOFF] + assert ha_state.attributes[ATTR_COLOR_MODE] == ColorMode.ONOFF + assert ha_state.attributes[ATTR_SUPPORTED_COLOR_MODES] == [ColorMode.ONOFF] assert ha_state.attributes[ATTR_SUPPORTED_FEATURES] == 0 await hass.services.async_call( @@ -286,7 +284,7 @@ async def test_hmip_wired_multi_dimmer(hass, default_mock_hap_factory): assert ha_state.state == STATE_OFF assert ATTR_COLOR_MODE not in ha_state.attributes - assert ha_state.attributes[ATTR_SUPPORTED_COLOR_MODES] == [COLOR_MODE_BRIGHTNESS] + assert ha_state.attributes[ATTR_SUPPORTED_COLOR_MODES] == [ColorMode.BRIGHTNESS] assert ha_state.attributes[ATTR_SUPPORTED_FEATURES] == 0 service_call_counter = len(hmip_device.mock_calls) @@ -309,8 +307,8 @@ async def test_hmip_wired_multi_dimmer(hass, default_mock_hap_factory): ha_state = hass.states.get(entity_id) assert ha_state.state == STATE_ON assert ha_state.attributes[ATTR_BRIGHTNESS] == 255 - assert ha_state.attributes[ATTR_COLOR_MODE] == COLOR_MODE_BRIGHTNESS - assert ha_state.attributes[ATTR_SUPPORTED_COLOR_MODES] == [COLOR_MODE_BRIGHTNESS] + assert ha_state.attributes[ATTR_COLOR_MODE] == ColorMode.BRIGHTNESS + assert ha_state.attributes[ATTR_SUPPORTED_COLOR_MODES] == [ColorMode.BRIGHTNESS] assert ha_state.attributes[ATTR_SUPPORTED_FEATURES] == 0 await hass.services.async_call( diff --git a/tests/components/hyperion/test_light.py b/tests/components/hyperion/test_light.py index 69473ae8efa..2514f6b6cba 100644 --- a/tests/components/hyperion/test_light.py +++ b/tests/components/hyperion/test_light.py @@ -22,9 +22,9 @@ from homeassistant.components.light import ( ATTR_BRIGHTNESS, ATTR_EFFECT, ATTR_HS_COLOR, - COLOR_MODE_HS, DOMAIN as LIGHT_DOMAIN, - SUPPORT_EFFECT, + ColorMode, + LightEntityFeature, ) from homeassistant.config_entries import ( RELOAD_AFTER_UPDATE_DELAY, @@ -259,9 +259,9 @@ async def test_light_basic_properties(hass: HomeAssistant) -> None: # By default the effect list is the 3 external sources + 'Solid'. assert len(entity_state.attributes["effect_list"]) == 4 - assert entity_state.attributes["color_mode"] == COLOR_MODE_HS - assert entity_state.attributes["supported_color_modes"] == [COLOR_MODE_HS] - assert entity_state.attributes["supported_features"] == SUPPORT_EFFECT + assert entity_state.attributes["color_mode"] == ColorMode.HS + assert entity_state.attributes["supported_color_modes"] == [ColorMode.HS] + assert entity_state.attributes["supported_features"] == LightEntityFeature.EFFECT async def test_light_async_turn_on(hass: HomeAssistant) -> None: diff --git a/tests/components/knx/test_light.py b/tests/components/knx/test_light.py index 9c7ef0e91ec..56cf5b2c00a 100644 --- a/tests/components/knx/test_light.py +++ b/tests/components/knx/test_light.py @@ -14,13 +14,7 @@ from homeassistant.components.light import ( ATTR_COLOR_TEMP, ATTR_HS_COLOR, ATTR_RGBW_COLOR, - COLOR_MODE_BRIGHTNESS, - COLOR_MODE_COLOR_TEMP, - COLOR_MODE_HS, - COLOR_MODE_ONOFF, - COLOR_MODE_RGB, - COLOR_MODE_RGBW, - COLOR_MODE_XY, + ColorMode, ) from homeassistant.const import CONF_NAME, STATE_OFF, STATE_ON from homeassistant.core import HomeAssistant @@ -56,7 +50,7 @@ async def test_light_simple(hass: HomeAssistant, knx: KNXTestKit): knx.assert_state( "light.test", STATE_ON, - color_mode=COLOR_MODE_ONOFF, + color_mode=ColorMode.ONOFF, ) # turn off light await hass.services.async_call( @@ -115,7 +109,7 @@ async def test_light_brightness(hass: HomeAssistant, knx: KNXTestKit): "light.test", STATE_ON, brightness=80, - color_mode=COLOR_MODE_BRIGHTNESS, + color_mode=ColorMode.BRIGHTNESS, ) # receive brightness changes from KNX await knx.receive_write(test_brightness_state, (255,)) @@ -170,7 +164,7 @@ async def test_light_color_temp_absolute(hass: HomeAssistant, knx: KNXTestKit): "light.test", STATE_ON, brightness=255, - color_mode=COLOR_MODE_COLOR_TEMP, + color_mode=ColorMode.COLOR_TEMP, color_temp=370, ) # change color temperature from HA @@ -226,7 +220,7 @@ async def test_light_color_temp_relative(hass: HomeAssistant, knx: KNXTestKit): "light.test", STATE_ON, brightness=255, - color_mode=COLOR_MODE_COLOR_TEMP, + color_mode=ColorMode.COLOR_TEMP, color_temp=250, ) # change color temperature from HA @@ -285,7 +279,7 @@ async def test_light_hs_color(hass: HomeAssistant, knx: KNXTestKit): "light.test", STATE_ON, brightness=255, - color_mode=COLOR_MODE_HS, + color_mode=ColorMode.HS, hs_color=(360, 100), ) # change color from HA - only hue @@ -360,7 +354,7 @@ async def test_light_xyy_color(hass: HomeAssistant, knx: KNXTestKit): "light.test", STATE_ON, brightness=204, - color_mode=COLOR_MODE_XY, + color_mode=ColorMode.XY, xy_color=(0.8, 0.8), ) # change color and brightness from HA @@ -440,7 +434,7 @@ async def test_light_xyy_color_with_brightness(hass: HomeAssistant, knx: KNXTest "light.test", STATE_ON, brightness=255, # brightness form xyy_color ignored when extra brightness GA is used - color_mode=COLOR_MODE_XY, + color_mode=ColorMode.XY, xy_color=(0.8, 0.8), ) # change color from HA @@ -526,7 +520,7 @@ async def test_light_rgb_individual(hass: HomeAssistant, knx: KNXTestKit): "light.test", STATE_ON, brightness=255, - color_mode=COLOR_MODE_RGB, + color_mode=ColorMode.RGB, rgb_color=(255, 255, 255), ) # change color from HA @@ -680,7 +674,7 @@ async def test_light_rgbw_individual(hass: HomeAssistant, knx: KNXTestKit): "light.test", STATE_ON, brightness=255, - color_mode=COLOR_MODE_RGBW, + color_mode=ColorMode.RGBW, rgbw_color=(0, 0, 0, 255), ) # change color from HA @@ -835,7 +829,7 @@ async def test_light_rgb(hass: HomeAssistant, knx: KNXTestKit): "light.test", STATE_ON, brightness=255, - color_mode=COLOR_MODE_RGB, + color_mode=ColorMode.RGB, rgb_color=(255, 255, 255), ) # change color from HA @@ -943,7 +937,7 @@ async def test_light_rgbw(hass: HomeAssistant, knx: KNXTestKit): "light.test", STATE_ON, brightness=255, - color_mode=COLOR_MODE_RGBW, + color_mode=ColorMode.RGBW, rgbw_color=(255, 101, 102, 103), ) # change color from HA @@ -1060,7 +1054,7 @@ async def test_light_rgbw_brightness(hass: HomeAssistant, knx: KNXTestKit): "light.test", STATE_ON, brightness=255, - color_mode=COLOR_MODE_RGBW, + color_mode=ColorMode.RGBW, rgbw_color=(255, 101, 102, 103), ) # change color from HA diff --git a/tests/components/kulersky/test_light.py b/tests/components/kulersky/test_light.py index fabd263771f..907956b3709 100644 --- a/tests/components/kulersky/test_light.py +++ b/tests/components/kulersky/test_light.py @@ -18,8 +18,8 @@ from homeassistant.components.light import ( ATTR_RGBW_COLOR, ATTR_SUPPORTED_COLOR_MODES, ATTR_XY_COLOR, - COLOR_MODE_RGBW, SCAN_INTERVAL, + ColorMode, ) from homeassistant.const import ( ATTR_ENTITY_ID, @@ -69,7 +69,7 @@ async def test_init(hass, mock_light): assert state.state == STATE_OFF assert dict(state.attributes) == { ATTR_FRIENDLY_NAME: "Bedroom", - ATTR_SUPPORTED_COLOR_MODES: [COLOR_MODE_RGBW], + ATTR_SUPPORTED_COLOR_MODES: [ColorMode.RGBW], ATTR_SUPPORTED_FEATURES: 0, } @@ -187,7 +187,7 @@ async def test_light_update(hass, mock_light): assert state.state == STATE_OFF assert dict(state.attributes) == { ATTR_FRIENDLY_NAME: "Bedroom", - ATTR_SUPPORTED_COLOR_MODES: [COLOR_MODE_RGBW], + ATTR_SUPPORTED_COLOR_MODES: [ColorMode.RGBW], ATTR_SUPPORTED_FEATURES: 0, } @@ -201,7 +201,7 @@ async def test_light_update(hass, mock_light): assert state.state == STATE_UNAVAILABLE assert dict(state.attributes) == { ATTR_FRIENDLY_NAME: "Bedroom", - ATTR_SUPPORTED_COLOR_MODES: [COLOR_MODE_RGBW], + ATTR_SUPPORTED_COLOR_MODES: [ColorMode.RGBW], ATTR_SUPPORTED_FEATURES: 0, } @@ -215,9 +215,9 @@ async def test_light_update(hass, mock_light): assert state.state == STATE_ON assert dict(state.attributes) == { ATTR_FRIENDLY_NAME: "Bedroom", - ATTR_SUPPORTED_COLOR_MODES: [COLOR_MODE_RGBW], + ATTR_SUPPORTED_COLOR_MODES: [ColorMode.RGBW], ATTR_SUPPORTED_FEATURES: 0, - ATTR_COLOR_MODE: COLOR_MODE_RGBW, + ATTR_COLOR_MODE: ColorMode.RGBW, ATTR_BRIGHTNESS: 255, ATTR_HS_COLOR: (approx(212.571), approx(68.627)), ATTR_RGB_COLOR: (80, 160, 255), @@ -235,9 +235,9 @@ async def test_light_update(hass, mock_light): assert state.state == STATE_ON assert dict(state.attributes) == { ATTR_FRIENDLY_NAME: "Bedroom", - ATTR_SUPPORTED_COLOR_MODES: [COLOR_MODE_RGBW], + ATTR_SUPPORTED_COLOR_MODES: [ColorMode.RGBW], ATTR_SUPPORTED_FEATURES: 0, - ATTR_COLOR_MODE: COLOR_MODE_RGBW, + ATTR_COLOR_MODE: ColorMode.RGBW, ATTR_BRIGHTNESS: 255, ATTR_HS_COLOR: (approx(199.701), approx(26.275)), ATTR_RGB_COLOR: (188, 233, 255), @@ -255,9 +255,9 @@ async def test_light_update(hass, mock_light): assert state.state == STATE_ON assert dict(state.attributes) == { ATTR_FRIENDLY_NAME: "Bedroom", - ATTR_SUPPORTED_COLOR_MODES: [COLOR_MODE_RGBW], + ATTR_SUPPORTED_COLOR_MODES: [ColorMode.RGBW], ATTR_SUPPORTED_FEATURES: 0, - ATTR_COLOR_MODE: COLOR_MODE_RGBW, + ATTR_COLOR_MODE: ColorMode.RGBW, ATTR_BRIGHTNESS: 240, ATTR_HS_COLOR: (approx(200.0), approx(27.059)), ATTR_RGB_COLOR: (186, 232, 255), diff --git a/tests/components/myq/test_light.py b/tests/components/myq/test_light.py index acc12ef0ce1..701bfa0864c 100644 --- a/tests/components/myq/test_light.py +++ b/tests/components/myq/test_light.py @@ -1,6 +1,5 @@ """The scene tests for the myq platform.""" - -from homeassistant.components.light import COLOR_MODE_ONOFF +from homeassistant.components.light import ColorMode from homeassistant.const import STATE_OFF, STATE_ON from .util import async_init_integration @@ -16,7 +15,7 @@ async def test_create_lights(hass): expected_attributes = { "friendly_name": "Garage Door Light Off", "supported_features": 0, - "supported_color_modes": [COLOR_MODE_ONOFF], + "supported_color_modes": [ColorMode.ONOFF], } # Only test for a subset of attributes in case # HA changes the implementation and a new one appears @@ -29,7 +28,7 @@ async def test_create_lights(hass): expected_attributes = { "friendly_name": "Garage Door Light On", "supported_features": 0, - "supported_color_modes": [COLOR_MODE_ONOFF], + "supported_color_modes": [ColorMode.ONOFF], } # Only test for a subset of attributes in case # HA changes the implementation and a new one appears diff --git a/tests/components/senseme/test_light.py b/tests/components/senseme/test_light.py index c585cfc31bf..d4a8eddc91c 100644 --- a/tests/components/senseme/test_light.py +++ b/tests/components/senseme/test_light.py @@ -1,6 +1,4 @@ """Tests for senseme light platform.""" - - from aiosenseme import SensemeDevice from homeassistant.components import senseme @@ -9,11 +7,10 @@ from homeassistant.components.light import ( ATTR_COLOR_MODE, ATTR_COLOR_TEMP, ATTR_SUPPORTED_COLOR_MODES, - COLOR_MODE_BRIGHTNESS, - COLOR_MODE_COLOR_TEMP, DOMAIN as LIGHT_DOMAIN, SERVICE_TURN_OFF, SERVICE_TURN_ON, + ColorMode, ) from homeassistant.components.senseme.const import DOMAIN from homeassistant.const import ATTR_ENTITY_ID, STATE_ON @@ -60,8 +57,8 @@ async def test_fan_light(hass: HomeAssistant) -> None: assert state.state == STATE_ON attributes = state.attributes assert attributes[ATTR_BRIGHTNESS] == 255 - assert attributes[ATTR_COLOR_MODE] == COLOR_MODE_BRIGHTNESS - assert attributes[ATTR_SUPPORTED_COLOR_MODES] == [COLOR_MODE_BRIGHTNESS] + assert attributes[ATTR_COLOR_MODE] == ColorMode.BRIGHTNESS + assert attributes[ATTR_SUPPORTED_COLOR_MODES] == [ColorMode.BRIGHTNESS] await hass.services.async_call( LIGHT_DOMAIN, SERVICE_TURN_OFF, {ATTR_ENTITY_ID: entity_id}, blocking=True @@ -85,8 +82,8 @@ async def test_fan_light_no_brightness(hass: HomeAssistant) -> None: assert state.state == STATE_ON attributes = state.attributes assert attributes[ATTR_BRIGHTNESS] == 255 - assert attributes[ATTR_COLOR_MODE] == COLOR_MODE_BRIGHTNESS - assert attributes[ATTR_SUPPORTED_COLOR_MODES] == [COLOR_MODE_BRIGHTNESS] + assert attributes[ATTR_COLOR_MODE] == ColorMode.BRIGHTNESS + assert attributes[ATTR_SUPPORTED_COLOR_MODES] == [ColorMode.BRIGHTNESS] async def test_standalone_light(hass: HomeAssistant) -> None: @@ -103,8 +100,8 @@ async def test_standalone_light(hass: HomeAssistant) -> None: assert state.state == STATE_ON attributes = state.attributes assert attributes[ATTR_BRIGHTNESS] == 255 - assert attributes[ATTR_COLOR_MODE] == COLOR_MODE_COLOR_TEMP - assert attributes[ATTR_SUPPORTED_COLOR_MODES] == [COLOR_MODE_COLOR_TEMP] + assert attributes[ATTR_COLOR_MODE] == ColorMode.COLOR_TEMP + assert attributes[ATTR_SUPPORTED_COLOR_MODES] == [ColorMode.COLOR_TEMP] assert attributes[ATTR_COLOR_TEMP] == 250 await hass.services.async_call( diff --git a/tests/components/switch/test_light.py b/tests/components/switch/test_light.py index 62fef242e9f..b37b6cf4471 100644 --- a/tests/components/switch/test_light.py +++ b/tests/components/switch/test_light.py @@ -1,9 +1,8 @@ """The tests for the Light Switch platform.""" - from homeassistant.components.light import ( ATTR_COLOR_MODE, ATTR_SUPPORTED_COLOR_MODES, - COLOR_MODE_ONOFF, + ColorMode, ) from homeassistant.setup import async_setup_component @@ -36,7 +35,7 @@ async def test_default_state(hass): assert state.attributes.get("white_value") is None assert state.attributes.get("effect_list") is None assert state.attributes.get("effect") is None - assert state.attributes.get(ATTR_SUPPORTED_COLOR_MODES) == [COLOR_MODE_ONOFF] + assert state.attributes.get(ATTR_SUPPORTED_COLOR_MODES) == [ColorMode.ONOFF] assert state.attributes.get(ATTR_COLOR_MODE) is None @@ -63,7 +62,7 @@ async def test_light_service_calls(hass): assert hass.states.get("light.light_switch").state == "on" assert ( hass.states.get("light.light_switch").attributes.get(ATTR_COLOR_MODE) - == COLOR_MODE_ONOFF + == ColorMode.ONOFF ) await common.async_turn_off(hass, "light.light_switch") diff --git a/tests/components/switch_as_x/test_light.py b/tests/components/switch_as_x/test_light.py index 75e62008e7b..7026a6dea76 100644 --- a/tests/components/switch_as_x/test_light.py +++ b/tests/components/switch_as_x/test_light.py @@ -8,8 +8,8 @@ from homeassistant.components.light import ( ATTR_HS_COLOR, ATTR_SUPPORTED_COLOR_MODES, ATTR_WHITE_VALUE, - COLOR_MODE_ONOFF, DOMAIN as LIGHT_DOMAIN, + ColorMode, ) from homeassistant.components.switch import DOMAIN as SWITCH_DOMAIN from homeassistant.components.switch_as_x.const import CONF_TARGET_DOMAIN, DOMAIN @@ -53,7 +53,7 @@ async def test_default_state(hass: HomeAssistant) -> None: assert state.attributes.get(ATTR_WHITE_VALUE) is None assert state.attributes.get(ATTR_EFFECT_LIST) is None assert state.attributes.get(ATTR_EFFECT) is None - assert state.attributes.get(ATTR_SUPPORTED_COLOR_MODES) == [COLOR_MODE_ONOFF] + assert state.attributes.get(ATTR_SUPPORTED_COLOR_MODES) == [ColorMode.ONOFF] assert state.attributes.get(ATTR_COLOR_MODE) is None @@ -96,7 +96,7 @@ async def test_light_service_calls(hass: HomeAssistant) -> None: assert hass.states.get("light.decorative_lights").state == STATE_ON assert ( hass.states.get("light.decorative_lights").attributes.get(ATTR_COLOR_MODE) - == COLOR_MODE_ONOFF + == ColorMode.ONOFF ) await hass.services.async_call( diff --git a/tests/components/template/test_light.py b/tests/components/template/test_light.py index 255cea6348f..2b877c52c4f 100644 --- a/tests/components/template/test_light.py +++ b/tests/components/template/test_light.py @@ -11,7 +11,7 @@ from homeassistant.components.light import ( ATTR_HS_COLOR, ATTR_TRANSITION, ATTR_WHITE_VALUE, - SUPPORT_TRANSITION, + LightEntityFeature, ) from homeassistant.const import ( ATTR_ENTITY_ID, @@ -1344,7 +1344,7 @@ async def test_supports_transition_template( assert state is not None assert ( - int(state.attributes.get("supported_features")) & SUPPORT_TRANSITION + int(state.attributes.get("supported_features")) & LightEntityFeature.TRANSITION ) != expected_value diff --git a/tests/components/zerproc/test_light.py b/tests/components/zerproc/test_light.py index e72ba2bcb66..59fba0da963 100644 --- a/tests/components/zerproc/test_light.py +++ b/tests/components/zerproc/test_light.py @@ -11,10 +11,10 @@ from homeassistant.components.light import ( ATTR_RGB_COLOR, ATTR_SUPPORTED_COLOR_MODES, ATTR_XY_COLOR, - COLOR_MODE_HS, SCAN_INTERVAL, SUPPORT_BRIGHTNESS, SUPPORT_COLOR, + ColorMode, ) from homeassistant.components.zerproc.const import ( DATA_ADDRESSES, @@ -100,7 +100,7 @@ async def test_init(hass, mock_entry): assert state.state == STATE_OFF assert state.attributes == { ATTR_FRIENDLY_NAME: "LEDBlue-CCDDEEFF", - ATTR_SUPPORTED_COLOR_MODES: [COLOR_MODE_HS], + ATTR_SUPPORTED_COLOR_MODES: [ColorMode.HS], ATTR_SUPPORTED_FEATURES: SUPPORT_BRIGHTNESS | SUPPORT_COLOR, ATTR_ICON: "mdi:string-lights", } @@ -109,10 +109,10 @@ async def test_init(hass, mock_entry): assert state.state == STATE_ON assert state.attributes == { ATTR_FRIENDLY_NAME: "LEDBlue-33445566", - ATTR_SUPPORTED_COLOR_MODES: [COLOR_MODE_HS], + ATTR_SUPPORTED_COLOR_MODES: [ColorMode.HS], ATTR_SUPPORTED_FEATURES: SUPPORT_BRIGHTNESS | SUPPORT_COLOR, ATTR_ICON: "mdi:string-lights", - ATTR_COLOR_MODE: COLOR_MODE_HS, + ATTR_COLOR_MODE: ColorMode.HS, ATTR_BRIGHTNESS: 255, ATTR_HS_COLOR: (221.176, 100.0), ATTR_RGB_COLOR: (0, 80, 255), @@ -279,7 +279,7 @@ async def test_light_update(hass, mock_light): assert state.state == STATE_OFF assert state.attributes == { ATTR_FRIENDLY_NAME: "LEDBlue-CCDDEEFF", - ATTR_SUPPORTED_COLOR_MODES: [COLOR_MODE_HS], + ATTR_SUPPORTED_COLOR_MODES: [ColorMode.HS], ATTR_SUPPORTED_FEATURES: SUPPORT_BRIGHTNESS | SUPPORT_COLOR, ATTR_ICON: "mdi:string-lights", } @@ -298,7 +298,7 @@ async def test_light_update(hass, mock_light): assert state.state == STATE_UNAVAILABLE assert state.attributes == { ATTR_FRIENDLY_NAME: "LEDBlue-CCDDEEFF", - ATTR_SUPPORTED_COLOR_MODES: [COLOR_MODE_HS], + ATTR_SUPPORTED_COLOR_MODES: [ColorMode.HS], ATTR_SUPPORTED_FEATURES: SUPPORT_BRIGHTNESS | SUPPORT_COLOR, ATTR_ICON: "mdi:string-lights", } @@ -316,7 +316,7 @@ async def test_light_update(hass, mock_light): assert state.state == STATE_OFF assert state.attributes == { ATTR_FRIENDLY_NAME: "LEDBlue-CCDDEEFF", - ATTR_SUPPORTED_COLOR_MODES: [COLOR_MODE_HS], + ATTR_SUPPORTED_COLOR_MODES: [ColorMode.HS], ATTR_SUPPORTED_FEATURES: SUPPORT_BRIGHTNESS | SUPPORT_COLOR, ATTR_ICON: "mdi:string-lights", } @@ -334,10 +334,10 @@ async def test_light_update(hass, mock_light): assert state.state == STATE_ON assert state.attributes == { ATTR_FRIENDLY_NAME: "LEDBlue-CCDDEEFF", - ATTR_SUPPORTED_COLOR_MODES: [COLOR_MODE_HS], + ATTR_SUPPORTED_COLOR_MODES: [ColorMode.HS], ATTR_SUPPORTED_FEATURES: SUPPORT_BRIGHTNESS | SUPPORT_COLOR, ATTR_ICON: "mdi:string-lights", - ATTR_COLOR_MODE: COLOR_MODE_HS, + ATTR_COLOR_MODE: ColorMode.HS, ATTR_BRIGHTNESS: 220, ATTR_HS_COLOR: (261.429, 31.818), ATTR_RGB_COLOR: (202, 173, 255),