Unable to send cmnd/nodemcu/power2 to relay

Hi All,

very beginner trying to control 8ch relay with nodemcu (running tasmota) relay 1 works but not relay2 or relay3 etc
mqtt broker/server setup - all ok
able to control 2 sonoff devices (running tasmota) - all ok

i guess what precisely i'm unable to do is send "cmnd/nodemcu/power2" using nodered. :frowning:

i read couple threads/guides and feel most people figure it out easily but not thick-heads like me. (i wish i could figure it out)

here's my flow today from node-red that i'm seeking help with. it would be a big favor if someone can tell me what should i do to fix it. all i should send is cmnd/nodemcu/power2 with payload ON/OFF. Attaching 2 pics hoping someone can help me out.

[{"id":"cc97bdff.914f9","type":"ui_switch","z":"f087d4d8.c328d8","name":"","label":"TWO","tooltip":"","group":"bd562bdd.0a98e","order":0,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"","style":"","onvalue":"ON","onvalueType":"str","onicon":"","oncolor":"","offvalue":"OFF","offvalueType":"str","officon":"","offcolor":"","x":190,"y":240,"wires":[["b16c9847.2625f"]]},{"id":"bd562bdd.0a98e","type":"ui_group","z":"","name":"8Relay","tab":"6e3d9ae8.7efe4c","disp":true,"width":"6","collapse":false},{"id":"6e3d9ae8.7efe4c","type":"ui_tab","z":"","name":"8Relay","icon":"dashboard","disabled":false,"hidden":false}]

not familiar with much programming at this stage. sorry

Your flow contains only a switch node
and your inages are too small to read. Please do a copy/paste of the logs

When pasting in logs use the </> button so that the forum does not mess with the formatting.

You are sending to the wrong topic. It must be cmnd/nodemcu/power2 and not power
Look at you log.
Capture

Yes I saw that. But couldn’t modify the message on nodered

I’m afraid I tried to paste the picture for the logs taken and topic mentioned on tasmota webpage but this forum limited me to paste only 2 attachments.
I’ll paste in text fresh logs

Despite what i do to modify It to power2 It goes as power1

Paul,

sharing below the fresh logs
<
Sep 8 22:14:23 192.168.1.138 nodemcu ESP-WIF: Checking connection...
Sep 8 22:14:23 192.168.1.138 nodemcu ESP-WIF: Connected
Sep 8 22:14:28 192.168.1.138 nodemcu ESP-SRC: MQTT
Sep 8 22:14:28 192.168.1.138 nodemcu ESP-RSL: Received Topic cmnd/nodemcu/power, Data Size 2, Data ON
Sep 8 22:14:28 192.168.1.138 nodemcu ESP-RSL: Group 0, Index 1, Command POWER, Data ON
Sep 8 22:14:28 192.168.1.138 nodemcu ESP-MQT: stat/nodemcu/RESULT = {"POWER1":"ON"}
Sep 8 22:14:28 192.168.1.138 nodemcu ESP-MQT: stat/nodemcu/POWER1 = ON
Sep 8 22:14:29 192.168.1.138 nodemcu ESP-CFG: Saved to flash at F5, Count 240, Bytes 3584
Sep 8 22:14:29 192.168.1.138 nodemcu ESP-SRC: MQTT
Sep 8 22:14:29 192.168.1.138 nodemcu ESP-RSL: Received Topic cmnd/nodemcu/power, Data Size 3, Data OFF
Sep 8 22:14:29 192.168.1.138 nodemcu ESP-RSL: Group 0, Index 1, Command POWER, Data OFF
Sep 8 22:14:29 192.168.1.138 nodemcu ESP-MQT: stat/nodemcu/RESULT = {"POWER1":"OFF"}
Sep 8 22:14:29 192.168.1.138 nodemcu ESP-MQT: stat/nodemcu/POWER1 = OFF
Sep 8 22:14:30 192.168.1.138 nodemcu ESP-CFG: Saved to flash at F4, Count 241, Bytes 3584
Sep 8 22:14:30 192.168.1.138 nodemcu ESP-SRC: MQTT
Sep 8 22:14:30 192.168.1.138 nodemcu ESP-RSL: Received Topic cmnd/nodemcu/power, Data Size 2, Data ON
Sep 8 22:14:30 192.168.1.138 nodemcu ESP-RSL: Group 0, Index 1, Command POWER, Data ON
Sep 8 22:14:30 192.168.1.138 nodemcu ESP-MQT: stat/nodemcu/RESULT = {"POWER1":"ON"}
Sep 8 22:14:30 192.168.1.138 nodemcu ESP-MQT: stat/nodemcu/POWER1 = ON
Sep 8 22:14:31 192.168.1.138 nodemcu ESP-CFG: Saved to flash at FB, Count 242, Bytes 3584
Sep 8 22:14:31 192.168.1.138 nodemcu ESP-SRC: MQTT
Sep 8 22:14:31 192.168.1.138 nodemcu ESP-RSL: Received Topic cmnd/nodemcu/power, Data Size 3, Data OFF
Sep 8 22:14:31 192.168.1.138 nodemcu ESP-RSL: Group 0, Index 1, Command POWER, Data OFF
Sep 8 22:14:31 192.168.1.138 nodemcu ESP-MQT: stat/nodemcu/RESULT = {"POWER1":"OFF"}
Sep 8 22:14:31 192.168.1.138 nodemcu ESP-MQT: stat/nodemcu/POWER1 = OFF
Sep 8 22:14:32 192.168.1.138 nodemcu ESP-CFG: Saved to flash at FA, Count 243, Bytes 3584
Sep 8 22:14:43 192.168.1.138 nodemcu ESP-WIF: Checking connection...
Sep 8 22:14:43 192.168.1.138 nodemcu ESP-WIF: Connected
^C
/>

