Skip to content

Keep the integration device ID from its first read - #5943

Merged
bgoncal merged 1 commit into
home-assistant:mainfrom
bgoncal:persist-integration-device-id
Oct 1, 2026
Merged

bgoncal merged 1 commit into
home-assistant:mainfrom
bgoncal:persist-integration-device-id

Conversation

@bgoncal

@bgoncal bgoncal commented Oct 1, 2026

Copy link
Copy Markdown
Member

AI Policy

Select exactly one option that describes AI usage in this contribution:

  • I have not used AI for this contribution.
  • AI assistance was used for this contribution.
  • AI fully generated the code for this contribution, but I've reviewed and understood it before submitting and will respond without AI during review.

Summary

integrationDeviceID, the identifier the server knows an installation by, was derived from the platform's vendor identifier on every read. The first value seen is now stored in the app group and preferred from then on, so a build that derives the identifier differently keeps the registration it already has instead of registering a second device the next time a server is added.

This prepares the move from the Mac Catalyst app to the native macOS app (#5935): the native app cannot produce UIDevice.identifierForVendor, and in a test upgrade on the same Mac, adding a server again went to the "name this device" step because the server's registered device did not match. With the identifier stored by a Catalyst release first, the native app reads the same value.

Nothing is stored while the platform has no identifier to give, so a later read can still pick it up; until then the keychain deviceID fallback applies as before.

Screenshots

Link to pull request in Documentation repository

Documentation: home-assistant/companion.home-assistant#

Any other notes

Should ship in a release before the native macOS app does.

The identifier the server knows an installation by came straight from the platform's vendor identifier on every read. A build that derives it differently, such as the Mac moving from Catalyst to a native app, would register a second device the next time a server is added. The first value seen is now stored in the app group and preferred from then on.
@bgoncal
bgoncal requested a balanced review from Copilot October 1, 2026 15:37
@bgoncal
bgoncal marked this pull request as ready for review October 1, 2026 15:37

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

The implementation matches the migration requirements and includes appropriate isolated tests.

Review effort: Balanced
Findings: None

What changed in this PR

Persists the first available vendor identifier to preserve server registration across Catalyst-to-native macOS migration.

Changes:

  • Store and reuse the first non-nil vendor identifier.
  • Add persistence and fallback tests.
  • Isolate the Watch registrar test from persisted state.
File Description
Sources/​Shared/​Settings/​SettingsStore.swift Persists and reuses the integration device ID.
Tests/​App/​Settings/​SettingsStoreIntegrationDeviceID.test.swift Tests persistence and delayed identifier availability.
Tests/​Shared/​Watch/​WatchDeviceRegistrar.test.swift Preserves stored ID around the test.

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

@codecov

codecov Bot commented Oct 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 51.74%. Comparing base (763d6f0) to head (a45d704).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5943      +/-   ##
==========================================
+ Coverage   51.65%   51.74%   +0.09%     
==========================================
  Files        1231     1231              
  Lines       81093    81146      +53     
==========================================
+ Hits        41888    41990     +102     
+ Misses      39205    39156      -49     
Files with missing lines Coverage Δ
Sources/Shared/Settings/SettingsStore.swift 86.80% <100.00%> (+0.18%) ⬆️

... and 8 files with indirect coverage changes

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@bgoncal
bgoncal merged commit aafbfa6 into home-assistant:main Oct 1, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants