Zerodha Integration: A Game-Changer for Portfolio Tracking

Hi everyone! I wanted to share a custom Home Assistant integration for Zerodha (Kite) that I’ve been using to track my Indian stock portfolio directly inside Home Assistant. The goal was to expose clean, agent-friendly sensors that work well with InfluxDB, Grafana, and future Home Assistant Agent workflows, while keeping API usage minimal.

What it does

The integration creates three primary sensors:

  • Portfolio Value
  • Cash Available
  • Unrealized PnL

All sensors:

  • Update together via a single coordinator
  • Use last-known values when no fresh data is available
  • Are safe for time-series storage and visualization

Smart update strategy

To avoid rate limits and unnecessary logins:

  • Market hours (Mon–Fri, 09:15–15:30 IST) → update every 1 hour
  • Off-market hours → update every 6 hours

This works well for long-term portfolio monitoring without hammering Zerodha endpoints.

Dashboards & Grafana

The sensors are designed to work cleanly with InfluxDB + Grafana:

  • Stacked bars for Cash vs Portfolio value
  • Line overlay for PnL
  • Forward-filled values so charts stay aligned
  • Easy alerting (cash below threshold, PnL drawdown, etc.)

Agent-friendly by design

Entities are intentionally simple and semantic:

  • sensor.zerodha_portfolio_value
  • sensor.zerodha_cash_available
  • sensor.zerodha_unrealized_pnl

This makes them suitable for:

  • Home Assistant Agent reasoning
  • Natural language queries
  • Financial health summaries

Authentication notes

  • Uses Zerodha’s web login flow (enctoken)
  • Supports TOTP (PyOTP) for automated login
  • Intended for personal / educational use
  • Not affiliated with Zerodha

Feedback welcome

Thanks, and hope this is useful to others in the community! :rocket: