Send IP Address of Node-Red on power up or deploy

Flow to email you the Node-Red machine IP address on boot.

[{"id":"6e578f42.6895f8","type":"exec","command":"ifconfig","append":"","useSpawn":false,"name":"ifconfig","x":261,"y":58.5,"z":"aca355e7.0e11d8","wires":[["9936f703.65e7c"],[],[]]},{"id":"e2189fdd.57ff08","type":"inject","name":"get ip - eth0","topic":"ip","payload":"eth0","payloadType":"none","repeat":"","crontab":"","once":true,"x":109,"y":58,"z":"aca355e7.0e11d8","wires":[["6e578f42.6895f8"]]},{"id":"98f6980a.edf428","type":"debug","name":"test out","active":true,"console":"false","complete":"payload","x":318,"y":185,"z":"aca355e7.0e11d8","wires":[]},{"id":"9936f703.65e7c","type":"function","name":"Extract network config","func":"// Initialize variables\nvar input, tokens, inet, bcast, mask;\nvar outString = \"TestRasPi network config for eth0\\n\";\n\n// Parse the entire string by spaces, and put each item into an array called tokens\n\ninput = msg.payload;\ntokens = input.split(\":\", 10);\n\n// Get the 7th token (example: \"addr:192.168.0.120\")\n// and get the substring from character 6 to the end\ninet = tokens[7].split(\" \", 1);\noutString += \"\\n\" + \"inet addr: \" + inet[0];\n\n// Get the 8th token (example: \"Bcast:192.168.0.255\")\n// and get the substring from character 7 to the end\nbcast = tokens[8].split(\" \", 1);\noutString += \"\\n\" + \"Bcast: \" + bcast[0];\n\n// Get the 9th token (example: \"Mask:255.255.255.0\")\n// and get the substring from character 6 to the end\nmask = tokens[9].split(\" \", 1);\noutString += \"\\n\" + \"Mask: \" + mask[0];\n\n// Don't send a message if the IF is the known default. Change to default ip.\nif (inet==\"192.168.0.120\") { \n//outString = \"\"; // set output to null if ip is the same so no message is sent\nreturn null;\n}else{\n// return the final output\nreturn {payload: outString};\n}\n","outputs":1,"noerr":0,"x":428,"y":45.5,"z":"aca355e7.0e11d8","wires":[["f681b6c4.529c28"]]},{"id":"f681b6c4.529c28","type":"delay","name":"Delay","pauseType":"delay","timeout":"5","timeoutUnits":"seconds","rate":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":144,"y":197.5,"z":"aca355e7.0e11d8","wires":[["98f6980a.edf428","cfcdfb82.50e1e"]]},{"id":"cfcdfb82.50e1e","type":"e-mail","server":"smtp.gmail.com","port":"465","name":"someemail@msn.com","dname":"Gmail Out","x":325,"y":227,"z":"aca355e7.0e11d8","wires":[]}]
ElectronHacks

Flow Info

created 1 year, 2 months ago

Node Types

Core
  • debug (x1)
  • delay (x1)
  • e-mail (x1)
  • exec (x1)
  • function (x1)
  • inject (x1)

Tags

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