Skip to content

chore: split AiroticDeviceProvider into factory, drop dead Zc95SerialReader#96

Merged
heavyrubberslave merged 2 commits into
mainfrom
chore/small-cleanup
Jul 16, 2026
Merged

chore: split AiroticDeviceProvider into factory, drop dead Zc95SerialReader#96
heavyrubberslave merged 2 commits into
mainfrom
chore/small-cleanup

Conversation

@heavyrubberslave

@heavyrubberslave heavyrubberslave commented Jul 16, 2026

Copy link
Copy Markdown
Member

Changes

  • Extract AiroticDeviceFactory from AiroticDeviceProvider, matching the factory pattern already used by the other device providers (Zc95, Estim2b, SlvCtrlPlus). The provider now only handles BLE transport/protocol/handshake; device construction (known device resolution, attribute setup) lives in the factory.
  • Remove Zc95SerialReader — dead code, unused since the message-factory based zc95 protocol implementation replaced it (untouched since Cleanup devicemanager provider and events #74).
  • Fix typo: airtonicProtocol.ts -> airoticProtocol.ts (pure rename, no content change).

Testing

  • npm run typecheck
  • npm run lint
  • npm run build
  • npm test (358 tests passing)

Summary by CodeRabbit

  • New Features

    • Added support for connecting to and creating Airotic devices over Bluetooth.
    • Added protocol actions for selecting, setting, and resetting colors, plus rebooting.
    • Initial device colors are detected from advertised Bluetooth data.
    • Registered Airotic device discovery and creation with the service system.
  • Bug Fixes

    • Corrected the Airotic protocol module reference to ensure device connections and tests use the proper implementation.
  • Refactor

    • Centralized Airotic device creation to improve connection handling.

…Reader

- Extract AiroticDeviceFactory from AiroticDeviceProvider, matching the
  factory pattern used by the other device providers (Zc95, Estim2b,
  SlvCtrlPlus). Provider now only handles BLE transport/protocol/handshake.
- Remove Zc95SerialReader, unused since the message-factory based zc95
  protocol implementation replaced it.
- Fix typo: airtonicProtocol.ts -> airoticProtocol.ts
@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@heavyrubberslave, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 42 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 79df02c1-7d07-44e9-b0c5-bb153859935f

📥 Commits

Reviewing files that changed from the base of the PR and between b047661 and dc07ea9.

📒 Files selected for processing (1)
  • src/device/protocol/airotic/airoticDeviceFactory.ts
📝 Walkthrough

Walkthrough

Adds the Airotic protocol and factory, delegates BLE device construction through dependency injection, corrects protocol imports, and removes the Zc95 serial reader.

Changes

Airotic device creation flow

Layer / File(s) Summary
Airotic protocol contract
src/device/protocol/airotic/airoticProtocol.ts, src/device/protocol/airotic/airoticDevice.ts, tests/unit/device/protocol/airotic/*
Defines Airotic message types, encoding, decoding, response matching, and command builders, with corrected protocol import paths in device code and tests.
Factory-backed device construction
src/device/protocol/airotic/airoticDeviceFactory.ts, src/device/protocol/airotic/airoticDeviceProvider.ts
Moves known-device resolution, advertised-color parsing, attribute creation, and device instantiation into AiroticDeviceFactory; the provider invokes it after the BLE handshake.
Service wiring
src/serviceMap.ts, src/serviceProvider/deviceServiceProvider.ts
Registers the Airotic factory and injects it into the Airotic provider factory.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant BLEPeripheral
  participant AiroticDeviceProvider
  participant AiroticProtocol
  participant AiroticDeviceFactory
  participant KnownDeviceRegistry
  BLEPeripheral->>AiroticDeviceProvider: establish UART transport
  AiroticDeviceProvider->>AiroticProtocol: send hello message
  AiroticProtocol-->>AiroticDeviceProvider: match hello response
  AiroticDeviceProvider->>AiroticDeviceFactory: create device
  AiroticDeviceFactory->>KnownDeviceRegistry: resolve and persist identity
  AiroticDeviceFactory-->>AiroticDeviceProvider: return AiroticDevice
Loading

Possibly related PRs

Suggested labels: patch

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main changes: extracting the Airotic device factory and removing the unused Zc95SerialReader.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/small-cleanup

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/device/protocol/airotic/airoticDeviceFactory.ts`:
- Around line 87-100: Verify the device protocol’s advertised color byte layout,
then resolve the mismatch between the parseAdvertisedColors JSDoc and its
colorStartH/S and colorTargetH/S assignments. Update the documentation or
implementation so indices 3–4 and 5–6 consistently represent the actual protocol
fields, preserving the resulting restColor and breathInColor behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 06079e88-4723-489a-a866-ad3ac0f32078

📥 Commits

Reviewing files that changed from the base of the PR and between afb2358 and b047661.

📒 Files selected for processing (9)
  • src/device/protocol/airotic/airoticDevice.ts
  • src/device/protocol/airotic/airoticDeviceFactory.ts
  • src/device/protocol/airotic/airoticDeviceProvider.ts
  • src/device/protocol/airotic/airoticProtocol.ts
  • src/device/protocol/zc95/Zc95SerialReader.ts
  • src/serviceMap.ts
  • src/serviceProvider/deviceServiceProvider.ts
  • tests/unit/device/protocol/airotic/airoticDevice.spec.ts
  • tests/unit/device/protocol/airotic/airoticProtocol.spec.ts
💤 Files with no reviewable changes (1)
  • src/device/protocol/zc95/Zc95SerialReader.ts

Comment thread src/device/protocol/airotic/airoticDeviceFactory.ts
@heavyrubberslave
heavyrubberslave merged commit 5cfa364 into main Jul 16, 2026
7 checks passed
@heavyrubberslave
heavyrubberslave deleted the chore/small-cleanup branch July 16, 2026 20:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant