Skip to content

Use zc95's serial no. info in fw >=2.0#94

Merged
heavyrubberslave merged 2 commits into
mainfrom
chore/zc95-deterministic-device-id
Jul 14, 2026
Merged

Use zc95's serial no. info in fw >=2.0#94
heavyrubberslave merged 2 commits into
mainfrom
chore/zc95-deterministic-device-id

Conversation

@heavyrubberslave

@heavyrubberslave heavyrubberslave commented Jul 14, 2026

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • New Features

    • Devices with available serial numbers now receive consistent identities and names across connections.
    • Previously recognized devices retain their existing identity and name.
    • Devices without serial numbers continue using their transport-provided identity.
  • Bug Fixes

    • Prevented known-device records from being saved when serial information is unavailable.
    • Device creation now correctly surfaces pattern-list retrieval errors without saving incomplete records.

@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The ZC95 version response now includes an optional serial number. The device factory derives deterministic identities from serial numbers, reuses existing known devices, persists new known devices when applicable, and adds unit coverage for fallback, reuse, persistence, and failure paths.

Changes

ZC95 known-device identity

Layer / File(s) Summary
Serial-based identity and factory integration
src/device/protocol/zc95/zc95MessageFactory.ts, src/device/protocol/zc95/zc95DeviceFactory.ts
VersionDetails exposes SerialNo; the factory resolves existing or new known devices and uses their identity and name when constructing Zc95Device.
Factory behavior coverage
tests/unit/device/protocol/zc95/zc95DeviceFactory.spec.ts
Tests cover serial-less fallback, deterministic serial-based identity, existing-device reuse, persistence, and failed pattern-list retrieval.

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

Sequence Diagram(s)

sequenceDiagram
  participant Zc95DeviceFactory
  participant ProtocolHandler
  participant Settings
  participant NameGenerator
  Zc95DeviceFactory->>ProtocolHandler: Fetch device version and pattern list
  Zc95DeviceFactory->>Settings: Look up serial-derived KnownDevice
  Settings-->>Zc95DeviceFactory: Return existing device or no match
  Zc95DeviceFactory->>NameGenerator: Generate name for a new device
  Zc95DeviceFactory->>Settings: Persist KnownDevice when SerialNo exists
  Zc95DeviceFactory-->>Zc95DeviceFactory: Construct Zc95Device
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
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.
Title check ✅ Passed The title matches the main change: using ZC95 serial number data for devices on firmware 2.0+.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/zc95-deterministic-device-id

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.

@heavyrubberslave
heavyrubberslave marked this pull request as ready for review July 14, 2026 19:00

@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: 2

🤖 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 `@tests/unit/device/protocol/zc95/zc95DeviceFactory.spec.ts`:
- Around line 89-90: Update the assertions in
tests/unit/device/protocol/zc95/zc95DeviceFactory.spec.ts at lines 89-90,
108-110, and 140-141 to use PeripheralDevice properties deviceId and deviceName
instead of getDeviceId and getDeviceName, preserving the existing expected
values.
- Around line 89-90: Update the assertions in the device factory test to access
the existing deviceId and deviceName getter properties instead of getDeviceId
and getDeviceName, while preserving the expected transportDeviceId and Generated
Name values.
🪄 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: b5aff874-ba04-4406-921b-11ce5a3a6176

📥 Commits

Reviewing files that changed from the base of the PR and between b97411c and 3139ca6.

📒 Files selected for processing (3)
  • src/device/protocol/zc95/zc95DeviceFactory.ts
  • src/device/protocol/zc95/zc95MessageFactory.ts
  • tests/unit/device/protocol/zc95/zc95DeviceFactory.spec.ts

Comment thread tests/unit/device/protocol/zc95/zc95DeviceFactory.spec.ts
@heavyrubberslave heavyrubberslave added the patch Creates a new patch/bugfix release if merged label Jul 14, 2026
@heavyrubberslave
heavyrubberslave merged commit 1822628 into main Jul 14, 2026
7 checks passed
@heavyrubberslave
heavyrubberslave deleted the chore/zc95-deterministic-device-id branch July 14, 2026 21:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

patch Creates a new patch/bugfix release if merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant