Skip to content

Add Bouncie as a second vehicle-tracking provider (v0.5.0) - #1

Merged
aniceberg merged 3 commits into
mainfrom
bouncie-provider
Oct 29, 2026
Merged

aniceberg merged 3 commits into
mainfrom
bouncie-provider

Conversation

@aniceberg

Copy link
Copy Markdown
Owner

What

Parents can now choose where a bus's position comes from: a Traccar server (as before) or a Bouncie OBD-II tracker. To use both, add Bus Monitor once per account; each bus profile follows one vehicle from its own entry.

  • Config flow opens with a provider menu (Traccar / Bouncie). The Traccar step is unchanged.
  • Bouncie signs in with OAuth through HA Application Credentials. Each parent registers their own free app at bouncie.dev with the redirect URI https://my.home-assistant.io/redirect/oauth. Positions are polled from GET /v1/vehicles: every 30 s by default, 15 s minimum. Reauth reruns the OAuth flow and rejects a different Bouncie account.
  • Provider layer in providers/: base.py holds the shared Device type, errors and Provider protocol, traccar.py is the moved client, and bouncie.py is new. traccar_client.py stays as a re-export so scripts/probe.py still works.
  • Device ids are now strings everywhere. A v1 → v2 config entry migration adds provider: traccar and turns stored ids into strings. Entity unique_ids ({entry}_{id}_…) don't change, so existing installs keep their entities, profiles and settings.
  • Docs and tools: docs/bouncie.md covers setup, the README is updated, and scripts/bouncie_probe.py measures how often Bouncie positions refresh during a drive.

Why

The goal is to support one or more tracking providers as inputs. Bouncie is the first addition after Traccar.

Reviewer notes

  • Not yet tried against a real Bouncie account. Bouncie doesn't document how often stats.location refreshes mid-trip, the units of REST speed (mph assumed, matching the webhook docs), or any rate limits. Run scripts/bouncie_probe.py on a drive before relying on the alerts. If positions refresh slowly, tripData webhooks (on the roadmap) become the priority.
  • Token request override. Bouncie's token endpoint wants a JSON body, so BouncieOAuth2Implementation._token_request overrides HA's form post. It reuses HA's private config_entry_oauth2_flow._raise_mapped_token_error so error handling matches HA's (4xx → reauth, 429/5xx → retry). A future HA release could rename or remove that function.
  • Device identifiers stay (DOMAIN, id): HA 2026.10 (our minimum) already scopes them per config entry, and a test confirms a Traccar and a Bouncie vehicle with the same raw id stay separate.
  • Rebased onto the rewritten main (v0.4.0). Upstream's new street and time checkpoint code needed only the str id change.

Tests

ruff check . is clean and pytest passes (92 tests). The new tests:

  • tests/test_bouncie.py: parsing, mph → m/s, name fallbacks, paging, HTTP and refresh error mapping, and a check that the token request is JSON.
  • tests/test_bouncie_ha.py: the full OAuth config flow, a Bouncie entry tracking and alerting, Traccar and Bouncie entries side by side, and the v1 → v2 migration keeping entities.

🤖 Generated with Claude Code

Parents choose Traccar or Bouncie when adding Bus Monitor; add it once per
account to use both. Bouncie signs in with OAuth (Application Credentials)
and is polled via GET /v1/vehicles. Device ids are now strings; v1 Traccar
entries migrate to v2 with their entities, profiles and settings intact.
Includes scripts/bouncie_probe.py to measure how often Bouncie positions
refresh during a drive, and docs/bouncie.md for setup.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-29T04:19:59.319005Z d2cd552 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d2cd552fa0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

aniceberg and others added 2 commits October 29, 2026 00:21
Move the Bouncie developer-portal and redirect URLs into description
placeholders, and drop the shared OAuth abort strings that Home Assistant
translates itself.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An InvalidAuth during polling (e.g. Bouncie API 401, changed Traccar
password) now raises ConfigEntryAuthFailed instead of UpdateFailed, so
Home Assistant shows the Reauthenticate prompt rather than retrying.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@aniceberg
aniceberg merged commit 6d4aa2c into main Oct 29, 2026
6 checks passed
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