Home Assistant and MQTT
Runsten publishes the state of your vehicles to your MQTT broker: battery, range, charging, plug, engine, odometer and position, and their health: tyres, service and warnings. Home Assistant creates a device for each vehicle with its entities, without any configuration; Node-RED, openHAB or any MQTT client read the same topics, in plain text.
It only publishes: nothing sent to the broker reaches the car, and Runsten sends it no command.
Setting the broker
In Settings → Integrations, under MQTT:
- Broker URL:
mqtt://host:1883, ormqtts://host:8883over TLS. For Home Assistant's Mosquitto add-on,mqtt://homeassistant.local:1883; if Runsten runs in Docker and that name does not resolve there, use Home Assistant's IP address. - Username and Password, if the broker asks for them. With the Mosquitto add-on, create a Home Assistant user for Runsten (or a login in the add-on's options). The password is stored encrypted, never shown again, and kept when the URL changes to the same host only.
- Home Assistant discovery: on by default; off, only the topics below are published.
- Publish the position: on by default; off, no position leaves Runsten, and Home Assistant gets no tracker.
- Under Advanced: the topic prefix (
runsten, to change when several instances share a broker), the discovery prefix (homeassistant, unless changed in Home Assistant's MQTT integration) and the client ID (empty: Runsten derives one from the account).
Runsten connects within a minute. The section then says since when it is connected, or why it is not:
| Message | What to check |
|---|---|
| The broker could not be reached | the host and port, and that the broker accepts connections from Runsten's address |
| This instance does not publish to that address | the broker must be reachable from the Internet (below) |
| The secure connection failed | the broker's certificate: issued by a public authority, for the name in the URL; or a port that does not speak TLS |
| The broker refused the username or the password | the credentials, and the user's rights on the broker |
| The broker refused the connection | the client ID (another client using it, or a broker limiting its length) |
When it publishes
After each reading of a vehicle: every 10 minutes while it is parked, every minute while it drives or charges. The health is read every hour. Only the values that changed are sent; nothing between two readings, since Runsten knows nothing more. At each connection, it publishes everything again.
Every message is retained, with QoS 1: a client that subscribes (Home Assistant after a restart) gets the latest values at once.
Topics
Under <prefix>/vehicles/<vehicle id>/, where the prefix is runsten by default and the vehicle ID is Runsten's (a UUID, the one in the web interface's addresses), never the VIN:
| Topic | Value |
|---|---|
battery_level | state of charge, in % |
range_km | range, in km |
charging_status | idle, charging, done, scheduled, discharging or error |
plug | connected, disconnected or fault |
charge_type | AC, DC, or none when the car says no charge runs |
charging_power_kw | charging power, in kW |
target_soc | charge limit, in % |
odometer_km | odometer, in km |
engine | running or stopped |
location | {"latitude": 45.764, "longitude": 4.8357}, when the position is published |
read_at | the latest reading of the vehicle, in RFC 3339, UTC (2026-10-04T10:00:00Z) |
tyre_pressure_front_left_kpa, …_front_right_kpa, …_rear_left_kpa, …_rear_right_kpa | each tyre's pressure, in kPa (100 kPa = 1 bar); unknown for a car that gives a warning per tyre only, as a Volvo |
tyre_warning | the worst warning of the tyres: high, fault, low or very_low as soon as one tyre says so; ok only when the four are known |
service | ok, soon, due or overdue |
service_days, service_months | the time left until the service, in days or in months, as the car counts it |
service_distance_km | the distance left until the service, in km |
warning_brake_fluid, warning_coolant, warning_oil, warning_washer_fluid, warning_low_voltage_battery | warning or ok |
warning_lights | warning when an exterior light fails; ok only when every light the car reports is known; the web interface names which |
credential_status | a Polestar's, a Hyundai's, a Kia's or a Genesis's only: valid, expiring (two weeks before its expiry), expired, refused (the brand refused it) or missing (none given) |
credential_expires_at | a Polestar's, a Hyundai's, a Kia's or a Genesis's only: when its credential expires at the latest (a Pleos key's 90 days after it was given, an estimate), in RFC 3339, UTC; empty without one |
outside_temp_c, cabin_temp_c | a Tesla's only: the temperature outside and in the cabin, in °C |
climate, preconditioning, battery_heater | a Tesla's only: on or off, whether the climate runs, the car preconditions, or heats its battery |
climate_setpoint_c | a Tesla's only: the cabin temperature its climate is set to, in °C, whether it runs or not |
locked | locked or unlocked |
door_front_left, door_front_right, door_rear_left, door_rear_right, hood, tailgate, tank_lid | closed, ajar (not fully shut) or open |
window_front_left, window_front_right, window_rear_left, window_rear_right, sunroof | closed, ajar (open a crack) or open |
sentry | a Tesla's only: on or off, whether Sentry Mode watches the car |
openings_read_at | when the car last told its doors and windows, in RFC 3339, UTC: a Volvo and a Polestar tell them once an hour |
left_open | on once the car has stood parked and open (unlocked, or a door, the hood, the tailgate, a window or the sunroof open or ajar) for 10 minutes, by its readings; off otherwise |
- Numbers are written with a point, as short as they read:
80,312.5,11.04. - An unknown value is an empty message, which removes the previous one: unknown is never zero.
- The credential's topics are checked at every pass of the collector, even while Polestar refuses the credential and nothing is read, and published when they change: the state follows the date by itself (Every 90 days).
<prefix>/statusisonlinewhile Runsten is connected, andofflineonce it stops or loses the connection (its last will).
These topics are a contract, like the API: a change to them is announced in the update notes.
To watch them, with Mosquitto's client:
mosquitto_sub -h homeassistant.local -u runsten -P '…' -v -t 'runsten/#'Home Assistant entities
With discovery on, each vehicle is a device named after the name you gave a Tesla in Tesla's app, else its model and model year, as in the web interface, but never after its VIN: before its details are read, it is Volvo and the first characters of its ID, and two that read alike end with characters of their ID, where the web interface shows its VIN. It has these entities:
| Entity | Type | From |
|---|---|---|
| Battery | sensor, battery, % | battery_level |
| Range | sensor, distance, km | range_km |
| Charging status | sensor, enum | charging_status |
| Charge type | sensor, enum (AC, DC, none) | charge_type |
| Charging power | sensor, power, kW | charging_power_kw |
| Charge limit | sensor, % | target_soc |
| Odometer | sensor, distance, km, total increasing | odometer_km |
| Last read | sensor, timestamp, diagnostic | read_at |
| Plug | binary sensor, plug | plug |
| Charging | binary sensor, battery charging | charging_status |
| Engine | binary sensor, running | engine |
| Location | device tracker | location |
| Tyre pressure front left, front right, rear left, rear right | sensor, pressure, kPa | tyre_pressure_…_kpa |
| Tyres | binary sensor, problem | tyre_warning |
| Service | sensor, enum | service |
| Days to service, Months to service | sensor | service_days, service_months |
| Distance to service | sensor, distance, km | service_distance_km |
| Brake fluid, Coolant, Oil, Washer fluid, 12 V battery, Lights | binary sensor, problem | warning_… |
| Credential | binary sensor, problem: on unless valid (a Polestar's, a Hyundai's, a Kia's or a Genesis's only) | credential_status |
| Credential expiry | sensor, timestamp, diagnostic (a Polestar's, a Hyundai's, a Kia's or a Genesis's only) | credential_expires_at |
| Outside temperature, Cabin temperature | sensor, temperature, °C (a Tesla's only) | outside_temp_c, cabin_temp_c |
| Climate, Preconditioning, Battery heater | binary sensor, running (a Tesla's only) | climate, preconditioning, battery_heater |
| Climate setpoint | sensor, temperature, °C (a Tesla's only) | climate_setpoint_c |
| Lock | binary sensor, lock: on unlocked | locked |
| Door front left, front right, rear left, rear right | binary sensor, door: on open or ajar | door_… |
| Hood, Tailgate, Tank lid | binary sensor, opening | hood, tailgate, tank_lid |
| Window front left, front right, rear left, rear right, Sunroof | binary sensor, window | window_…, sunroof |
| Sentry Mode | binary sensor (a Tesla's only) | sentry |
| Left open | binary sensor, problem | left_open |
| Doors last read | sensor, timestamp, diagnostic | openings_read_at |
The doors, windows and lock are entities only for what the car tells: a Tesla tells neither its tank lid nor its sunroof, a Polestar no sunroof, and the right and left doors of a Tesla only once Runsten knows its driver's side. The lock is a sensor: Runsten does not lock the car.
The Credential entity turns on two weeks before the Polestar credential expires, and stays on until another is given: an automation can notify your phone, without opening Runsten. For instance:
automation:
- alias: Renew the Polestar credential
triggers:
- trigger: state
entity_id: binary_sensor.polestar_3_2025_credential
to: "on"
actions:
- action: notify.mobile_app_my_phone
data:
title: Polestar credential
message: >-
{% set expiry = states('sensor.polestar_3_2025_credential_expiry') | as_datetime(none) %}
Create a new credential on Polestar's Data Portal and give it to Runsten{{
' before ' ~ (expiry | as_local).strftime('%d %B') if expiry else '' }}.The Left open entity turns on once the car has stood parked and open for 10 minutes: unlocked, or a door, the hood, the tailgate, a window or the sunroof open or ajar (not the tank lid, which may be an electric car's charge port). A Volvo and a Polestar tell their doors once an hour: it may turn on up to an hour late, and the message can say how old the reading is. For instance:
automation:
- alias: Car left open
triggers:
- trigger: state
entity_id: binary_sensor.ex30_2025_left_open
to: "on"
actions:
- action: notify.mobile_app_my_phone
data:
title: Car left open
message: >-
{% set read = states('sensor.ex30_2025_doors_last_read') | as_datetime(none) %}
The EX30 is parked and open{{ ', as read at ' ~ (read | as_local).strftime('%H:%M') if read else '' }}.The entity IDs follow the device's name: check them in Home Assistant.
Their configurations are published under <discovery prefix>/<component>/runsten_<vehicle id>/<object>/config. An unknown value shows as Unknown: what a car does not report (a Volvo's tyre pressures, a model's oil) stays so; while Runsten is stopped or cut off from the broker, the entities are Unavailable, and come back as they were.
Runsten clears what it published, and Home Assistant removes the entities:
- when the broker is removed from the settings, or replaced by another URL: the entities and the values;
- when discovery is turned off, or its prefix changes: the entities (created again under the new prefix);
- when the topic prefix changes: the values under the old one;
- when a vehicle leaves the account: its entities and values;
- when the position is no longer published: the tracker and the position.
This happens as the change is made, while Runsten is connected to the broker: what it could not clear then stays on the broker.
A broker on the Internet
An instance that serves others from the Internet may publish only to brokers on the Internet, over TLS: the settings then ask for mqtts://, and refuse a local address (192.168.…, homeassistant.local). Your broker, at home behind your router, must then be reached from the Internet. Three ways:
Expose your broker over TLS. Forward a port of your router (8883) to the broker, give the broker a certificate from a public authority for a name that leads to your address (Let's Encrypt, with a dynamic DNS name if your address changes), and keep its password strong. Runsten checks the certificate against the usual authorities: a self-signed one is refused. Mosquitto's add-on takes a certificate in its options (
certfile,keyfile) and listens over TLS on 8883. With Mosquitto of your own, a listener such as:textlistener 8883 certfile /mosquitto/certs/fullchain.pem keyfile /mosquitto/certs/privkey.pem allow_anonymous false password_file /mosquitto/config/passwords acl_file /mosquitto/config/aclwith an
aclfile that lets Runsten's user write its topics only:textuser runsten topic write runsten/# topic write homeassistant/#A broker in the cloud (HiveMQ Cloud, EMQX Cloud…): Runsten publishes to it, and Home Assistant's MQTT integration connects to it rather than to a local broker. Nothing to open at home.
A bridge: your local Mosquitto subscribes to that cloud broker's
runsten/#andhomeassistant/#topics (aconnectionwithtopic … in), and Home Assistant stays on the local broker.
A self-hosted instance reaches a broker on your own network directly, in mqtt://: none of this is needed.
Self-hosting
An instance publishes to brokers on its own network by default. RUNSTEN_MQTT_PRIVATE_BROKERS=false in .env restricts it to brokers on the Internet over TLS, as above: for an instance whose users are not all trusted, so that a broker URL cannot be used to reach the server's network. Runsten checks the addresses again each time it connects: a name may resolve to another one later.
To try the publishing without Home Assistant, compose.yaml has an mqtt profile that adds a Mosquitto broker, without a password, reachable from the host only (127.0.0.1:1883):
docker compose --profile mqtt up -dThen set mqtt://mosquitto:1883 in the settings, and watch what is published:
docker compose exec mosquitto mosquitto_sub -v -t '#'It is meant for trying and testing, not for a real broker: it keeps nothing across restarts and accepts anyone who reaches it.