After IP change (via dashboard), how can I redirect dashboard to new URL?

Hello.

Does anybody know a node which can take as a input a msg.payload (from a text input node) and open a New web Page with The format adress http://msg.payload?

Thank you!

I'm sure you could create a template node that could do something like that - but node of the default nodes will (or should) s it is a massive security hole to do that without input validation and sanitisation.

Thank you mister.

I tried to use a template node but I don't know exactly how to write the code to implement msg.payload within.

Using href, I only can put a fixed adress web. I need to do somehow to acces The msg.payload within href,which comes as an input from a text input node.

So you want to open a new web page from text entered into a text input?

Well the text input is a dashboard node and the user could just type into the address bar of the browser - so what's the difference?

You realise the text input is rendered client side (in the browser) and each character you type is sent to server side (node-red server) - how do you then expect that payload to come back to the client side (browser) and open a web page?

Please explain your exact requirement

Also, please stick to one thread.

Okay, I Will stay on this thread. This is my requirement:

I am currently running node Red with a raspberry pi, and for my Project i need to connect with pi through eth LAN IP remotely (I am doing this writing in the browser adress bar The IP of Raspberry, something like http:// 192.xxx.xx.x/ui for having acces to the dashboard) I want to have the possibility to change eth IP from raspberry pi, and for that I made a input text where I introduce my New IP and after I press a button (name Saved) I am Will execute a script(with exec node) to change my raspberry IP. But, after I change my LAN eth IP, The problem is I Will imediately lose my connection with pi, because obviously in the browser link I need to introduce the new LAN IP to connect again to my PI.

That being said, can anyone give me an idea how could I make after I press a button to open a new web Page adress which will include my New IP? Do you know about a node which after receive a msg.payload( equal with my New IP) can open a New web Page where msg.payload is include în adress?

Let's say input text IT Will give me a msg.payload='192. Xxx. X. X' as a string. This value i need to get through a node as a input and that node need to open http://192.Xxx.X.X/ui.

I was trying with Java function node but it gives me an error. Also with ui_template but in the Code for IT I don't really know how to include The msg.payload.

Thank you!

Its JavaScript not Java (big difference).

Have you read the built in help for ui_template? It has an example of getting payload from node-red to client side. Try adapting that.

There is a conundrum here...

  • If the IP change is successful, you will lose connection (so you won't get a msg.payload)

Off the top of my head....

  • In a ui_template, have a button that does the following (all client side script in the ui_template)
    • send a payload with new IP to the node-red.
    • set a timeout (setTimeout) of 60sec that redirects to the new address
    • Setup a <a> link pointing to the new page (so user can manually click instead of waiting 60sec)
  • In node-red
    • setup an inject to send a topic "ping" 40sec after the change IP command occurs - if the dashboard receives this msg, then the IP change failed - clear the timeout. If it doesn't receive the "ping" msg, then it (probably) worked and the 60 sec timeout will happen and the page redirects to the new address.

Its a cludge but should work.

1 Like

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