I have been having a problem with a Z83-V running Windows 10 sometimes freezing. This obviously stops openHAB from running. I’ve been looking for a simple watchdog timer (without having to flash non-standard Tasmota firmware.
Tasmota has two useful features Blink and Backlog. Blink allows the output to be blipped for a variable time and Backlog allows a series of MQTT commands to be stored in the Sonoff.
First we need to set up the Sonoff in the Sonoff console to blink once for 1 second
- Set up the Blink for 1 second
cmnd/sonoff/blinktime 10 - Set the Sonoff to resume after 1 blink
cmnd/sonoff/blinkcount 1
Then to setup the Sonoff in Items. This will tell the Sonoff to blink for 1 second after a 6 minute delay.
Switch Watchdog "Watchdog" <switch> (GroundFloor) {mqtt=">[mosquitto:cmnd/sonoff-watchdog/backlog:command:ON:delay 3600;power1 3],<[mosquitto:stat/sonoff-watchdog/POWER:state:default]"}
Then we need to set up a rule which will run every 5 minutes. The first command clears any delayed commands in the Sonoff and the second then starts the 6 minute delay to blink the Sonoff output. If everything is running OK then openHAB will cancel the backlogged command after 5 minutes. However, if openHAB has stopped, the Sonoff will blip the power supply for 1 second and restart the PC.
rule "Watchdog"
when
Time cron "0 0/5 * * * ? *"
then
publish("mosquitto","cmnd/sonoff-watchdog/Backlog","")
sendCommand(Watchdog, ON)
end
The PC power supply is connected to the normally closed contacts of the Sonof and set to auto start on power fail. Obviously the trigger could be anything that can be set to repeat (provided it is a shorter interval than 6 minutes). I presume that the Sonoff could ‘stack’ the delays, but the 5 minute repeat seems reasonable anyway.