Skip to content

About

Codex-LB Rates — Home Assistant sensors for Codex-LB pools and ChatGPT/CLI 5-hour & weekly quotas

Topics

Resources

Security policy

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

Codex-LB Rates

Home Assistant integration for monitoring Codex quota remaining and reset times from either a Codex-LB account pool or an individual ChatGPT / Codex CLI account.

HACS Validate CodeQL License

What it does

  • Codex-LB pools — one Home Assistant device per account plus pool-wide aggregate quota sensors.
  • ChatGPT / Codex CLI accounts — direct primary/secondary quota, reset time, reset credits, and status sensors.
  • Provider-aware window names — display names follow reported durations when available, so a 24-hour window can be shown as Daily instead of being hard-coded as Weekly.
  • Optional quota windows — monthly and GPT-5.3-Codex-Spark sensors appear only when Codex-LB actually reports them.
  • Capacity-aware pool gauges — measured accounts, including exhausted accounts at 0%, contribute to the pool aggregate; capacity weighting is used when valid weights are available for every reporting account.
  • Reset display choice — countdown by default, or local absolute date/time while keeping the exact ISO timestamp in resets_at.
  • Optional rich diagnostics — plan, credit balance, last refresh, and request-usage totals.
  • Optional used-% sensors — Configure option (off by default) adds used-percentage entities; remaining % stays primary for dashboards and the quota-alert blueprint.
  • Quota-alert blueprint — low, exceeded, and refreshed notifications with hysteresis and remembered alert state.
  • Bundled Lovelace card — optional custom:codex-rates-card for pool and remaining-% sensors, with a theme picker, minute-resolution reset countdowns or local reset times for every row, and a visual config editor. Tap a quota to open More info.

Install

Open your Home Assistant instance and open this repository in HACS.

  1. Install through HACS, or add https://github.com/uniskela/codex-lb-rates as a custom Integration repository.
  2. Restart Home Assistant.
  3. Open Settings → Devices & services → Add integration → Codex-LB Rates.
  4. Choose Codex-LB or ChatGPT / Codex CLI.

Manual installation is also supported by copying custom_components/codex_rates into Home Assistant's config/custom_components/ directory.

Full instructions: Installation.

Choose a provider

Mode Best for Authentication
Codex-LB Multiple accounts behind a Codex-LB server Admin dashboard session, or read-only Guest session when enabled
ChatGPT / Codex CLI Monitoring one ChatGPT account directly Device code (recommended), browser paste-callback, mounted auth.json, or advanced tokens

Codex-LB API keys cannot read the account quota endpoint used by this integration; use the dashboard/guest session flow. A Cloudflare Access bypass on /v1 alone is not enough — this integration uses /api/dashboard-auth/* and /api/accounts.

Cloudflare Access (tunnel hosts)

Home Assistant cannot complete the browser Access login. Use a service token instead:

  1. Zero Trust → Access → Service credentials → create a service token; copy Client ID and Client Secret.
  2. On the Access application for your Codex-LB hostname, add a Service Auth policy that includes that token (keep your normal Allow policy for humans on /login).
  3. In this integration, set Cloudflare Access Client ID and Client Secret (also editable later under Configure).
  4. Keep dashboard admin/guest password fields as usual — Access and Codex-LB login are separate layers.

Prefer a LAN URL when HA and Codex-LB share a private network and you do not need the public tunnel.

Setup failures report specific auth codes (password, TOTP, Access, and similar) — see Troubleshooting.

See Configuration for the complete setup guide.

Documentation

The canonical user documentation is published at uniskela.com/docs/codex-lb-rates.

Guide Covers
Overview How the integration is structured and where to start
Installation HACS/manual install and first setup
Configuration Codex-LB and ChatGPT authentication, options
Entities and data Sensors, reset attributes, pool weighting, optional windows
Dashboard examples Copyable Lovelace examples, including the bundled remaining card
Quota alert automations Blueprint setup, behaviour, updates, migration
Upgrading Integration updates vs blueprint updates
Troubleshooting Authentication, missing sensors, stale data, diagnostics
Releases Maintainer release/versioning process

Quota alerts

Current blueprint: Codex-LB Rates quota alerts v2.0.1

It can monitor one or more remaining-% sensors and send one-shot low, exceeded, and refreshed alerts without repeatedly notifying while a sensor remains in the same band.

Breaking change

Blueprint 2.0.1 ignores used-percent sensors. An automation that alerted on a used-percent sensor will stop alerting for that sensor. Switch it to the matching remaining-percent sensor. The sensor picker also lists only percent sensors from this integration. Re-import the blueprint after updating the integration.

Open your Home Assistant instance and import the Codex-LB Rates quota alert blueprint.

The blueprint requires a Home Assistant Text helper for its alert memory and is versioned independently from the integration. Follow Quota alert automations rather than copying the YAML blindly.

Integration options

Open Settings → Devices & services → Codex-LB Rates → Configure.

  • Poll interval — default 60 seconds; minimum 30 seconds.
  • Enable rich sensors — plan, credit balance, last-refresh, and request-count diagnostics when available.
  • Enable used-% sensors — off by default; adds optional used-percentage entities for the same quota windows. Remaining % stays primary.
  • Reset sensor display — countdown or local absolute date/time.
  • Cloudflare Access Client ID / Secret (Codex-LB only) — optional Zero Trust service token for Access-protected hosts; leave the secret blank to keep the stored value.

Security

  • Credentials are stored in the Home Assistant config entry rather than configuration.yaml.
  • Password, TOTP, Cloudflare Access client secret, access-token, refresh-token, and ID-token fields are redacted from integration diagnostics.
  • Codex-LB uses a private HTTP session so its dashboard cookies are not shared with other integrations.
  • Diagnostics can still contain account IDs, email addresses, quota values, and timing information; review them before sharing publicly.

See SECURITY.md for vulnerability reporting.

Development

pip install -r requirements-dev.txt
pytest

Releases use Release Please and Conventional Commits. Maintainer workflow details live in AGENTS.md and the releases guide.

License

MIT

About

Codex-LB Rates — Home Assistant sensors for Codex-LB pools and ChatGPT/CLI 5-hour & weekly quotas

Topics

Resources

Security policy

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages