How to control Tasmota-Devices via Node-Red and MQTT?

Hi all,

I am running Node-Red on a Raspberry Pi together with my MQTT server.
As a client I am using a Sonoff SP111 Power Plug flashed with Tasmota.

I can easily connect and read data via MQTT from the Device. Unfortunately I am not able to format the query string in the right way to control the device over MQTT.
All I want is to turn the power on and off.

The connection string the device posts its MQTT messages looks like that: tele/SP111_AT61/#
So I tried to send a MQTT command looking like that:


But you can imagine ... nothing happens.
Any idea what I am doing wrong ?


An mqtt messages consists of two parts. First a topic you send the message to and secondly the message. So its not just one string.
Everything left of the last dash, so tele/SP111_AT61/ is your topic and the rest is your command. The command needs to be send as a msg.payload and the topic can be put in two ways. Either directly in the ui of the mqtt out node or via the msg.topic.
I hope this helps.

Do you have an example how the topic / payload has to look like ?

The "tele" topic is a "telegram" topic, only used for receiving data. See the documentation.

To send a command you need to use the topic you specificied in the tasmota config and prepend cmnd and append POWER. Remove tele from the topic. (i have switched all prefix/topics to topic/prefix), cannot give an example because it confuses me with the default :wink:

topic should become: cmnd/SP111_AT61/power
The payload for tasmota can be either; 0/1, true/false, ON/OFF

Still confused why they put the command first in the topic.

1 Like

thanks for your replies - i managed to control the device by using the connection string:


and the value ON or OFF

as suggested.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.