Can Node-red force browser to reload the editor?

On the Raspberry Pi you can turn on the read-only overlay filesystem by editing /boot/firmware/cmdline.txt and rebooting, easy enough with exec nodes.

I show the readonly status of the Pi in the editor header, eg
image
or
image

But it only shows up in the browser when I manually reload. (The browser is not on the Pi but on a PC, so it is not restarted)

So is there a way to force a page reload when the Pi or Node-red starts?

You can use the ClientCode node - that executes Javascript code in the browser but triggered by a Node-RED server flow.

For example, this will reload the browser by pressing the inject button:

[{"id":"caefbf26df6e28fc","type":"ClientCode","z":"5e62ac9a3cf72547","name":"","clientcode":"window.location.reload()","format":"javascript","x":1094.4444160461426,"y":665.5555686950684,"wires":[[]]},{"id":"b4010190f671fcae","type":"inject","z":"5e62ac9a3cf72547","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":758.888916015625,"y":670,"wires":[["caefbf26df6e28fc"]]}]
1 Like

Thanks very much for that Gerrit.

It does indeed reload the page if I click inject, but setting it to automatically inject after 0.1 sec does not work.
I think that's an issue with the Inject node - separate thread created.

The work-around is to make the inject node fire after 10 seconds not 0.1 sec.

This is unlikely to be a problem with the inject node. More likely is that it is happening before the browser has connected, or something along those lines. I would say that increasing the time is the solution, not a workaround.

:slight_smile: Thank you, glad it helped!

I would agree, that 0.1 sec is a terribly short time. You could also try a delay node, perhaps that would do a better job.

Slight difficulty: I can't get window.location.reload() to work in Firefox.

If I change it to window.location.reload(true) then it works when I manually inject but not automatic inject at startup, regardless of the delay before injecting.

Indeed even this
image
shows nothing in Firefox after a reboot without a manual reload.

I guess it's one more reason to switch from Firefox to Brave.

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