Skip to content

Add cursor-based household timeline page API - #241

Open
jbjardine wants to merge 1 commit into
benleb:devfrom
jbjardine:codjardine/surepy-timeline-page
Open

jbjardine wants to merge 1 commit into
benleb:devfrom
jbjardine:codjardine/surepy-timeline-page

Conversation

@jbjardine

Copy link
Copy Markdown

Change

Add Surepy.get_household_timeline_page(household_id, *, before_id=None) for the newest 25 timeline records, or the page preceding a source event ID. Return the API dictionaries without dropping unknown event types or timestamps. Existing timeline and reporting methods retain their interfaces.

The HTTP client gains an opt-in raise_on_error flag. Unexpected HTTP statuses raise SurePetcareError in this mode, so callers cannot confuse HTTP failures with an empty page or a cached 304 result. The new method validates the page shape and event IDs before returning it.

Motivation

Home Assistant needs a stable source cursor to catch up after an interruption without replaying all history on first activation. Keeping URL construction, ETag handling and transport errors inside the library avoids duplicating API internals in HA.

Validation

15 offline tests in tests/test_timeline.py: newest/older page URLs, preservation of unknown types and source timestamps, empty/malformed responses (including actual HTTP JSON decoding paths), cached 304, HTTP 500/429, authentication failure and compatibility of the legacy method. No real account credentials are used.

Review points

Please confirm that before_id and fixed page size 25 are suitable as a supported public API, and the opt-in HTTP error behavior is acceptable. A released version is required before the HA dependency update and feature can be submitted.

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.

1 participant