You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix: restore pyscript state on Home Assistant 2026.11 - #883
Home Assistant 2026.11 replaces RestoreStateData.last_states with last_states_by_entity_id and last_states_by_entity_registry_id (home-assistant/core#183906), so restore_state() raises AttributeError and pyscript fails to set up. This reads last_states_by_entity_id when it exists and falls back to last_states on older versions. Pyscript's states have no registry entry, so that dict holds all of them.
When it is needed: before Home Assistant 2026.11 reaches users. The beta is expected Wednesday 28 October and the release Wednesday 4 November. A pyscript release with this fix before then avoids an outage for everyone who upgrades.
Tested:
2026.11.0.dev202610260230: without the change pyscript fails setup with the error in the issue. With it, pyscript loads, and a state.persist variable set to a new value keeps that value across a restart.
Pinned test requirements (Home Assistant 2026.5.0b0): ruff check, ruff format, pytest (179 passed), pylint and mypy are clean.
The test suite can exercise the new attribute only once pytest-homeassistant-custom-component publishes a 2026.11 build.
One caveat: this is still accessing Home Assistant's internal storage implementation, rather than a supported public API. A longer-term solution would be for Pyscript to manage its persistent entities through RestoreEntity or its own storage mechanism.
Agreed, it's still internal, and it was before this change too: restore_state() and register_persist() in state.py both reach into RestoreStateData. This PR only keeps that working on 2026.11 so pyscript still loads after the upgrade. Moving persisted states to RestoreEntity or pyscript's own storage changes both the save and the restore path, so I've opened #885 to track that separately.
Installing the updated init.py from this PR fixes pyscript on my HA 2026.11 beta install. Could we get this merged (and the version bumped) while discussions continue for a more robust fix/refactoring? Otherwise the 2026.11 update WILL break pyscript installs.
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
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.
Closes #882
Home Assistant 2026.11 replaces
RestoreStateData.last_stateswithlast_states_by_entity_idandlast_states_by_entity_registry_id(home-assistant/core#183906), sorestore_state()raisesAttributeErrorand pyscript fails to set up. This readslast_states_by_entity_idwhen it exists and falls back tolast_stateson older versions. Pyscript's states have no registry entry, so that dict holds all of them.When it is needed: before Home Assistant 2026.11 reaches users. The beta is expected Wednesday 28 October and the release Wednesday 4 November. A pyscript release with this fix before then avoids an outage for everyone who upgrades.
Tested:
state.persistvariable set to a new value keeps that value across a restart.The test suite can exercise the new attribute only once pytest-homeassistant-custom-component publishes a 2026.11 build.