I`ve been coming across a recurring issue using the mqtt in nodes to UI dashboard.
I have a simple layout - topic , function - ui as shown:
The function code is very simple such that :
Now , I am finding inconsistencies within the data displayed on the UI. Certain times when restarting flows, the ui shows a data value that isn`t the one pushed through the topic. The data is a prior value , almost like a stored value internally on node red that takes priority over current mqtt data coming through.
I can only compare it to say matlab , where you have stored variables on the programme, once assigned then aren`t being reassigned. On matlab you use a clr all, to whip any prior values before running the code each time and I feel like this is something similar - any suggestions as to what is going on here?
In addition, if you set the MQTT node Output a Parsed JSON Object then it will parse the JSON and output an object for you, so you can remove the function node.
However, surely when I then pull more current data through mqtt then it will update the retained value with the newest value? As when I do this , the older value takes priority and the new value ignored?
That should not happen. Add debug nodes showing what is coming out of the MQTT node. If you set the debug node to output to the console then it will also send it to the node-red log so you can see there what happens on startup, if that is where the confusion is happening.
Yes so if every message coming from that topic is retain true, then it doesn`t matter really right? as the new messages will just overwrite the old retained one? However this is not the case as a prior value is still taking priority over the new ones coming through ?