Repository navigation
Handle incomplete SensorPush records without losing healthy readings - #4
Open
econstantin wants to merge 1 commit into
Open
econstantin wants to merge 1 commit into
econstantin wants to merge 1 commit into
Conversation
econstantin
marked this pull request as ready for review
October 23, 2026 06:03
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.
Context
PR #1 handles missing and empty sample lists. This draft proposes a small defensive follow-up for three other incomplete-response cases.
sensorpush-api2.1.3 accepts missingSensor.name,Sample.observed, andSamples.sensorsfields asNone, while the helper assumes they are present. A few explicit checks can handle those inputs without discarding healthy readings or hiding an invalid whole response. Whether this protection is useful given the service's actual behavior is open for maintainer feedback.Repro steps
Mock the endpoint results and call
SensorPushCloudHelper.async_get_data()with:observed, alongside a healthy sensor.Samples()without asensorsmapping, with populated or empty sensor metadata.Expected
Incomplete records should not block usable readings. An invalid whole response should raise a library error.
Actual
A missing name or observation timestamp raises a validation error and aborts the account update. A missing samples mapping raises
AttributeErrorwhen sensor metadata is present, or silently returns an empty update when it is empty.Fix
Use the device ID as the fallback name, skip samples without observation timestamps, and raise
SensorPushCloudErrorfor a missing samples mapping. Never substitute the current time. Preserve PR #1's missing/empty-sample behavior and API error propagation.Testing
git diff --checkpass.Notes
Only mocked responses were used, without credentials or live SensorPush/HA requests. Builds emit the existing license-classifier deprecation warning.