Tasmota turns cheap ESP8266 and ESP32 smart plugs, relays and sensors into well-behaved MQTT devices. Point it at a broker, give it a topic name, and it accepts commands on cmnd/<topic>/…, reports results on stat/<topic>/… and sends periodic telemetry on tele/<topic>/…. Once you understand those three prefixes, you can control any Tasmota device from any MQTT client.
This guide configures the broker connection, explains Topic and FullTopic, walks through the commands and telemetry you will use daily, and tests everything from the browser before you wire it into Home Assistant or Node-RED.
Configure the broker
Open the device's web UI and go to Configuration → Configure MQTT:
| Field | Value | Notes |
|---|---|---|
| Host | broker.connectmq.com | Hostname or IP of your broker |
| Port | 1883 | 8883 only on TLS-enabled builds (see below) |
| Client | tasmota-plug1 | Must be unique per device; default DVES_%06X uses the chip ID |
| User / Password | your broker credentials | Leave empty only on brokers without authentication |
| Topic | testmqtt-plug1 | The device's short name |
| Full Topic | testmqtt/tasmota/%prefix%/%topic%/ | The template for every topic |
Saving restarts the device. You can do the same from the Console in one line with Backlog, which is handy when you configure many devices:
Backlog MqttHost broker.connectmq.com; MqttPort 1883; MqttUser username; MqttPassword password; MqttClient tasmota-plug1; Topic testmqtt-plug1; FullTopic testmqtt/tasmota/%prefix%/%topic%/Make sure MQTT itself is enabled (Configuration → Configure Other → MQTT enable, or SetOption3 1). After the restart the console should print:
MQT: Attempting connection...
MQT: ConnectedIf you see MQT: Connect failed to broker.connectmq.com:1883, rc -2. Retry in 10 sec instead, the device could not open a TCP connection; rc 4 or rc 5 means the credentials were rejected. The Tasmota not connecting guide covers every case.
Topic and FullTopic
Tasmota builds every MQTT topic from the FullTopic template. Three tokens are replaced at runtime:
%prefix%becomescmnd,statortele.%topic%becomes the device's Topic (testmqtt-plug1).%hostname%and%id%are also available if you prefer names derived from the chip.
With the default FullTopic %prefix%/%topic%/, a plug named kitchen uses cmnd/kitchen/POWER. On a shared test broker that is far too generic: your cmnd/kitchen/POWER would collide with anyone else's. The FullTopic above prefixes everything with testmqtt/tasmota/, which gives you a private namespace and makes subscriptions easy:
| Purpose | Topic with our FullTopic |
|---|---|
| Send a command | testmqtt/tasmota/cmnd/testmqtt-plug1/POWER |
| Command result | testmqtt/tasmota/stat/testmqtt-plug1/RESULT |
| Current power state | testmqtt/tasmota/stat/testmqtt-plug1/POWER |
| Periodic state | testmqtt/tasmota/tele/testmqtt-plug1/STATE |
| Sensor readings | testmqtt/tasmota/tele/testmqtt-plug1/SENSOR |
| Online / Offline (LWT) | testmqtt/tasmota/tele/testmqtt-plug1/LWT |
For a larger installation, pick a scheme by location or function and stick to it; smart home topic design has patterns that scale.
Commands: cmnd and stat
Any console command can be sent over MQTT. The command name is the last topic level and the argument is the payload:
# Switch on
mosquitto_pub -h broker.connectmq.com -u "$MQTT_USER" -P "$MQTT_PASS" \
-t testmqtt/tasmota/cmnd/testmqtt-plug1/POWER -m ON
# Toggle
mosquitto_pub -h broker.connectmq.com -u "$MQTT_USER" -P "$MQTT_PASS" \
-t testmqtt/tasmota/cmnd/testmqtt-plug1/POWER -m TOGGLE
# Query the state: an empty payload asks without changing anything
mosquitto_pub -h broker.connectmq.com -u "$MQTT_USER" -P "$MQTT_PASS" \
-t testmqtt/tasmota/cmnd/testmqtt-plug1/POWER -nThe device answers on two topics: stat/testmqtt-plug1/RESULT with JSON such as {"POWER":"ON"}, and stat/testmqtt-plug1/POWER with the plain value ON. Devices with several relays use POWER1, POWER2, and so on.
Other commands you will use often:
| Command | Payload | Effect |
|---|---|---|
Status | 0 | Full status dump, answered as several stat/.../STATUS* messages |
Status | 6 | MQTT configuration only, handy for checking FullTopic and client ID |
TelePeriod | 60 | Send telemetry every 60 seconds (10–3600) |
Dimmer | 0–100 | Brightness on dimmable lights |
Restart | 1 | Reboot the device |
Backlog | cmd1 arg; cmd2 arg | Run several commands in sequence |
You can also send Backlog over MQTT, which makes remote reconfiguration of many devices a one-line script. For more terminal patterns, see mosquitto_pub and mosquitto_sub examples.
Telemetry: tele
Every TelePeriod seconds (300 by default) Tasmota publishes two messages:
{"Time":"2026-10-17T10:15:00","Uptime":"0T02:14:31","Heap":25,"POWER":"ON","Wifi":{"SSId":"home","RSSI":72,"Signal":-64}}{"Time":"2026-10-17T10:15:00","ENERGY":{"Total":3.214,"Yesterday":0.412,"Today":0.183,"Power":46,"Voltage":231,"Current":0.214}}The exact fields depend on the device template and attached sensors. tele/.../LWT is special: Tasmota publishes Online retained after connecting and registers Offline as its Last Will, so subscribers always know whether the device is reachable.
If you need values faster than TelePeriod allows, use a rule to publish on change. Rules run on the device itself:
Rule1 ON Power1#State DO Publish testmqtt/tasmota/events/testmqtt-plug1 {"power":%value%} ENDON
Rule1 1Test everything from the browser
- Open the online MQTT client and connect to
broker.connectmq.comon port 8084 with path/mqtt. - Subscribe to
testmqtt/tasmota/#. You should immediately receive the retainedtele/testmqtt-plug1/LWT = Online. - Publish
TOGGLEtotestmqtt/tasmota/cmnd/testmqtt-plug1/POWER. The relay clicks andstat/.../RESULTandstat/.../POWERarrive within a fraction of a second. - Publish
10totestmqtt/tasmota/cmnd/testmqtt-plug1/TelePeriodand watchtele/.../STATEarrive every ten seconds. Set it back to a sensible value afterwards. - Unplug the device. After the keep-alive timeout the broker publishes
LWT = Offline.
Watch your Tasmota device in the online client
When a subscription shows nothing, check the filter against a real topic with the topic matcher. A missing trailing segment or the wrong prefix order in FullTopic is the usual culprit.
Retained messages and power state
Tasmota does not retain its stat messages by default. If a dashboard needs the current state right after it subscribes, either query it (empty payload to cmnd/.../POWER) or enable PowerRetain 1 so stat/.../POWER is retained.
Never publish commands with the retain flag. A retained ON on cmnd/.../POWER is redelivered every time the device reconnects, and the relay switches on by itself after every power cut or Wi-Fi drop. If that happens, clear it by publishing an empty retained message to the same topic:
mosquitto_pub -h broker.connectmq.com -u "$MQTT_USER" -P "$MQTT_PASS" \
-t testmqtt/tasmota/cmnd/testmqtt-plug1/POWER -r -nMore on how retention works in MQTT retained messages.
TLS and Home Assistant
TLS depends on the firmware build. Many ESP32 builds include MQTT TLS support, while most ESP8266 builds need a custom compile with USE_MQTT_TLS. On a TLS-capable build, set MqttPort 8883 and SetOption103 1, then check the Tasmota TLS documentation for how your build validates the broker's certificate. On plain builds, keep port 1883 and use a trusted local network.
Home Assistant uses the Tasmota integration, which reads Tasmota's own discovery messages (enabled by default with SetOption19 0). Point Home Assistant's MQTT integration at the same broker and the devices appear automatically. The Home Assistant side is covered in Home Assistant MQTT.
Tasmota's MQTT model is simple once the prefixes click: commands go in on cmnd, answers come out on stat, and telemetry arrives on tele every TelePeriod. Give each device a unique client ID and a FullTopic that keeps your devices in their own namespace, verify command, telemetry and LWT from the online client, and every automation you build on top will behave predictably.
Frequently asked questions
What is the difference between Topic and FullTopic in Tasmota?
Topic is the device's short name, such as kitchen-plug. FullTopic is the template that builds every MQTT topic from it, by default %prefix%/%topic%/, where %prefix% becomes cmnd, stat or tele. Change Topic to rename a device; change FullTopic to move all devices under a common namespace.
How often does Tasmota send telemetry?
Every TelePeriod seconds, 300 by default. Set it with the TelePeriod command, for example TelePeriod 60. Sensor values go to tele/<topic>/SENSOR and device state to tele/<topic>/STATE.
Why does my Tasmota relay switch on by itself after a reboot?
Usually a retained message on a cmnd topic: the broker redelivers it every time the device reconnects. Clear it by publishing an empty retained message to that topic, and do not publish commands with the retain flag.


