Skip to content

fix(leds): add initial color parameter and implement retry logic for … - #102

Merged
Tanchouteur merged 1 commit into
mainfrom
fix-leds
Sep 4, 2026
Merged

fix(leds): add initial color parameter and implement retry logic for …#102
Tanchouteur merged 1 commit into
mainfrom
fix-leds

Conversation

@Tanchouteur

Copy link
Copy Markdown
Owner

This pull request introduces improvements to the LED controller service, focusing on more robust initial color dispatch and retry logic for BLE device communication. The changes allow the initial LED color to be set from the configuration, implement bounded retry attempts for startup color dispatch, and add comprehensive tests for these behaviors.

LED Controller Improvements:

  • The BleLedController now accepts an initial_color parameter, allowing the initial LED color to be set from the vehicle configuration instead of being hardcoded. (main.py, src/services/led_service.py) [1][2][3]
  • On startup, the controller attempts to dispatch the initial color to all devices with multiple retries (bounded by STARTUP_RETRY_DELAYS), improving reliability in case of transient connection issues. Subsequent color updates do not use retries. (src/services/led_service.py) [1][2][3]
  • The method for sending colors to devices has been refactored: _send_to_device now supports bounded retries and returns a boolean indicating success, while the actual send logic is moved to _send_to_device_once. (src/services/led_service.py) [1][2][3][4]

Testing Enhancements:

  • New and updated tests verify that the initial color is queued and dispatched correctly, that startup dispatch uses retries, and that retries stop after the first update. (tests/test_led_service.py) [1][2]

Other:

  • The project version is bumped from 2.0.1-rc.15 to 2.0.1-rc.16. (VERSION)

@TanchouteurTanchouteur self-assigned this Sep 4, 2026
CopilotAI lite review requested due to automatic review settings September 4, 2026 10:09
@TanchouteurTanchouteur added the enhancement New feature or request label Sep 4, 2026

CopilotAI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

It introduces a couple of correctness edge cases (config-driven color normalization and retry delay indexing safety) that should be addressed before merging.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR improves the BLE LED controller startup behavior by allowing the initial LED color to come from vehicle configuration and by adding bounded retry logic for the initial (startup) dispatch, with tests covering the new behavior.

Changes:

  • Added initial_color parameter to BleLedController and wired it from vehicle_config["theme"]["main"].
  • Implemented bounded retry attempts for the startup color dispatch only, refactoring send logic into retry wrapper + single-attempt method.
  • Expanded unit tests to cover startup retry behavior and ensure later updates do not retry; bumped project version.
File summaries
FileDescription
src/services/led_service.pyAdds initial_color, startup-only retry logic, and refactors device send into retry + single-attempt methods.
main.pyPasses the configured theme color into BleLedController as initial_color.
tests/test_led_service.pyAdds/updates tests for initial color queueing and startup retry vs. subsequent update behavior.
VERSIONBumps version from 2.0.1-rc.15 to 2.0.1-rc.16.
Review details
  • Files reviewed: 4/4 changed files
  • Comments generated: 3
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines 33 to 36
def __init__(self, storage=None, catalog: Optional[DeviceCatalog] = None,
registry: Optional[ProtocolRegistry] = None):
registry: Optional[ProtocolRegistry] = None,
initial_color: str = "#48B8FF"):
super().__init__("Leds", storage)
Comment on lines +286 to +287
delay_index = min(attempt_index, len(self.STARTUP_RETRY_DELAYS) - 1)
await asyncio.sleep(self.STARTUP_RETRY_DELAYS[delay_index])

with mock.patch.object(service, "_send_to_device", side_effect=capture):
await service._ble_worker()
self.assertEqual(attempts, [3, 1])
@Tanchouteur
Tanchouteur merged commit aa6e4a7 into mainSep 4, 2026
8 checks passed
@Tanchouteur
Tanchouteur deleted the fix-leds branch September 4, 2026 10:27
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancementNew feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@Tanchouteur