Email Alert if Public IP address changes - Updated

This is an updated version of Paul Reed's flow which can be found here: https://flows.nodered.org/flow/9559f217b08913702c38.

I modified the flow slightly and it has worked flawlessly for a couple of years now. Until, that is, the address https://bot.whatismyipaddress.com/ stopped working due to being discontinued by https://whatismyipaddress.com/ because of "abuse" as stated on their website. It stopped working on November 10, 2021. So, I found a site that can return the same text results as http://bot.whatismyipaddress.com/. This new flow uses https://ident.me. This address can also be used with the original flow.

To paraphrase Paul: The flow needs little explanation, it obtains your current public IP address via https://ident.me but there are other services available - http://echoip.com/ and http://ipecho.net/plain (I haven't verified whether these services still work or not) and passes the result through a 'switch' node programmed only to accept data in the format of a IP address - regex validity check (thanks Nick). The IP address is then compared to the previous recorded IP address, and if they differ - then an email is sent to the email address provided, otherwise the flow ends.

I've set up this flow up to check every hour if the IP address has changed or not. Also, once a week it will reset the flow to an IP address of 0.0.0.0. This way, you can be sure that the flow is still working. That's how I knew it wasn't working anymore. I stopped getting the weekly emails.

Hope someone finds this helpful.

[{"id":"830214f0b506b3b0","type":"tab","label":"Flow 2","disabled":false,"info":"","env":[]},{"id":"2e4e54fe96dc1eee","type":"inject","z":"830214f0b506b3b0","name":"Get IP","repeat":"","crontab":"0 0-23 * * *","once":false,"topic":"This is your current Server IP address","payload":"","payloadType":"date","x":320,"y":140,"wires":[["95db8ad270a91ea4"]]},{"id":"5414456618b075f6","type":"function","z":"830214f0b506b3b0","name":"Compare IP","func":"context.lastip = context.lastip || 'initial';\nvar currentip = msg.payload;\n\nif (context.lastip == 'initial') {\ncontext.lastip = currentip;\n}\nelse if (context.lastip != currentip) {\nmsg.payload = \"My current Server IP is http://\"+currentip +\":XXX\";\n//Replace XXXX with the Port number you use to access your network if needed.\n//If you don't need a port number in the address, delete the +\":XXXX\" above.\ncontext.lastip = currentip;\nreturn msg;\n}","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":830,"y":120,"wires":[["4e5f33475c2035d2","9684e3f51f6e674a"]]},{"id":"95db8ad270a91ea4","type":"exec","z":"830214f0b506b3b0","command":"wget -qO- https://ident.me","addpay":false,"append":"","useSpawn":"","timer":"","winHide":false,"oldrc":false,"name":"Call IP","x":470,"y":140,"wires":[["cea1f268fd6a6a2f"],["977a0bd7f5fbd677"],[]]},{"id":"cea1f268fd6a6a2f","type":"switch","z":"830214f0b506b3b0","name":"Integrity check","property":"payload","propertyType":"msg","rules":[{"t":"regex","v":"\\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\b","vt":"str","case":false},{"t":"else"}],"checkall":"true","outputs":2,"x":640,"y":160,"wires":[["5414456618b075f6","15778f8cf162d5af"],[]]},{"id":"4e5f33475c2035d2","type":"debug","z":"830214f0b506b3b0","name":"","active":true,"console":"false","complete":"payload","x":990,"y":140,"wires":[]},{"id":"882f971959ec95d4","type":"inject","z":"830214f0b506b3b0","name":"Reset Notification","props":[{"p":"payload","v":"0.0.0.0","vt":"str"},{"p":"topic","v":"This is NOT your current IP. This is only to reset the IP notification. DELETE THIS","vt":"str"}],"repeat":"","crontab":"55 01 * * 0","once":false,"topic":"This is NOT your current IP. This is only to reset the IP notification. DELETE THIS","payload":"0.0.0.0","payloadType":"str","x":430,"y":200,"wires":[["cea1f268fd6a6a2f"]]},{"id":"9684e3f51f6e674a","type":"e-mail","z":"830214f0b506b3b0","server":"","port":"465","secure":true,"tls":true,"name":"[email protected]","dname":"Send an email","x":1000,"y":100,"wires":[]},{"id":"15778f8cf162d5af","type":"debug","z":"830214f0b506b3b0","name":"","active":true,"console":"false","complete":"payload","x":830,"y":180,"wires":[]},{"id":"977a0bd7f5fbd677","type":"debug","z":"830214f0b506b3b0","name":"","active":true,"console":"false","complete":"payload","x":630,"y":200,"wires":[]}]

Flow Info

Created 3 years, 9 months ago
Rating: not yet rated

Owner

Actions

Rate:

Node Types

Core
  • debug (x3)
  • exec (x1)
  • function (x1)
  • inject (x2)
  • switch (x1)
Other
  • e-mail (x1)
  • tab (x1)

Tags

  • IP
  • address
  • network
  • email
  • notification
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option