Use ColorMode enum in iglo (#70512)

This commit is contained in:
epenet 2022-04-23 21:16:58 +02:00 committed by GitHub
parent 2f26407a31
commit 5811e43319
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -12,9 +12,8 @@ from homeassistant.components.light import (
ATTR_COLOR_TEMP, ATTR_COLOR_TEMP,
ATTR_EFFECT, ATTR_EFFECT,
ATTR_HS_COLOR, ATTR_HS_COLOR,
COLOR_MODE_COLOR_TEMP,
COLOR_MODE_HS,
PLATFORM_SCHEMA, PLATFORM_SCHEMA,
ColorMode,
LightEntity, LightEntity,
LightEntityFeature, LightEntityFeature,
) )
@ -53,7 +52,7 @@ def setup_platform(
class IGloLamp(LightEntity): class IGloLamp(LightEntity):
"""Representation of an iGlo light.""" """Representation of an iGlo light."""
_attr_supported_color_modes = {COLOR_MODE_COLOR_TEMP, COLOR_MODE_HS} _attr_supported_color_modes = {ColorMode.COLOR_TEMP, ColorMode.HS}
_attr_supported_features = LightEntityFeature.EFFECT _attr_supported_features = LightEntityFeature.EFFECT
def __init__(self, name, host, port): def __init__(self, name, host, port):
@ -73,13 +72,13 @@ class IGloLamp(LightEntity):
return int((self._lamp.state()["brightness"] / 200.0) * 255) return int((self._lamp.state()["brightness"] / 200.0) * 255)
@property @property
def color_mode(self) -> str | None: def color_mode(self) -> ColorMode:
"""Return the color mode of the light.""" """Return the color mode of the light."""
if self._lamp.state()["mode"] == MODE_WHITE: if self._lamp.state()["mode"] == MODE_WHITE:
return COLOR_MODE_COLOR_TEMP return ColorMode.COLOR_TEMP
# The iglo library reports MODE_WHITE when an effect is active, this is not # The iglo library reports MODE_WHITE when an effect is active, this is not
# supported by Home Assistant, just report COLOR_MODE_HS # supported by Home Assistant, just report ColorMode.HS
return COLOR_MODE_HS return ColorMode.HS
@property @property
def color_temp(self): def color_temp(self):