
If you’re like me and constantly running up your Claude subscription usage to its limits, you want a graph. Anthropic has two rate limit windows; one which is five hours long and one which is a week. Go beyond either and you need to put in a credit card for extra usage, upgrade to Max, or – wait! What kind of AI charged engineer wants to wait?
I do more than half of my usage on my mobile phone, so I wanted the best and easiest graph platform a mobile user can get: Home Assistant.
Check out the open sourced code: https://github.com/trickv/hass-claude-usage
Installation with HACS is easy:
-
- Add the repository as a custom repository in HACS
- Restart Home Assistant
- Install “Claude Usage”
- Restart Home Assistant
- Go to Settings → Devices & Services → Add Integration → “Claude Usage”
Once it starts collecting data, make a History Graph with the data points and the window you find this useful for; I usually look at the 24 hour window. See the README for an example dashboard.
Let me know if you find this useful or are managing your usage in other ways?
How I built it – iteratively
Building this little tool was certainly different to how I would have approached this in the pre-AI past. I would have defined not just the end goal but also the methods clearly and worked straight towards it, optimizing to spend as little time coding as possible. Given that this is a hobby project, I probably never would have finished it! The API was elusive at first and I couldn’t find examples for how to use it. But the AI-enabled engineer approach lends us to an iterative approach, where code is cheap, and making something that works is important to justify spending more time on. My iterations looked something like this:
- First version which used the HA API to create sensors, and used Claude Code CLI in a tmux session to get usage data. It would run Claude Code, wait a few seconds, type /usage, and grep the output. It worked, albeit running claude code periodically contributed to usage! But it gave me a graph, and it was useful.
- Refactored to run Claude Code and keep it open in a persistent tmux
- Somewhere in here I learned about Anthropic’s rate limits on the usage endpoints which block you for 24 hours when you hit them too much!
- Learned how to use the APIs directly to fetch usage status, but this approach had to steal Claude Code’s session token (which expires every few hours).
- Moved from HA API to MQTT integration to get better data into Home Assistant. This was a surprisingly easy refactor for Sonnet 4.5!
- Refactored to standalone OAuth (first time I used Opus 4.5 on this code)
- Now refactored into this Home Assistant custom integration, installable by HACS
How are you managing usage?
I’m curious to hear how others on low usage plans like mine (Pro) are managing their usage. Let me know if you find this useful!