Skip to content

Add nameBasedUniqueId for stable device identification across re-pairings#35

Merged
bwp91 merged 8 commits into
beta-3.3.1from
copilot/fix-uniqueid-issue
Mar 4, 2026
Merged

Add nameBasedUniqueId for stable device identification across re-pairings#35
bwp91 merged 8 commits into
beta-3.3.1from
copilot/fix-uniqueid-issue

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 2, 2026

  • Add nameBasedUniqueId field to ServiceType interface in interfaces.ts
  • Compute nameBasedUniqueId in index.ts using stable fields joined with | delimiters
  • Sync branch with latest beta-3.3.1 changes (monitor fix, dependency updates)
  • Add .github/copilot-instructions.md with note to always update CHANGELOG with code changes
  • Add changelog entry for nameBasedUniqueId feature under existing v3.4.0 release
  • Build and tests pass (19/19)
Original prompt

This section details on the original issue you should resolve

<issue_title>HAP-Client uniqueId is different when a device is removed then added, even though HomeKit thinks its the same device</issue_title>
<issue_description>### Current Situation

service.uniqueId = createHash('sha256')
.update(${service.instance.username}${service.aid}${service.iid}${service.type})
.digest('hex');

AID increments when a accessory is removed and added

Proposed Change

This creates the same token for the same device when deleting and adding - ${service.instance.name}${service.instance.username}${service.accessoryInformation.Manufacturer}${friendlyName}${service.uuid.slice(0, 8)}

Additional Context

No response</issue_description>

<agent_instructions>When resolving this issue, pls create a new variable, 'nameBasedUniqueID', and to maintain backwards compatibility pls do not change uniqueID</agent_instructions>

Comments on the Issue (you are @copilot in this section)

@bwp91 @NorthernMan54 could we revisit this proposal again? it would be really helpful for the UI if accessories always had the same unique id. @NorthernMan54 @bwp91 definitely, let me look at the dependant projects to see about usage etc

One challenge with changing a unique ID definition is that all the devices will appear as new on implementation. Which will cause issues for the dependant projects.

But I recall over riding this, so it may be a non issue.</comment_new>
<comment_new>@NorthernMan54
Checking dependencies, only UI, GSH and Homebridge-automation use this package

Homebridge-automation overwrites the supplied unique ID - https://github.com/NorthernMan54/node-red-contrib-homebridge-automation/blob/f5bf77077439179325bbf01367f8c4dcd8f23e57/src/hbConfigNode.js#L70

GSH - And it is overwritten here as well, but with the broken approach - https://github.com/homebridge-plugins/homebridge-gsh/blob/f499173ed59952e274d773a5c01d9651ac8ea0f9/src/hap.ts#L381

When I refreshed GSH, I did not change the uniqueID logic, as it would break the setup of all existing users.....

So we can go ahead with this, and I will do a test of the packages when it is in Beta</comment_new>


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: NorthernMan54 <19808920+NorthernMan54@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix uniqueId generation for added devices Add nameBasedUniqueId for stable device identification across re-pairings Mar 2, 2026
@bwp91 bwp91 deleted the branch beta-3.3.1 March 3, 2026 21:34
@bwp91 bwp91 closed this Mar 3, 2026
@NorthernMan54 NorthernMan54 reopened this Mar 4, 2026
@NorthernMan54
Copy link
Copy Markdown
Contributor

@copilot Pls rebase this PR

Co-authored-by: NorthernMan54 <19808920+NorthernMan54@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Mar 4, 2026

@copilot Pls rebase this PR

Done in commit 311000d. Since force-push isn't available in this environment, I applied the upstream changes from beta-3.3.1 (3a0aea5 monitor fix + 5fe1273 dependency updates) as a new commit. The branch now includes all changes from beta-3.3.1 and all tests pass.

@NorthernMan54 NorthernMan54 marked this pull request as ready for review March 4, 2026 07:15
@NorthernMan54 NorthernMan54 self-requested a review March 4, 2026 07:15
@NorthernMan54
Copy link
Copy Markdown
Contributor

@copilot please update the repo instructions with a comment that the change log should be included in changes.

Also pls include the new feature in the changelog

Co-authored-by: NorthernMan54 <19808920+NorthernMan54@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Mar 4, 2026

@copilot please update the repo instructions with a comment that the change log should be included in changes.

Also pls include the new feature in the changelog

Done in commit 89357fe. Created .github/copilot-instructions.md with a note that changelog updates should be included with all code changes, and added a changelog entry for the nameBasedUniqueId feature under v3.4.0 (unreleased).

@NorthernMan54
Copy link
Copy Markdown
Contributor

@copilot pls correct your changelog update. It created a new release.

… release

Co-authored-by: NorthernMan54 <19808920+NorthernMan54@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Mar 4, 2026

@copilot pls correct your changelog update. It created a new release.

Fixed in commit 4ff0ac5. The nameBasedUniqueId entry is now added to the existing v3.4.0 (2026-02-24) section instead of creating a duplicate release.

@bwp91 bwp91 merged commit a5cb0f3 into beta-3.3.1 Mar 4, 2026
6 checks passed
@bwp91 bwp91 deleted the copilot/fix-uniqueid-issue branch March 4, 2026 18:02
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.

3 participants