Skip to content

Commit

Permalink
Fix light color modes in the Hass 2024.1
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexxIT committed Jan 18, 2024
1 parent 97b8ead commit 387256c
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion custom_components/xiaomi_gateway3/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
ATTR_BRIGHTNESS,
ATTR_COLOR_TEMP,
ATTR_EFFECT,
ATTR_TRANSITION,
LightEntity,
LightEntityFeature,
ATTR_TRANSITION,
ColorMode,
)
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import STATE_ON
Expand Down Expand Up @@ -49,6 +50,7 @@ def __init__(self, gateway: "XGateway", device: XDevice, conv: Converter):
if conv.attr == ATTR_BRIGHTNESS:
self._attr_supported_features |= LightEntityFeature.TRANSITION
elif conv.attr == ATTR_COLOR_TEMP:
self._attr_supported_color_modes = {ColorMode.COLOR_TEMP}
if hasattr(conv, "minm") and hasattr(conv, "maxm"):
self._attr_min_mireds = conv.minm
self._attr_max_mireds = conv.maxm
Expand All @@ -59,6 +61,13 @@ def __init__(self, gateway: "XGateway", device: XDevice, conv: Converter):
self._attr_supported_features |= LightEntityFeature.EFFECT
self._attr_effect_list = list(conv.map.values())

if self._attr_supported_color_modes is None:
self._attr_supported_color_modes = {
ColorMode.BRIGHTNESS
if self._attr_supported_features & LightEntityFeature.TRANSITION
else ColorMode.ONOFF
}

@callback
def async_set_state(self, data: dict):
if self.attr in data:
Expand Down

0 comments on commit 387256c

Please sign in to comment.