tasmota , node red, mqtt and ws2812 leds

605 views
Skip to first unread message

Graham Monks

unread,
Sep 8, 2018, 2:08:01 PM9/8/18
to SonoffUsers
Hi .
Im trying to get the LED's controlled via nqtt on node red, here is what i have done.

Using command line mqtt publish , everything works perfectly eg

root@debiandell:/home/mozart# mosquitto_pub -h 192.168.2.117 -t cmnd/tasled1/color -m 1
root@debiandell:/home/mozart# mosquitto_pub -h 192.168.2.117 -t cmnd/tasled2/color -m 1
root@debiandell:/home/mozart# mosquitto_pub -h 192.168.2.117 -t cmnd/tasled2/color -m 2
root@debiandell:/home/mozart# mosquitto_pub -h 192.168.2.117 -t cmnd/tasled2/color -m 3

Using this i can control the colour , scheme perfectly.

the problem i am having is in node red , i just can't get the command correct.

If i publish cmnd/tasled2/color3 i get no change in colour and this in the log window

19:04:17 MQT: stat/tasled2/RESULT = {"Color3":"000000"}

If i try and publish a scheme i get no scheme change  and this in the command window

cmnd/tasled2/scheme4

19:05:30 MQT: stat/tasled2/RESULT = {"Scheme":1}
19:05:30 MQT: tele/tasled2/WAKEUP = {"Wakeup":"Done"}

I'm pretty sure its how to make the command correct .

Can anyone point me in the right direction

Many thanks


pete c

unread,
Sep 8, 2018, 2:53:25 PM9/8/18
to SonoffUsers

Here test the mosquitto commands in the tasmota console then replicate them in the software.

I have only used Node Red here for my 1-wire OWFS stuff which is just a broadcast through the broker.

I did massage the numbers here with Node Red.  (humidity, temperature and dual counter).

Phil

unread,
Sep 8, 2018, 2:55:37 PM9/8/18
to SonoffUsers
dont you need to preceed the cmnd element  with the full topic addressing your device?

ie tasled1/cmnd/colour -m 1
Message has been deleted

Philip Knowles

unread,
Sep 8, 2018, 6:58:15 PM9/8/18
to Graham Monks, SonoffUsers

Only a guess but it looks like the color3 command is asking for the status (you're getting a stat reply) and you need to add some values after color3


--
You received this message because you are subscribed to the Google Groups "SonoffUsers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonoffusers+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Philip Knowles

unread,
Sep 8, 2018, 7:05:51 PM9/8/18
to Graham Monks, SonoffUsers

From the wiki you also need to have a space between scheme and 4


On Sep 8, 2018 7:08 PM, "Graham Monks" <monks...@gmail.com> wrote:

roguestreak

unread,
Oct 2, 2018, 8:45:35 AM10/2/18
to SonoffUsers
I believe you need a msg.topic of "cmnd/tasled2/color", with a msg.payload of 3.  Change the payload to change the colour.

You can also address colours for multiple individual LEDs all at once by using the "backlog" topic;
var msgNew = {};
msgNew.topic = 'cmnd/tasled2/Backlog';
msgNew.payload='Led1 FF0000; Led2 00FF00; Led3 00FF00; etc...';  // I populate this using a for loop, msgNew.payload += "Led"+i+" "+pixelArr[i];
return msgNew;

Greg from Oz

unread,
Oct 3, 2018, 3:26:36 AM10/3/18
to SonoffUsers

To test the node red do the following.
What this does is creates 2 injection nodes and will inject the values of 1 and a 2 into the mqtt node so you can see if it works.
Copy all the code  between the [ and ] and its in bold into the clipboard.
Then in node red click on the 3 lines on the right top (next to the deploy button)
Then select import clipboard.
Past in the code below.
You might have to change the ip address of the mqtt output node to your ip address of your broker. The example below is running on the local host IP

[{"id":"aba1725d.04ad9","type":"mqtt out","z":"80890e29.c9df","name":"","topic":"cmnd/tasled1/color","qos":"1","retain":"true","broker":"f36a2894.93ba88","x":1950,"y":2020,"wires":[]},{"id":"b1a1978c.42d678","type":"inject","z":"80890e29.c9df","name":"","topic":"","payload":"1","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":1670,"y":2020,"wires":[["aba1725d.04ad9"]]},{"id":"23e8ce61.136272","type":"inject","z":"80890e29.c9df","name":"","topic":"","payload":"2","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":1670,"y":2060,"wires":[["aba1725d.04ad9"]]},{"id":"f36a2894.93ba88","type":"mqtt-broker","z":"","name":"Broker-ip","broker":"192.168.2.117","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"willTopic":"","willQos":"0","willPayload":"","birthTopic":"","birthQos":"1","birthRetain":"true","birthPayload":""}]

Greg from Oz

unread,
Oct 3, 2018, 3:43:11 AM10/3/18
to SonoffUsers
I forgot to say when you click on the injector node make sure you click the LEFT part of it and not the middle bit or it won't inject anything. It got me with that one once.
Reply all
Reply to author
Forward
0 new messages