Skip to content

Persist display content and queued uploads#66

Open
LordMike wants to merge 5 commits into
OpenDisplay:feat/clean-portfrom
LordMike:feat/persist-display-content
Open

Persist display content and queued uploads#66
LordMike wants to merge 5 commits into
OpenDisplay:feat/clean-portfrom
LordMike:feat/persist-display-content

Conversation

@LordMike

@LordMike LordMike commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

This PR persists OpenDisplay display content and the latest queued image delivery across Home Assistant restarts.

Previously, queued image delivery was runtime-only. If HA restarted while a sleepy display had a pending image, the queue slot was lost and the content/pending entities no longer represented the intended delivery state. This makes the delivery queue behave more like an actual queue: once HA accepts a queued image, it can survive a restart and resume waiting for the next device wake.

Changes:

  • Adds a versioned HA Store for persisted display content and queued upload state.
  • Persists the latest queued prepared image, preview JPEG, refresh mode, PartialState, target device, queue timestamps, attempts, and paused/auth state.
  • Restores a pending queued upload on config entry setup if it has not expired.
  • Rearms the queue expiry timer using the original expires_at timestamp rather than starting a fresh timeout after restart.
  • Avoids storing large image payloads in config entry data; persisted content goes through HA storage instead.
  • Delays image-bearing persistence writes for 60 seconds so quickly drained queues are usually not written, while queue-clearing writes use a 1 second delay so delivered content is not resurrected after restart.

Entities with persistence:

  • Content image entity:
    • Persists the last JPEG returned by the image entity.
    • Persists its existing queue-related attributes: pending, queued_at, and last_error.
  • Update pending binary sensor:
    • Restores its state from the persisted delivery queue snapshot through the delivery manager.
    • Restores queued_at, expires_at, attempts, and last_error attributes.
  • Last seen sensor:
    • Restores the last timestamp through HA’s native RestoreEntity path.
    • Stays available after a timestamp has been observed.

Validation:

  • pytest -q -p no:cacheprovider tests
  • compileall for the integration and updated tests

@LordMike LordMike marked this pull request as ready for review July 16, 2026 21:13
@LordMike LordMike requested a review from g4bri3lDev as a code owner July 16, 2026 21:13
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