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
Rule1 ON Time#Minute|1 DO backlog Ping4 192.168.0.119 ENDON ON Ping#192.168.0.119#Success==0 DO Backlog Power1 1; Delay 100; Power1 0; ENDON
To enable rule1
Rule1 1
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
Rule1 0
To delete/clear rule1 use double quote
Rule1 "
Rule settings to ping the MaxAir Gateway
Rule2 ON Time#Minute|1 DO backlog Ping4 192.168.0.101 ENDON ON Ping#192.168.0.101#Success==0 DO Backlog Power2 1; Delay 100; Power2 0; ENDON
To enable rule2
Rule2 1
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
Rule1 ON system#boot do Var1 1 ENDON ON Var1#State>1439 DO Var1 1439 ENDON ON Time#Minute|%var1% DO backlog Ping4 192.168.0.119 ENDON ON Ping#192.168.0.119#Success==0 DO backlog Mult1 3; Power1 0; Delay 100; Power1 1 ENDON ON Ping#192.168.0.119#Success>0 DO Var1 1 ENDON
To enable rule1
Rule1 1
Rule settings to ping the MaxAir Gateway
Rule2 ON system#boot do Var2 2 ENDON ON Var2#State>1439 DO Var2 1439 ENDON ON Time#Minute|%var2% DO backlog Ping4 192.168.0.101 ENDON ON Ping#192.168.0.101#Success==0 DO backlog Mult1 3; Power2 0; Delay 100; Power2 1 ENDON ON Ping#192.168.0.101#Success>0 DO Var2 2 ENDON
To enable rule2
Rule2 1
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
For some reason, ping didn’t work on my Wemos D1 Mini, so another solution had to be found.
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
Rule1 ON system#boot do Var1 2 ENDON ON Var1#State>1439 DO Var1 1439 ENDON ON Time#Minute|%var1% DO backlog WebQuery http://192.168.0.118/ GET ENDON ON WebQuery#Data$!Done DO backlog Mult1 3; Power1 1; Delay 100; Power1 0 ENDON ON WebQuery#Data=Done DO Var1 2 ENDON
To enable rule1
Rule1 1
Rule2 settings to WebQuery the MaxAir Gateway
Rule2 ON system#boot do Var2 2 ENDON ON Var2#State>1439 DO Var2 1439 ENDON ON Time#Minute|%var2% DO backlog WebQuery http://192.168.0.101/ GET ENDON ON WebQuery#Data$!Done DO backlog Mult1 3; Power2 1; Delay 100; Power2 0 ENDON ON WebQuery#Data=Done DO Var2 2 ENDON
To enable rule2
Rule2 1
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
Rule2 ON system#boot do Var2 2 ENDON ON Var2#State>1439 DO Var2 1439 ENDON ON Time#Minute|%var2% DO backlog WebQuery http://192.168.0.101/ GET ENDON ON WebQuery#Data$!Done DO backlog Mult1 3; Power1 1; Delay 100; Power1 0 ENDON ON WebQuery#Data=Done DO Var2 2 ENDON
Rule2 1
So now if either MaxAir Gateway or the BLE-MQTT Gateway loses network connection, both will be power reset.