From 6b4e0c744c794b2338c95abfed078dd8ac64a129 Mon Sep 17 00:00:00 2001 From: Erik Montnemery Date: Mon, 4 Apr 2022 17:39:21 +0200 Subject: [PATCH] Migrate hyperion light to color_mode (#69276) --- homeassistant/components/hyperion/light.py | 14 +++++--------- tests/components/hyperion/test_light.py | 8 +++++--- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/homeassistant/components/hyperion/light.py b/homeassistant/components/hyperion/light.py index 8b809bdec8a..fe25b147b5f 100644 --- a/homeassistant/components/hyperion/light.py +++ b/homeassistant/components/hyperion/light.py @@ -13,8 +13,7 @@ from homeassistant.components.light import ( ATTR_BRIGHTNESS, ATTR_EFFECT, ATTR_HS_COLOR, - SUPPORT_BRIGHTNESS, - SUPPORT_COLOR, + COLOR_MODE_HS, SUPPORT_EFFECT, LightEntity, ) @@ -74,8 +73,6 @@ DEFAULT_PORT = const.DEFAULT_PORT_JSON DEFAULT_HDMI_PRIORITY = 880 DEFAULT_EFFECT_LIST: list[str] = [] -SUPPORT_HYPERION = SUPPORT_COLOR | SUPPORT_BRIGHTNESS | SUPPORT_EFFECT - ICON_LIGHTBULB = "mdi:lightbulb" ICON_EFFECT = "mdi:lava-lamp" ICON_EXTERNAL_SOURCE = "mdi:television-ambient-light" @@ -127,6 +124,10 @@ async def async_setup_entry( class HyperionBaseLight(LightEntity): """A Hyperion light base class.""" + _attr_color_mode = COLOR_MODE_HS + _attr_supported_color_modes = {COLOR_MODE_HS} + _attr_supported_features = SUPPORT_EFFECT + def __init__( self, server_id: str, @@ -221,11 +222,6 @@ class HyperionBaseLight(LightEntity): """Return the list of supported effects.""" return self._effect_list - @property - def supported_features(self) -> int: - """Flag supported features.""" - return SUPPORT_HYPERION - @property def available(self) -> bool: """Return server availability.""" diff --git a/tests/components/hyperion/test_light.py b/tests/components/hyperion/test_light.py index 0cb85aeb5e2..69473ae8efa 100644 --- a/tests/components/hyperion/test_light.py +++ b/tests/components/hyperion/test_light.py @@ -22,7 +22,9 @@ from homeassistant.components.light import ( ATTR_BRIGHTNESS, ATTR_EFFECT, ATTR_HS_COLOR, + COLOR_MODE_HS, DOMAIN as LIGHT_DOMAIN, + SUPPORT_EFFECT, ) from homeassistant.config_entries import ( RELOAD_AFTER_UPDATE_DELAY, @@ -257,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["supported_features"] == hyperion_light.SUPPORT_HYPERION - ) + 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 async def test_light_async_turn_on(hass: HomeAssistant) -> None: