Skip to content

fix(storage): use Store.async_remove() for HA 2026.9+ compat - #357

Open
pgress wants to merge 1 commit into
OpenEPaperLink:mainfrom
pgress:fix/storage-remove-compat
Open

pgress wants to merge 1 commit into
OpenEPaperLink:mainfrom
pgress:fix/storage-remove-compat

Conversation

@pgress

@pgress pgress commented Sep 29, 2026 •

Copy link
Copy Markdown

Summary

Fixes the AttributeError: module 'homeassistant.helpers.storage' has no attribute 'async_remove_store' error that occurs on Home Assistant 2026.9+ when removing the integration.

HA 2026.9 removed the module-level storage.async_remove_store helper. The public API for removing a storage store is now Store(...).async_remove(). The previous code in async_remove_storage_files (__init__.py:593) called the removed helper unconditionally, crashing whenever a user uninstalled the integration and preventing clean reinstall cycles.

Fixes #358.

Motivation

Observed in the wild on HA core-2026.9.4 with OEPL integration v3.0.0:

Logger: custom_components.open_epaper_link
Source: custom_components/open_epaper_link/__init__.py:593
Level: ERROR
Message: Error removing tag types storage file: module 'homeassistant.helpers.storage' has no attribute 'async_remove_store'

Reported in #358. The crash happens during async_remove_storage_files, which is called from async_remove_entry whenever the integration is completely removed from Home Assistant.

Change

Replace the unconditional call to storage.async_remove_store(hass, "open_epaper_link_tagtypes") with a version-aware approach:

  1. Try Store(hass, version=1, key="open_epaper_link_tagtypes").async_remove() first — this is the public API on HA 2026.9+.
  2. On AttributeError, fall back to the legacy storage.async_remove_store(...) helper for older HA versions that don't expose Store.async_remove yet.

This keeps the integration compatible across HA releases without requiring a hard version bump.

Testing

  • Verified that homeassistant.helpers.storage.Store.async_remove exists and storage.async_remove_store does NOT exist on HA 2026.9 (confirmed via python -c "from homeassistant.helpers.storage import Store; ...").
  • Added tests/test_storage_remove_compat.py covering both branches:
    • test_async_remove_storage_files_no_longer_crashes_on_modern_ha — asserts Store.async_remove is awaited and no AttributeError reaches the caller on HA 2026.9+.
    • test_async_remove_storage_files_legacy_fallback_compat — injects a fake legacy helper and forces Store.async_remove to raise AttributeError, asserting the fallback path invokes storage.async_remove_store once.
  • Both tests pass:
    tests/test_storage_remove_compat.py::test_async_remove_storage_files_no_longer_crashes_on_modern_ha PASSED
    tests/test_storage_remove_compat.py::test_async_remove_storage_files_legacy_fallback_compat PASSED
    2 passed in 0.09s
    
  • Smoke-tested on a live HA core-2026.9.4 instance by deploying the patched __init__.py to /config/custom_components/open_epaper_link/, reloading the integration (disable → enable), and confirming the async_remove_store error no longer appears in the system log on subsequent remove/re-add cycles.

Scope

This PR only fixes the async_remove_store crash. It does NOT address the separate WebSocket-connection issue described in #356 (AP-status sensors staying unknown because the WebSocket to the AP never establishes). That is a distinct problem and warrants a separate investigation/PR.

Checklist

  • The code change is tested and works locally (unit tests + smoke test on live HA 2026.9.4).
  • Local pytest passes for the new test file.
  • No new dependencies introduced.
  • Backwards-compatible with older HA versions (legacy fallback preserved).

Fixes #358

HA 2026.9 removed the module-level  helper.
The public API for removing a storage store is now .

The previous code raised:
  AttributeError: module 'homeassistant.helpers.storage' has no attribute
  'async_remove_store'

This was triggered whenever a user removed the integration (calling
). The crash prevented clean uninstall/reinstall
cycles, leaving stale storage behind.

The fix tries the new  API first and falls back to
the legacy  helper for older HA versions that
don't have the instance method yet, keeping the integration compatible
across releases.

Refs: OpenEPaperLink#356
nlimper pushed a commit to nlimper/OpenEPaperLink-HA-integration that referenced this pull request Oct 8, 2026
HA 2026.9 removed the module-level  helper.
The public API for removing a storage store is now .

The previous code raised:
  AttributeError: module 'homeassistant.helpers.storage' has no attribute
  'async_remove_store'

This was triggered whenever a user removed the integration (calling
). The crash prevented clean uninstall/reinstall
cycles, leaving stale storage behind.

The fix tries the new  API first and falls back to
the legacy  helper for older HA versions that
don't have the instance method yet, keeping the integration compatible
across releases.

Refs: OpenEPaperLink#356
(cherry picked from commit 26d0e92)

Source: upstream PR OpenEPaperLink#357 by @pgress,
fixes OpenEPaperLink#358.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
nlimper added a commit to nlimper/OpenEPaperLink-HA-integration that referenced this pull request Oct 8, 2026
Store.async_remove() exists since at least HA 2023.3 (the minimum version
in hacs.json), and a module-level storage.async_remove_store doesn't exist
in 2023.3 either, so the AttributeError fallback from 0d96d6c (upstream PR
OpenEPaperLink#357 by @pgress) can never work.
Also removes that PR's tests: they replicate the call instead of running
the integration code, and the second one only covered the fallback.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

AttributeError: storage.async_remove_store removed in HA 2026.9 — integration uninstall crashes

1 participant