Schedule hub reboot at a specific time

@davidgeo63

Here's a shell script you can use to reboot your Hubitat. Edit it to add your HE's IP address, login name and password. The reboot script can be scheduled via cron.

#!/bin/bash
#
he_login=hubitat_login
he_passwd=hubitat_password
he_ipaddr=hubitat_ip_address
cookiefile=`/bin/mktemp`
#
curl -k -c $cookiefile -d username=$he_login -d password=$he_passwd https://$he_ipaddr/login
curl -k -sb $cookiefile -X POST https://$he_ipaddr/hub/reboot
rm $cookiefile
2 Likes

I tried installing the rebooter app. Sure wish I could get it to work as it is very simple to use. It does not work either.

Post the log output from the app on the main thread for that app (linked above), There's no reason it shouldn't have worked. When you load the app, do you see this screen:

42%20PM

The username and password that you use should be the ones used locally for your Hubitat, and not the username/password for the Hubitat portal.

Outside of that, there isn't much to configure.

1 Like

As Aaiyar stated , the username and password are the ones you used when you you set up the Hub security under the settings tab. ALSO just as important, the username and password are CASE SENSITIVE. So watch out for capital letters. Once you set up hub security, then use that username and password and make sure in the app, you click on the option stating "security on" . Hope that helps

1 Like

@davidgeo63 I use the Hubitat Rebooter and it works. I never had a issue and you can set it for a certain day and time.

Does the IP in the code have to be modified to the IP of my hub or is that done automatically?

It uses the localhost ip 127.0.0.1, so it does not have to be modified.

1 Like

Can you think of a way to shutdown the Hub on low UPS power? I use your script to reboot my (password protected) hub's nightly from a synology NAS. But dont really know how to trigger these scripts apart from "time based".

Previously, I had a Rule Machine Rule that shutdown my hubs on <30% UPS battery remaining AND power = battery.

Can you run apcupsd on your Synology NAS (and is it connected by USB to your UPS)?

apcupsd creates a file called /etc/apcupsd/doshutdown, which is basically a shell script. You can use it to shutdown your Hubitat remotely when apcupsd says there's 10% or 15% (or whatever) battery left in the UPS.

http://www.apcupsd.org

1 Like

Would it be possible to run in a docker container?

I've never done it - I don't use Docker, but Google says [yes]

1 Like

@mike this service is available by default on both Synology and QNAP branded NAS’s. Check in the settings around external devices to hopefully find it, that is where my settings are. I am a QNAP user but know a Synology owner used my driver. Once you are monitoring the UPS hooked up to the NAS you can then write a rule to shutdown the hub.
QNAP NAS Integrations for UPS Monitoring, NodeRed, Home Bridge, etc

1 Like

Thank God for that app. My motion lighting always starts to get noticeably slower after a while so I end up rebooting the hub manually every couple weeks, which speeds things back up. I didn't have any user apps until this one and I don't have any Zigbee or Z-wave devices connected to the hub (radios disabled, only have Hue and Lutron integrations set up), so it's definitely due to a bug or memory leak in the Hubitat's code. It's been like this since I bought the Hubitat 6 months ago. Can't believe it hasn't been fixed. Seems like the Hubitat moderators / devs usually dismiss it as either being caused by user code or by rogue Z-wave devices, but there are plenty of posts on these forums proving otherwise. They should take it more seriously, or at least add a built in way to schedule reboots if they're going to ignore the issue.

4 Likes

Yeah my hub just freezes about once a week and is unresponsive - even to ping. It appears that the logs are not saved after reboot (there is nothing in the tab) and the debugging tools for this device are seemingly nonexistent. I admit I am a bit disappointed that it isn't easier to figure out what was happening when the hub crashed or hung or whatever it is doing.

BTW I have no custom code and only 6 zwave of devices...so the normal things people blame don't exist for me...the device is seemingly just not stable.

1 Like

Whilst I agree this was the case early on, HE have said they have identified one (memory leak) and a fix is coming, and they have identified another which they are looking into.
Lets all keep are fingers crossed and hope things improve. :crossed_fingers:

3 Likes

Man I sure hope so, I just put the rebooter in, probably overkill but doing daily reboots, because why not?

I also have Hub Security enabled so I can't use RM to do a post...I installed the Rebooter app which is great because it handles the login and session cookie, but I don't want to reboot on a schedule.

I'm using bptworld's hub watchdog app, so ideally I want to have that kick off a rule or turn on a switch when it detects the hub moving slowly.

I tried modifying Rebooter to subscribe to a switch so it would do the POSTs (login and then /hub/reboot) but I can't get it working.

Does anyone have any simpler ideas (other than using another machine to run a script) or an example of an app that subscribes to a switch and runs something when it turns on/off?

If you are using Hub Information Driver, it has a reboot() custom command that could be called from RM.