Skip to content

Allow manually removing orphaned lock/gateway devices - #318

Merged
jbergler merged 1 commit into
developfrom
fix-114-remove-orphaned-device
Jul 25, 2026
Merged

Allow manually removing orphaned lock/gateway devices#318
jbergler merged 1 commit into
developfrom
fix-114-remove-orphaned-device

Conversation

@jbergler

Copy link
Copy Markdown
Owner

Summary

  • A lock or gateway removed from the TTLock account drops out of the next get_locks()/get_gateways() call, but its device stays behind in HA's registry as an unavailable, entity-less orphan with no way to delete it.
  • Implements async_remove_config_entry_device so the device can be manually deleted from HA's device page, guarded so a lock/gateway that's still active on the account can't be removed by mistake (it would just be recreated on the next reload).
  • Applies to both lock and gateway devices. Missing runtime data (failed/unloaded entry) allows removal, since there's nothing to check against and that's plausibly when a user is pruning stale devices anyway.

Closes #114

Test plan

  • script/check passes (lint, type-check, full suite)
  • New tests cover: active lock blocked, orphaned lock allowed, active gateway blocked, missing entry data allowed
  • Manual verification in a live HA instance (not done — no real TTLock account in this environment)

🤖 Generated with Claude Code

https://claude.ai/code/session_01Qps3xgXbFK1fcxd4ZeRgZY

A lock or gateway removed from the TTLock account drops out of the next
get_locks()/get_gateways() call, but its device stays behind in HA's
registry with no entities and no way to delete it. Implement
async_remove_config_entry_device to allow manual deletion from the
device page, guarded so a still-active lock/gateway can't be removed
by mistake.

Closes #114

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Qps3xgXbFK1fcxd4ZeRgZY
@codecov

codecov Bot commented Jul 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.02%. Comparing base (18c9ad6) to head (c0dd0c1).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #318      +/-   ##
===========================================
+ Coverage    96.00%   96.02%   +0.02%     
===========================================
  Files           17       17              
  Lines         1602     1611       +9     
===========================================
+ Hits          1538     1547       +9     
  Misses          64       64              

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

@jbergler
jbergler merged commit ac5eff4 into develop Jul 25, 2026
8 checks passed
@jbergler
jbergler deleted the fix-114-remove-orphaned-device branch July 25, 2026 22:55
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.

How do I remove previously added lock?

1 participant