Lots of folks asking how to reboot their Hubitat because of unresponsive issues. I’m not doing regular reboots but I am monitoring it for network connectivity and cycling power if it’s unresponsive. The benefit is it’s not rebooted unless it needs it. The drawback is that this could happen at an inopportune time. You also need to make sure your monitoring doesn’t reboot your device during an upgrade!
My C4 device is running lots of custom code with 139 devices has been relatively stable and not required an unresponsive reboot recently that wasn’t induced by me adding something or by me leaving many tabs open within the GUI and logs running (I try to close all GUI tabs unless I’m working on something, but I do forget).
To do this, you need a get a sonoff/tasmota-compatible smart plug and monitor and trigger power cycles via another device on your network (Rpi) running Monit.
For the outlet, see this post. You can get 2 plugs for $12.99 on Amazon and can flash via your Rpi: [Release] Tasmota Sonoff Hubitat Driver & Device Support
Install monit on your Rpi and add a hubitat.conf file in the /etc/monit/conf.d dir. Note, if you just want to ping and not connect to port 80 to check for web, you can comment out the last lines starting with “if failed port 80”. Checking ping is probably sufficient and will not put unnecessary taxing on the web server. I’m doing both and haven’t had an issue.
$ more hubitat.conf check host hubitat with address HUBITAT.IP.ADDRESS if failed icmp type echo count 5 with timeout 5 seconds 3 times within 5 cycles then exec "/etc/monit/pushover-hubitat-restart.sh" else if succeeded for 3 cycles then exec "/etc/monit/pushover.sh" if failed port 80 for 3 times within 5 cycles then exec "/etc/monit/pushover-hubitat-restart.sh" else if succeeded for 2 cycles then exec "/etc/monit/pushover.sh"
Here are my Restart and pushover files. You’ll need to create pushover apps and add your appid and userid. You’ll need the IP of the smart outlet so that monit can do the restart.
$ more pushover-hubitat-restart.sh #!/bin/bash OUT1=`curl -s http://IP.OF.PLUG/cm?cmnd=Power%200` sleep 3 OUT2=`curl -s http://IP.OF.PLUG/cm?cmnd=Power%201` /usr/bin/curl -s --form-string "token=APPTOKENID" \ --form-string "user=USERAPIID" \ --form-string "message=[$MONIT_HOST] $MONIT_SERVICE - $MONIT_DESCRIPTION $OUT1 $OUT2" \ https://api.pushover.net/1/messages.jsonop
$ more pushover.sh #!/bin/bash /usr/bin/curl -s --form-string "token=APPTOKENID" \ --form-string "user=USERAPIID" \ --form-string "message=[$MONIT_HOST] $MONIT_SERVICE - $MONIT_DESCRIPTION" \ https://api.pushover.net/1/messages.jsonop