mirror of
https://github.com/home-assistant/core.git
synced 2025-07-20 11:47:06 +00:00
Use ColorMode enum in vesync (#70553)
This commit is contained in:
parent
753a13d68d
commit
9906fd649e
@ -4,8 +4,7 @@ import logging
|
|||||||
from homeassistant.components.light import (
|
from homeassistant.components.light import (
|
||||||
ATTR_BRIGHTNESS,
|
ATTR_BRIGHTNESS,
|
||||||
ATTR_COLOR_TEMP,
|
ATTR_COLOR_TEMP,
|
||||||
COLOR_MODE_BRIGHTNESS,
|
ColorMode,
|
||||||
COLOR_MODE_COLOR_TEMP,
|
|
||||||
LightEntity,
|
LightEntity,
|
||||||
)
|
)
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
@ -88,7 +87,7 @@ class VeSyncBaseLight(VeSyncDevice, LightEntity):
|
|||||||
"""Turn the device on."""
|
"""Turn the device on."""
|
||||||
attribute_adjustment_only = False
|
attribute_adjustment_only = False
|
||||||
# set white temperature
|
# set white temperature
|
||||||
if self.color_mode in (COLOR_MODE_COLOR_TEMP,) and ATTR_COLOR_TEMP in kwargs:
|
if self.color_mode == ColorMode.COLOR_TEMP and ATTR_COLOR_TEMP in kwargs:
|
||||||
# get white temperature from HA data
|
# get white temperature from HA data
|
||||||
color_temp = int(kwargs[ATTR_COLOR_TEMP])
|
color_temp = int(kwargs[ATTR_COLOR_TEMP])
|
||||||
# ensure value between min-max supported Mireds
|
# ensure value between min-max supported Mireds
|
||||||
@ -108,7 +107,7 @@ class VeSyncBaseLight(VeSyncDevice, LightEntity):
|
|||||||
attribute_adjustment_only = True
|
attribute_adjustment_only = True
|
||||||
# set brightness level
|
# set brightness level
|
||||||
if (
|
if (
|
||||||
self.color_mode in (COLOR_MODE_BRIGHTNESS, COLOR_MODE_COLOR_TEMP)
|
self.color_mode in (ColorMode.BRIGHTNESS, ColorMode.COLOR_TEMP)
|
||||||
and ATTR_BRIGHTNESS in kwargs
|
and ATTR_BRIGHTNESS in kwargs
|
||||||
):
|
):
|
||||||
# get brightness from HA data
|
# get brightness from HA data
|
||||||
@ -133,20 +132,16 @@ class VeSyncBaseLight(VeSyncDevice, LightEntity):
|
|||||||
class VeSyncDimmableLightHA(VeSyncBaseLight, LightEntity):
|
class VeSyncDimmableLightHA(VeSyncBaseLight, LightEntity):
|
||||||
"""Representation of a VeSync dimmable light device."""
|
"""Representation of a VeSync dimmable light device."""
|
||||||
|
|
||||||
@property
|
_attr_color_mode = ColorMode.BRIGHTNESS
|
||||||
def color_mode(self):
|
_attr_supported_color_modes = {ColorMode.BRIGHTNESS}
|
||||||
"""Set color mode for this entity."""
|
|
||||||
return COLOR_MODE_BRIGHTNESS
|
|
||||||
|
|
||||||
@property
|
|
||||||
def supported_color_modes(self):
|
|
||||||
"""Flag supported color_modes (in an array format)."""
|
|
||||||
return [COLOR_MODE_BRIGHTNESS]
|
|
||||||
|
|
||||||
|
|
||||||
class VeSyncTunableWhiteLightHA(VeSyncBaseLight, LightEntity):
|
class VeSyncTunableWhiteLightHA(VeSyncBaseLight, LightEntity):
|
||||||
"""Representation of a VeSync Tunable White Light device."""
|
"""Representation of a VeSync Tunable White Light device."""
|
||||||
|
|
||||||
|
_attr_color_mode = ColorMode.COLOR_TEMP
|
||||||
|
_attr_supported_color_modes = {ColorMode.COLOR_TEMP}
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def color_temp(self):
|
def color_temp(self):
|
||||||
"""Get device white temperature."""
|
"""Get device white temperature."""
|
||||||
@ -183,13 +178,3 @@ class VeSyncTunableWhiteLightHA(VeSyncBaseLight, LightEntity):
|
|||||||
def max_mireds(self):
|
def max_mireds(self):
|
||||||
"""Set device warmest white temperature."""
|
"""Set device warmest white temperature."""
|
||||||
return 370 # 370 Mireds ( 1,000,000 divided by 2700 Kelvin = 370 Mireds)
|
return 370 # 370 Mireds ( 1,000,000 divided by 2700 Kelvin = 370 Mireds)
|
||||||
|
|
||||||
@property
|
|
||||||
def color_mode(self):
|
|
||||||
"""Set color mode for this entity."""
|
|
||||||
return COLOR_MODE_COLOR_TEMP
|
|
||||||
|
|
||||||
@property
|
|
||||||
def supported_color_modes(self):
|
|
||||||
"""Flag supported color_modes (in an array format)."""
|
|
||||||
return [COLOR_MODE_COLOR_TEMP]
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user