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
Persist pyscript states through supported Home Assistant APIs #885
state.persist relies on Home Assistant internals in two places:
register_persist() in state.py hands a stand-in PyscriptEntity to RestoreStateData.async_restore_entity_added, so Home Assistant saves the state at shutdown.
restore_state() in __init__.py reads the stored states back out of RestoreStateData at startup. Its own comment says it "should re-implement using RestoreEntity".
Home Assistant 2026.11 changed that internal data (home-assistant/core#183906), which stopped pyscript from setting up (#882, worked around in #883). Any later change to it can break persistence again.
Two ways to move onto supported APIs:
Make each persisted variable a real RestoreEntity, so Home Assistant saves and restores it through the entity API.
Keep persisted variables in pyscript's own Store (homeassistant.helpers.storage), saved on change and at shutdown, loaded at setup.
Either way, restore timing should stay as it is today: every persisted pyscript.* state is back at startup, before any script calls state.persist.
Reacted by Satadru Pramanik, DO, MPH, MEng and Eric
Activity