Skip to content

Commit dbafdde

Browse files
committed
Use get_extended_color_zones on devices that support it
Signed-off-by: Avi Miller <me@dje.li>
1 parent cc3c624 commit dbafdde

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

aiolifx_effects/aiolifx_effects.py

+18-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import asyncio
22
import random
3+
from aiolifx.aiolifx import features_map
34

45
from functools import partial
56

@@ -10,7 +11,15 @@
1011
NEUTRAL_WHITE = 3500
1112

1213
def lifx_white(device):
13-
return device.product and device.product in [10, 11, 18]
14+
"""Return true if the device supports neither color or variable temperature and is not a switch."""
15+
return bool(
16+
features_map[device.product]["color"] is False
17+
and features_map[device.product]["temperature_range"] is None
18+
)
19+
20+
def extended_multizone(device):
21+
"""Return try if the device supports extended multizone messages."""
22+
return features_map[device.product]["extended_multizone"]
1423

1524
class PreState:
1625
"""Structure describing a power/color state."""
@@ -85,8 +94,11 @@ async def start(self, effect, participants):
8594
if not self.running.get(device.mac_addr):
8695
tasks.append(AwaitAioLIFX().wait(device.get_color))
8796
if device.color_zones:
88-
for zone in range(0, len(device.color_zones), 8):
89-
tasks.append(AwaitAioLIFX().wait(partial(device.get_color_zones, start_index=zone)))
97+
if extended_multizone(device):
98+
tasks.append(AwaitAioLIFX().wait(device.get_extended_color_zones))
99+
else:
100+
for zone in range(0, len(device.color_zones), 8):
101+
tasks.append(AwaitAioLIFX().wait(partial(device.get_color_zones, start_index=zone)))
90102
if tasks:
91103
await asyncio.wait(tasks)
92104

@@ -95,8 +107,9 @@ async def start(self, effect, participants):
95107
pre_state = running.pre_state if running else PreState(device)
96108
self.running[device.mac_addr] = RunningEffect(effect, pre_state)
97109

98-
# Powered off zones report zero brightness. Get the real values.
99-
await self._fixup_multizone(participants)
110+
# Powered off zones report zero brightness on older multizone devices. Get the real values.
111+
if extended_multizone(device) is False:
112+
await self._fixup_multizone(participants)
100113

101114
self.loop.create_task(effect.async_perform(participants))
102115

0 commit comments

Comments
 (0)