Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Sep 8, 2024
Merged
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
4 changes: 2 additions & 2 deletions homeassistant/components/lifx/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
}
4 changes: 2 additions & 2 deletions requirements_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions requirements_test_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 15 additions & 5 deletions tests/components/lifx/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,13 @@ def __init__(self, bulb, **kwargs: Any) -> None:
"""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."""
Expand Down Expand Up @@ -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)
Expand Down
33 changes: 33 additions & 0 deletions tests/components/lifx/test_diagnostics.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
DEFAULT_ENTRY_TITLE,
IP_ADDRESS,
SERIAL,
MockLifxCommand,
_mocked_bulb,
_mocked_clean_bulb,
_mocked_infrared_bulb,
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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),
Expand Down
85 changes: 55 additions & 30 deletions tests/components/lifx/test_light.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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 = [
Expand All @@ -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

Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -1308,7 +1294,11 @@ def __init__(self, bulb, **kwargs: Any) -> None:
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)

Expand Down Expand Up @@ -1349,7 +1339,15 @@ def __call__(self, callb=None, *args, **kwargs):
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
Expand Down Expand Up @@ -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 (
Expand Down
Loading