Help with Sonoff-tasmota node

I have just installed this node:

Sonoff node.

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.

[{"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:

[{"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.

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

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

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.

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.

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.

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.

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.

1 Like

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....

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

1 Like

Thanks. I shall do that.