Repository navigation
v0.5.1: card works on dashboards opened during startup - #8
Merged
Merged
Conversation
Dashboards opened while Home Assistant was still starting never loaded the card and showed "Configuration error" until the page was reloaded, because the integration's own card URL only exists once it is set up. The card is now also copied to /config/www/battery_roi and added as a dashboard resource; /local is served from the start. Removing the integration removes both again. Version 0.5.1.
PeterSlijkhuis
marked this pull request as ready for review
September 29, 2026 09:01
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Before: A dashboard opened while Home Assistant was still starting (after a restart or update, often in the phone app) showed "Configuration error" instead of the card. It stayed that way until the page was fully reloaded, even though the sensors were fine.
After: The card loads on those dashboards too. Reproduced in a test Home Assistant by opening the dashboard during startup: before the change the error stayed for 45 s and more; after it the card showed right away.
Cause: the card was only served from the integration's own URL, which exists once the integration is set up. Home Assistant serves dashboards well before that, and a page never picks up a card that is added after it has loaded.
How: on setup the card files are copied to
/config/www/battery_roiand added as a dashboard resource (/local/battery_roi/battery-roi-card.js?v=<version>)./localis served from the moment Home Assistant starts. The old URL stays as a fallback, and the card ignores being loaded twice. The resource URL follows the version, so updates bust the cache. Removing the integration removes the copy and the resource. YAML-managed resources are left alone (README explains the one line to add). If the resource step fails for any reason, setup continues and logs a warning. Version 0.5.1.Release note for v0.5.1:
Tests: 27 pass, including a new one that checks the copy, the resource and the cleanup on removal.
Generated by Claude Code