Skip to content

Fix OpenDisplay config-entry persistence after device deletion#35

Merged
Misiu merged 16 commits into
deep_sleep__clean-portfrom
copilot/fix-websocket-api-error
Jun 8, 2026
Merged

Fix OpenDisplay config-entry persistence after device deletion#35
Misiu merged 16 commits into
deep_sleep__clean-portfrom
copilot/fix-websocket-api-error

Conversation

Copilot AI commented May 29, 2026

Copy link
Copy Markdown

Home Assistant could not persist OpenDisplay config-entry changes because the integration stored raw bytes in entry data. When storage writes failed, deleting the device/integration entry did not survive restart and the same device reappeared in initialize state.

  • Config-entry migration on setup

    • Normalize legacy entry data before Home Assistant writes it back.
    • Convert stored encryption keys from raw bytes to lowercase hex strings.
    • Drop cached runtime config blobs if they still contain byte fields and cannot be safely persisted.
  • JSON-safe cached device config

    • Replace ad-hoc dataclass serialization with the library’s config JSON serializer.
    • Deserialize cached config through the matching library parser so deep-sleep recovery still works without reintroducing non-serializable fields.
  • Legacy auth-key compatibility

    • Keep service-side key handling tolerant of older byte-backed entries during the transition window, so existing installs can self-heal on next startup.
  • Regression coverage

    • Add coverage for legacy byte-backed entry data and for JSON-safe cache writes.

Example of the migration behavior:

normalized = _normalize_entry_data(
    {
        CONF_ENCRYPTION_KEY: b"\x01" * 16,
        CONF_CACHED_DEVICE_CONFIG: {"system": {"reserved": b"\x00" * 15}},
        CONF_CACHED_FIRMWARE: {"major": 1, "minor": 0},
        CONF_CACHED_IS_FLEX: False,
    }
)

# persisted safely
assert normalized[CONF_ENCRYPTION_KEY] == "01" * 16
assert CONF_CACHED_DEVICE_CONFIG not in normalized

Copilot AI changed the title Deep-sleep aware availability and runtime config resync on reconnect Cover deep-sleep restart wake-up sync paths and clarify coordinator listener intent May 29, 2026
Copilot finished work on behalf of Misiu May 29, 2026 10:16
Copilot AI requested a review from Misiu May 29, 2026 10:16
Copilot AI changed the title Cover deep-sleep restart wake-up sync paths and clarify coordinator listener intent Improve deep-sleep upload observability and queued-image TTL replacement semantics May 29, 2026
Copilot finished work on behalf of Misiu May 29, 2026 10:55
Copilot AI changed the title Improve deep-sleep upload observability and queued-image TTL replacement semantics Preserve deep-sleep queued uploads across transient wake-up BLE failures May 29, 2026
Copilot finished work on behalf of Misiu May 29, 2026 12:01
Copilot AI changed the title Preserve deep-sleep queued uploads across transient wake-up BLE failures Fix deep-sleep queued upload silently dropped when BLE cache expires on wake May 29, 2026
Copilot finished work on behalf of Misiu May 29, 2026 12:31
Copilot AI changed the title Fix deep-sleep queued upload silently dropped when BLE cache expires on wake Fix OpenDisplay config-entry persistence after device deletion May 29, 2026
Copilot finished work on behalf of Misiu May 29, 2026 13:29
@Misiu

Misiu commented May 29, 2026

Copy link
Copy Markdown
Owner

@copilot ok, were in devcontainers, you can run tests

Copilot AI commented May 29, 2026

Copy link
Copy Markdown
Author

@copilot ok, were in devcontainers, you can run tests

I ran the local validation path in the repo. scripts/setup succeeds, but python -m pytest -q tests/test_deep_sleep_runtime_sync.py is currently blocked during collection by an unrelated Home Assistant selector compatibility issue in custom_components/opendisplay/services.py (MediaSelectorConfig(accept=["image/*"]) is rejected by the installed HA version with extra keys not allowed @ data['accept']). I didn’t make code changes for this PR because that failure is outside the config-entry persistence fix.

Copilot finished work on behalf of Misiu May 29, 2026 14:29
Misiu added 2 commits May 29, 2026 17:12
added extra sensors, fixed timeout calculation, tests.
@Misiu Misiu marked this pull request as ready for review June 8, 2026 20:20
@Misiu Misiu merged commit f59ffbb into deep_sleep__clean-port Jun 8, 2026
2 checks passed
@Misiu Misiu deleted the copilot/fix-websocket-api-error branch June 8, 2026 20:20
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.

2 participants