This PR addresses several critical issues that were breaking the PostNord (PN) delivery tracking API and causing the sensors to show up as unavailable or throw backend exceptions.#44
Open
ticstyle wants to merge 21 commits into
Conversation
Just fixed the code formatting
…nord api Added synchronous fetch method using requests and updated error handling for delivery data and the new postnord api.
Updated badge links and installation instructions for clarity.
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.
**Robust PostNord Date Parsing (
worker/__init__.py):** Rewrote the
_handle_pn_datamethod to safely parse delivery strings without throwingIndexError(list index out of range). It now gracefully handles variance in spaces, commas, or alternative status messages, falling back to a string representation safely.Type-Mismatch Resolution (
worker/__init__.py): Fixed an issue where sensors would remainunavailabledue to strict dictionary lookups using mixed types (intvsstrfor postal codes). The parsed data is now stored under both integer and string keys to ensure compatibility regardless of how other components query it.Backward-Compatible Hybrid Worker (
worker/__init__.py): Restored and harmonized the synchronousfetch()method alongside the asynchronous implementation. This completely resolves the'HttpWorker' object has no attribute 'fetch'exception caused by version discrepancies between the component core and the module file. It also provides aliases for bothfetch_postal_cityandfetchPostalCity.CI Line-Length Lint Fix (
config_flow.py): Split the long_LOGGER.warningstring on line 142 into multiple lines to conform to strict PEP8/linter line-length constraints (e.g., Black/Ruff) that were previously failing the GitHub Actions CI workflow.Changes Made
custom_components/swemail/worker/__init__.py_handle_pn_datato clean up string inputs and check list boundaries before indexing.int(postalcode)andstr(postalcode)) for the cached data payload.requests-basedfetch) and asynchronous ones (aiohttp-basedfetch_async).custom_components/swemail/config_flow.py_LOGGER.warningunder the options flow fallback to comply with max line-length rules.Testing
unavailableto presenting accurate delivery tracking states (e.g., "Today").