Smart Home Assistant
HA 2024.1+Read-only

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.

Get a free share →

Screenshots

Default card style

Mushroom card style

Installation

  1. 1

    Open HACS → Integrations, then click the ⋮ menu (top-right) → Custom Repositories.

  2. 2

    Paste https://github.com/Smart-Home-Assistant-UK/homeassistant-trading212 as the URL, set Category to Integration, and click Add.

  3. 3

    Search for Trading212 in HACS, select it, and click Download.

  4. 4

    Restart Home Assistant.

  5. 5

    Go to Settings → Devices & Services → Add Integration and search for Trading212.

  6. 6

    Enter your API key — generate one at Settings → API inside the Trading212 app.

  7. 7

    Enter your API secret (also from Settings → API).

  8. 8

    Choose your environment: Live or Demo.

  9. 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

FieldDefaultNotes
API KeyRequired. Generate in Trading212 app → Settings → API.
API SecretRequired.
EnvironmentLiveLive or Demo. Add the integration twice to use both.
Poll Interval60 sMinimum 30 s. How often HA fetches fresh data.

Sensors reference

Account sensors

Entity ID pattern: sensor.trading212_<key>

KeyTracks
total_valueTotal portfolio value
cash_availableUninvested cash
cash_in_piesCash held inside pies
investedTotal cost basis
unrealized_pnlOpen profit/loss
realized_pnlAll-time realised gains/losses
result_percentOverall return %
open_positions_countCount of open positions
active_orders_countCount of pending orders
total_dividendsTotal dividends received
daily_gain_lossToday's P&L
daily_gain_loss_percentToday's return %
top_daily_moverBest performing ticker today
bottom_daily_moverWorst performing ticker today
biggest_daily_gainLargest single gain today
biggest_daily_lossLargest single loss today
last_updatedTimestamp of last successful poll

Position sensors

Entity ID pattern: sensor.trading212_<ticker_slug>_<suffix> — e.g. sensor.trading212_vwrl_l_value

SuffixTracks
valueCurrent market value
pnlUnrealised P&L
pnl_percentReturn %
quantityShares held
avg_priceAverage purchase price
current_priceCurrent market price

Pie sensors

Entity ID pattern: sensor.trading212_<pie_slug>_<suffix>

SuffixTracks
valuePie market value
investedAmount invested in pie
pnlUnrealised P&L
pnl_percentReturn %
cashUninvested cash in pie
progressProgress toward goal %
goalTarget goal amount
dividends_gainedTotal dividends earned
dividends_in_cashDividends held as cash
dividends_reinvestedDividends 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.