Controll Tasmota-Client via MQTT using Node-Red?

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

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.

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.

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.

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.

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.

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


ScreenShot030
ScreenShot031

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?

(Sorry)

try:
cmnd/PV_01_Front/POWER1

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

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 :smiley: :smiley:

1 Like

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