A bit of MQTT help please.

142 views
Skip to first unread message

shykitten55

unread,
Sep 19, 2017, 4:03:37 AM9/19/17
to Node-RED
I am sending data (stuff) from a pi to another via MQTT.

3 machines send their temperature to one of them and it displays the temperatures.

The "problem" is if one is turned off, the graph isn't indicating that.

There is an option to show stuff if no data is received. but for some reason when the other pi is turned off the central one isn't seeing it as turned off.
MQTT is set to QOS to 2.  It also has birth and death certificates.


Zenofmud

unread,
Sep 19, 2017, 5:37:06 AM9/19/17
to node...@googlegroups.com
Could you explain this and define the pi's as 'A', 'B' and 'C'. I'm not sure if you have an issue when one machine or two are off when you say '...if one is turned off...' then say '...when the other pi is turned off...'.

I know it is clear to you, but it's not clear to this reader (grin)

Sent from my iPad
--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+u...@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.
To view this discussion on the web, visit https://groups.google.com/d/msgid/node-red/69cfb1ee-d7fd-4407-8be6-a756776b0ba8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Cat

unread,
Sep 19, 2017, 5:09:46 PM9/19/17
to node...@googlegroups.com
Yeah, ok, sorry.  My bad.

Three Pis.  A, B and C.
All three are running MQTT and all three are running Node-Red.  Also all three have Node-Red web pages to help me with what is going on.

A is the main broker for MQTT.
It is on 24/7.
B is this machine and is connected directly to the net.
C is a music playing Pi and is only on when I want to listen to music.

Just now A and B are on.

Yet, on A's web page, I am seeing temperature on C's gauge.
I hope the two attachments will help clear things up.

To help with names:
A = TimePi
B = PiFace
C = MusicPi

Only A and B are on at this time, and so I would expect C to show up as "Not connected" as that is the option I  put in the graph.

It would be good if this could be reflected on the gauge too.
So if the Pi is off, the gauge is "dead".




On 19 September 2017 at 19:37, Zenofmud <zeno...@zenofmud.org> wrote:
Could you explain this and define the pi's as 'A', 'B' and 'C'. I'm not sure if you have an issue when one machine or two are off when you say '...if one is turned off...' then say '...when the other pi is turned off...'.

I know it is clear to you, but it's not clear to this reader (grin)

Sent from my iPad

On Sep 19, 2017, at 4:03 AM, shykitten55 <fuzzywu...@gmail.com> wrote:

I am sending data (stuff) from a pi to another via MQTT.

3 machines send their temperature to one of them and it displays the temperatures.

The "problem" is if one is turned off, the graph isn't indicating that.

There is an option to show stuff if no data is received. but for some reason when the other pi is turned off the central one isn't seeing it as turned off.
MQTT is set to QOS to 2.  It also has birth and death certificates.


--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+unsubscribe@googlegroups.com.

To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.
To view this discussion on the web, visit https://groups.google.com/d/msgid/node-red/69cfb1ee-d7fd-4407-8be6-a756776b0ba8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to a topic in the Google Groups "Node-RED" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/node-red/K6P6-4PGNyk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to node-red+unsubscribe@googlegroups.com.

To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.
Main Telemetry page.png
Pi B's page.png
Bargraph settings.png

Mark Setrem

unread,
Sep 19, 2017, 5:53:42 PM9/19/17
to Node-RED
The graph/dial can only display the data that is sent to it (and then only if it is in the right format)

What do you see if you turn the debug on that is attached to the mqtt-in for that machine. If you could capture and post here the message that is sent when the machine disconnects and reconnect we should be able to help you.

Dave C-J

unread,
Sep 19, 2017, 5:54:04 PM9/19/17
to node...@googlegroups.com

​the NoData field is only shown before any data arrives... as soon as data arrive the graph is drawn and those values will remain.
If you want to do something when one of the nodes disconnects then you should​ use something like the LWT (Last Will and Testament) message form the MQTT broker to inform of the missing node and use that to create a suitable message - eg to set the gauge to 0. or to wipe out any graph (but hen you will lose history - sending and empty array  []  will wipe it out).
Or finally you could set the property msg.enabled to false and that will grey out the control.

Cat

unread,
Sep 20, 2017, 1:41:38 AM9/20/17
to node...@googlegroups.com
Well, there seems to be no data arriving.
Looking at the atachment you can see that PiFace (just powered on) has a display of the REALTIME temperature.
MusicPi - which is not powered on - has a huge hole in the graph time - shown in red.
It seems to me that the gauge shows the last thing given to it and the graph just shows nothing and doesn't show the "no connection" message.

There is also the other problem that the temperature measurement on TimePI has also stopped at about 01:00 today but that is a whole other problem.


On 20 September 2017 at 07:53, Mark Setrem <mse...@gmail.com> wrote:
The graph/dial can only display the data that is sent to it (and then only if it is in the right format)

