# Controll Tasmota-Client via MQTT using Node-Red?

**URL:** <https://discourse.nodered.org/t/controll-tasmota-client-via-mqtt-using-node-red/24700>\
**Category:** General\
**Created:** [12 April 2020 12:59 UTC](https://discourse.nodered.org/t/controll-tasmota-client-via-mqtt-using-node-red/24700 "2020-04-12T12:59:01Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gawan](https://avatars.discourse-cdn.com/v4/letter/g/e9c0ed/32.png) [@Gawan](https://discourse.nodered.org/u/Gawan)\
**Post date:** [12 April 2020 12:59 UTC](https://discourse.nodered.org/t/controll-tasmota-client-via-mqtt-using-node-red/24700/1 "2020-04-12T12:59:01Z")

</div>

Hi,

I have a Tasmota 8.2 client with 2 Relays here - connected to a local MQTT Server.  
I can easily access the client via HTTP and it pushes all commands via MQTT to the MQTT Server.  
I get all of these messages in Node-Red and can read and use it for different actions inside NR.

BUT ... I am not able to send the same command I can trigger by pressing the Web-Button on the HTTP-Device (turn ON / turn OFF) via Node-Red.

The MQTT message arrives at Node-Red in this format: topic: stat/PV\_01\_Front/POWER1 msg: ON  
Unfortunately I cannot create the same message using the MQTT node, because all I can set is the TOPIC-parameter, but no message or text or anything.

Has someone already found a way to make this work ?  
BR  
G

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [12 April 2020 13:18 UTC](https://discourse.nodered.org/t/controll-tasmota-client-via-mqtt-using-node-red/24700/2 "2020-04-12T13:18:47Z")

</div>

As described in the Info panel for the MQTT Out node, the value to publish is picked up from msg.payload. So all you need to do is to set msg.topic to the MQTT topic you want to send to and set msg.payload the value you want to send ("ON" for example) and pass it to the MQTT Out node.

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [12 April 2020 14:09 UTC](https://discourse.nodered.org/t/controll-tasmota-client-via-mqtt-using-node-red/24700/3 "2020-04-12T14:09:02Z")

</div>

To (maybe) help you with this:

Get two `inject` nodes.  
Set one to send `on` and one to send `off`.

Connect both of them to an `MQTT OUT` node.

Set that node's topic to `stat/PV_01_Front/POWER1` and deploy that.

Press the OFF _button_ (`inject` node) and see what happens.  
Then try the ON _button_.

I probably should have just started with the `ON`, but.....

If you get that working, you are moving in the right direction.

As stated by @Colin, it is the `topic` which determines the _channel_ in `MQTT` that is used.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [12 April 2020 14:32 UTC](https://discourse.nodered.org/t/controll-tasmota-client-via-mqtt-using-node-red/24700/4 "2020-04-12T14:32:52Z")

</div>

That isn't the right topic to control when using tasmotta, that is the status topic it responds on, you have to use the related command topic to set it.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [12 April 2020 14:34 UTC](https://discourse.nodered.org/t/controll-tasmota-client-via-mqtt-using-node-red/24700/5 "2020-04-12T14:34:39Z")

</div>

To be pedantic, which one should be in these matters, setting the topic doesn't set the mqtt channel, it sets the mqtt topic, oddly enough.

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [12 April 2020 14:35 UTC](https://discourse.nodered.org/t/controll-tasmota-client-via-mqtt-using-node-red/24700/6 "2020-04-12T14:35:47Z")

</div>

Ah, yes, I think I goofed.

It should be `tele` not `stat`.

`tele` sends commands  
`stat` is a status report topic/channel.  
Though after a quick bit of looking at some of mine, it is `cmd`.

So a lot would depend on how the `tasmota` device is configured.

---

<div class="post-metadata">

**Author:** ![dynamicdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dynamicdave/32/96_2.png) [@dynamicdave](https://discourse.nodered.org/u/dynamicdave)\
**Post date:** [12 April 2020 14:38 UTC](https://discourse.nodered.org/t/controll-tasmota-client-via-mqtt-using-node-red/24700/7 "2020-04-12T14:38:25Z")

</div>

Here are some screen-shots of my set-up for controlling a set of SonOff S20 mains switches.

Notice the topic setting is... cmnd/node51/power which matches up with Tasmota's MQTT settings

 ![ScreenShot029](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/9/99c914817ca19039bb5a8aa76b36ac91c43d871e.png)  
 ![ScreenShot030](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/6/1612a94757d826271c758f449814d19f7c6be924.png)  
 ![ScreenShot031](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/a/0a82d78015284aa1129fee0e36fc2684223c1498.png)

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [12 April 2020 14:40 UTC](https://discourse.nodered.org/t/controll-tasmota-client-via-mqtt-using-node-red/24700/8 "2020-04-12T14:40:43Z")

</div>

I think it may be a good idea if @Gawan can confirm he can _talk_ to the device and show a screen shot of the device's MQTT-config page.

That would help with what _channel_/topic to use to talk to it.

Can he control it from the device's `console`?

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [12 April 2020 14:42 UTC](https://discourse.nodered.org/t/controll-tasmota-client-via-mqtt-using-node-red/24700/9 "2020-04-12T14:42:26Z")

</div>

> [@Gawan](#):
>
> stat/PV\_01\_Front/POWER1

(Sorry)

try:  
`cmnd/PV_01_Front/POWER1`

(It is 00:42 local here. I'm off to bed.)  
Good luck.

---

<div class="post-metadata">

**Author:** ![Gawan](https://avatars.discourse-cdn.com/v4/letter/g/e9c0ed/32.png) [@Gawan](https://discourse.nodered.org/u/Gawan)\
**Post date:** [12 April 2020 14:51 UTC](https://discourse.nodered.org/t/controll-tasmota-client-via-mqtt-using-node-red/24700/10 "2020-04-12T14:51:40Z")

</div>

yes, THAT was the solution for me !

I had to switch the topic from **stat/PV\_01\_Front/POWER1** to **cmnd/PC\_01\_Front/POWER1** and it was necessary to inject msg.payload = ON or OFF into the MQTT Node

Now it works fine 😃 😃

---

<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:** [11 June 2020 14:51 UTC](https://discourse.nodered.org/t/controll-tasmota-client-via-mqtt-using-node-red/24700/11 "2020-06-11T14:51:41Z")

</div>

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