Router rebooter logic. Use hub variable?

I have a Starlink connection and an Asus router. Every once in a while i get a dhcp error that only resolves with a router reboot.

I will set up a rule that pings google every 10 minutes and cycles a zigbee plug that the router is plugged into if it sees 100 percent packet loss.

I would like to also put something in the rule, however, that will only do this power cycle once every 12 hours just in case there is an actual internet outage. I don't want the router stuck in an endless reboot cycle.

I was thinking about setting a hub variable after the reset, then have the rule run only if the variable is not that value. Then have the variable reset every 12 hours or so.

There has got to be a simpler, more eloquent way to do this. I just cant wrap my head around it.

How about something like this?

1 Like

Set a variable to the last time you rebooted the router (unix timestamp style I think), then you just check if its been 12 hours worth of milliseconds since that was set when the rule triggers. If its too soon you bail, if its past it you set the variable again and reboot.

@aaiyar solution above is probably easiest, only downfall is if the hub reboots while the 12 hour delay is pending the delayed actions will never fire. So you could possibly get stuck where the Boolean is false and the rule will never trigger. For this reason I try to keep any delays in RM short.

4 Likes

Thanks for the ideas and examples. I have it set up now.

1 Like

Good point.

@jessie.slimer - if you use something like what I've posted, you probably want to reset the PB for that rule automatically during a systemStart. It is available under Location triggers in RM.

2 Likes

This has been working great. It has rebooted a couple of times already when I was not there.

Would there be any downsides to have it check more often, say every minute? This way it can reset within a minute of the outage.

Should be fine, ping is not very intense on the network. You could try it out and then check the Logs > App stats after a day or two and see how much CPU time that rule (app) is using up.

I also found out from someone else in another thread that delayed actions should actually survive a reboot as long as they were not supposed to happen DURING the reboot. Anything schedule during the hub being off/rebooting will be skipped.

2 Likes

I was thinking it might get stuck in a loop if it checks the internet every minute, but it takes longer than that for the router to come back up and get online from the last reboot.

Good to know ping shouldnt use too much hub resources.

Nevermind, it shouldnt reboot it again anyway if the variable has been changed.

Yes if you are using the Required Expression as suggested, the rule wont even try to run until that condition is met first, so should be 12 hours with no ping checks after it fails and reboots.

2 Likes

Working on adding this rule. Is the value variable equal to the percentage of packets lost? So 100 means all packets were lost?

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.