lifx-async 4.3.4__py3-none-any.whl → 4.3.5__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
lifx/devices/matrix.py CHANGED
@@ -171,11 +171,6 @@ class MatrixEffect:
171
171
 
172
172
  def __post_init__(self) -> None:
173
173
  """Initialize defaults and validate fields."""
174
- # Initialize default palette if not provided
175
- if self.palette is None:
176
- # Default palette: single white color
177
- self.palette = [HSBK(0, 0, 1.0, 3500)]
178
-
179
174
  # Validate all fields
180
175
  # Speed can be 0 only when effect is OFF
181
176
  if self.effect_type != FirmwareEffect.OFF:
@@ -184,7 +179,11 @@ class MatrixEffect:
184
179
  raise ValueError(f"Effect speed must be non-negative, got {self.speed}")
185
180
 
186
181
  self._validate_duration(self.duration)
187
- self._validate_palette(self.palette)
182
+
183
+ # Only validate palette if provided
184
+ if self.palette is not None:
185
+ self._validate_palette(self.palette)
186
+
188
187
  self._validate_saturation(self.cloud_saturation_min, "cloud_saturation_min")
189
188
  self._validate_saturation(self.cloud_saturation_max, "cloud_saturation_max")
190
189
 
@@ -762,7 +761,7 @@ class MatrixLight(Light):
762
761
  effect_type: Type of effect (OFF, MORPH, FLAME, SKY)
763
762
  speed: Effect speed in seconds (default: 3)
764
763
  duration: Total effect duration in nanoseconds (0 for infinite)
765
- palette: Color palette for the effect (max 16 colors)
764
+ palette: Color palette for the effect (max 16 colors, None for no palette)
766
765
  sky_type: Sky effect type (SUNRISE, SUNSET, CLOUDS)
767
766
  cloud_saturation_min: Minimum cloud saturation (0-255, for CLOUDS)
768
767
  cloud_saturation_max: Maximum cloud saturation (0-255, for CLOUDS)
@@ -780,6 +779,12 @@ class MatrixLight(Light):
780
779
  ... speed=5.0,
781
780
  ... palette=rainbow,
782
781
  ... )
782
+
783
+ >>> # Set effect without a palette
784
+ >>> await matrix.set_effect(
785
+ ... effect_type=FirmwareEffect.FLAME,
786
+ ... speed=3.0,
787
+ ... )
783
788
  """
784
789
  _LOGGER.debug(
785
790
  "Setting matrix effect %s (speed=%d) for %s",
@@ -801,20 +806,22 @@ class MatrixLight(Light):
801
806
  )
802
807
 
803
808
  # Convert to protocol format
804
- # Note: palette is guaranteed to be non-None by MatrixEffect.__post_init__
805
- palette = effect.palette if effect.palette is not None else []
806
809
  proto_palette = []
807
- for color in palette:
808
- proto_palette.append(
809
- LightHsbk(
810
- hue=int(color.hue / 360 * 65535),
811
- saturation=int(color.saturation * 65535),
812
- brightness=int(color.brightness * 65535),
813
- kelvin=color.kelvin,
810
+ palette_count = 0
811
+
812
+ if effect.palette is not None:
813
+ palette_count = len(effect.palette)
814
+ for color in effect.palette:
815
+ proto_palette.append(
816
+ LightHsbk(
817
+ hue=int(color.hue / 360 * 65535),
818
+ saturation=int(color.saturation * 65535),
819
+ brightness=int(color.brightness * 65535),
820
+ kelvin=color.kelvin,
821
+ )
814
822
  )
815
- )
816
823
 
817
- # Pad palette to 16 colors
824
+ # Pad palette to 16 colors (protocol requirement)
818
825
  while len(proto_palette) < 16:
819
826
  proto_palette.append(LightHsbk(0, 0, 0, 3500))
820
827
 
@@ -828,7 +835,7 @@ class MatrixLight(Light):
828
835
  cloud_saturation_min=effect.cloud_saturation_min,
829
836
  cloud_saturation_max=effect.cloud_saturation_max,
830
837
  ),
831
- palette_count=len(palette),
838
+ palette_count=palette_count,
832
839
  palette=proto_palette,
833
840
  )
834
841
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: lifx-async
3
- Version: 4.3.4
3
+ Version: 4.3.5
4
4
  Summary: A modern, type-safe, async Python library for controlling LIFX lights
5
5
  Author-email: Avi Miller <me@dje.li>
6
6
  Maintainer-email: Avi Miller <me@dje.li>
@@ -9,7 +9,7 @@ lifx/devices/base.py,sha256=uD3hQe2kjycRZneSptON6psOhoEgPRHVelCoLgdHbFw,41482
9
9
  lifx/devices/hev.py,sha256=2zZNYm3TFrL755B4cRPNdYtcDLZEQwGl_22112WsSZc,9504
10
10
  lifx/devices/infrared.py,sha256=TrCgJyEioIPlFumMmcSmuGYmRsSGlQ5Rllg6_9Wtg4Y,4248
11
11
  lifx/devices/light.py,sha256=9rL24fa44Y7QrRBDSQuG6xpWsaPbQTTm4ExvrDnYWHo,27572
12
- lifx/devices/matrix.py,sha256=zj_AE2C0WfSjMZw8X7Y6KkG1PUr0ViLC7zvVrVnWMPI,32504
12
+ lifx/devices/matrix.py,sha256=mleYYsXkvvfXxV_pScb_D7VoX0AEJkClpzpNXOzQyGs,32643
13
13
  lifx/devices/multizone.py,sha256=c-lXcp8c1Mhs8me6smGkqQFrOOxdoGjWrOO5HnAVooY,27209
14
14
  lifx/effects/__init__.py,sha256=4DF31yp7RJic5JoltMlz5dCtF5KQobU6NOUtLUKkVKE,1509
15
15
  lifx/effects/base.py,sha256=YO0Hbg2VYHKPtfYnWxmrtzYoPGOi9BUXhn8HVFKv5IM,10283
@@ -40,7 +40,7 @@ lifx/theme/canvas.py,sha256=4h7lgN8iu_OdchObGDgbxTqQLCb-FRKC-M-YCWef_i4,8048
40
40
  lifx/theme/generators.py,sha256=L0X6_iApLx6XDboGlYunaVsl6nvUCqMfn23VQmRkyCk,6125
41
41
  lifx/theme/library.py,sha256=tKlKZNqJp8lRGDnilWyDm_Qr1vCRGGwuvWVS82anNpQ,21326
42
42
  lifx/theme/theme.py,sha256=qMEx_8E41C0Cc6f083XHiAXEglTv4YlXW0UFsG1rQKg,5521
43
- lifx_async-4.3.4.dist-info/METADATA,sha256=MkrET2BAkIwK9D5rlzSmJyM9pp2DyHzBbSjHLvF27AM,2609
44
- lifx_async-4.3.4.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
45
- lifx_async-4.3.4.dist-info/licenses/LICENSE,sha256=eBz48GRA3gSiWn3rYZAz2Ewp35snnhV9cSqkVBq7g3k,1832
46
- lifx_async-4.3.4.dist-info/RECORD,,
43
+ lifx_async-4.3.5.dist-info/METADATA,sha256=S7yNp4EX1b3pNjZUoGGcF7GX5_YpHgpeh0qhKClN0S4,2609
44
+ lifx_async-4.3.5.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
45
+ lifx_async-4.3.5.dist-info/licenses/LICENSE,sha256=eBz48GRA3gSiWn3rYZAz2Ewp35snnhV9cSqkVBq7g3k,1832
46
+ lifx_async-4.3.5.dist-info/RECORD,,