Skip to content

Commit e484521

Browse files
authored
Handle speed not being in delay format for newer 0x35 devices (#438)
1 parent 7d5f9c3 commit e484521

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

flux_led/base_device.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1063,7 +1063,7 @@ def getCCT(self) -> tuple[int, int]:
10631063
@property
10641064
def speed(self) -> int:
10651065
assert self.raw_state is not None
1066-
if self.protocol in ADDRESSABLE_PROTOCOLS:
1066+
if self._protocol is not None and not self._protocol.speed_is_delay:
10671067
return self.raw_state.speed
10681068
if self.protocol in CHRISTMAS_EFFECTS_PROTOCOLS:
10691069
return utils.delayToSpeed(self.raw_state.green)

flux_led/protocol.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,11 @@ def __init__(self) -> None:
416416
self._counter = -1
417417
super().__init__()
418418

419+
@property
420+
def speed_is_delay(self) -> bool:
421+
"""If True the speed is a delay."""
422+
return True
423+
419424
@property
420425
def requires_turn_on(self) -> bool:
421426
"""If True the device must be turned on before setting level/patterns/modes."""
@@ -1408,6 +1413,11 @@ class ProtocolLEDENET25Byte(ProtocolLEDENET9Byte):
14081413

14091414
level_write_modes = LevelWriteModeData(ALL=0x00, COLORS=0xA1, WHITES=0xB1)
14101415

1416+
@property
1417+
def speed_is_delay(self) -> bool:
1418+
"""If True the speed is a delay."""
1419+
return False
1420+
14111421
@property
14121422
def name(self) -> str:
14131423
"""The name of the protocol."""
@@ -1499,6 +1509,11 @@ def timer_len(self) -> int:
14991509
"""Return a single timer len."""
15001510
return 14
15011511

1512+
@property
1513+
def speed_is_delay(self) -> bool:
1514+
"""If True the speed is a delay."""
1515+
return False
1516+
15021517

15031518
class ProtocolLEDENETAddressableA1(ProtocolLEDENETAddressableBase):
15041519
def construct_request_strip_setting(self) -> bytearray:
@@ -2386,6 +2401,11 @@ def construct_levels_change(
23862401

23872402

23882403
class ProtocolLEDENETAddressableChristmas(ProtocolLEDENETAddressableBase):
2404+
@property
2405+
def speed_is_delay(self) -> bool:
2406+
"""If True the speed is a delay in ms."""
2407+
return True
2408+
23892409
def construct_state_query(self) -> bytearray:
23902410
"""The bytes to send for a query request."""
23912411
return self.construct_wrapped_message(

tests/test_sync.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -873,6 +873,7 @@ def read_data(expected):
873873
self.assertEqual(light.protocol, PROTOCOL_LEDENET_25BYTE)
874874
self.assertEqual(light.model_num, 0x35)
875875
self.assertEqual(light.version_num, 10)
876+
self.assertEqual(light.speed, 64)
876877

877878
light.setRgb(255, 100, 50)
878879
self.assertEqual(mock_send.call_count, 2)

0 commit comments

Comments
 (0)