Skip to content

MQTT and Home Assistant

Here for Home Assistant?

Skip to Home Assistant mode, where the panel behaves as a process data server — the same idea as an OPC server.

The panel can publish tag values to an MQTT broker, typically ThingsBoard or OpenRemote, where you build the charts, dashboards and alerts. The panel is a data source, not a historian: it sends the current state, the server keeps the history.

Switching it on

  1. In the device tree, double-click the MQTT node (or right-click → MQTT settings…).
  2. Tick Publish telemetry to broker and fill in the broker address and login.
  3. In the tag list, tick the tags that should be sent.
  4. ApplyDownload to panel. The configuration is part of the package, so changing the broker or the tag list does not need new firmware.

MQTT is a FULL feature, like CAN and Modbus.

Field Meaning
broker IP address or host name, for example 192.168.0.10
port 1883 (plain MQTT, unencrypted)
username / token in ThingsBoard this is the device access token
password for a generic broker; ThingsBoard does not need one
topic the base topic; the default is v1/devices/me/telemetry
interval how often a message may leave at most (default 5 s, minimum 1 s)
setTag commands allows writes from a dashboard (see below)

What the panel sends

Flat JSON goes to the base topic, containing only the values that changed since the last message:

{"voltage_l1": 231.4, "contactor": true, "pieces": 1250}
  • If nothing changed, nothing is sent. No traffic for its own sake.
  • After connecting — including after an outage — the complete state is sent once so the dashboard has everything.
  • Decimal places follow the tag's setting; bool goes out as true/false.
  • The tag's deadband filters the noise. Without one, a noisy analogue input would publish forever.

Commands from a dashboard (setTag)

With commands enabled, the panel listens on the ThingsBoard RPC topic and accepts:

{"method":"setTag","params":{"pieces":0}}

A write is a command, not direct access to memory — the panel carries it out only if the tag is among the published ones and has rw access. Otherwise it answers with an error and writes nothing. The reply goes to .../rpc/response/<id>.

Warning

Never use remote commands for safety functions. Emergency stop, end-of-travel limits and doors must be hard-wired.

Security and limits

  • No TLS. Encryption is not enabled on the ESP32-S3 — it does not fit in RAM alongside control and graphics. The broker belongs on the machine's isolated network, not on the internet. The panel does not belong on a public network.
  • The token and password are stored in the project package in readable form.
  • The limit on published tags is 64. The editor will not allow more.
  • One broker per panel.
Situation Behaviour
Broker unreachable at start-up the panel runs normally and connects in the background
Broker drops out one diagnostic event, repeated reconnection, and the full state on return
Slow network telemetry never extends the control cycle — it runs on the other core
Package without MQTT the client is never started, and costs no memory at all

ThingsBoard, step by step

  1. DevicesAdd device, copy the access token.
  2. In the editor: broker = the ThingsBoard server's IP, username = the token, leave the topic at its default.
  3. After deploying, the values appear under the device's Latest telemetry.
  4. A Switch or Knob widget in a dashboard → RPC method setTag, parameters {"tag_name": value}.

For OpenRemote or any other broker only the topic and login change — the message format is the same.

Home Assistant mode: one topic per tag

The MQTT settings can switch publishing to one topic per tag. In that mode the panel behaves as a process data server, the equivalent of an OPC server:

What Topic Note
tag value <base>/<tag> retained — a new client gets the state immediately
write to a tag <base>/<tag>/set only tags with writing enabled
availability <base>/status online / offline (last will)

With a base topic of inogui32/boilerroom, the temperature arrives on inogui32/boilerroom/temperature and the setpoint is changed by writing to inogui32/boilerroom/setpoint/set.

Why retained, and why a last will

  • Retained: after a restart, Home Assistant is given the last value of every tag by the broker immediately. Without it, entities would stay empty until a value on the machine happened to change.
  • Last will (LWT): when the panel disappears — network or power — the broker itself publishes offline and the entities in Home Assistant grey out. Without it, Home Assistant would keep showing the last known value as though it were current, which is worse than no value at all.

Writing is enabled per tag

Every published tag has its own write checkbox, and it can only be ticked for a tag that is rw in the project. Without it the panel ignores a write from the broker, even if someone sends one. What a supervisory system may reach into is decided by the machine builder, not the other way round.

The quickest route: MQTT Discovery

In one-topic-per-tag mode there is a MQTT Discovery option. On connecting, the panel sends the broker a configuration for every entity and Home Assistant creates them itself — you write no YAML. All you need is the MQTT integration set up in Home Assistant.

The entities are grouped under one device, so you see the panel as a whole with all its values beneath it. The entity type follows the tag:

Tag Entity in Home Assistant
numeric, read only sensor with a unit
boolean, read only binary sensor
numeric, writable number
boolean, writable switch

The configuration is sent retained, so it survives a restart of both Home Assistant and the broker. After a project change the entities update themselves.

Exporting the configuration, if you want YAML

To keep the configuration under your own control — version-controlled, edited by hand — turn Discovery off and use the export instead.

The Export YAML for Home Assistant button writes a file with one entity per tag:

  • numeric, read only → sensor (with a unit)
  • boolean, read only → binary_sensor
  • numeric, writable → number
  • boolean, writable → switch

Paste the file into configuration.yaml, or pull it in with !include, and restart Home Assistant. The ranges on number entities are deliberately wide — narrow them in Home Assistant to suit the machine.

Control stays on the panel

Logic, timers and local buttons keep running even with Home Assistant switched off, the network dead and the broker unreachable. MQTT is only a window out. Measured: with an unreachable broker the cycle runs in 24 µs with zero overruns. Nothing on the machine stops while Home Assistant updates.

MQTT costs about 12 kB of RAM — and only when the project has it enabled.

Ghosts after a project change

Retained messages stay on the broker even after a tag is renamed. Clear an old topic with an empty retained message:

mosquitto_pub -h <broker> -t inogui32/boilerroom/old_tag -r -n

Common traps

Trap What to do
Nothing appears in the dashboard check the token (in ThingsBoard it is the username, not the password) and that the tag is ticked
Values arrive rarely that is the design — only changes are sent; check the tag's deadband
A command from the dashboard does nothing the tag must be published and have rw access
Broker behind NAT or on the internet not supported without TLS — the broker belongs on the machine's network