What do you see if you turn the debug on that is attached to the mqtt-in for that machine.  If you could capture and post here the message that is sent when the machine disconnects and reconnect we should be able to help you.
--
http://nodered.org

Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to a topic in the Google Groups "Node-RED" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/node-red/K6P6-4PGNyk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to node-red+unsubscribe@googlegroups.com.
To post to this group, send an email to node...@googlegroups.com.
New_Boot_Picture_of_Graphs.png

Mark Setrem

unread,
Sep 20, 2017, 3:03:05 AM9/20/17
to Node-RED

Yes, a gauge will display the last value it was sent until you send it something different.   

So if you want the gauge to reset to zero, you either need to use the the last will and testament functionality in MQTT ( as Dave suggested) or reset
the graph to zero after a period with no message.


Cat

unread,
Sep 20, 2017, 3:22:10 AM9/20/17
to node...@googlegroups.com
Thanks.

At least I am going in the right direction.

This is an exert from the flow which encompasses the problem:

I'm guessing I just need to tweek the MQTT settings, and I shuld look more into that myself, but a bit of help would be appreciated.



[{"id":"8d28ad77.27ca28","type":"ui_gauge","z":"3a962246.4b4b06","name":"","group":"310ebb9d.061b4c","order":1,"width":"3","height":"2","gtype":"gage","title":"Temp","label":"Celcious","format":"{{value}}","min":"10","max":"80","colors":["#00b500","#e6e600","#ca3838"],"seg1":"50","seg2":"60","x":257.5,"y":188.44445037841797,"wires":[]},{"id":"3ea3613f.62815e","type":"mqtt in","z":"3a962246.4b4b06","name":"TimePi","topic":"TEMP/TimePi","qos":"2","broker":"683b90c5.4cf61","x":55,"y":188.44445037841797,"wires":[["8d28ad77.27ca28","c8d94a8d.7d11c8","6abeadab.a49064"]]},{"id":"c8d94a8d.7d11c8","type":"ui_chart","z":"3a962246.4b4b06","name":"","group":"310ebb9d.061b4c","order":3,"width":"6","height":"4","label":"History","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"No Connection","dot":false,"ymin":"","ymax":"","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"x":268,"y":221,"wires":[[],[]]},{"id":"6abeadab.a49064","type":"debug","z":"3a962246.4b4b06","name":"VALUE","active":false,"console":"false","complete":"payload","x":258,"y":254,"wires":[]},{"id":"310ebb9d.061b4c","type":"ui_group","z":"","name":"TimePi","tab":"d29ccfb1.b5e108","order":1,"disp":true,"width":"6"},{"id":"683b90c5.4cf61","type":"mqtt-broker","z":"","broker":"192.168.0.99","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"willTopic":"EOM","willQos":"2","willPayload":"","birthTopic":"SOM","birthQos":"2","birthPayload":""},{"id":"d29ccfb1.b5e108","type":"ui_tab","z":"","name":"TELEMETRY","icon":"dashboard","order":1}]



--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to a topic in the Google Groups "Node-RED" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/node-red/K6P6-4PGNyk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to node-red+unsubscribe@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.

Zenofmud

unread,
Sep 20, 2017, 5:03:16 AM9/20/17
to node...@googlegroups.com
Yes you should so look into it more yourself and here are two things you can do to help you learn about MQTT

First - to follow the advice that has already been offer, go look at the MQTT Output node, click the pencil icon next to the server and look at the options.

Second go read this blog series: http://www.hivemq.com/mqtt-essentials/ If you want to jump in the deep end, here is the LWOT section: http://www.hivemq.com/blog/mqtt-essentials-part-9-last-will-and-testament 

Cat

unread,
Sep 20, 2017, 5:21:52 AM9/20/17
to node...@googlegroups.com
Seem I am smarter than I think.

I (now and then) get "disconnected" messages on the main web page.

That is the LWAT telling me the connection is lost.

Ok.  I can live with that.

But that begs the question:  How do I get that information to a format that will then turn the gauge "off" - so it shows zero?
(Semi-rhetorical)

--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to a topic in the Google Groups "Node-RED" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/node-red/K6P6-4PGNyk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to node-red+unsubscribe@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.

Zenofmud

unread,
Sep 20, 2017, 6:48:20 AM9/20/17
to node...@googlegroups.com
 (now and then) get "disconnected" messages on the main web page.
by the main web page do you mean the back-end or the UI? 

You should stick a debug node on the MQTT Input node and see what it displays in msg.payload. Once you find out what the disconnect sends, you could feed the MQTT Input into a switch node and test for that case and have that leg of the switch’s output turn the gauge off (see Dave’s post for details)


You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+u...@googlegroups.com.

To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.

Cat

unread,
Sep 20, 2017, 6:03:52 PM9/20/17
to node...@googlegroups.com
Ok, here's the latest results of requests.

From MusicPi's point of view it sends MQTT messages to TimePI every ten seconds.
This is the flow from MusicPi:

[{"id":"a7528130.3606e","type":"exec","z":"98cfac7a.d84cf8","command":"/opt/vc/bin/vcgencmd measure_temp| sed 's/[^0-9]*//g'","addpay":false,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"Check Temp","x":377.5,"y":28.5,"wires":[["f1faa02f.c5e46"],[],[]]},{"id":"7dd04217.7008f4","type":"ui_chart","z":"98cfac7a.d84cf8","name":"","group":"e9f0b290.19343","order":2,"width":0,"height":0,"label":"chart","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"x":768.5,"y":113,"wires":[[],[]]},{"id":"53fe212a.32bd7","type":"ui_gauge","z":"98cfac7a.d84cf8","name":"","group":"e9f0b290.19343","order":1,"width":"3","height":"2","gtype":"gage","title":"Temp","label":"Celcious","format":"{{value}}","min":0,"max":"80","colors":["#00b500","#e6e600","#ca3838"],"seg1":"30","seg2":"60","x":766.5,"y":66,"wires":[]},{"id":"42369b57.304f74","type":"debug","z":"98cfac7a.d84cf8","name":"VALUE","active":true,"console":"false","complete":"payload","x":768.5,"y":22,"wires":[]},{"id":"f1faa02f.c5e46","type":"function","z":"98cfac7a.d84cf8","name":"Make number","func":"msg.payload = Number(msg.payload)/10;\nreturn msg;\n","outputs":1,"noerr":0,"x":565.5,"y":21,"wires":[["42369b57.304f74","53fe212a.32bd7","7dd04217.7008f4","6665f760.9931b8"]]},{"id":"6665f760.9931b8","type":"mqtt out","z":"98cfac7a.d84cf8","name":"MusicPi","topic":"TEMP/MusicPi","qos":"","retain":"","broker":"af39dd36.0e8058","x":775.5,"y":163,"wires":[]},{"id":"ced77591.c75d08","type":"inject","z":"98cfac7a.d84cf8","name":"Timer","topic":"","payload":"","payloadType":"date","repeat":"10","crontab":"","once":true,"x":103.5,"y":27,"wires":[["a7528130.3606e"]]},{"id":"e9f0b290.19343","type":"ui_group","z":"","name":"MusicPi","tab":"e078f775.80aae8","order":1,"disp":true,"width":"6"},{"id":"af39dd36.0e8058","type":"mqtt-broker","z":"","broker":"192.168.0.99","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"willTopic":"","willQos":"0","willPayload":"","birthTopic":"","birthQos":"0","birthPayload":""},{"id":"e078f775.80aae8","type":"ui_tab","z":"","name":"MAIN","icon":"dashboard","order":1}]

TimePi gets the packet and is happy.

Turning on the debug for that INPUT (from MusicPi) but I don't see any MQTT stuff.

This is the flow on TimePi for the input from MusicPi:

[{"id":"6b9e0c10.7a3d14","type":"mqtt in","z":"3a962246.4b4b06","name":"MusicPi","topic":"TEMP/MusicPi","qos":"2","broker":"683b90c5.4cf61","x":90.72222900390625,"y":300.9999694824219,"wires":[["fda6db41.2648b8","ee82f7a0.feed18","aeebe412.70fb58"]]},{"id":"fda6db41.2648b8","type":"ui_gauge","z":"3a962246.4b4b06","name":"","group":"e1a1c61b.39e76","order":1,"width":"3","height":"2","gtype":"gage","title":"Temp","label":"Celcious","format":"{{value}}","min":"10","max":"80","colors":["#00b500","#e6e600","#ca3838"],"seg1":"50","seg2":"60","x":259.111083984375,"y":300.3333435058594,"wires":[]},{"id":"ee82f7a0.feed18","type":"ui_chart","z":"3a962246.4b4b06","name":"","group":"e1a1c61b.39e76","order":0,"width":"6","height":"4","label":"History","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"No Connection","dot":false,"ymin":"","ymax":"","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"x":269.611083984375,"y":334.3333435058594,"wires":[[],[]]},{"id":"aeebe412.70fb58","type":"debug","z":"3a962246.4b4b06","name":"VALUE","active":true,"console":"false","complete":"payload","x":261,"y":367,"wires":[]},{"id":"683b90c5.4cf61","type":"mqtt-broker","z":"","broker":"192.168.0.99","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"willTopic":"EOM","willQos":"2","willPayload":"","birthTopic":"SOM","birthQos":"2","birthPayload":""},{"id":"e1a1c61b.39e76","type":"ui_group","z":"","name":"MusicPi","tab":"d29ccfb1.b5e108","order":2,"disp":true,"width":"6"},{"id":"d29ccfb1.b5e108","type":"ui_tab","z":"","name":"TELEMETRY","icon":"dashboard","order":1}]

Rather than power down MusicPi, I unplug the Cat5 cable and watch the debug info on TimePi's screen.

All that pahhens is the data packets stop coming in.

Also, weirdly enough the MQTT says it is still connected to MusicPi.   So I'm at a loss to what is happening.



On 20 September 2017 at 20:48, Zenofmud <zeno...@zenofmud.org> wrote:
 (now and then) get "disconnected" messages on the main web page.
by the main web page do you mean the back-end or the UI? 

You should stick a debug node on the MQTT Input node and see what it displays in msg.payload. Once you find out what the disconnect sends, you could feed the MQTT Input into a switch node and test for that case and have that leg of the switch’s output turn the gauge off (see Dave’s post for details)


On Sep 20, 2017, at 5:21 AM, Cat <fuzzywu...@gmail.com> wrote:

Seem I am smarter than I think.

I (now and then) get "disconnected" messages on the main web page.

That is the LWAT telling me the connection is lost.

Ok.  I can live with that.

But that begs the question:  How do I get that information to a format that will then turn the gauge "off" - so it shows zero?
(Semi-rhetorical)

On 20 September 2017 at 19:03, Zenofmud <zenofmud@zenofmud.org> wrote:
Yes you should so look into it more yourself and here are two things you can do to help you learn about MQTT

First - to follow the advice that has already been offer, go look at the MQTT Output node, click the pencil icon next to the server and look at the options.

Second go read this blog series: http://www.hivemq.com/mqtt-essentials/ If you want to jump in the deep end, here is the LWOT section: http://www.hivemq.com/blog/mqtt-essentials-part-9-last-will-and-testament 


On Sep 20, 2017, at 3:22 AM, Cat <fuzzywu...@gmail.com> wrote:

I'm guessing I just need to tweek the MQTT settings, and I shuld look more into that myself,


-- 
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
--- 
You received this message because you are subscribed to a topic in the Google Groups "Node-RED" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/node-red/K6P6-4PGNyk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to node-red+unsubscribe@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.
To view this discussion on the web, visit https://groups.google.com/d/msgid/node-red/07CFA6C3-D12B-4FEA-8A49-630399983CA6%40zenofmud.org.

For more options, visit https://groups.google.com/d/optout.


-- 
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
--- 
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+unsubscribe@googlegroups.com.

To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.

--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to a topic in the Google Groups "Node-RED" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/node-red/K6P6-4PGNyk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to node-red+unsubscribe@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.

Mark Setrem

unread,
Sep 20, 2017, 6:24:16 PM9/20/17
to Node-RED

The reason the MQTT-in node says that it is connected is that it is connected to the broker.

Your MusicPi MQTT-out node config doesn't contain a Will or Birth Message, so your debug will only see the values being sent ( as you still haven't configured it to do anything else.)

It might be a good time to stop and actually read the guide to MQTT that Paul linked to. There are at least 3 posts in this thread that suggest you need to look at last will and testament within MQTT and yet your flow still doesn't have this configured.

Cat

unread,
Sep 20, 2017, 9:12:57 PM9/20/17
to node...@googlegroups.com
I shall have to cop that.

My mistake.

However, I thought I had been through the BirthCert' and LWT on all the connections, so as I didn't konw how it all works, I didn't double check the setting.


--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to a topic in the Google Groups "Node-RED" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/node-red/K6P6-4PGNyk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to node-red+unsubscribe@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.

Cat

unread,
Sep 20, 2017, 10:20:07 PM9/20/17
to node...@googlegroups.com
Well, I went through the steps of adding a LWT at both ends of the MusicPi - TimePi link.
Both QOS 2.
I see the packets coming in on the debug node (TimePi)
Go to the MusicPi and unplug the cat 5 cable and again:  All that happens is the numbers stop coming in.
No extra packets or data seen.


9/21/2017, 12:15:22 PMnode: VALUETEMP/MusicPi : msg.payload : string[4]
"35.4"
9/21/2017, 12:15:32 PMnode: VALUE
TEMP/MusicPi : msg.payload : string[4]
"35.9"

Dave C-J

unread,
Sep 21, 2017, 3:48:27 AM9/21/17
to node...@googlegroups.com
how have you configured the LWT parts ? - do you have a node that is subscribed to the chosen LWT topic ?

Cat

unread,
Sep 21, 2017, 5:13:03 AM9/21/17
to node...@googlegroups.com
Ah!

So I have to have something SUBSCRIBED to the topic of the LWT?

How I read it, the message is what is sent when the connection is lost.

Not that you have to have someone subscribed to the TOPIC.....

Ok, I'll take that on and try to get it working now.


On 21 September 2017 at 17:48, Dave C-J <dce...@gmail.com> wrote:
how have you configured the LWT parts ? - do you have a node that is subscribed to the chosen LWT topic ?

--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to a topic in the Google Groups "Node-RED" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/node-red/K6P6-4PGNyk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to node-red+unsubscribe@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.

Nick O'Leary

unread,
Sep 21, 2017, 5:49:45 AM9/21/17
to Node-RED Mailing List
The LWT gets published to a topic by the broker on behalf of the client that has unexpectedly disconnected. At that point it is just like any other message published to a topic - you need to be subscribed to the topic to receive it.

Nick

You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+unsubscribe@googlegroups.com.

To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.

Cat

unread,
Sep 21, 2017, 6:12:02 AM9/21/17
to node...@googlegroups.com
So if I have it set so A talks to B  with a topic MQTT/TEST/<message>

The topic on which the LWT is published is not the one the usual messages go over.   (eg:  MQTT/TEST/)

So on the LWT tab there is a TOPIC and PAYLOAD field.

So the TOPIC is the one on which the LWT is published and the PAYLOAD is the message - right?


Following on from there:
On the LWT tab, I put EOM as the TOPIC and put MQTT_FAILURE in the PAYLOAD field, I need someone subscribed to EOM looking for MQTT_FAILURE message.

Am I right?

Nick O'Leary

unread,
Sep 21, 2017, 6:30:33 AM9/21/17
to Node-RED Mailing List
So if I have it set so A talks to B  with a topic MQTT/TEST/<message>

If you mean client A publishes a message to a topic MQTT/TEST and client B subscribes to that topic, then client B will receive the message published by client A.

The topic on which the LWT is published is not the one the usual messages go over.   (eg:  MQTT/TEST/)

The LWT can be published to whatever topic you want it to be published on. It could be the same topic as your regular messages or not. 

So on the LWT tab there is a TOPIC and PAYLOAD field.
> So the TOPIC is the one on which the LWT is published and the PAYLOAD is the message - right?

Yes - it is exactly that

> Following on from there:
> On the LWT tab, I put EOM as the TOPIC and put MQTT_FAILURE in the PAYLOAD field,
> I need someone subscribed to EOM looking for MQTT_FAILURE message.

Yes.


Nick


--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+unsubscribe@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.

Dave C-J

unread,
Sep 21, 2017, 6:31:09 AM9/21/17
to node...@googlegroups.com
yes 
though there is nothing to stop you setting the LWT topic to be one you already use. For example in your case MQTT/TEST/<message> as long as the payload is such that you can make use of it...  (indeed in your original case you could just send 0 and feed it to the gauge to set it to 0)

Zenofmud

unread,
Sep 21, 2017, 6:49:20 AM9/21/17
to node...@googlegroups.com
Vocabulary, to communicate clearly use the correct vocabulary.

‘A' publishes a message to a broker using a topic MQTT/TEST/<message>. ‘A' doesn’t know (or care) who subscribes to that topic. After a period of time, if the broker has not heard from ‘A' it will publish the LWT message using the LTW topic you have defined and any machine that has subscribed to the LWT topic will get the message and determines what it should do.

The broker could be on the same computer that ‘A’ is on or it could be across the planet. 
There might be only one client that has subscribed to the topic, or there could be 1000, but none of the clients care about the other clients.
You could have a client that only subscribes to the LWT topic or maybe no client subscribes to the LWT topic (which might not be a good idea)

I would suggest that any client that subscribes to a topic also has another flow that subscribes to the LWT topic (from the client that is publishing the original topic) and has logic to deal with it.

--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+u...@googlegroups.com.

To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.

Cat

unread,
Sep 21, 2017, 7:18:26 AM9/21/17
to node...@googlegroups.com
Well, that's good to hear.

I'm sort of understanding it.

So if what I said is right, I am sure I did that with this bit and yet it doesn't seem to work.

Idea:
MQTT topic with QOS and LWT settings as mentioned.

The Broker is on another machine and this part of the flow is on THIS machine.

I'm not sure any traffic is on the topic, but at this level, it is more to get a "disconnected incorrectly" message if connection is broken.

So it shows as connected.

I reach over and unplug the ethernet cable from the other machine.

I don't get any messages on the EOM msg.payload debug node.



[{"id":"f1d92361.0bdf28","type":"mqtt in","z":"5b95490e.a46ab8","name":"","topic":"TEMP/Alarm","qos":"2","broker":"281932a8.0517e6","x":470.55555555555554,"y":233.66666666666666,"wires":[["710c66b3.f82048","768b2629.d06"]]},{"id":"710c66b3.f82048","type":"exec","z":"5b95490e.a46ab8","command":"espeak ","addpay":true,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"","x":699.9444580078125,"y":233.50003051757812,"wires":[[],[],[]]},{"id":"768b2629.d06","type":"debug","z":"5b95490e.a46ab8","name":"","active":false,"console":"false","complete":"false","x":720.5555555555555,"y":286.6666666666667,"wires":[]},{"id":"c07e4b1c.c513f","type":"mqtt in","z":"5b95490e.a46ab8","name":"","topic":"EOM","qos":"0","broker":"281932a8.0517e6","x":412.5,"y":394,"wires":[["5f6c59db.c3c08"]]},{"id":"5f6c59db.c3c08","type":"debug","z":"5b95490e.a46ab8","name":"","active":true,"console":"false","complete":"false","x":597,"y":394,"wires":[]},{"id":"281932a8.0517e6","type":"mqtt-broker","z":"","broker":"192.168.0.99","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"20","cleansession":true,"willTopic":"EOM","willQos":"2","willPayload":"MQTT_Failure","birthTopic":"SOM","birthQos":"2","birthPayload":""}]

You received this message because you are subscribed to a topic in the Google Groups "Node-RED" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/node-red/K6P6-4PGNyk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to node-red+unsubscribe@googlegroups.com.

To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.

Mark Setrem

unread,
Sep 21, 2017, 7:33:43 AM9/21/17
to Node-RED
OK lets try explaining this again...

Your setup appears to be...

[Audio Machine Node-red MQTT OUT] -------- [MQTT Broker]

[MQTT Broker] -------- [ Node-red 2nd machine MQTT IN]



The flow you shown your last post is the MQTT IN 
i.e. [Broker] -------- [ Node-red 2nd machine MQTT IN]"  

 As that connection isn't broken the MQTT-IN node shows it is connected and no break in connection messages are triggered.

If you want a signal when the "[Audio Machine Node-red MQTT OUT] -------- [Broker]" connection is broken where do you think you need to set the will message?

Dave C-J

unread,
Sep 21, 2017, 8:09:44 AM9/21/17
to node...@googlegroups.com
OK - so I think we have misunderstood what is going on... maybe... :-)...
the broker is on another machine, and all this client code is on the local machine...
When the link between local and remote breaks... the BROKER publishes the LWT message on the REMOTE machine... - but because the link in broken the local client will never see that... 
Instead, locally you have to rely on the status of the node (green/red blob under the node... - which can also be caught and reported by the STATUS node locally...

Cat

unread,
Sep 21, 2017, 8:15:08 AM9/21/17
to node...@googlegroups.com
I am learning.

But I am still confused, and that isn't anything against anyone here.

But reading the last couple of posts, I see a BIG problem.
I explained the "problem" and Nick and Dave seemed to agree with what I said.

I reposted my take on what I said and then was corrected that I had it back to front - kinda.

So it seems I have a basic "messed up" idea of how it all works.

The last example I posted was (using the machine's names) using PiFace and TimePi.   The MusicPi wasn't in the equation as best I know.   It is long ago powered down.

The example I posted monitored a MQTT link from TimePi to PiFace and if it was broken, a LWT message should have come up on a second MQTT node which was listening to (subscribed to?) the EOM topic which would indicate a  failure of the afore mentioned link.

I unplug the cable from the other machine and don't get a message.
(The time out is set to 20 seconds - I hope.)

Yet what Mark just said says something else again - to me.

If I am wrong - and I admit I spend a lot of my life being that - and think that what I wrote actually means "the opposite" could someone please show me an example of how to extract a LWT from a NON-BROKER machine if a MQTT link is broken?

Because as is, all I am going to do is go in ever decreasing circles until I just give up.


--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to a topic in the Google Groups "Node-RED" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/node-red/K6P6-4PGNyk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to node-red+unsubscribe@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.

Cat

unread,
Sep 21, 2017, 8:24:28 AM9/21/17
to node...@googlegroups.com
Dave C-J,

Yes!

That's it.


I did (earlier on) try monitoring the link between the BROKER and the machine called MusicPi.
So I could always see the BROKER even though the link between it (the BROKER) and the MusicPi was broken.

This didn't work/yielded nothing and so I gave up on that.   Reading that the LWT was yet ANOTHER topic and msg.payload thing, I thought I would just do it "locally" between this machine and the BROKER.
Therefore I turned the MusicPi off, as it was no longer needed for testing.

Alas that also didn't work.

And from there confusion only became worse.

No worries.  At least now (or just before now with my just posted post) clarifying the scenario - I hope.

Folks, as much as I would love to stay awake and actually get this resolved tonight:  It is 22:21 local time and I am tired.

Also I see my typing skills are falling off a bit and I need to keep going back and correcting mistakes I shouldn't be making.
I think that is my body's message to me to "call it a day".


Thanks to you all for tolerating my ignorance and dumb questions (etc).   I just hope that at the end, I really learn something and can use it for bigger and better things.

Until tomorrow.




--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to a topic in the Google Groups "Node-RED" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/node-red/K6P6-4PGNyk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to node-red+unsubscribe@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.

shykitten55

unread,
Sep 22, 2017, 7:59:47 PM9/22/17
to Node-RED
I'm ba-ack!

This is getting more and more confusing for me in some ways the more I look into it.

Today I was surprised to get a "MQTT_Failure" message on a DEBUG node.

Hmmmm..   MQTT_Failure.   Bit vague.

I know!  I'll make the message more accurate.

Now, here's the state of the nation as I understand it:
A sends a message to B   (QOS = 2 and there is a LWT set.  The LWT topic EOM)
This is because I can have a different topic for the LWT.

So I have another MQTT (send) node subscribed to EOM.
Then a MQTT (receive) node subscribed to that.

This is the message originated that I saw/got.

Putting aside that entire flow with how it works in telling me the source of the error,but I'm getting there.

I then opened another MQTT (receive) node and went to it's LWT tab.
It simply has No_Comms in the payload field.
This node is on the topic:  TEMP/TimePi
I changed the payload to "No TimePi Temperature received"
The TOPIC field was EOM

This is looking good.   The EOM LWT message is more descriptive.

Next I go to the next MQT (receive) node from MusicPI.
This one's TOPIC is TEMP/MusicPi
I open it and go to the LWT tab.

TOPIC = EOM
Payload:   "No TimePi Temperature recived"...   ??!!

Ok, something is gong on.   Hang on.  I'll look at the third node.

This one is from PiFace
Topic:   TEMP/PiFace
LWT tab:
Topic EOM
Payload  No TimePi Temperature received.



Now, what am I missing?

These are three DIFFERENT nodes, all subscribed to DIFFERENT TOPICS.
TEMP/TimePi
TEMP/MusicPi
TEMP/PiFace

All three are also "subscribed" to the EOM topic to publish a message if there is a comms failure.
Therefore I would think that all three are able to post unique messages.

Seems not.

Someone - please.


I can post the flows, but there are 4 of them and they are rather "messed up" as I am new to this.

I don't mind, as it will remove any errors introduced from me not saying exactly the right thing, but it is a bit of work required to understand them.
(Well, maybe not - I don't know.  I'm still new to this.)





Colin Law

unread,
Sep 23, 2017, 2:20:30 AM9/23/17
to node...@googlegroups.com
You *must* get your details and terms right if we are to understand your problem. See below.


On 23 Sep 2017 12:59 a.m., "shykitten55" <fuzzywu...@gmail.com> wrote:
I'm ba-ack!

This is getting more and more confusing for me in some ways the more I look into it.

Today I was surprised to get a "MQTT_Failure" message on a DEBUG node.

Hmmmm..   MQTT_Failure.   Bit vague.

I know!  I'll make the message more accurate.

Now, here's the state of the nation as I understand it:
A sends a message to B   (QOS = 2 and there is a LWT set.  The LWT topic EOM)

A does not send a message to B. A may publish a value to a topic on an MQTT server. Do you mean the server is on B? 

This is because I can have a different topic for the LWT.

So I have another MQTT (send) node subscribed to EOM.

A send node is for publishing not subscribing so what do you mean here? Nobody should publish to the lwt topic.

Then a MQTT (receive) node subscribed to that. 

This suggests you did mean that you are publishing to the lwt topic. Also make clear which device each of the subscribe/publish nodes are on. Clarify the points please.

Colin


--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+unsubscribe@googlegroups.com.

To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.

Cat

unread,
Sep 23, 2017, 2:55:05 AM9/23/17
to node...@googlegroups.com
Again Colin, I am not messing around with the wrong terms for the fun of it.  It is just confusion.

I have also since learned more, so I shall modify it with the new data - where needed.

Attempt 2 of the explanation:

In a flow, I open the MQTT PUBLISH node from MusicPI.
The LWT TOPIC is EOM and they PAYLOAD is "No temperature from MusicPi"
To me, that means that if this link fails (unexpectedly) the LWT message will go to the BROKER.

Fine.

Now I open another MQTT PUBLISH node.  This time from PiFace.
The LWT TOPIC is EOM and the payload is.....
Hang on!  It says "No temperature from MusicPi"
I change it to suit this machine:  "No temperature from PiFace" and save it.

Weird.

I then go to the third MQTT PUBLISH node.   From TimePi.
Go to the LWT tab.
(this is carzy!  It says "No temperature data from PiFace")


I'm confused.

As I see it:
Each MQTT PUBLISH node is sending its own piece of data down the pipe (TOPIC) TEMP/(name of the machine)
The LWT is set to PUBLISH a message on the topic EOM in the event of failure.
The contents of said message seems to be fixed and if I change one, all get changed.

I was told that the LWT can publish to its "own" TOPIC - which is EOM in my case.  I didn't get that at the beginning, but since have understood the meaning of the "EOM" in the TOPIC part of the LWT tab.

And, that the LWT message is set by the SENDING/PUBLISHING node.  Not the RECEIVING/SUBSCRIBING one.
Makes sense now, but not originally.

(Tangent)
I PUBLISH a message in TOPIC/blah.
Also added is the LWT message so if SUBSEQUENT messages are not received the message is "actioned" - Don't pick on that.   That is the level at this stage of my understanding.
So, having got that under the belt, I moved on.
(End tanget)


I have THREE machines PUBLISHING on their own UNIQUE TOPIC their temperature.
I have set all LWT tabs to EOM as the TOPIC.
So:  If any of them "fail", the PAYLOAD of the LWT is published to the TOPIC EOM.

I've set up a test and that seems to be what is happening.

So, I am stumped why when I open the individual PUBLISH nodes for the DIFFERENT machines and change the PAYLOAD of the LWT, all of them change.

Is that any clearer?



You received this message because you are subscribed to a topic in the Google Groups "Node-RED" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/node-red/K6P6-4PGNyk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to node-red+unsubscribe@googlegroups.com.

To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.

Nick O'Leary

unread,
Sep 23, 2017, 3:44:10 AM9/23/17
to Node-RED Mailing List
Hi Cat,

lets start with a bit more theory to help you understand what's going on.


When you add an MQTT node to your Node-RED flow you have to configure what MQTT broker it connects to. You did that by clicking the button next to the 'add new mqtt-broker' option. That create an mqtt-broker configuration node where you set the address details of the server and the LWT details.

This is an important point for you to understand: when you add another MQTT node to the same Node-RED instance, it is able to reuse that mqtt-broker configuration. That configuration node can be shared be multiple MQTT nodes in your workspace. When deployed, the mqtt-broker node creates the network connection to the broker, and each MQTT node uses that one connection.

Now, lets look at what you've said:

> You edited an MQTT PUBLISH node from MusicPI.
>The LWT TOPIC is EOM and they PAYLOAD is "No temperature from MusicPi".

Ok - so building on what I said above, that means you edited the mqtt-broker config node to set the LWT details.


> Now I open another MQTT PUBLISH node.  This time from PiFace.
> The LWT TOPIC is EOM and the payload is.....
> Hang on!  It says "No temperature from MusicPi"
> I change it to suit this machine:  "No temperature from PiFace" and save it.

So the fact your mqtt-broker node here already had its LWT set to "No temperature from MusicPi" makes me think that you are editing the same mqtt-broker node as before. But you imply this is an entirely different node-red instance running on a different machine.
Something isn't right here.

That suspicion only increases when you say:

> I then go to the third MQTT PUBLISH node.   From TimePi.
> Go to the LWT tab.
> (this is carzy!  It says "No temperature data from PiFace")


Question:  are all of the nodes you're editing above actually in the same Node-RED instance?

From what you describe I suspect the answer is YES, in which case you haven't quite understood what's going on.

 - The LWT set on the connection between a client and a broker.
 - Each MQTT node in node-red does not create its own connection to the broker, they share a connection. (It is possible to give each node its own connection, but there's no reason for you to do this)
 - You should have a single mqtt-broker connection from each of MusicPi, PiFace and PiTime to the broker - and each connection will have its unique LWT configured. If you are trying to configure different LWTs within the same node-red instance, you're doing it wrong.


Given these misunderstandings, it is hard to help based on your written descriptions alone - because they don't contain enough precise detail to be sure what exactly you're doing. But that's okay - you're still learning about this stuff.

What would REALLY help is screenshots of your Node-RED instance on each of MusicPi, PiFace and PiTime. Make sure your nodes have unique names in the screenshots so when you refer to them there can be no doubt which node on which node-red instance you are talking about.



Colin Law

unread,
Sep 23, 2017, 10:40:08 AM9/23/17
to node...@googlegroups.com
I think Nick may have hit the nail on the head here. Just to provide a
bit more information that may help. Node red itself runs on a
computer. You connect to node red running a browser either in the same
machine or another, but where ever you connect from it is the same
instance of node-red. To find out which instance of node-red you are
running then look in the browser address bar. If it says
localhost://... then node red is running on the same machine as the
browser. If it has an ip address then that is the address of the
machine running node red. MQTT LWT will only tell you about
connection failure between the computer running node red and the
computer running the MQTT server (as you setup in via the MQTT nodes).
It will not tell you about problems between the computer running the
browser and the one running node red.

Colin
>>> email to node-red+u...@googlegroups.com.
>>> To post to this group, send email to node...@googlegroups.com.
>>> Visit this group at https://groups.google.com/group/node-red.
>>> To view this discussion on the web, visit
>>> https://groups.google.com/d/msgid/node-red/c4e68b85-1d5b-4a54-8d7a-ae54528e85f4%40googlegroups.com.
>>>
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>>
>>> --
>>> http://nodered.org
>>>
>>> Join us on Slack to continue the conversation: http://nodered.org/slack
>>> ---
>>> You received this message because you are subscribed to a topic in the
>>> Google Groups "Node-RED" group.
>>> To unsubscribe from this topic, visit
>>> https://groups.google.com/d/topic/node-red/K6P6-4PGNyk/unsubscribe.
>>> To unsubscribe from this group and all its topics, send an email to
>>> node-red+u...@googlegroups.com.
>>> To post to this group, send email to node...@googlegroups.com.
>>> Visit this group at https://groups.google.com/group/node-red.
>>> To view this discussion on the web, visit
>>> https://groups.google.com/d/msgid/node-red/CAL%3D0gLvzS2MEC6xVEoWUgwUZ%3D0F5yCA5Vc9POs1cRnRoCO8rXg%40mail.gmail.com.
>>>
>>> For more options, visit https://groups.google.com/d/optout.
>>
>>
>> --
>> http://nodered.org
>>
>> Join us on Slack to continue the conversation: http://nodered.org/slack
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "Node-RED" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to node-red+u...@googlegroups.com.
>> To post to this group, send email to node...@googlegroups.com.
>> Visit this group at https://groups.google.com/group/node-red.
>> To view this discussion on the web, visit
>> https://groups.google.com/d/msgid/node-red/CACM_FR6zMyXhB57uQjTXbvr4qV3TRhyx%3Dsv1k1TaFO%3DqxY-C0w%40mail.gmail.com.
>>
>> For more options, visit https://groups.google.com/d/optout.
>
>
> --
> http://nodered.org
>
> Join us on Slack to continue the conversation: http://nodered.org/slack
> ---
> You received this message because you are subscribed to the Google Groups
> "Node-RED" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to node-red+u...@googlegroups.com.
> To post to this group, send email to node...@googlegroups.com.
> Visit this group at https://groups.google.com/group/node-red.
> To view this discussion on the web, visit
> https://groups.google.com/d/msgid/node-red/CAF%3Dvhqcs5Pzy5-P6fn7PK0bX8V%2BFj7BkoAZM3wbaKZKkUbMikA%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages