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

**URL:** <https://discourse.nodered.org/t/how-to-control-tasmota-devices-via-node-red-and-mqtt/26110>\
**Category:** General\
**Created:** [5 May 2020 04:50 UTC](https://discourse.nodered.org/t/how-to-control-tasmota-devices-via-node-red-and-mqtt/26110 "2020-05-05T04:50:12Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Birdy](https://avatars.discourse-cdn.com/v4/letter/b/85e7bf/32.png) [@Birdy](https://discourse.nodered.org/u/Birdy)\
**Post date:** [5 May 2020 04:50 UTC](https://discourse.nodered.org/t/how-to-control-tasmota-devices-via-node-red-and-mqtt/26110/1 "2020-05-05T04:50:12Z")

</div>

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:

tele/SP111\_AT61/cmnd/Power  
ON

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

BR  
Birdy

---

<div class="post-metadata">

**Author:** ![JGKK](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jgkk/32/18515_2.png) [@JGKK](https://discourse.nodered.org/u/JGKK)\
**Post date:** [5 May 2020 05:38 UTC](https://discourse.nodered.org/t/how-to-control-tasmota-devices-via-node-red-and-mqtt/26110/2 "2020-05-05T05:38:32Z")

</div>

Hello,  
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.  
Johannes

---

<div class="post-metadata">

**Author:** ![Birdy](https://avatars.discourse-cdn.com/v4/letter/b/85e7bf/32.png) [@Birdy](https://discourse.nodered.org/u/Birdy)\
**Post date:** [5 May 2020 06:06 UTC](https://discourse.nodered.org/t/how-to-control-tasmota-devices-via-node-red-and-mqtt/26110/3 "2020-05-05T06:06:25Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [5 May 2020 06:15 UTC](https://discourse.nodered.org/t/how-to-control-tasmota-devices-via-node-red-and-mqtt/26110/4 "2020-05-05T06:15:30Z")

</div>

The "tele" topic is a "telegram" topic, only used for receiving data. See [the documentation](https://tasmota.github.io/docs/MQTT/).

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 😉

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.

---

<div class="post-metadata">

**Author:** ![Birdy](https://avatars.discourse-cdn.com/v4/letter/b/85e7bf/32.png) [@Birdy](https://discourse.nodered.org/u/Birdy)\
**Post date:** [6 May 2020 04:41 UTC](https://discourse.nodered.org/t/how-to-control-tasmota-devices-via-node-red-and-mqtt/26110/5 "2020-05-06T04:41:48Z")

</div>

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

cmnd/SP111\_AT61/Power

and the value ON or OFF

as suggested.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [20 May 2020 04:42 UTC](https://discourse.nodered.org/t/how-to-control-tasmota-devices-via-node-red-and-mqtt/26110/6 "2020-05-20T04:42:01Z")

</div>

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