WAN IP address flow

Finding out your Internet IP address can sometimes be a bit tricky. Services like http://icanhazip.com make it a lot simpler, but even so, from within a PAC, you need to open a comm handle, make the http post, get the return string, and sift through it. Node-RED makes all that super simple.

Here is a flow I created to get my WAN (Internet) IP address into a PAC controller string.

Just copy the flow text (bracket to bracket) from below. Then, open Node-RED, click on the menu bar on the top right (the three bars that look like a hamburger), select Import, then Clipboard. Paste the text in and click OK.

[{"id":"5f91384b.2a7718","type":"inject","z":"f57e300c.3660e","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":102,"y":895,"wires":[["480512d2.d0d744"]]},{"id":"480512d2.d0d744","type":"http request","z":"f57e300c.3660e","name":"i can haz ip","method":"GET","ret":"txt","url":"http://icanhazip.com","tls":"","x":290,"y":894,"wires":[["57dd1e3c.943bf"]]},{"id":"57dd1e3c.943bf","type":"pac-write","z":"f57e300c.3660e","device":"47fe29ec.29b8e8","dataType":"string-variable","tagName":"icanhazip","tableStartIndex":"","value":"","valueType":"msg.payload","name":"icanhazip","x":488,"y":894,"wires":[["2dd02b34.3927b4"]]},{"id":"2dd02b34.3927b4","type":"debug","z":"f57e300c.3660e","name":"","active":true,"console":"false","complete":"false","x":668.3333396911621,"y":893.3333683013916,"wires":[]},{"id":"47fe29ec.29b8e8","type":"pac-device","z":"","address":"","protocol":"http"}]

Here is a screen shot of how it looks once you do the import.

As exported, I do not have the timestamp node on any sort of repeat. I’ll leave it to you to decide how often you would fire this flow and check your IP address.

The yellow node does the web call to the website. Next is the red node, our SNAP-PAC-Write node. In this node, put the IP address of your PAC controller that’s running 9.5 firmware or better, plus the user/pass credentials. Finally, the green node on the end is the debug node, so you can see the IP address in the Node-RED debug tab.

For more information on setting up your PAC Controller, check out the walk-through on the http://developer.opto22.com website.