Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions custom_components/govee/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,3 @@
CONF_DISABLE_ATTRIBUTE_UPDATES = "disable_attribute_updates"
CONF_OFFLINE_IS_OFF = "offline_is_off"
CONF_USE_ASSUMED_STATE = "use_assumed_state"

COLOR_TEMP_KELVIN_MIN = 2000
COLOR_TEMP_KELVIN_MAX = 9000
39 changes: 18 additions & 21 deletions custom_components/govee/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from homeassistant.components.light import (
ATTR_BRIGHTNESS,
ATTR_COLOR_TEMP,
ATTR_COLOR_TEMP_KELVIN,
ATTR_HS_COLOR,
SUPPORT_BRIGHTNESS,
SUPPORT_COLOR,
Expand All @@ -23,8 +23,6 @@
DOMAIN,
CONF_OFFLINE_IS_OFF,
CONF_USE_ASSUMED_STATE,
COLOR_TEMP_KELVIN_MIN,
COLOR_TEMP_KELVIN_MAX,
)


Expand Down Expand Up @@ -186,15 +184,16 @@ async def async_turn_on(self, **kwargs):
just_turn_on = False
bright_set = brightness - 1
_, err = await self._hub.set_brightness(self._device, bright_set)
if ATTR_COLOR_TEMP in kwargs:
color_temp = kwargs.pop(ATTR_COLOR_TEMP)
if ATTR_COLOR_TEMP_KELVIN in kwargs:
color_temp = kwargs.pop(ATTR_COLOR_TEMP_KELVIN)
just_turn_on = False
color_temp_kelvin = color.color_temperature_mired_to_kelvin(color_temp)
if color_temp_kelvin > COLOR_TEMP_KELVIN_MAX:
color_temp_kelvin = COLOR_TEMP_KELVIN_MAX
elif color_temp_kelvin < COLOR_TEMP_KELVIN_MIN:
color_temp_kelvin = COLOR_TEMP_KELVIN_MIN
_, err = await self._hub.set_color_temp(self._device, color_temp_kelvin)
color_temp_clamped = min(
self._device.color_temp_max,
max(color_temp, self._device.color_temp_min)
)
_, err = await self._hub.set_color_temp(
self._device, color_temp_clamped
)

# if there is no known specific command - turn on
if just_turn_on:
Expand Down Expand Up @@ -291,21 +290,19 @@ def brightness(self):
return self._device.brightness + 1

@property
def color_temp(self):
def color_temp_kelvin(self):
"""Return the color_temp of the light."""
if not self._device.color_temp:
return None
return color.color_temperature_kelvin_to_mired(self._device.color_temp)
return self._device.color_temp or None

@property
def min_mireds(self):
"""Return the coldest color_temp that this light supports."""
return color.color_temperature_kelvin_to_mired(COLOR_TEMP_KELVIN_MAX)
def min_color_temp_kelvin(self):
"""Return the warmest color_temp that this light supports."""
return self._device.color_temp_min

@property
def max_mireds(self):
"""Return the warmest color_temp that this light supports."""
return color.color_temperature_kelvin_to_mired(COLOR_TEMP_KELVIN_MIN)
def max_color_temp_kelvin(self):
"""Return the coldest color_temp that this light supports."""
return self._device.color_temp_max

@property
def extra_state_attributes(self):
Expand Down