Categories :

Monitor network connections and power cycle them if they fail

Last Updated on 16/12/2023 by Kevin Agar

The object is to monitor some systems connected to the network, and if they fail to communicate, then power them off for a short period and then repower them.

This can be done by adding Rules to a unit running Tasmota. In my case it’s a Wemos D1 Mini that is used to remotely power cycle the Gateways that was explained here

Rule settings to ping the BLE-MQTT Gateway

To enable rule1

This will check the ping to 192.168.0.119 every minute, and if no response will power it off for 10 seconds and then power it back on.
Backlog command allows executing up to 30 consecutive commands with a single command line. Each command is separated by a semicolon (“;”).
A Backlog command without an argument clears a possible existing Backlog queue.

To disable rule1


To delete/clear rule1 use double quote

Rule settings to ping the MaxAir Gateway

To enable rule2

This will check the ping to 192.168.0.101 every minute and if no response will power it off for 10 seconds and then power it back on.
Backlog command allows executing up to 30 consecutive commands with a single command line. Each command is separated by a semicolon (“;”).
A Backlog command without an argument clears a possible existing Backlog queue.

However, if the endpoint becomes unreachable for a long time, the watchdog will keep cycling it every minute. This could reduce the watchdog’s relay lifetime to months, at most years. A safer option would be to use an exponential backoff algorithm. Var1 contains the current interval in minutes, which is tripled after each failed query, but limited to 1439 minutes (1 day).

Rule1 settings to ping the BLE-MQTT Gateway

To enable rule1

Rule settings to ping the MaxAir Gateway

To enable rule2

Rule1 //the rule number
ON system#boot do Var1 1 ENDON //when booting start with Var1 at 2 minute
ON Var1#State>1439 DO Var1 1439 ENDON //the max value for Var1 is 1439 minutes = 1 day

ON Time#Minute|%var1% DO backlog Ping4 192.168.1.10 ENDON //on the time value of Var1 ping 192.168.119 4 times
ON Ping#192.168.1.10#Success==0 DO backlog Mult1 3; Power1 0; Delay 100; Power1 1 ENDON //If ping fails then increase the time to the next ping by 3x and power1 OFF for 10 seconds then power1 ON
ON Ping#192.168.1.10#Success>0 DO Var1 1 ENDON //If ping succeeds then leave time to next ping at 1 minute and wait for next ping

From the Tasmota rules webpage “If your Tasmota doesn’t have ping compiled in and your remote host has an HTTP server you can access, you can use WebQuery as below:”

Rule1 settings to WebQuery the BLE-MQTT Gateway

To enable rule1

Rule2 settings to WebQuery the MaxAir Gateway

To enable rule2

As the MaxAir Gateway and the BLE-MQTT Gateway are both connected to the same relay there is no need to have rule2 switching power2 as shown above, but rather change it to the below

So now if either MaxAir Gateway or the BLE-MQTT Gateway loses network connection, both will be power reset.

Leave a Reply

Your email address will not be published. Required fields are marked *