Skip to content

fix: remove registry devices for locks that leave the entry's key set - #68

Merged
roquerodrigo merged 1 commit into
mainfrom
fix/remove-stale-devices
Aug 7, 2026
Merged

fix: remove registry devices for locks that leave the entry's key set#68
roquerodrigo merged 1 commit into
mainfrom
fix/remove-stale-devices

Conversation

@roquerodrigo

Copy link
Copy Markdown
Owner

Summary

A lock removed from the TTLock account became a permanent orphan: reauth and reconfigure replace entry.data["keys"] wholesale with whatever the cloud returns, but the device registry kept the old device and the UI offered no way to delete it (the integration did not implement async_remove_config_entry_device).

Changes

  • async_setup_entry now prunes registry devices whose MAC is no longer among the entry's stored keys, so a reauth/reconfigure that drops a lock cleans up its device on the reload that follows.
  • async_remove_config_entry_device is implemented: the UI can delete a device whose lock is gone from the key set, while devices for configured locks stay protected.

Tests

  • Setup prunes a pre-existing device for a removed lock and keeps the configured one.
  • async_remove_config_entry_device denies removal for a configured lock and allows it for a stale one.
  • End-to-end reauth flow: the cloud returning a different key set removes the replaced lock's device and registers the new one.

Suite: 266 passed, coverage 100%.

Reauth and reconfigure replace the stored keys wholesale with whatever
the cloud returns, so a lock removed from the TTLock account lingered as
a dead device that the UI refused to delete.

Setup now prunes registry devices whose MAC is no longer among the
entry's keys, and async_remove_config_entry_device lets the UI delete
any device whose lock is gone while protecting the configured ones.
@roquerodrigo
roquerodrigo merged commit 2e43dea into main Aug 7, 2026
10 checks passed
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