Bump aiolifx and aiolifx-themes to support more than 82 zones (#125487)

Signed-off-by: Avi Miller <me@dje.li>
This commit is contained in:
Avi Miller 2024-09-08 17:53:32 +10:00 committed by GitHub
parent 5e1b4b2d23
commit 5108e1a1cd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 109 additions and 41 deletions

View File

@ -48,8 +48,8 @@
"iot_class": "local_polling",
"loggers": ["aiolifx", "aiolifx_effects", "bitstring"],
"requirements": [
"aiolifx==1.0.9",
"aiolifx==1.1.1",
"aiolifx-effects==0.3.2",
"aiolifx-themes==0.5.0"
"aiolifx-themes==0.5.5"
]
}

View File

@ -273,10 +273,10 @@ aiokef==0.2.16
aiolifx-effects==0.3.2
# homeassistant.components.lifx
aiolifx-themes==0.5.0
aiolifx-themes==0.5.5
# homeassistant.components.lifx
aiolifx==1.0.9
aiolifx==1.1.1
# homeassistant.components.livisi
aiolivisi==0.0.19

View File

@ -255,10 +255,10 @@ aiokafka==0.10.0
aiolifx-effects==0.3.2
# homeassistant.components.lifx
aiolifx-themes==0.5.0
aiolifx-themes==0.5.5
# homeassistant.components.lifx
aiolifx==1.0.9
aiolifx==1.1.1
# homeassistant.components.livisi
aiolivisi==0.0.19

View File

@ -65,10 +65,13 @@ class MockLifxCommand:
"""Init command."""
self.bulb = bulb
self.calls = []
self.msg_kwargs = kwargs
self.msg_kwargs = {
k.removeprefix("msg_"): v for k, v in kwargs.items() if k.startswith("msg_")
}
for k, v in kwargs.items():
if k != "callb":
setattr(self.bulb, k, v)
if k.startswith("msg_") or k == "callb":
continue
setattr(self.bulb, k, v)
def __call__(self, *args, **kwargs):
"""Call command."""
@ -156,9 +159,16 @@ def _mocked_infrared_bulb() -> Light:
def _mocked_light_strip() -> Light:
bulb = _mocked_bulb()
bulb.product = 31 # LIFX Z
bulb.color_zones = [MagicMock(), MagicMock()]
bulb.zones_count = 3
bulb.color_zones = [MagicMock()] * 3
bulb.effect = {"effect": "MOVE", "speed": 3, "duration": 0, "direction": "RIGHT"}
bulb.get_color_zones = MockLifxCommand(bulb)
bulb.get_color_zones = MockLifxCommand(
bulb,
msg_seq_num=bulb.seq_next(),
msg_count=bulb.zones_count,
msg_index=0,
msg_color=bulb.color_zones,
)
bulb.set_color_zones = MockLifxCommand(bulb)
bulb.get_multizone_effect = MockLifxCommand(bulb)
bulb.set_multizone_effect = MockLifxCommand(bulb)

View File

