Trading212 Home Assistant Integration
A free custom component that pulls your Trading212 portfolio into Home Assistant — account value, open positions, pie performance, daily P&L, and dividends, all as native HA sensors.
What it tracks
Account
Total value, cash, invested amount, unrealised and realised P&L, dividends, daily movers.
Positions
Per-ticker value, P&L, quantity, average purchase price, and current price.
Pies
Pie value, goal progress, dividends earned, reinvested, and held as cash.
Don't have Trading212 yet?
Sign up with this link and we both get a free share worth up to £100.
Screenshots
Default card style
Mushroom card style
Installation
- 1
Open HACS → Integrations, then click the ⋮ menu (top-right) → Custom Repositories.
- 2
Paste
https://github.com/Smart-Home-Assistant-UK/homeassistant-trading212as the URL, set Category to Integration, and click Add. - 3
Search for Trading212 in HACS, select it, and click Download.
- 4
Restart Home Assistant.
- 5
Go to Settings → Devices & Services → Add Integration and search for Trading212.
- 6
Enter your API key — generate one at Settings → API inside the Trading212 app.
- 7
Enter your API secret (also from Settings → API).
- 8
Choose your environment: Live or Demo.
- 9
Set a poll interval (default 60 s, minimum 30 s) and complete setup.
Manual install: Copy custom_components/trading212 into your HA config/custom_components/ directory, then restart.
Configuration
| Field | Default | Notes |
|---|---|---|
| API Key | — | Required. Generate in Trading212 app → Settings → API. |
| API Secret | — | Required. |
| Environment | Live | Live or Demo. Add the integration twice to use both. |
| Poll Interval | 60 s | Minimum 30 s. How often HA fetches fresh data. |
Sensors reference
Account sensors
Entity ID pattern: sensor.trading212_<key>
| Key | Tracks |
|---|---|
| total_value | Total portfolio value |
| cash_available | Uninvested cash |
| cash_in_pies | Cash held inside pies |
| invested | Total cost basis |
| unrealized_pnl | Open profit/loss |
| realized_pnl | All-time realised gains/losses |
| result_percent | Overall return % |
| open_positions_count | Count of open positions |
| active_orders_count | Count of pending orders |
| total_dividends | Total dividends received |
| daily_gain_loss | Today's P&L |
| daily_gain_loss_percent | Today's return % |
| top_daily_mover | Best performing ticker today |
| bottom_daily_mover | Worst performing ticker today |
| biggest_daily_gain | Largest single gain today |
| biggest_daily_loss | Largest single loss today |
| last_updated | Timestamp of last successful poll |
Position sensors
Entity ID pattern: sensor.trading212_<ticker_slug>_<suffix> — e.g. sensor.trading212_vwrl_l_value
| Suffix | Tracks |
|---|---|
| value | Current market value |
| pnl | Unrealised P&L |
| pnl_percent | Return % |
| quantity | Shares held |
| avg_price | Average purchase price |
| current_price | Current market price |
Pie sensors
Entity ID pattern: sensor.trading212_<pie_slug>_<suffix>
| Suffix | Tracks |
|---|---|
| value | Pie market value |
| invested | Amount invested in pie |
| pnl | Unrealised P&L |
| pnl_percent | Return % |
| cash | Uninvested cash in pie |
| progress | Progress toward goal % |
| goal | Target goal amount |
| dividends_gained | Total dividends earned |
| dividends_in_cash | Dividends held as cash |
| dividends_reinvested | Dividends reinvested |
Troubleshooting
"Trading212" doesn't appear when searching HACS
This integration isn't in the default HACS catalog — you need to add it as a custom repository first. Follow steps 1–2 in the installation guide above, then search again.
Daily P&L resets at the wrong time
The daily gain/loss is calculated against a snapshot taken at midnight using your Home Assistant server's local time. If your HA instance runs in UTC, the reset happens at midnight UTC rather than your local midnight. Adjust your HA timezone in Settings → System → General.
Pie sensors are missing after renaming a pie
Sensor IDs are generated from the pie name at setup time. If you rename a pie in Trading212, the old sensors become stale. Remove the integration and re-add it — new sensor IDs will be generated from the updated name.
Sensors show "unavailable" straight after setup
Home Assistant hasn't completed the first poll yet. Wait one poll interval (default 60 s) or restart HA. If sensors remain unavailable, check Settings → System → Logs for Trading212 errors.
"Invalid API key" error during setup
You need the API key and secret from Trading212's built-in API settings, not your login email and password. Open the Trading212 app → Settings → API → Create key. Make sure you're copying both the key and the secret before closing that screen — the secret is only shown once.
Sensors stop updating or show stale data
Go to Developer Tools → States and search for sensor.trading212. If the last_updated timestamp is old, remove the integration and re-add it. Also check that your API key hasn't been revoked in the Trading212 app.
API rate-limit or "too many requests" errors in the logs
Trading212's API enforces rate limits. Increase your poll interval to 120 s or higher in the integration options (Settings → Devices & Services → Trading212 → Configure).
Sensors show Demo account data instead of Live
During setup you selected the Demo environment. Remove the integration and re-add it, choosing Live this time. You can also add the integration twice — once for Live and once for Demo — to track both simultaneously.
Still stuck? Open an issue on GitHub.