Hi all,
I am using MQTT a lot to get status information from my Tasmota Devices into Node-Red for further usage.
Next I would like to change the status of one of these devices using MQTT - but sending seems to be much more complicated than reading.
The tasmota website (MQTT - Tasmota) tells me to do it like that:
cmnd/tasmota/POWER on
adapted to my setup it would be: cmnd/sonoff/s095/POWER on
But if I send this to my MQTT device via Node-Red nothing happens:
So I assume something in this setup is wrong. Maybe the "cmnd" command ?
I am not sure and did not succeed after several different tests.
So you do know the topic that the device uses to send an MQTT message.
For regular telemetry it will begin with "tele/"
Does your working MQTT In node have topic set to "tele/sonoff/095/#" or to "tele/sonoff095/#"?
Have you tried injecting msg.topic = "cmnd/sonoff/095/power" and msg.payload = "on"?
What about msg.topic = "cmnd/sonoff095/power"?
Don't know if this would help, but you can use programs such as MQTT Explorer to log into your MQTT server and see all of the messages going to and from it. It may not immediately help fix any problem, but, with a little experience, it does allow you to see what is going on and make better 'guesses' as to what needs to be done
Normal Tasmota commands over MQTT are (from Tasmota site;
## Commands over MQTT[~](https://tasmota.github.io/docs/MQTT/#commands-over-mqtt)
To send commands and view responses you'll need an [MQTT client](http://www.hivemq.com/blog/seven-best-mqtt-client-tools).
Commands over MQTT are issued to Tasmota by using topic `cmnd/%topic%/<command>` and payload `<parameter>`. If there is no `<parameter>` (an empty MQTT message/payload), a query is sent for current status of the `<command>`.
Tip
If you are using *mosquitto_pub*, you can issue an empty payload using the `-n` command line option. If your MQTT client cannot issue an empty payload, you can use the single character `?` instead.
### Command flow[~](https://tasmota.github.io/docs/MQTT/#command-flow)
The following example will go in depth on what happens when you send an MQTT command.
A device was flashed and configured with the **FullTopic** as default `%prefix%/%topic%/` and the **Topic** set to `tasmota_switch`. We want to see the current status of the switch and change it.
By looking at the commands table we can learn about the [`POWER`](https://tasmota.github.io/docs/Commands/#power) command and options associated with it.
#### Ask the device for status[~](https://tasmota.github.io/docs/MQTT/#ask-the-device-for-status)
cmnd/tasmota_switch/Power ← // an empty message/payload sends a status query
↳ stat/tasmota_switch/RESULT → {"POWER":"OFF"}
↳ stat/tasmota_switch/POWER → OFF
We can see that the switch (device's relay) is turned off.
#### Send a command to toggle the relay[~](https://tasmota.github.io/docs/MQTT/#send-a-command-to-toggle-the-relay)
cmnd/tasmota_switch/Power TOGGLE
↳ // Power for relay 1 is toggled
↳ stat/tasmota_switch/RESULT → {"POWER":"ON"}
↳ stat/tasmota_switch/POWER → ON
We've sent the toggle command and received confirmation that the switch is turned on.
Set teleperiod to (say 60) so it is not updating too fast and then watch the screen - you will see the Tele messages it is sending out - both state and status and when you send a command you can see it come in and whether Tasmota likes it or not