feat: dedicated ProtocolLEDENETExtendedCustom + LED count for 0xB6#539
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests.
... and 1 file with indirect coverage changes 🚀 New features to boost your workflow:
|
617a4b8 to
12c8d8b
Compare
Introduces a dedicated protocol class for the Surplife 0xB6 device, switches the model to it, and adds synchronous-path support. - protocol.py: PROTOCOL_LEDENET_EXTENDED_CUSTOM, LEDENET_EXTENDED_STATE_RESPONSE_LEN, and ProtocolLEDENETExtendedCustom (name, 21-byte state length, extended-only is_valid_state_response, white-off-aware extended_state_to_state, and named_raw_state that converts extended -> standard for the sync path) - device.py: read the full 21-byte extended state and accept it while probing - base_device.py: register the protocol and add supports_extended_custom_effects - models_db.py: point the 0xB6 model at PROTOCOL_LEDENET_EXTENDED_CUSTOM Stacked on the reuse PR.
12c8d8b to
6608f52
Compare
|
Hello @bdraco , this PR is ready for review. |
|
|
bluetoothbot
left a comment
There was a problem hiding this comment.
Blocking issues found.
- led_count only populated on the async path — sync WifiLedBulb.led_count is always None
|
|
bluetoothbot
left a comment
There was a problem hiding this comment.
Blocking issues found.
- Sync read length (21) is shorter than the real 27-byte device frame
5a60df2 to
e0381b2
Compare
|
|
bluetoothbot
left a comment
There was a problem hiding this comment.
Blocking issues found.
- Sync read length (21) truncates the real 27-byte extended frame
LEDENET_EXTENDED_STATE_RESPONSE_LEN was 21 but the real 0xB6 device frame is 27 bytes, so the sync read (device.py::_determine_protocol and ProtocolLEDENETExtendedCustom.state_response_length -> query_state) left 6 trailing bytes in the reused socket buffer, desyncing later same-socket reads. Set it to 27 (0xB6-only: keyed purely off the 0xEA 0x81 header, the sole extended-only device), and replace the synthetic test frames in test_setup_0xB6_surplife / test_0xB6_surplife_sync with the real 27-byte capture so extended_state_to_state is exercised against real wire data.
PR Review — feat: dedicated ProtocolLEDENETExtendedCustom + LED count for 0xB6Solid follow-up to #538 — gives 0xB6 its own protocol class and exposes What's done well:
What needs attention (non-blocking):
Note: PR is marked Draft pending #538 — merge order is a process gate, not a code issue. 🟢 Suggestions
1. extended_state_to_state largely duplicates the parent implementation
|
That's likely going to bite us in the future. Should be refactored into a helper |
Already refactored in this diff. Shared |
PR Review — feat: dedicated ProtocolLEDENETExtendedCustom + LED count for 0xB6Solid, well-scoped protocol addition — the two earlier blockers are resolved and the duplication concern is already refactored away. Merge-ready pending the noted process gate (#538). Strengths:
Needs attention (both non-blocking):
🟢 Suggestions
1. mode = raw_state[8] branch (preset 0x25) is untested and unused by current callers
|
Merge order: #538 → this → effects-api → timers → cli. Draft until #538 lands.
The 0xB6 replies only with the extended state frame (
0xEA 0x81), never the standard0x81. #538 made basic on/off work by reusingProtocolLEDENET25Byte(which already parses that frame). This PR introduces the device's own protocol class so the effect/segment/scribble/timer methods (later PRs) have a home, and exposes the configured pixel count.Changes
protocol.py(+110)ProtocolLEDENETExtendedCustom(subclass ofProtocolLEDENET25Byte). Adds the 21-byte extended-state probe fork,named_raw_stateextended conversion, andextended_state_led_count()(+LEDENET_EXTENDED_STATE_LED_COUNT_POS).base_device.py(+17)process_extended_state_response; add theled_countproperty andsupports_extended_custom_effects.device.py(+13)models_db.py(±10)PROTOCOL_LEDENET_EXTENDED_CUSTOM.tests/test_aio.py(+75),tests/test_sync.py(+38)led_counttests, incl. real captured frames.Protocol: extended state response (
EA 81, 27 bytes, after unwrap)b6), byte 5 = fw version (9), byte 6 = power (0x23on /0x24off), byte 7 = preset (0x66in scribble/static), byte 18 = configured LED count (0x64=100,0x50=80, verified against two real frames).Testing
test_extended_state_led_count: asserts100and80from the two captured frames andNonefor an invalid/short frame. Existing protocol/state tests extended for 0xB6.pytestgreen,ruffclean, no newmypyerrors.On-device verification (device
192.168.1.78):flux_led -s7C3E821AE33F/ 192.168.1.78flux_led <ip> -i--on/--offled_count(state byte 18) tracked the change; bitmap sizing follows