Dropdown node wont refresh text output .It will only do it after URL refresh

i investigated it and for my eyes it is related to the dropdown node . i really do not have the knoweledge to troubleshoot its configuration .Colin could i send you a video through emailo or somehow?

It isn't to do with the dropdown node because you said if you bypass the persist node, and send the dropdown node the same message from an inject node then it works ok. Post the flow that fails and the one that works and show us the message that is sent to the dropdown node in each case (in debug nodes). Set the debug nodes to show Complete message. Give the debug nodes names so that it is clear which output is which.

Something has just occurred to me, how are you checking what you are sending to the dropdown node on startup? You can't see it in the editor because the browser will not be open in the editor to see it. Presumably you have configured the debug node to output to the console and then viewed it there.

i use a delay before feeding to the dropdown node

What is that in answer to?

"how are you checking what you are sending to the dropdown node on startup?" its a responce to this question .

You said you have a three second delay. That is not long enough on boot to open a browser on the editor, is it?

OK, so let me make sure I understand. You reboot, open the browser on the editor and on the dashboard, then wait for the inject to trigger, but it does not update the dropdown?

Then you look in the editor window and you can see the message that was sent and it looks ok.

If you then manually click the inject does it update the dropdown?

You said it does work if you drive it directly from an Inject node. If you now click that inject node does it then update the dropdown? If yes then the messages must be different. So please do what I asked ages ago which is to show us those messages, the one that works and the one that doesn't. Also post the flow with the failing and working flows on it.

Please read post #7, starting: In order to make code more readable ...

flows (33).json (3.1 KB)

That is not what post #7 says.

See this post for more how to post flows - How to share code or flow json

Edit, also you have not included the Inject node that does work.
Can you also confirm that my understanding in post #31 is entirely correct please.

All you said in post 31 is correct . plus that if i refresh the url of the 1880/ui page the output appears correctly also in he ui wihout any change happen to node-red in the meanwhile.

The forum shows the post number of the post which is at the top of the window, on the right hand side. It is the one starting "OK, so let me make sure I understand".

Had you taken my advice earlier, to set the debug node to show Full Message you would have seen a clue as to what the problem is. As with most (maybe all) ui nodes when they send a message it contains a property msg.socketid which indicates the websocket connection of the browser which caused the message to be sent. Also, as with other ui nodes, if you send it a message that contains a socketid then only the matching browser session will be affected.

The message that you are persisting contains the socketid of the browser session that selected the value in the dropdown, but having restarted the flows that connection is lost and the browser will start a new connection when it reconnects. The message stored in the persist node is then passed to the dropdown node, but that message includes the id of socket from the previous run. That id does not match the new connection so the display is not updated.

To fix it add a Change node in the wire out of the persist node, set to Delete msg.socketid, then I think you will find it works ok.

Alternative ditch the persist node, which, when used with nodejs 14, produces a warning message:

"[RED.events] Deprecated use of "nodes-started" event from "/home/colinl/.node-red/node_modules/node-red-contrib-persist/persist.js:164:20". Use "flows:started" instead."

and switch to using persistent context. Then you can just save the payload value and inject it via an Inject node on startup, so you won't need the Change node and also you wont have to worry about whether the persist node will stop working at some point when you upgrade your system.

3 Likes

Dear Colin thank you very much for the support .You r n1.

I don't think you should need the Delay node either.

i have an mqtt in node feeding also the dropdown . but there is one issue. on redeploy the mqtt in node fires a message to the dropdown node changing the state so i use a delay in order to override this mqtt in message. I tried to put an rbe node to ignore the initial state of mqtt in node but i have problem because in that point of the flow i must toggle sometimes using the same msg with the last one and with rbe it cant work.

Is it sending a value on deploy because something is publishing at that time or because the topic is retained?

In fact if you are already using MQTT there is a much better way to do what you want. You don't need the persist node or persistent context. You can use MQTT. Wire it like this

Make sure that If msg arrives on input, pass through to Output is not set (that is important or you will get an MQTT loop) and make sure the topic is set as Retained in the MQTT Out node.

A big advantage of structuring like that is that you can keep the control logic (what happens when the value changes) separate from the UI nodes. It doesn't even need to be in the same computer.

1 Like

Colin , its a script on a esp and i dont know why it is sending the value when the node red is re-deployed . Even if i shutdown the esp and restart node-red It is sending the value again on deploy .