Below is my current flow, no matter what switch i press it sends cmnd/nodemcu/power always...and turns on relay 1 :frowning:

[{"id":"f087d4d8.c328d8","type":"tab","label":"8RELAY-FLOW","disabled":false,"info":""},{"id":"883b65c0.5679c","type":"ui_switch","z":"f087d4d8.c328d8","name":"","label":"ONE","tooltip":"","group":"bd562bdd.0a98e","order":0,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"","style":"","onvalue":"ON","onvalueType":"str","onicon":"","oncolor":"","offvalue":"OFF","offvalueType":"str","officon":"","offcolor":"","x":180,"y":140,"wires":[["9df69021.59b658"]]},{"id":"9df69021.59b658","type":"Sonoff device","z":"f087d4d8.c328d8","mode":"0","broker":"b650332e.d12ee","device":"nodemcu","name":"","onValue":"ON","offValue":"OFF","cmdPrefix":"cmnd","statPrefix":"stat","telePrefix":"tele","x":350,"y":140,"wires":[]},{"id":"cc97bdff.914f9","type":"ui_switch","z":"f087d4d8.c328d8","name":"","label":"TWO","tooltip":"","group":"bd562bdd.0a98e","order":0,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"","style":"","onvalue":"ON","onvalueType":"str","onicon":"","oncolor":"","offvalue":"OFF","offvalueType":"str","officon":"","offcolor":"","x":190,"y":240,"wires":[["b16c9847.2625f"]]},{"id":"b16c9847.2625f","type":"Sonoff device","z":"f087d4d8.c328d8","mode":"0","broker":"b650332e.d12ee","device":"nodemcu","name":"","onValue":"ON","offValue":"OFF","cmdPrefix":"cmnd","statPrefix":"stat","telePrefix":"tele","x":360,"y":240,"wires":[]},{"id":"bd562bdd.0a98e","type":"ui_group","z":"","name":"8Relay","tab":"6e3d9ae8.7efe4c","disp":true,"width":"6","collapse":false},{"id":"b650332e.d12ee","type":"mqtt-broker","z":"","name":"pi","broker":"192.168.1.9","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"6e3d9ae8.7efe4c","type":"ui_tab","z":"","name":"8Relay","icon":"dashboard","disabled":false,"hidden":false}]

Evert,

is there a way to modify the command sent to nodemcu

When pasting a flow here you have to use the </> button to stop the forum from messing with the format. Otherwise it is not importable.

Colin,

i think i tried. i'm sorry if it messed up still

pasted again using </>

[{"id":"f087d4d8.c328d8","type":"tab","label":"8RELAY-FLOW","disabled":false,"info":""},{"id":"883b65c0.5679c","type":"ui_switch","z":"f087d4d8.c328d8","name":"","label":"ONE","tooltip":"","group":"bd562bdd.0a98e","order":0,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"","style":"","onvalue":"ON","onvalueType":"str","onicon":"","oncolor":"","offvalue":"OFF","offvalueType":"str","officon":"","offcolor":"","x":180,"y":140,"wires":[["9df69021.59b658","1f5c550c.12bcf3"]]},{"id":"9df69021.59b658","type":"Sonoff device","z":"f087d4d8.c328d8","mode":"0","broker":"b650332e.d12ee","device":"nodemcu","name":"","onValue":"ON","offValue":"OFF","cmdPrefix":"cmnd","statPrefix":"stat","telePrefix":"tele","x":460,"y":180,"wires":[["1f5c550c.12bcf3"]]},{"id":"cc97bdff.914f9","type":"ui_switch","z":"f087d4d8.c328d8","name":"","label":"TWO","tooltip":"","group":"bd562bdd.0a98e","order":0,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"","style":"","onvalue":"ON","onvalueType":"str","onicon":"","oncolor":"","offvalue":"OFF","offvalueType":"str","officon":"","offcolor":"","x":190,"y":240,"wires":[["b16c9847.2625f","1f5c550c.12bcf3"]]},{"id":"b16c9847.2625f","type":"Sonoff device","z":"f087d4d8.c328d8","mode":"0","broker":"b650332e.d12ee","device":"nodemcu","name":"","onValue":"ON","offValue":"OFF","cmdPrefix":"cmnd","statPrefix":"stat","telePrefix":"tele","x":460,"y":240,"wires":[["1f5c550c.12bcf3"]]},{"id":"1f5c550c.12bcf3","type":"debug","z":"f087d4d8.c328d8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":670,"y":60,"wires":[]},{"id":"bd562bdd.0a98e","type":"ui_group","z":"","name":"8Relay","tab":"6e3d9ae8.7efe4c","disp":true,"width":"6","collapse":false},{"id":"b650332e.d12ee","type":"mqtt-broker","z":"","name":"pi","broker":"192.168.1.9","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"6e3d9ae8.7efe4c","type":"ui_tab","z":"","name":"8Relay","icon":"dashboard","disabled":false,"hidden":false}]

is there an example/sample that you can paste where you've 2 or more relays with topics/commands modified.

i tried to understand the modification of msg.payload which may do the trick using function node...but i couldn't get it

This works fine for me to switch POWER2

[{"id":"80d0cb32.955df8","type":"mqtt out","z":"c4d9fae1.52009","name":"Set DualTvMeubel-2","topic":"/vm/cmnd/DualTvMeubel/power2","qos":"0","retain":"","broker":"2db287b.addf978","x":1160,"y":2440,"wires":[]},{"id":"b75e27bb.799f1","type":"ui_switch","z":"c4d9fae1.52009","name":"","label":"MediaStreamer","tooltip":"","group":"fab7d57b.deb688","order":2,"width":0,"height":0,"passthru":false,"decouple":"true","topic":"","style":"","onvalue":"ON","onvalueType":"str","onicon":"icofont-power","oncolor":"light-green","offvalue":"OFF","offvalueType":"str","officon":"icofont-power","offcolor":"black","x":640,"y":2440,"wires":[["80d0cb32.955df8"]]},{"id":"8dddbe9c.f700b8","type":"mqtt in","z":"c4d9fae1.52009","name":"DualTvMeubel-2","topic":"/vm/stat/DualTvMeubel/POWER2","qos":"0","broker":"2db287b.addf978","x":280,"y":2440,"wires":[["b75e27bb.799f1","584f8c65.069cb4"]]},{"id":"2db287b.addf978","type":"mqtt-broker","z":"","name":"Mosquitto1","broker":"192.168.1.127","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"/vm/mqtt/birth","birthQos":"0","birthPayload":"birth","closeTopic":"","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"fab7d57b.deb688","type":"ui_group","z":"","name":"Begane Grond","tab":"209f7863.40989","order":2,"disp":true,"width":"6"},{"id":"209f7863.40989","type":"ui_tab","z":"","name":"Verlichting","icon":"lightbulb_outline","order":1,"disabled":false,"hidden":false}]
1 Like

At the top of the edit box you type into on the forum there is a button showing </>. That is the button to use. I will edit your previous post to fix it for you.

YAY !!!!!!!!! This one did the trick :slight_smile:

i wish you could teach me. :smile:

i guess what i was doing was too much wrong.
1- i was using sonoff/sonoff-advanced (nodes) instead of mqtt in/out
2- Also i wasn't using set topic for example..was willing to find some how-to
3- on top of everything i was confused when i started exploring similar issues. i saw people trying to use maybe function node for modifying the msg.payload and so advanced stuff that i left the grip on the ground.

here's my current flow working perfectly (to see the switch icon, i had to choose default icon.)

[{"id":"6300df8d.87cc4","type":"ui_switch","z":"f087d4d8.c328d8","name":"","label":"R4","tooltip":"","group":"bd562bdd.0a98e","order":2,"width":0,"height":0,"passthru":false,"decouple":"true","topic":"","style":"","onvalue":"ON","onvalueType":"str","onicon":"","oncolor":"","offvalue":"OFF","offvalueType":"str","officon":"","offcolor":"","x":270,"y":540,"wires":[["be2a1503.87f508"]]},{"id":"bd562bdd.0a98e","type":"ui_group","z":"","name":"8Relay","tab":"6e3d9ae8.7efe4c","disp":true,"width":"6","collapse":false},{"id":"6e3d9ae8.7efe4c","type":"ui_tab","z":"","name":"8Relay","icon":"dashboard","disabled":false,"hidden":false}]

Using sonoff with tasmota was easy for me. along with nodemcu running tasmota i got stumbled literally. This example really got me started again.

i am thankful to be a part of this forum.

1 Like

Again you have not used the </> button at the top of the forum edit window. Did you see my last post?

terribly sorry Colin.

now i see what you mean. didn't know it. couldn't find it before.

will take care of it. appreciate your guidance.

No problem, most things are obvious once you know how :slight_smile:

1 Like

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