Simple watchdog using Sonoff

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

  1. Set up the Blink for 1 second
    cmnd/sonoff/blinktime 10
  2. 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.

why not just buy a pi and put openhab there? Or put linux on you z83? I have by far found linux more stable vs windows.

1 Like

Over the years I have tried linux in several guises (Mandriva, Red Hat, Ubuntu). I hate having to delve into the OS to have to add things like a USB wifi adaptor. The PC has frozen twice since I started in January – I think it is the Z83-V not Windows which is the issue… On both occasions it was overnight with the result that the water heater didn’t come on and there was cold water. I have since modified the rule so that it now looks for an MQTT status update every five minutes from the watchdog so it tests the whole system rather than relying on a cron…

If you search openHAB and Tasmota watchdog solutions you’ll find people with issues with Pis and Linux too