@ -9,6 +9,7 @@ from . import (
DEFAULT_ENTRY_TITLE,
IP_ADDRESS,
SERIAL,
MockLifxCommand,
_mocked_bulb,
_mocked_clean_bulb,
_mocked_infrared_bulb,
@ -188,6 +189,22 @@ async def test_legacy_multizone_bulb_diagnostics(
)
config_entry.add_to_hass(hass)
bulb = _mocked_light_strip()
bulb.get_color_zones = MockLifxCommand(
bulb,
msg_seq_num=0,
msg_count=8,
msg_color=[
(54612, 65535, 65535, 3500),
(54612, 65535, 65535, 3500),
(54612, 65535, 65535, 3500),
(54612, 65535, 65535, 3500),
(46420, 65535, 65535, 3500),
(46420, 65535, 65535, 3500),
(46420, 65535, 65535, 3500),
(46420, 65535, 65535, 3500),
],
msg_index=0,
)
bulb.zones_count = 8
bulb.color_zones = [
(54612, 65535, 65535, 3500),
@ -302,6 +319,22 @@ async def test_multizone_bulb_diagnostics(
config_entry.add_to_hass(hass)
bulb = _mocked_light_strip()
bulb.product = 38
bulb.get_color_zones = MockLifxCommand(
bulb,
msg_seq_num=0,
msg_count=8,
msg_color=[
(54612, 65535, 65535, 3500),
(54612, 65535, 65535, 3500),
(54612, 65535, 65535, 3500),
(54612, 65535, 65535, 3500),
(46420, 65535, 65535, 3500),
(46420, 65535, 65535, 3500),
(46420, 65535, 65535, 3500),
(46420, 65535, 65535, 3500),
],
msg_index=0,
)
bulb.zones_count = 8
bulb.color_zones = [
(54612, 65535, 65535, 3500),

View File

@ -192,15 +192,7 @@ async def test_light_strip(hass: HomeAssistant) -> None:
{ATTR_ENTITY_ID: entity_id, ATTR_BRIGHTNESS: 100},
blocking=True,
)
call_dict = bulb.set_color_zones.calls[0][1]
call_dict.pop("callb")
assert call_dict == {
"apply": 0,
"color": [],
"duration": 0,
"end_index": 0,
"start_index": 0,
}
assert len(bulb.set_color_zones.calls) == 0
bulb.set_color_zones.reset_mock()
await hass.services.async_call(
@ -209,15 +201,7 @@ async def test_light_strip(hass: HomeAssistant) -> None:
{ATTR_ENTITY_ID: entity_id, ATTR_HS_COLOR: (10, 30)},
blocking=True,
)
call_dict = bulb.set_color_zones.calls[0][1]
call_dict.pop("callb")
assert call_dict == {
"apply": 0,
"color": [],
"duration": 0,
"end_index": 0,
"start_index": 0,
}
assert len(bulb.set_color_zones.calls) == 0
bulb.set_color_zones.reset_mock()
bulb.color_zones = [
@ -238,7 +222,7 @@ async def test_light_strip(hass: HomeAssistant) -> None:
blocking=True,
)
# Single color uses the fast path
assert bulb.set_color.calls[0][0][0] == [1820, 19660, 65535, 3500]
assert bulb.set_color.calls[1][0][0] == [1820, 19660, 65535, 3500]
bulb.set_color.reset_mock()
assert len(bulb.set_color_zones.calls) == 0
@ -422,7 +406,9 @@ async def test_light_strip(hass: HomeAssistant) -> None:
blocking=True,
)
bulb.get_color_zones = MockLifxCommand(bulb)
bulb.get_color_zones = MockLifxCommand(
bulb, msg_seq_num=0, msg_color=[0, 0, 65535, 3500] * 3, msg_index=0, msg_count=3
)
bulb.get_color = MockFailingLifxCommand(bulb)
with pytest.raises(HomeAssistantError):
@ -587,14 +573,14 @@ async def test_extended_multizone_messages(hass: HomeAssistant) -> None:
bulb.set_extended_color_zones.reset_mock()
bulb.color_zones = [
(0, 65535, 65535, 3500),
(54612, 65535, 65535, 3500),
(54612, 65535, 65535, 3500),
(54612, 65535, 65535, 3500),
(46420, 65535, 65535, 3500),
(46420, 65535, 65535, 3500),
(46420, 65535, 65535, 3500),
(46420, 65535, 65535, 3500),
[0, 65535, 65535, 3500],
[54612, 65535, 65535, 3500],
[54612, 65535, 65535, 3500],
[54612, 65535, 65535, 3500],
[46420, 65535, 65535, 3500],
[46420, 65535, 65535, 3500],
[46420, 65535, 65535, 3500],
[46420, 65535, 65535, 3500],
]
await hass.services.async_call(
@ -1308,7 +1294,11 @@ async def test_config_zoned_light_strip_fails(
def __call__(self, callb=None, *args, **kwargs):
"""Call command."""
self.call_count += 1
response = None if self.call_count >= 2 else MockMessage()
response = (
None
if self.call_count >= 2
else MockMessage(seq_num=0, color=[], index=0, count=0)
)
if callb:
callb(self.bulb, response)
@ -1349,7 +1339,15 @@ async def test_legacy_zoned_light_strip(
self.call_count += 1
self.bulb.color_zones = [None] * 12
if callb:
callb(self.bulb, MockMessage())
callb(
self.bulb,
MockMessage(
seq_num=0,
index=0,
count=self.bulb.zones_count,
color=self.bulb.color_zones,
),
)
get_color_zones_mock = MockPopulateLifxZonesCommand(light_strip)
light_strip.get_color_zones = get_color_zones_mock
@ -1946,6 +1944,33 @@ async def test_light_strip_zones_not_populated_yet(hass: HomeAssistant) -> None:
bulb.power_level = 65535
bulb.color_zones = None
bulb.color = [65535, 65535, 65535, 65535]
bulb.get_color_zones = next(
iter(
[
MockLifxCommand(
bulb,
msg_seq_num=0,
msg_color=[0, 0, 65535, 3500] * 8,
msg_index=0,
msg_count=16,
),
MockLifxCommand(
bulb,
msg_seq_num=1,
msg_color=[0, 0, 65535, 3500] * 8,
msg_index=0,
msg_count=16,
),
MockLifxCommand(
bulb,
msg_seq_num=2,
msg_color=[0, 0, 65535, 3500] * 8,
msg_index=8,
msg_count=16,
),
]
)
)
assert bulb.get_color_zones.calls == []
with (