1
1
import asyncio
2
2
import random
3
+ from aiolifx .aiolifx import features_map
3
4
4
5
from functools import partial
5
6
10
11
NEUTRAL_WHITE = 3500
11
12
12
13
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" ]
14
23
15
24
class PreState :
16
25
"""Structure describing a power/color state."""
@@ -85,8 +94,11 @@ async def start(self, effect, participants):
85
94
if not self .running .get (device .mac_addr ):
86
95
tasks .append (AwaitAioLIFX ().wait (device .get_color ))
87
96
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 )))
90
102
if tasks :
91
103
await asyncio .wait (tasks )
92
104
@@ -95,8 +107,9 @@ async def start(self, effect, participants):
95
107
pre_state = running .pre_state if running else PreState (device )
96
108
self .running [device .mac_addr ] = RunningEffect (effect , pre_state )
97
109
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 )
100
113
101
114
self .loop .create_task (effect .async_perform (participants ))
102
115
0 commit comments