Some lights only support hs, like the lidl christmas lights (#44059)
parent
9cfeb44b56
commit
0e871c3390
|
@ -114,7 +114,9 @@ class DeconzBaseLight(DeconzDevice, LightEntity):
|
||||||
if self._device.ct is not None:
|
if self._device.ct is not None:
|
||||||
self._features |= SUPPORT_COLOR_TEMP
|
self._features |= SUPPORT_COLOR_TEMP
|
||||||
|
|
||||||
if self._device.xy is not None:
|
if self._device.xy is not None or (
|
||||||
|
self._device.hue is not None and self._device.sat is not None
|
||||||
|
):
|
||||||
self._features |= SUPPORT_COLOR
|
self._features |= SUPPORT_COLOR
|
||||||
|
|
||||||
if self._device.effect is not None:
|
if self._device.effect is not None:
|
||||||
|
@ -141,8 +143,10 @@ class DeconzBaseLight(DeconzDevice, LightEntity):
|
||||||
@property
|
@property
|
||||||
def hs_color(self):
|
def hs_color(self):
|
||||||
"""Return the hs color value."""
|
"""Return the hs color value."""
|
||||||
if self._device.colormode in ("xy", "hs") and self._device.xy:
|
if self._device.colormode in ("xy", "hs"):
|
||||||
|
if self._device.xy:
|
||||||
return color_util.color_xy_to_hs(*self._device.xy)
|
return color_util.color_xy_to_hs(*self._device.xy)
|
||||||
|
return (self._device.hue / 65535 * 360, self._device.sat / 255 * 100)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -163,7 +167,11 @@ class DeconzBaseLight(DeconzDevice, LightEntity):
|
||||||
data["ct"] = kwargs[ATTR_COLOR_TEMP]
|
data["ct"] = kwargs[ATTR_COLOR_TEMP]
|
||||||
|
|
||||||
if ATTR_HS_COLOR in kwargs:
|
if ATTR_HS_COLOR in kwargs:
|
||||||
|
if self._device.xy is not None:
|
||||||
data["xy"] = color_util.color_hs_to_xy(*kwargs[ATTR_HS_COLOR])
|
data["xy"] = color_util.color_hs_to_xy(*kwargs[ATTR_HS_COLOR])
|
||||||
|
else:
|
||||||
|
data["hue"] = int(kwargs[ATTR_HS_COLOR][0] / 360 * 65535)
|
||||||
|
data["sat"] = int(kwargs[ATTR_HS_COLOR][1] / 100 * 255)
|
||||||
|
|
||||||
if ATTR_BRIGHTNESS in kwargs:
|
if ATTR_BRIGHTNESS in kwargs:
|
||||||
data["bri"] = kwargs[ATTR_BRIGHTNESS]
|
data["bri"] = kwargs[ATTR_BRIGHTNESS]
|
||||||
|
|
|
@ -353,3 +353,55 @@ async def test_configuration_tool(hass):
|
||||||
await setup_deconz_integration(hass, get_state_response=data)
|
await setup_deconz_integration(hass, get_state_response=data)
|
||||||
|
|
||||||
assert len(hass.states.async_all()) == 0
|
assert len(hass.states.async_all()) == 0
|
||||||
|
|
||||||
|
|
||||||
|
async def test_lidl_christmas_light(hass):
|
||||||
|
"""Test that lights or groups entities are created."""
|
||||||
|
data = deepcopy(DECONZ_WEB_REQUEST)
|
||||||
|
data["lights"] = {
|
||||||
|
"0": {
|
||||||
|
"etag": "87a89542bf9b9d0aa8134919056844f8",
|
||||||
|
"hascolor": True,
|
||||||
|
"lastannounced": None,
|
||||||
|
"lastseen": "2020-12-05T22:57Z",
|
||||||
|
"manufacturername": "_TZE200_s8gkrkxk",
|
||||||
|
"modelid": "TS0601",
|
||||||
|
"name": "xmas light",
|
||||||
|
"state": {
|
||||||
|
"bri": 25,
|
||||||
|
"colormode": "hs",
|
||||||
|
"effect": "none",
|
||||||
|
"hue": 53691,
|
||||||
|
"on": True,
|
||||||
|
"reachable": True,
|
||||||
|
"sat": 141,
|
||||||
|
},
|
||||||
|
"swversion": None,
|
||||||
|
"type": "Color dimmable light",
|
||||||
|
"uniqueid": "58:8e:81:ff:fe:db:7b:be-01",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
config_entry = await setup_deconz_integration(hass, get_state_response=data)
|
||||||
|
gateway = get_gateway_from_config_entry(hass, config_entry)
|
||||||
|
xmas_light_device = gateway.api.lights["0"]
|
||||||
|
|
||||||
|
assert len(hass.states.async_all()) == 1
|
||||||
|
|
||||||
|
with patch.object(xmas_light_device, "_request", return_value=True) as set_callback:
|
||||||
|
await hass.services.async_call(
|
||||||
|
LIGHT_DOMAIN,
|
||||||
|
SERVICE_TURN_ON,
|
||||||
|
{
|
||||||
|
ATTR_ENTITY_ID: "light.xmas_light",
|
||||||
|
ATTR_HS_COLOR: (20, 30),
|
||||||
|
},
|
||||||
|
blocking=True,
|
||||||
|
)
|
||||||
|
await hass.async_block_till_done()
|
||||||
|
set_callback.assert_called_with(
|
||||||
|
"put",
|
||||||
|
"/lights/0/state",
|
||||||
|
json={"on": True, "hue": 3640, "sat": 76},
|
||||||
|
)
|
||||||
|
|
||||||
|
assert hass.states.get("light.xmas_light")
|
||||||
|
|
Loading…
Reference in New Issue