# Help with Sonoff-tasmota node

**URL:** https://discourse.nodered.org/t/help-with-sonoff-tasmota-node/18218
**Category:** General
**Created:** [21 November 2019 08:00 UTC](https://discourse.nodered.org/t/help-with-sonoff-tasmota-node/18218 "2019-11-21T08:00:17Z")
**Posts on this page:** 10
**Page:** 1

<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: [21 November 2019 08:00 UTC](https://discourse.nodered.org/t/help-with-sonoff-tasmota-node/18218/1 "2019-11-21T08:00:17Z")

</div>

I have just installed this node:

[Sonoff node.](https://github.com/steffenmllr/node-red-contrib-sonoff-tasmota)

I also have a 3 point power board.

With _brute force_ I can control all three points, but this node looks nicer as it gives feedback better than what I can do.

Alas I can only get it working on the first power point. How do I get the second and third ones controlled?

I was trying with the `msg.topic` but that doesn't seem to work.

This is the flow which I use to control all three.

```auto
[{"id":"89f68b43.91be9","type":"mqtt out","z":"9245b569.9f881","name":"","topic":"","qos":"","retain":"","broker":"8a2e80be.f7c928","x":620,"y":1730,"wires":[]},{"id":"5e0ef4a2.9acb64","type":"inject","z":"9245b569.9f881","name":"Relay 1 on","topic":"","payload":"on","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":240,"y":1570,"wires":[["411e6b81.f9b094"]]},{"id":"7c8fe55b.5f0014","type":"mqtt in","z":"9245b569.9f881","name":"","topic":"stat/BAUHN-1/RESULT/#","qos":"2","datatype":"auto","broker":"8a2e80be.f7c928","x":240,"y":1990,"wires":[["cf12eaa8.eeb75"]]},{"id":"cf12eaa8.eeb75","type":"debug","z":"9245b569.9f881","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":470,"y":1990,"wires":[]},{"id":"411e6b81.f9b094","type":"change","z":"9245b569.9f881","name":"Topic","rules":[{"t":"set","p":"topic","pt":"msg","to":"cmnd/BAUHN-1/power1","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":380,"y":1570,"wires":[["89f68b43.91be9"]]},{"id":"95e63238.856a18","type":"inject","z":"9245b569.9f881","name":"Relay 1 off","topic":"","payload":"off","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":240,"y":1530,"wires":[["411e6b81.f9b094"]]},{"id":"4a405b28.1f358c","type":"change","z":"9245b569.9f881","name":"Topic","rules":[{"t":"set","p":"topic","pt":"msg","to":"cmnd/BAUHN-1/power2","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":380,"y":1730,"wires":[["89f68b43.91be9"]]},{"id":"5b52550a.e1cda4","type":"inject","z":"9245b569.9f881","name":"Relay 1 toggle","topic":"","payload":"toggle","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":220,"y":1490,"wires":[["411e6b81.f9b094"]]},{"id":"e93f9b85.3be278","type":"comment","z":"9245b569.9f881","name":"Power point 1","info":"","x":400,"y":1530,"wires":[]},{"id":"31ed400a.bb1cc","type":"comment","z":"9245b569.9f881","name":"Power point 2","info":"","x":400,"y":1690,"wires":[]},{"id":"b0db65c.9540998","type":"inject","z":"9245b569.9f881","name":"Relay 2 on","topic":"","payload":"on","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":240,"y":1730,"wires":[["4a405b28.1f358c"]]},{"id":"27a89635.8ac80a","type":"inject","z":"9245b569.9f881","name":"Relay 2 off","topic":"","payload":"off","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":240,"y":1690,"wires":[["4a405b28.1f358c"]]},{"id":"4c0f966a.29b3d","type":"inject","z":"9245b569.9f881","name":"Relay 2 toggle","topic":"","payload":"toggle","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":220,"y":1650,"wires":[["4a405b28.1f358c"]]},{"id":"7651561e.93b0e","type":"change","z":"9245b569.9f881","name":"Topic","rules":[{"t":"set","p":"topic","pt":"msg","to":"cmnd/BAUHN-1/power3","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":380,"y":1890,"wires":[["89f68b43.91be9"]]},{"id":"f810191a.c6888","type":"comment","z":"9245b569.9f881","name":"Power point 3","info":"","x":400,"y":1850,"wires":[]},{"id":"7610c78f.a7dca8","type":"inject","z":"9245b569.9f881","name":"Relay 3 on","topic":"","payload":"on","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":240,"y":1890,"wires":[["7651561e.93b0e"]]},{"id":"bb3c97b.fdfde68","type":"inject","z":"9245b569.9f881","name":"Relay 3 off","topic":"","payload":"off","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":240,"y":1850,"wires":[["7651561e.93b0e"]]},{"id":"bd7ed733.28ee18","type":"inject","z":"9245b569.9f881","name":"Relay 3 toggle","topic":"","payload":"toggle","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":220,"y":1810,"wires":[["7651561e.93b0e"]]},{"id":"a8832b05.3c548","type":"comment","z":"9245b569.9f881","name":"","info":"","x":440,"y":1480,"wires":[]},{"id":"fc2b0448.9f6db","type":"inject","z":"9245b569.9f881","name":"Relay 1 status","topic":"","payload":"status","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":230,"y":1610,"wires":[["411e6b81.f9b094"]]},{"id":"4044e30f.21fe14","type":"inject","z":"9245b569.9f881","name":"Relay 2 status","topic":"","payload":"status","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":230,"y":1770,"wires":[["4a405b28.1f358c"]]},{"id":"82462faa.bef36","type":"inject","z":"9245b569.9f881","name":"Relay 3 status","topic":"","payload":"status","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":230,"y":1930,"wires":[["7651561e.93b0e"]]},{"id":"8a2e80be.f7c928","type":"mqtt-broker","z":"","name":"MQTT host","broker":"192.168.0.99","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"ARDUINO_STATUS","birthQos":"2","birthPayload":"connected","willTopic":"ARDUINO_STATUS","willQos":"0","willPayload":"disconnected"}]

```

Given that works, I wrote this:

```auto
[{"id":"7c474bc5.7fe634","type":"Sonoff device","z":"9245b569.9f881","mode":"0","broker":"8a2e80be.f7c928","device":"BAUHN-1","name":"","onValue":"ON","offValue":"OFF","cmdPrefix":"cmnd","statPrefix":"stat","telePrefix":"tele","x":360,"y":2860,"wires":[["ed31c6ad.8176f8"]]},{"id":"c3382a43.b13c38","type":"inject","z":"9245b569.9f881","name":"On","topic":"","payload":"true","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":200,"y":2840,"wires":[["7c474bc5.7fe634"]]},{"id":"92ba4105.786ec8","type":"inject","z":"9245b569.9f881","name":"Off","topic":"","payload":"false","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":200,"y":2890,"wires":[["7c474bc5.7fe634"]]},{"id":"ddf086d3.c5de4","type":"Sonoff device","z":"9245b569.9f881","mode":"0","broker":"8a2e80be.f7c928","device":"BAUHN-1","name":"","onValue":"ON","offValue":"OFF","cmdPrefix":"cmnd","statPrefix":"stat","telePrefix":"tele","x":360,"y":2960,"wires":[["7d6012a1.bf44d4"]]},{"id":"8d846d95.00538","type":"inject","z":"9245b569.9f881","name":"On","topic":"power2","payload":"true","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":200,"y":2940,"wires":[["ddf086d3.c5de4"]]},{"id":"2133f537.f9a58a","type":"inject","z":"9245b569.9f881","name":"Off","topic":"power2","payload":"false","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":200,"y":2990,"wires":[["ddf086d3.c5de4"]]},{"id":"ed31c6ad.8176f8","type":"debug","z":"9245b569.9f881","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":520,"y":2860,"wires":[]},{"id":"7d6012a1.bf44d4","type":"debug","z":"9245b569.9f881","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":520,"y":2960,"wires":[]},{"id":"8a2e80be.f7c928","type":"mqtt-broker","z":"","name":"MQTT host","broker":"192.168.0.99","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"ARDUINO_STATUS","birthQos":"2","birthPayload":"connected","willTopic":"ARDUINO_STATUS","willQos":"0","willPayload":"disconnected"}]

```

But it only controls output #1.

---

<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: [21 November 2019 08:51 UTC](https://discourse.nodered.org/t/help-with-sonoff-tasmota-node/18218/2 "2019-11-21T08:51:44Z")

</div>

Is it not easier to just use mqtt for controlling devices running on tasmota ?

`{topic:'devicename/cmnd/POWER',payload:'ON'}` or `payload:1`

---

<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: [21 November 2019 08:53 UTC](https://discourse.nodered.org/t/help-with-sonoff-tasmota-node/18218/3 "2019-11-21T08:53:51Z")

</div>

Yes, that is what I did in my flow.

Just all that "fluffing around" - though it worked - I saw the node and was curious on how to use it.

I guess I am lucky I am not a cat.

---

<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: [21 November 2019 09:01 UTC](https://discourse.nodered.org/t/help-with-sonoff-tasmota-node/18218/4 "2019-11-21T09:01:06Z")

</div>

There are so many ways to do this. I use a lot of tasmota devices, I am thinking to create 1 mqtt node that receives everything and parse each device separately (in a subflow maybe) to clean up all my flows. There are "better" practices, but no "best" practice I think. I am still searching for the most efficient way dealing with mqtt.

---

<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: [21 November 2019 09:06 UTC](https://discourse.nodered.org/t/help-with-sonoff-tasmota-node/18218/5 "2019-11-21T09:06:02Z")

</div>

I kind of like how the node shows the state.

That is neat. Though granted not useful/able for dashboard use. However, it is nice.

I am not understanding how the node mentioned is supposed to be used if there is more than 1 output.

---

<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: [21 November 2019 09:17 UTC](https://discourse.nodered.org/t/help-with-sonoff-tasmota-node/18218/6 "2019-11-21T09:17:35Z")

</div>

I think it only supports 1 relay (looking at the code).

The state you could create with a function node. (it is more convoluted than the sonoff node ofcourse).  
With the `status 0` command you can send all the device status information to mqtt (default 300 seconds, you can change that with the `TelePeriod x` where x is the number of seconds per update.)

Lots of info coming from it.

With mqtt I use `device/#` to capture everything and handle from there.

---

<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: [21 November 2019 09:22 UTC](https://discourse.nodered.org/t/help-with-sonoff-tasmota-node/18218/7 "2019-11-21T09:22:20Z")

</div>

Thanks.

As said, my flow does that. I was just looking at this (other) node.

I know I should probably ask the person who wrote it, but. . . . . . hey, I like to try alternatives.

---

<div class="post-metadata">

### Author: ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)
#### Post date: [21 November 2019 11:02 UTC](https://discourse.nodered.org/t/help-with-sonoff-tasmota-node/18218/8 "2019-11-21T11:02:59Z")

</div>

Andrew, you might want to make it a habit to check on when nodes you use were last updated before spending too much time with them....

---

<div class="post-metadata">

### Author: ![craigcurtin](https://avatars.discourse-cdn.com/v4/letter/c/94ad74/32.png) [@craigcurtin](https://discourse.nodered.org/u/craigcurtin)
#### Post date: [25 November 2019 04:23 UTC](https://discourse.nodered.org/t/help-with-sonoff-tasmota-node/18218/9 "2019-11-25T04:23:12Z")

</div>

Based on the code this was written for the original Sonoff (and Clones) that only have a single relay on board.

By you saying you have a 3 port power board - one assumes that you have a 3rd party device (as Sonoff do not make a 3 port unit) that is sonoff compatible.

Contact the author and see if he is interested in upgrading the node to support additional ports

Craig

---

<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: [25 November 2019 19:49 UTC](https://discourse.nodered.org/t/help-with-sonoff-tasmota-node/18218/10 "2019-11-25T19:49:14Z")

</div>

Thanks. I shall do that.
