Applies to: Node-RED for SNAP PAC; Node-RED for groov

It’s often handy to know the current IP address of your network’s Internet connection (aka the WAN IP address).

Get WAN IP Address Flow

In this flow:

  • The http request node gets the WAN IP address of the device configured in the Opto22 write node.
  • The Opto22 write node writes the address to a string variable in a PAC Control strategy.

From there, you can extend the example by displaying the string in an HMI like PAC Display, or saving it in a groov data store.

Steps

  1. In a PAC Control strategy, add a string variable named WAN_IP_Address.

    String Variable

  2. Import this flow into the Node-Red editor:

    
    [{"id":"2449f0fd.cd5ca","type":"inject","z":"11314554.e8c4fb","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":208,"y":121,"wires":[["3f161b91.ff9244"]]},{"id":"3f161b91.ff9244","type":"http request","z":"11314554.e8c4fb","name":"http request","method":"GET","ret":"txt","url":"http://icanhazip.com","tls":"","x":365,"y":121,"wires":[["ece5c65d.c693e8"]]},{"id":"ece5c65d.c693e8","type":"pac-write","z":"11314554.e8c4fb","device":"1108855e.077bbb","dataType":"string-variable","tagName":"WAN_IP_Address","tableStartIndex":"","value":"","valueType":"msg.payload","name":"Opto22 write","x":534,"y":121,"wires":[["5b863cb3.eabf44"]]},{"id":"5b863cb3.eabf44","type":"debug","z":"11314554.e8c4fb","name":"","active":true,"console":"false","complete":"false","x":698.3333129882812,"y":120.33336639404297,"wires":[]},{"id":"1108855e.077bbb","type":"pac-device","z":"","address":"192.168.0.1","protocol":"http"}]
    
    
  3. In the Edit pac-device node panel, enter your controller’s IP address, and the API key and value for your login credentials.

    Controller Credentials

  4. Deploy, and then click the Inject button. Then open your strategy to see the WAN IP address.

    Results

For more information about this example, see the Opto 22’s Node-RED OptoForum.