I recently just setup dual wan on my Asus AC68 Router. But I needed a way to be notified if it switched over. As it’s a limited data plan.
Here’s what i did.
The Router can output the Sys log to a Remote log server, there is a node-red input for receiving system logs. I am sending the Syslog to Node-Red and using this input node
You also have to set the remote log server in the router settings to point to the same IP Adress as your HA install.
Next I set up a flow in node-red, the syslog has many topics, but the topics we are looking for are “payload.hostname”
WAN(0) is the primary WAN
WAN(1) is the Secondary WAN
It contains the message “WAN was restored” when connected to either one
So a switch to split WAN(0) and WAN(1) and another to look for “WAN Was Restored”
We have the notifications from the router to node-red and we can do what we like with them.
I setup 2 MQTT binary sensors WAN(0) on/off & WAN(1) on/off. And added email, and device notifications.
And added a conditional banner in Lovelace
Node-Red Flow
[{"id":"77172bb7.a1a824","type":"tab","label":"Test area","disabled":false,"info":""},{"id":"25035a6a.2f36c6","type":"syslog-input","z":"77172bb7.a1a824","name":"syslog","socktype":"udp","address":"","port":"514","topic":"","x":70,"y":200,"wires":[["3b04f0fa.d3311"]]},{"id":"3b04f0fa.d3311","type":"switch","z":"77172bb7.a1a824","name":"","property":"payload.hostname","propertyType":"msg","rules":[{"t":"eq","v":"WAN(0)","vt":"str"},{"t":"eq","v":"WAN(1)","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":190,"y":200,"wires":[["7605b68a.f7c958"],["b99c8e6a.a7ce8"]]},{"id":"228510a4.59784","type":"change","z":"77172bb7.a1a824","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"true","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":480,"y":140,"wires":[["3a50b28b.f5b11e"]]},{"id":"7605b68a.f7c958","type":"switch","z":"77172bb7.a1a824","name":"","property":"payload.msg","propertyType":"msg","rules":[{"t":"cont","v":"WAN was restored","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":230,"y":140,"wires":[["228510a4.59784","58f29bc3.d10d24","d710165a.8c0148","85a38b0.f18ec78"]]},{"id":"b99c8e6a.a7ce8","type":"switch","z":"77172bb7.a1a824","name":"","property":"payload.msg","propertyType":"msg","rules":[{"t":"cont","v":"WAN was restored","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":250,"y":260,"wires":[["944f28fe.5db9e8","f1059a7b.7f98d8","fa3e9973.16c028","68e370a3.d2465"]]},{"id":"3a50b28b.f5b11e","type":"mqtt out","z":"77172bb7.a1a824","name":"","topic":"wanfail/primary","qos":"2","retain":"true","broker":"342bfe0.d38be02","x":860,"y":140,"wires":[]},{"id":"892581e3.4bd16","type":"mqtt out","z":"77172bb7.a1a824","name":"","topic":"wanfail/secondary","qos":"2","retain":"true","broker":"342bfe0.d38be02","x":870,"y":240,"wires":[]},{"id":"58f29bc3.d10d24","type":"change","z":"77172bb7.a1a824","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"false","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":480,"y":180,"wires":[["892581e3.4bd16"]]},{"id":"944f28fe.5db9e8","type":"change","z":"77172bb7.a1a824","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"true","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":480,"y":220,"wires":[["892581e3.4bd16"]]},{"id":"f1059a7b.7f98d8","type":"change","z":"77172bb7.a1a824","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"false","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":480,"y":260,"wires":[["3a50b28b.f5b11e"]]},{"id":"fa3e9973.16c028","type":"api-call-service","z":"77172bb7.a1a824","name":"","server":"6fca15de.88c21c","version":1,"debugenabled":false,"service_domain":"notify","service":"mobile_app_gm1914","entityId":"","data":"{\"title\":\"WAN Failover\",\"message\":\"Secondary WAN Active\"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":530,"y":320,"wires":[[]]},{"id":"d710165a.8c0148","type":"api-call-service","z":"77172bb7.a1a824","name":"","server":"6fca15de.88c21c","version":1,"debugenabled":false,"service_domain":"notify","service":"mobile_app_gm1914","entityId":"","data":"{\"title\":\"WAN Failover\",\"message\":\"Primary WAN Active\"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":530,"y":80,"wires":[[]]},{"id":"be9060d4.8c9e7","type":"e-mail","z":"77172bb7.a1a824","server":"smtp.gmail.com","port":"465","secure":true,"tls":false,"name":"[email protected]","dname":"","x":920,"y":380,"wires":[]},{"id":"b1ef051.f7a34f8","type":"change","z":"77172bb7.a1a824","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"Secondary WAN Active","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":660,"y":380,"wires":[["be9060d4.8c9e7"]]},{"id":"68e370a3.d2465","type":"change","z":"77172bb7.a1a824","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"WAN Failover","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":470,"y":380,"wires":[["b1ef051.f7a34f8"]]},{"id":"be203503.cae068","type":"e-mail","z":"77172bb7.a1a824","server":"smtp.gmail.com","port":"465","secure":true,"tls":false,"name":"[email protected]","dname":"","x":920,"y":40,"wires":[]},{"id":"e186d6c4.efc358","type":"change","z":"77172bb7.a1a824","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"Primary WAN Active","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":660,"y":40,"wires":[["be203503.cae068"]]},{"id":"85a38b0.f18ec78","type":"change","z":"77172bb7.a1a824","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"WAN Failover","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":470,"y":40,"wires":[["e186d6c4.efc358"]]},{"id":"342bfe0.d38be02","type":"mqtt-broker","z":"","name":"UrServer","broker":"192.168.1.48","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"6fca15de.88c21c","type":"server","z":"","name":"Home Assistant","legacy":false,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true}]