OpenSpec 1.16 requires ## Purpose; the specs predate that. Purposes are reconstructed from the 2026-04-13 greenfield proposal and the current requirements. Plain validation now passes 5/5; strict still flags two over-long requirements, tracked in PROJECT_HYGIENE. Co-authored-by: Cursor <cursoragent@cursor.com>
2.0 KiB
2.0 KiB
Purpose
Polls the PerfectDraft API once per interval for each configured account and shares the result with every entity, so request volume stays low enough to avoid the API's rate limiting. It also turns API failures into Home Assistant's reauth and unavailable states.
Requirements
Requirement: Single DataUpdateCoordinator per config entry
The integration SHALL use one PerfectDraftDataUpdateCoordinator per config entry that polls the API on a configurable interval. All entities SHALL read from the coordinator's shared data.
Scenario: Coordinator polls successfully
- WHEN the update interval elapses
- THEN the coordinator SHALL call
get_machine_details(machine_id)using the machine ID from the config entry - THEN it SHALL store the full response in
coordinator.datawith an added_machine_idkey
Scenario: Machine ID not in config entry
- WHEN the config entry has no machine ID
- THEN the coordinator SHALL call
get_user_profile()to discover the machine ID fromperfectdraftMachines[0].id - THEN if no machines are found, it SHALL raise
UpdateFailed
Scenario: Authentication failure during poll
- WHEN the API client raises
AuthenticationError - THEN the coordinator SHALL raise
ConfigEntryAuthFailedto trigger HA's reauth flow
Scenario: API or connection error during poll
- WHEN the API client raises
PerfectDraftApiErrororPerfectDraftConnectionError - THEN the coordinator SHALL raise
UpdateFailedso HA marks entities as unavailable and retries with backoff
Requirement: Dynamic polling interval
The coordinator SHALL support changing the polling interval at runtime via config entry options.
Scenario: Options updated
- WHEN the user changes the polling interval in integration options
- THEN the coordinator SHALL update its
update_intervalto the new value - THEN the minimum interval SHALL be 60 seconds
- THEN the default interval SHALL be 900 seconds (15 minutes)