Migrate zerproc light to ColorMode (#70851)

This commit is contained in:
epenet 2022-04-27 09:52:41 +02:00 committed by GitHub
parent ea4979c511
commit 492e183b7c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 17 deletions

View file

@ -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."""

View file

@ -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,