Skip to content

Fix crash on setup from removed hass.components.persistent_notification - #10

Merged
jsight merged 2 commits into
mainfrom
fix/persistent-notification-crash
Jul 30, 2026
Merged

Fix crash on setup from removed hass.components.persistent_notification#10
jsight merged 2 commits into
mainfrom
fix/persistent-notification-crash

Conversation

@jsight

@jsight jsight commented Jul 30, 2026

Copy link
Copy Markdown
Owner

Summary

  • hass.components.persistent_notification was removed from modern Home Assistant core. Every persistent-notification call site in __init__.py, switch.py, and select.py still used the old accessor, so any code path that tried to show a notification (no devices found, initial connection failure, invalid/read-only property, failed switch/select control) raised AttributeError: 'HomeAssistant' object has no attribute 'components' and aborted config entry setup entirely.
  • Replaced all 12 call sites with homeassistant.components.persistent_notification.async_create(hass, ...).
  • This was the actual cause of the crash traceback reported in API error 5041: No permission #8 — the "API error 5014: No permission" property-fetch failure resulted in an empty device dict, which then tried to show a "no devices found" notification and crashed setup with an unrelated AttributeError, masking the real error message. The underlying cloud-side "No permission" error itself is still open and needs further investigation with the reporter's account, but setup no longer crashes and the real error now reaches the log/user.

Relates to #8.

Test plan

  • ruff format + ruff check clean (aside from one pre-existing unrelated unused import)
  • pytest — all 43 existing tests pass
  • Manual verification against a live HA instance with a device that returns 5014/5041 (not available in this environment)

🤖 Generated with Claude Code

jsight pushed a commit that referenced this pull request Jul 30, 2026
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
jsightler and others added 2 commits July 30, 2026 19:18
hass.components was removed from modern Home Assistant core, so every
persistent notification call (no devices found, connection failure,
invalid/read-only property, failed switch/select control) raised
AttributeError and aborted config entry setup entirely. Switch to
homeassistant.components.persistent_notification.async_create(hass, ...).

This was masking the real error message in GH#8 (API error 5014/5041:
No permission), turning a soft failure into a hard setup crash.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@jsight
jsight force-pushed the fix/persistent-notification-crash branch from b5e6a23 to c13bc9c Compare July 30, 2026 23:19
@jsight
jsight merged commit f28c1c3 into main Jul 30, 2026
5 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