Repository navigation
feat: add a refine dithering option to image uploads - #141
Merged
Merged
Conversation
Image preparation for uploads now runs in a worker thread instead of on Home Assistant's event loop, BLE disconnects and config reads are more robust, unrecognised device-config data is kept when the configuration is written back, and the bundled dithering library is rebuilt with a patched PyO3 (security advisories). Diagnostics now redact the new raw `unparsed_tail` config bytes, whose content is unknown.
New optional "Refine dithering" switch (off by default) on the upload_image and drawcustom actions. It refines the dithered image for how it is perceived at a normal viewing distance, which typically reproduces colors and tones more faithfully, at the cost of a noticeably slower upload. Passed to py-opendisplay as dbs=True.
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.
Summary
Two commits:
fix: update py-opendisplay to 7.18.17.16.0 → 7.18.1 in
manifest.json,pyproject.tomlanduv.lock. For users this brings:upload_image()used to dither on HA's loop. The integration's ownprepare_image()path was already in an executor, so this mainly helps other callers, but it's the same library fix.unparsed_tailfield).epaper-dithering6.1.1, rebuilt with pyo3 0.29.3 for two advisories.Diagnostics now redact
unparsed_tail. It holds raw bytes of unrecognised config packets, so its content is unknown; without redaction it would appear as hex in downloads. A new test uses a non-empty value and assertsREDACTED. (The main snapshot shows'', because HA's redaction leaves empty values as they are.) This was flagged by Copilot on the equivalent core change.feat: add a refine dithering option to image uploadsNew optional
refine_ditheringswitch (off by default) onupload_image(under Additional options) anddrawcustom, passed toprepare_image(..., dbs=...).DBS (Direct Binary Search) refines the dithered image to minimise the error as perceived at a normal viewing distance. The library sizes its eye model from the panel's real pixel density, taken from the config's physical size. It typically reproduces colours and tones more faithfully (see the epaper-dithering README comparison), but it's slower: ~0.3 s for 800×480 on a multi-core desktop, longer on a Pi. It runs inside the existing executor job, so it never blocks the loop, and with the sleepy-device queue it's computed once at queue time.
UI metadata follows each action's existing pattern:
upload_imageis translated throughstrings.jsonandtranslations/en.json;drawcustomuses inlinename/descriptioninservices.yaml. Noicons.jsonchange, since fields have no icons there.Tests
refine_ditheringreachesprepare_imageasdbs(off by default, on when set), for both actions;unparsed_tailredaction.scripts/test232 passed,scripts/test --min-ha232 passed.ruff checkandruff format --checkclean;scripts/verify_translations.pypasses;compileallpasses.Heads-up
#133 also bumps
py-opendisplay(to 7.17.0) in the same three files, so whichever merges second needs a quick rebase. Keep 7.18.1.