Skip to content

Commit

Permalink
replace deprecated 2026.1 constants
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertD502 authored Dec 26, 2024
1 parent 9e95d6d commit 7fe523b
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions custom_components/vesync/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@

from homeassistant.components.light import (
ATTR_BRIGHTNESS,
ATTR_COLOR_TEMP,
COLOR_MODE_BRIGHTNESS,
COLOR_MODE_COLOR_TEMP,
ATTR_COLOR_TEMP_KELVIN,
ColorMode,
LightEntity,
)
from homeassistant.config_entries import ConfigEntry
Expand Down Expand Up @@ -103,9 +102,9 @@ def turn_on(self, **kwargs):
"""Turn the device on."""
attribute_adjustment_only = False
# set white temperature
if self.color_mode in (COLOR_MODE_COLOR_TEMP,) and ATTR_COLOR_TEMP in kwargs:
if self.color_mode in (ColorMode.COLOR_TEMP,) and ATTR_COLOR_TEMP_KELVIN in kwargs:
# get white temperature from HA data
color_temp = int(kwargs[ATTR_COLOR_TEMP])
color_temp = int(kwargs[ATTR_COLOR_TEMP_KELVIN])
# ensure value between min-max supported Mireds
color_temp = max(self.min_mireds, min(color_temp, self.max_mireds))
# convert Mireds to Percent value that api expects
Expand All @@ -123,7 +122,7 @@ def turn_on(self, **kwargs):
attribute_adjustment_only = True
# set brightness level
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
):
# get brightness from HA data
Expand All @@ -148,12 +147,12 @@ def __init__(self, device, coordinator) -> None:
@property
def color_mode(self):
"""Set color mode for this entity."""
return COLOR_MODE_BRIGHTNESS
return ColorMode.BRIGHTNESS

@property
def supported_color_modes(self):
"""Flag supported color_modes (in an array format)."""
return [COLOR_MODE_BRIGHTNESS]
return [ColorMode.BRIGHTNESS]


class VeSyncTunableWhiteLightHA(VeSyncBaseLight, LightEntity):
Expand Down Expand Up @@ -203,12 +202,12 @@ def max_mireds(self):
@property
def color_mode(self):
"""Set color mode for this entity."""
return COLOR_MODE_COLOR_TEMP
return ColorMode.COLOR_TEMP

@property
def supported_color_modes(self):
"""Flag supported color_modes (in an array format)."""
return [COLOR_MODE_COLOR_TEMP]
return [ColorMode.COLOR_TEMP]


class VeSyncNightLightHA(VeSyncDimmableLightHA):
Expand Down

0 comments on commit 7fe523b

Please sign in to comment.