0788cffc88eca8b32c859aa2311c4b55a0a0a07b
AI Limits MQTT
Small Go service that publishes Claude Code and Codex CLI status to Home Assistant over MQTT.
What it reports
The CLIs do not expose a stable standalone "remaining quota" API. This service therefore performs a small real CLI probe and classifies the result:
ok: CLI authenticated and a tiny probe completed.limited: output matched rate/usage/quota-limit errors.auth_required: login/auth is missing or invalid.timeout/error: probe failed for another reason.
It also publishes any usage object returned by the CLI probe:
- Claude: JSON result
usagefromclaude -p ... --output-format json. - Codex: JSONL
usagefromcodex exec --jsonturn completion.
It now also reports rolling local token usage for each CLI:
session_5h.used_tokensandsession_5h.percent_usedweek.used_tokensandweek.percent_used
The percent fields are computed against env-configured token limits:
CLAUDE_SESSION_5H_TOKEN_LIMITCLAUDE_WEEK_TOKEN_LIMITCODEX_SESSION_5H_TOKEN_LIMITCODEX_WEEK_TOKEN_LIMIT
Set a limit to 0 to publish raw used tokens without a percentage.
MQTT topics
ai_limits/availabilityai_limits/claude/stateai_limits/codex/stateai_limits/summary/state
Home Assistant discovery is retained under:
homeassistant/sensor/ai_limits_claude/confighomeassistant/sensor/ai_limits_codex/confighomeassistant/sensor/ai_limits_summary/config
Run
docker compose up -d --build
Secrets live in .env and are intentionally gitignored.
Description
Languages
Go
97.8%
Dockerfile
2.2%