Skip to content

Allow deleting empty BPS devices from the UI - #42

Closed
cfoxga wants to merge 1 commit into
Hogster:mainfrom
cfoxga:feat/device-removal
Closed

cfoxga wants to merge 1 commit into
Hogster:mainfrom
cfoxga:feat/device-removal

Conversation

@cfoxga

@cfoxga cfoxga commented Oct 20, 2026

Copy link
Copy Markdown

Problem

Each tracked device gets a BPS device keyed by its Bermuda prefix (("bps", device_key) in sensor.py). When a tracker is renamed or dropped (for example, a private BLE device whose Bermuda name changes), the old BPS device is left behind with no entities. Home Assistant won't let you delete it:

Config entry does not support device removal

That's because BPS doesn't implement async_remove_config_entry_device. Empty BPS devices pile up and can't be deleted from the UI.

Change

Adds async_remove_config_entry_device to custom_components/bps/__init__.py. It allows removal only when the device has no entities (disabled ones included). A device that still has BPS sensors is kept, because the next update would only re-create it.

Testing

  • tests/test_device_removal.py: unit tests for both cases against the existing stubbed-HA suite. Full suite: 56 passed.
  • On real Home Assistant 2026.10.2 core (pytest-homeassistant-custom-component), using the same config/device_registry/remove_config_entry WebSocket command the UI's Delete sends:
    • Stock main: an empty BPS device is refused with Config entry does not support device removal.
    • This branch: the empty device is removed (success: True). A device that still has a BPS sensor is refused (rejected by integration) and stays in the registry.

🤖 Generated with Claude Code

A BPS device is keyed by its tracker's Bermuda prefix, so renaming or
dropping a tracker leaves an empty device behind, and Home Assistant
refuses to delete it ("Config entry does not support device removal")
because BPS has no async_remove_config_entry_device.

Add it, allowing removal only when the device holds no entities. A device
that still has BPS sensors is kept, since the next update would just
re-create it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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