Repository navigation
Conversation
The Strauss cloud API returns error responses (e.g. 422 DeviceNotConnectedException) that lack the expected keys like "drinks", "dynamicData", "filterInfo", and "uvInfo". This causes KeyError crashes in `get_device()` and TypeError crashes in `QualityInfo.__post_init__` when `upcoming_replacement` is None. - Use `.get()` with sensible defaults for all response fields - Guard `upcoming_replacement` timestamp conversion against None - Default `milli_litters_passed` to 0 when missing or null - Update type hint to reflect that `upcoming_replacement` can be None Made-with: Cursor
10 of 21 tasks
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
When the Tami4 device is temporarily disconnected from the Strauss cloud (e.g. due to WiFi issues), the
/api/v3/customer/mainPage/{psn}endpoint returns an error response (HTTP 422DeviceNotConnectedException) that lacks the expected keys. This causes cascading crashes:KeyError: 'drinks'— response has nodrinkskeyKeyError: 'dynamicData'— response has nodynamicDatakeyTypeError: unsupported operand type(s) for /: 'NoneType' and 'int'—upcoming_replacementisNone, andQualityInfo.__post_init__tries to divide it by 1000Changes
Tami4EdgeAPI.py:.get()with sensible defaults fordrinks,dynamicData,filterInfo,uvInfo, and their sub-keysmilli_litters_passedto0when missing ornullwater_quality.py:upcoming_replacementtimestamp conversion againstNoneOptional[date]since the field can legitimately be absentImpact
These changes are backwards-compatible — when the API returns complete data, behavior is identical. When data is missing (device offline, API errors), the library now returns safe defaults instead of crashing.
This directly fixes the Home Assistant
tami4integration failing withFailed setup, will retrywhen the device is temporarily unreachable.Made with Cursor