My modem/router occasionally lockup and I have to manually turn it off and on to resume internet service. This happens only occasionally. The issue is that I do not know when it goes down nor how long its been down, and in that time the phone will also be down, not to mention various IOT stuff connected round the place.
I came up with a brute force approach below using node red and broadlink spmini power connected to the modem.
The modem is plug into broadlink spmini power plug.
NR pings Google every 30s, if not false, do nothing.
If false (ie internet down), wait for 3 secs and re ping Google, if not false, do nothing.
If false, turn off power plug to modem, wait 5 s, then on power plug again (power resetting the modem).
By that time, ready for another check cycle timing at beginning of loop.
HW: Raspberry Pi, Broadlink SPmini3 power switch
SW: NodeRed v19.4;
Nodes: Ping, Advance Ping, Broadlink Control
I am not sure if this is the best approach or if it is robust enough, or it may goes to an endless loop turning the modem on and off under certain circumstances.
Testing it manually seems to work (note:I use a short cycle time in secs instead of minutes for testing purposes).
I am seeking the vast knowledge from the Forum to review, critique and help to improve my approach and make it practical. Also if someone can work out how to notify when internet is down, let me know!