Skip to content

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, or mqtts://host:8883 over 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:

MessageWhat to check
The broker could not be reachedthe host and port, and that the broker accepts connections from Runsten's address
This instance does not publish to that addressthe broker must be reachable from the Internet (below)
The secure connection failedthe 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 passwordthe credentials, and the user's rights on the broker
The broker refused the connectionthe 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:

TopicValue
battery_levelstate of charge, in %
range_kmrange, in km
charging_statusidle, charging, done, scheduled, discharging or error
plugconnected, disconnected or fault
charge_typeAC, DC, or none when the car says no charge runs
charging_power_kwcharging power, in kW
target_soccharge limit, in %
odometer_kmodometer, in km
enginerunning or stopped
location{"latitude": 45.764, "longitude": 4.8357}, when the position is published
read_atthe 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_kpaeach tyre's pressure, in kPa (100 kPa = 1 bar); unknown for a car that gives a warning per tyre only, as a Volvo
tyre_warningthe 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
serviceok, soon, due or overdue
service_days, service_monthsthe time left until the service, in days or in months, as the car counts it
service_distance_kmthe distance left until the service, in km
warning_brake_fluid, warning_coolant, warning_oil, warning_washer_fluid, warning_low_voltage_batterywarning or ok
warning_lightswarning when an exterior light fails; ok only when every light the car reports is known; the web interface names which
credential_statusa 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_ata 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_ca Tesla's only: the temperature outside and in the cabin, in °C
climate, preconditioning, battery_heatera Tesla's only: on or off, whether the climate runs, the car preconditions, or heats its battery
climate_setpoint_ca Tesla's only: the cabin temperature its climate is set to, in °C, whether it runs or not
lockedlocked or unlocked
door_front_left, door_front_right, door_rear_left, door_rear_right, hood, tailgate, tank_lidclosed, ajar (not fully shut) or open
window_front_left, window_front_right, window_rear_left, window_rear_right, sunroofclosed, ajar (open a crack) or open
sentrya Tesla's only: on or off, whether Sentry Mode watches the car
openings_read_atwhen the car last told its doors and windows, in RFC 3339, UTC: a Volvo and a Polestar tell them once an hour
left_openon 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>/status is online while Runsten is connected, and offline once 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:

sh
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:

EntityTypeFrom
Batterysensor, battery, %battery_level
Rangesensor, distance, kmrange_km
Charging statussensor, enumcharging_status
Charge typesensor, enum (AC, DC, none)charge_type
Charging powersensor, power, kWcharging_power_kw
Charge limitsensor, %target_soc
Odometersensor, distance, km, total increasingodometer_km
Last readsensor, timestamp, diagnosticread_at
Plugbinary sensor, plugplug
Chargingbinary sensor, battery chargingcharging_status
Enginebinary sensor, runningengine
Locationdevice trackerlocation
Tyre pressure front left, front right, rear left, rear rightsensor, pressure, kPatyre_pressure_…_kpa
Tyresbinary sensor, problemtyre_warning
Servicesensor, enumservice
Days to service, Months to servicesensorservice_days, service_months
Distance to servicesensor, distance, kmservice_distance_km
Brake fluid, Coolant, Oil, Washer fluid, 12 V battery, Lightsbinary sensor, problemwarning_…
Credentialbinary sensor, problem: on unless valid (a Polestar's, a Hyundai's, a Kia's or a Genesis's only)credential_status
Credential expirysensor, timestamp, diagnostic (a Polestar's, a Hyundai's, a Kia's or a Genesis's only)credential_expires_at
Outside temperature, Cabin temperaturesensor, temperature, °C (a Tesla's only)outside_temp_c, cabin_temp_c
Climate, Preconditioning, Battery heaterbinary sensor, running (a Tesla's only)climate, preconditioning, battery_heater
Climate setpointsensor, temperature, °C (a Tesla's only)climate_setpoint_c
Lockbinary sensor, lock: on unlockedlocked
Door front left, front right, rear left, rear rightbinary sensor, door: on open or ajardoor_…
Hood, Tailgate, Tank lidbinary sensor, openinghood, tailgate, tank_lid
Window front left, front right, rear left, rear right, Sunroofbinary sensor, windowwindow_…, sunroof
Sentry Modebinary sensor (a Tesla's only)sentry
Left openbinary sensor, problemleft_open
Doors last readsensor, timestamp, diagnosticopenings_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:

yaml
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:

yaml
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:

    text
    listener 8883
    certfile /mosquitto/certs/fullchain.pem
    keyfile /mosquitto/certs/privkey.pem
    allow_anonymous false
    password_file /mosquitto/config/passwords
    acl_file /mosquitto/config/acl

    with an acl file that lets Runsten's user write its topics only:

    text
    user 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/# and homeassistant/# topics (a connection with topic … 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):

sh
docker compose --profile mqtt up -d

Then set mqtt://mosquitto:1883 in the settings, and watch what is published:

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