Watchdog to restart openHAB when z-wave stalls

I am struggling with z-wave network which becomes unresponsive from time to time without any apparent reason so far. As a workaround a made a simple watchdog to restart openHAB when z-wave stops receiving updates from the nodes.

There is a switch item WatchDog, that is set to OFF whenever the z-wave node sends an update. Upon setting to off the timer is created. If the timer executes, the WatchDog is set to ON.

In OS cron there is a simple script executed every minute that checks the status of WatchDog. If it is ON, it copies over the log to the file marked with timestamp and restarts the openHAB.

In items file:
Switch WatchDog "Watch dog"

The rule:
import org.openhab.core.library.types.* import java.util.Date import org.joda.time.* import org.openhab.core.library.types.* var Timer tWatchdog rule "Watchdog" when Item ZwaveStatsSOF received update or Item HEM_E2 received update // choose items that get regular updates then //logInfo("WatchDog","Watchdog reset") if(tWatchdog!=null) { //logInfo("WatchDog","Timer cancelled") tWatchdog.cancel() } //logInfo("WatchDog","Timer tWatchdog created") sendCommand(WatchDog, OFF) tWatchdog = createTimer(now.plusSeconds(120)) [| //logInfo("WatchDog","Timer tWatchdog executed") sendCommand(WatchDog, ON) ] } end

The cron script:
#!/bin/bash zwaveWatchDog='curl -s http://localhost:8080/rest/items/WatchDog/state' if [ "$zwaveWatchDog" == "ON" ]; then logger "Z-Wave stalled, restarting openHAB" _now=date +"%Y_%m_%d_%H%M"_file="/opt/openhab/logs/openhab-$_now.log" cp /opt/openhab/logs/openhab.log "$_file" systemctl restart openhab fi

2 Likes

Cool! Thanks for this.

I have a stalling issue with RFXcom which periodically requires a restart, so I will try implementing this.

I implemented this same setup. It work’s like a champ.