Use ColorMode enum in philips_js (#70529)

pull/69919/head^2
epenet 2022-04-23 23:27:32 +02:00 committed by GitHub
parent 1179a88808
commit ca337b54a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 7 deletions

View File

@ -10,11 +10,10 @@ from homeassistant.components.light import (
ATTR_BRIGHTNESS, ATTR_BRIGHTNESS,
ATTR_EFFECT, ATTR_EFFECT,
ATTR_HS_COLOR, ATTR_HS_COLOR,
COLOR_MODE_HS,
COLOR_MODE_ONOFF,
SUPPORT_BRIGHTNESS, SUPPORT_BRIGHTNESS,
SUPPORT_COLOR, SUPPORT_COLOR,
SUPPORT_EFFECT, SUPPORT_EFFECT,
ColorMode,
LightEntity, LightEntity,
) )
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
@ -152,7 +151,7 @@ class PhilipsTVLightEntity(
self._last_selected_effect: AmbilightEffect = None self._last_selected_effect: AmbilightEffect = None
super().__init__(coordinator) super().__init__(coordinator)
self._attr_supported_color_modes = [COLOR_MODE_HS, COLOR_MODE_ONOFF] self._attr_supported_color_modes = {ColorMode.HS, ColorMode.ONOFF}
self._attr_supported_features = ( self._attr_supported_features = (
SUPPORT_EFFECT | SUPPORT_COLOR | SUPPORT_BRIGHTNESS SUPPORT_EFFECT | SUPPORT_COLOR | SUPPORT_BRIGHTNESS
) )
@ -217,16 +216,16 @@ class PhilipsTVLightEntity(
return AmbilightEffect(EFFECT_MODE, self._tv.ambilight_mode, None) return AmbilightEffect(EFFECT_MODE, self._tv.ambilight_mode, None)
@property @property
def color_mode(self): def color_mode(self) -> ColorMode:
"""Return the current color mode.""" """Return the current color mode."""
current = self._tv.ambilight_current_configuration current = self._tv.ambilight_current_configuration
if current and current["isExpert"]: if current and current["isExpert"]:
return COLOR_MODE_HS return ColorMode.HS
if self._tv.ambilight_mode in ["manual", "expert"]: if self._tv.ambilight_mode in ["manual", "expert"]:
return COLOR_MODE_HS return ColorMode.HS
return COLOR_MODE_ONOFF return ColorMode.ONOFF
@property @property
def is_on(self): def is_on(self):