I have the following network ping flow set up that works well:
[{"id":"e8c17b5587f8c344","type":"ping","z":"eb3cbe54.bd558","protocol":"Automatic","mode":"triggered","name":"Ping","host":"","timer":"5","inputs":1,"x":250,"y":840,"wires":[["20ef40f2d7f77dd9","f00eb1c8865e8424"]]},{"id":"20ef40f2d7f77dd9","type":"switch","z":"eb3cbe54.bd558","name":"Pass Ping?","property":"payload","propertyType":"msg","rules":[{"t":"istype","v":"number","vt":"number"},{"t":"false"}],"checkall":"true","repair":false,"outputs":2,"x":410,"y":840,"wires":[["6ac1ce40344acbb8"],["8704e1e24b44c5e8","99fb19c3d4ee24ca"]]},{"id":"bc89895a3aee3de4","type":"time-inject","z":"eb3cbe54.bd558","name":"Google","nameInt":"\"www.google.com\"","positionConfig":"580132a8.865a5c","props":[{"p":"","pt":"msgPayload","v":"www.google.com","vt":"str","o":"","oT":"none","oM":"60000","f":0,"fS":0,"fT":"UNIX timestamp (ms)","fI":"0","next":true,"days":"","months":"","onlyOddDays":false,"onlyEvenDays":false},{"p":"target","pt":"msg","v":"www.google.com","vt":"str","o":"","oT":"none","oM":"60000","f":0,"fS":0,"fT":"UNIX timestamp (ms)","fI":"0","next":false,"days":"","months":"","onlyOddDays":false,"onlyEvenDays":false}],"injectTypeSelect":"none","intervalCount":1,"intervalCountType":"num","intervalCountMultiplier":60000,"time":"","timeType":"entered","offset":0,"offsetType":"none","offsetMultiplier":60000,"timeEnd":"","timeEndType":"entered","timeEndOffset":0,"timeEndOffsetType":"none","timeEndOffsetMultiplier":60000,"timeDays":"*","timeOnlyOddDays":false,"timeOnlyEvenDays":false,"timeMonths":"*","timedatestart":"","timedateend":"","property":"","propertyType":"none","propertyCompare":"true","propertyThreshold":"","propertyThresholdType":"num","timeAlt":"","timeAltType":"entered","timeAltDays":"*","timeAltOnlyOddDays":false,"timeAltOnlyEvenDays":false,"timeAltMonths":"*","timeAltOffset":0,"timeAltOffsetType":"none","timeAltOffsetMultiplier":60000,"once":false,"onceDelay":0.1,"recalcTime":2,"x":90,"y":840,"wires":[["e8c17b5587f8c344"]]},{"id":"8704e1e24b44c5e8","type":"trigger","z":"eb3cbe54.bd558","name":"Wait 2 minutes","op1":"","op2":"0","op1type":"nul","op2type":"str","duration":"2","extend":false,"overrideDelay":false,"units":"min","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":840,"y":840,"wires":[["ae17c6d2dc52b5b4","81431809fee394f3"]]},{"id":"6ac1ce40344acbb8","type":"change","z":"eb3cbe54.bd558","name":"Reset Trigger","rules":[{"t":"set","p":"reset","pt":"msg","to":"true","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":620,"y":820,"wires":[["8704e1e24b44c5e8"]]},{"id":"6cde3bf3fd57f2eb","type":"time-inject","z":"eb3cbe54.bd558","name":"Bad Google","nameInt":"\"10.0.0.200\"","positionConfig":"580132a8.865a5c","props":[{"p":"","pt":"msgPayload","v":"10.0.0.200","vt":"str","o":"","oT":"none","oM":"60000","f":0,"fS":0,"fT":"UNIX timestamp (ms)","fI":"0","next":true,"days":"","months":"","onlyOddDays":false,"onlyEvenDays":false},{"p":"target","pt":"msg","v":"www.google.com","vt":"str","o":"","oT":"none","oM":"60000","f":0,"fS":0,"fT":"UNIX timestamp (ms)","fI":"0","next":false,"days":"","months":"","onlyOddDays":false,"onlyEvenDays":false}],"injectTypeSelect":"none","intervalCount":1,"intervalCountType":"num","intervalCountMultiplier":60000,"time":"","timeType":"entered","offset":0,"offsetType":"none","offsetMultiplier":60000,"timeEnd":"","timeEndType":"entered","timeEndOffset":0,"timeEndOffsetType":"none","timeEndOffsetMultiplier":60000,"timeDays":"*","timeOnlyOddDays":false,"timeOnlyEvenDays":false,"timeMonths":"*","timedatestart":"","timedateend":"","property":"","propertyType":"none","propertyCompare":"true","propertyThreshold":"","propertyThresholdType":"num","timeAlt":"","timeAltType":"entered","timeAltDays":"*","timeAltOnlyOddDays":false,"timeAltOnlyEvenDays":false,"timeAltMonths":"*","timeAltOffset":0,"timeAltOffsetType":"none","timeAltOffsetMultiplier":60000,"once":false,"onceDelay":0.1,"recalcTime":2,"x":110,"y":880,"wires":[["e8c17b5587f8c344"]]},{"id":"ae17c6d2dc52b5b4","type":"template","z":"eb3cbe54.bd558","name":"Set Message","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"Pings to {{{topic}}} have failed.","output":"str","x":1050,"y":840,"wires":[["6791d007d6b12a33"]]},{"id":"6791d007d6b12a33","type":"api-call-service","z":"eb3cbe54.bd558","name":"Notify iPhone","server":"296c0678.b5f9ca","version":5,"debugenabled":false,"domain":"notify","service":"mobile_app_iphone","areaId":[],"deviceId":[],"entityId":[],"data":"{\t \"title\": \"Network Problem\",\t \"message\": \"{{{payload}}}\"\t}","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1230,"y":840,"wires":[[]]},{"id":"580132a8.865a5c","type":"position-config","name":"Home","isValide":"true","longitude":"0","latitude":"0","angleType":"deg","timeZoneOffset":99,"timeZoneDST":0,"stateTimeFormat":"3","stateDateFormat":"12"},{"id":"296c0678.b5f9ca","type":"server","name":"Home Assistant","version":4,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":30,"areaSelector":"friendlyName","deviceSelector":"friendlyName","entitySelector":"friendlyName","statusSeparator":"at: ","statusYear":"hidden","statusMonth":"short","statusDay":"numeric","statusHourCycle":"h23","statusTimeFormat":"h:m"}]
I’m currently testing it with IP addresses (targets) set in the inject nodes. “Google” pings Google, and “Bad Google” pings an IP address that doesn’t exist in my network, so it fails every time. If the first ping fails, I wait for a second failed ping before passing along a notification. If the first ping fails and it’s followed by a successful ping, the trigger node is reset and no notification is sent.
Ultimately, one of my goals is to automatically reboot individual hardware (modem, router, access points) with plug-in modules based on the ping results. I’m pretty sure I can do that with a switch node.
However… for the purposes of notification, I’m wondering how I can dynamically interpret different IP addresses for correct wording in my notifications. I’ve proven that msg.topic containing the target IP makes it all the way through to the notification, and I’ve included the IP in the notification. However, instead of, “Pings to 192.168.1.40 have failed,” I would like the notification to say, “Pings to the router have failed.” I’m not sure how to set unique messages based on different msg.topics. Any help would be great.
EDIT: I believe I can use a switch node with n outputs, and then send each output through a change node… but there has to be a cleaner way of doing it.