Skip to content

Allow removing devices that are no longer on the gateway - #68

Merged
Breina merged 1 commit into
Breina:masterfrom
philippecottier:feat/remove-stale-devices
Oct 7, 2026
Merged

Breina merged 1 commit into
Breina:masterfrom
philippecottier:feat/remove-stale-devices

Conversation

@philippecottier

Copy link
Copy Markdown
Contributor

Problem

When a wireless device is removed from the gateway or replaced (in my case a faulty A9MEM1570 F63 3P+N swapped for three A9MEM1560 1P+N tags), the old device stays in Home Assistant forever:

  • the Delete action is not offered in the UI,
  • the API answers Config entry does not support device removal,

because the integration does not implement async_remove_config_entry_device.

The only workaround so far is to delete and re-add the whole integration (see the comment in #50), which loses entity customisations (names, areas, energy dashboard, automations).

Change

  • During the (sequential) platform setup scan, the identifiers of the gateway and of every wireless device found are collected in hass.data[DOMAIN][entry_id]["present_devices"].
  • async_remove_config_entry_device allows removal only if none of the device's identifiers are in that set:
    • devices still reported by the gateway are refused (they would be re-created on the next reload anyway),
    • if the entry is not loaded, removal is refused (we cannot tell what is on the gateway).
  • README: short Removing old devices section.

No change to unique IDs, entities or Modbus traffic.

Notes

  • A tag that is paired but currently unreachable is skipped by the scan (existing behaviour), so it can be deleted too; it is simply re-created on the next reload once reachable again.

@Breina

Breina commented Oct 7, 2026

Copy link
Copy Markdown
Owner

Very good! You even included a README section! <3

Thanks for the fix!

@Breina
Breina merged commit 7560ed0 into Breina:master Oct 7, 2026
2 checks passed
@Breina

Breina commented Oct 16, 2026

Copy link
Copy Markdown
Owner

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.

2 participants