Migrate zerproc light to ColorMode (#70851)
This commit is contained in:
parent
ea4979c511
commit
492e183b7c
2 changed files with 10 additions and 17 deletions
|
@ -9,8 +9,7 @@ import pyzerproc
|
|||
from homeassistant.components.light import (
|
||||
ATTR_BRIGHTNESS,
|
||||
ATTR_HS_COLOR,
|
||||
SUPPORT_BRIGHTNESS,
|
||||
SUPPORT_COLOR,
|
||||
ColorMode,
|
||||
LightEntity,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
|
@ -25,8 +24,6 @@ from .const import DATA_ADDRESSES, DATA_DISCOVERY_SUBSCRIPTION, DOMAIN
|
|||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
SUPPORT_ZERPROC = SUPPORT_BRIGHTNESS | SUPPORT_COLOR
|
||||
|
||||
DISCOVERY_INTERVAL = timedelta(seconds=60)
|
||||
|
||||
|
||||
|
@ -81,6 +78,9 @@ async def async_setup_entry(
|
|||
class ZerprocLight(LightEntity):
|
||||
"""Representation of an Zerproc Light."""
|
||||
|
||||
_attr_color_mode = ColorMode.HS
|
||||
_attr_supported_color_modes = {ColorMode.HS}
|
||||
|
||||
def __init__(self, light):
|
||||
"""Initialize a Zerproc light."""
|
||||
self._light = light
|
||||
|
@ -131,11 +131,6 @@ class ZerprocLight(LightEntity):
|
|||
"""Return the icon to use in the frontend."""
|
||||
return "mdi:string-lights"
|
||||
|
||||
@property
|
||||
def supported_features(self):
|
||||
"""Flag supported features."""
|
||||
return SUPPORT_ZERPROC
|
||||
|
||||
@property
|
||||
def brightness(self):
|
||||
"""Return the brightness of the light."""
|
||||
|
|
|
@ -12,8 +12,6 @@ from homeassistant.components.light import (
|
|||
ATTR_SUPPORTED_COLOR_MODES,
|
||||
ATTR_XY_COLOR,
|
||||
SCAN_INTERVAL,
|
||||
SUPPORT_BRIGHTNESS,
|
||||
SUPPORT_COLOR,
|
||||
ColorMode,
|
||||
)
|
||||
from homeassistant.components.zerproc.const import (
|
||||
|
@ -101,7 +99,7 @@ async def test_init(hass, mock_entry):
|
|||
assert state.attributes == {
|
||||
ATTR_FRIENDLY_NAME: "LEDBlue-CCDDEEFF",
|
||||
ATTR_SUPPORTED_COLOR_MODES: [ColorMode.HS],
|
||||
ATTR_SUPPORTED_FEATURES: SUPPORT_BRIGHTNESS | SUPPORT_COLOR,
|
||||
ATTR_SUPPORTED_FEATURES: 0,
|
||||
ATTR_ICON: "mdi:string-lights",
|
||||
}
|
||||
|
||||
|
@ -110,7 +108,7 @@ async def test_init(hass, mock_entry):
|
|||
assert state.attributes == {
|
||||
ATTR_FRIENDLY_NAME: "LEDBlue-33445566",
|
||||
ATTR_SUPPORTED_COLOR_MODES: [ColorMode.HS],
|
||||
ATTR_SUPPORTED_FEATURES: SUPPORT_BRIGHTNESS | SUPPORT_COLOR,
|
||||
ATTR_SUPPORTED_FEATURES: 0,
|
||||
ATTR_ICON: "mdi:string-lights",
|
||||
ATTR_COLOR_MODE: ColorMode.HS,
|
||||
ATTR_BRIGHTNESS: 255,
|
||||
|
@ -280,7 +278,7 @@ async def test_light_update(hass, mock_light):
|
|||
assert state.attributes == {
|
||||
ATTR_FRIENDLY_NAME: "LEDBlue-CCDDEEFF",
|
||||
ATTR_SUPPORTED_COLOR_MODES: [ColorMode.HS],
|
||||
ATTR_SUPPORTED_FEATURES: SUPPORT_BRIGHTNESS | SUPPORT_COLOR,
|
||||
ATTR_SUPPORTED_FEATURES: 0,
|
||||
ATTR_ICON: "mdi:string-lights",
|
||||
}
|
||||
|
||||
|
@ -299,7 +297,7 @@ async def test_light_update(hass, mock_light):
|
|||
assert state.attributes == {
|
||||
ATTR_FRIENDLY_NAME: "LEDBlue-CCDDEEFF",
|
||||
ATTR_SUPPORTED_COLOR_MODES: [ColorMode.HS],
|
||||
ATTR_SUPPORTED_FEATURES: SUPPORT_BRIGHTNESS | SUPPORT_COLOR,
|
||||
ATTR_SUPPORTED_FEATURES: 0,
|
||||
ATTR_ICON: "mdi:string-lights",
|
||||
}
|
||||
|
||||
|
@ -317,7 +315,7 @@ async def test_light_update(hass, mock_light):
|
|||
assert state.attributes == {
|
||||
ATTR_FRIENDLY_NAME: "LEDBlue-CCDDEEFF",
|
||||
ATTR_SUPPORTED_COLOR_MODES: [ColorMode.HS],
|
||||
ATTR_SUPPORTED_FEATURES: SUPPORT_BRIGHTNESS | SUPPORT_COLOR,
|
||||
ATTR_SUPPORTED_FEATURES: 0,
|
||||
ATTR_ICON: "mdi:string-lights",
|
||||
}
|
||||
|
||||
|
@ -335,7 +333,7 @@ async def test_light_update(hass, mock_light):
|
|||
assert state.attributes == {
|
||||
ATTR_FRIENDLY_NAME: "LEDBlue-CCDDEEFF",
|
||||
ATTR_SUPPORTED_COLOR_MODES: [ColorMode.HS],
|
||||
ATTR_SUPPORTED_FEATURES: SUPPORT_BRIGHTNESS | SUPPORT_COLOR,
|
||||
ATTR_SUPPORTED_FEATURES: 0,
|
||||
ATTR_ICON: "mdi:string-lights",
|
||||
ATTR_COLOR_MODE: ColorMode.HS,
|
||||
ATTR_BRIGHTNESS: 220,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue