mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Migrate hyperion light to color_mode (#69276)
This commit is contained in:
parent
7e6bb3354a
commit
6b4e0c744c
@ -13,8 +13,7 @@ from homeassistant.components.light import (
|
|||||||
ATTR_BRIGHTNESS,
|
ATTR_BRIGHTNESS,
|
||||||
ATTR_EFFECT,
|
ATTR_EFFECT,
|
||||||
ATTR_HS_COLOR,
|
ATTR_HS_COLOR,
|
||||||
SUPPORT_BRIGHTNESS,
|
COLOR_MODE_HS,
|
||||||
SUPPORT_COLOR,
|
|
||||||
SUPPORT_EFFECT,
|
SUPPORT_EFFECT,
|
||||||
LightEntity,
|
LightEntity,
|
||||||
)
|
)
|
||||||
@ -74,8 +73,6 @@ DEFAULT_PORT = const.DEFAULT_PORT_JSON
|
|||||||
DEFAULT_HDMI_PRIORITY = 880
|
DEFAULT_HDMI_PRIORITY = 880
|
||||||
DEFAULT_EFFECT_LIST: list[str] = []
|
DEFAULT_EFFECT_LIST: list[str] = []
|
||||||
|
|
||||||
SUPPORT_HYPERION = SUPPORT_COLOR | SUPPORT_BRIGHTNESS | SUPPORT_EFFECT
|
|
||||||
|
|
||||||
ICON_LIGHTBULB = "mdi:lightbulb"
|
ICON_LIGHTBULB = "mdi:lightbulb"
|
||||||
ICON_EFFECT = "mdi:lava-lamp"
|
ICON_EFFECT = "mdi:lava-lamp"
|
||||||
ICON_EXTERNAL_SOURCE = "mdi:television-ambient-light"
|
ICON_EXTERNAL_SOURCE = "mdi:television-ambient-light"
|
||||||
@ -127,6 +124,10 @@ async def async_setup_entry(
|
|||||||
class HyperionBaseLight(LightEntity):
|
class HyperionBaseLight(LightEntity):
|
||||||
"""A Hyperion light base class."""
|
"""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__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
server_id: str,
|
server_id: str,
|
||||||
@ -221,11 +222,6 @@ class HyperionBaseLight(LightEntity):
|
|||||||
"""Return the list of supported effects."""
|
"""Return the list of supported effects."""
|
||||||
return self._effect_list
|
return self._effect_list
|
||||||
|
|
||||||
@property
|
|
||||||
def supported_features(self) -> int:
|
|
||||||
"""Flag supported features."""
|
|
||||||
return SUPPORT_HYPERION
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def available(self) -> bool:
|
def available(self) -> bool:
|
||||||
"""Return server availability."""
|
"""Return server availability."""
|
||||||
|
@ -22,7 +22,9 @@ from homeassistant.components.light import (
|
|||||||
ATTR_BRIGHTNESS,
|
ATTR_BRIGHTNESS,
|
||||||
ATTR_EFFECT,
|
ATTR_EFFECT,
|
||||||
ATTR_HS_COLOR,
|
ATTR_HS_COLOR,
|
||||||
|
COLOR_MODE_HS,
|
||||||
DOMAIN as LIGHT_DOMAIN,
|
DOMAIN as LIGHT_DOMAIN,
|
||||||
|
SUPPORT_EFFECT,
|
||||||
)
|
)
|
||||||
from homeassistant.config_entries import (
|
from homeassistant.config_entries import (
|
||||||
RELOAD_AFTER_UPDATE_DELAY,
|
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'.
|
# By default the effect list is the 3 external sources + 'Solid'.
|
||||||
assert len(entity_state.attributes["effect_list"]) == 4
|
assert len(entity_state.attributes["effect_list"]) == 4
|
||||||
|
|
||||||
assert (
|
assert entity_state.attributes["color_mode"] == COLOR_MODE_HS
|
||||||
entity_state.attributes["supported_features"] == hyperion_light.SUPPORT_HYPERION
|
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:
|
async def test_light_async_turn_on(hass: HomeAssistant) -> None:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user