Method or Subscribe to Hub Reboots

Is there a method or subscription that I could subscribe to in an app or device driver that will execute after the hub reboots?

There are some things I run that after a reboot stops working that I would like to start up again.

I know I could setup a schedule to check if its running and start if if required that survives a reboot but just curious if there was another way.

You can do this with Rule Machine:

Use a trigger with event type Location, and value systemStart.


I'm guessing I would be able to do a 'subscribe("location", "systemStart", restartPolling)' in my app code?

1 Like

yes, that's how you do it.

1 Like

Perfect. Thanks again.

@bravenel I tried this in my app, I am not getting the event - and don;t see anything in the logs from my app
subscribe("location", "systemStart", reConnect)

and this is my handler
private reConnect()
log.debug "Reconnecting after system restart"
def theDevice = getDevicebyNetworkId()
if (theDevice) {

Try remove the quotes from location and give your method an evt parameter.

I may have put quotes by accident.

1 Like

Maybe you've considered this as well but you can make the device support initialization and then put anything you want done on startup in the initialize method I think. That's what I think I'm doing everywhere. I guess that doesn't work for apps though.

1 Like

I was thinking the same, but didn't have time to post it. I thought initialize() was run on each driver (and app?? Can't remember) after a reboot as well.

1 Like

For apps you need to subscribe to the reboot event.

On drivers you add the initialize capability and method.

1 Like

That worked - thanks - I had missed the initialize capability, I think I will refactor and simplify in the next round, for now this works.

1 Like

I guess I've never really thought about it on apps. Thanks.

I had recently lost power and when restored, my bulbs powered on in the on state. I wrote a rule to periodically turn off lights during day time. I say the original post today and wrote a trigger rule, which I thought would address the issue. Have a missed a step ?

Since you create a Triggered Rule, you must click on the "Define Rule" section. In it, you will be able to select your "Condition" regarding Mode.

Thanks for pointing that out, to me trigger rules area little "strange". However am I correct, that the rule as defined, will trigger when hub boots. I did boot several times and log show the trigger was invoked. I the reason I relied to the thread was that it appeared that a subscribe operation was required.

Yes, the trigger will fire each time the hub boots. For your Triggered Rule, when the hub restarts, the trigger fires and causes your rule to be evaluated. If the Mode is Day, your Actions for True will execute.

My needs are simpler... I use the following RM Trigger (not a triggered rule) to send me a notification each time my hub starts up.

1 Like

Is there an event related to a hub that has just started rebooting? Would it be possible to create one in a future release? It would greatly help with my app "CSP Watchdog" monitor the status of a second hub.

Initialize() typically can be used. It is called when an app is new and every time a reboot happens.

Thank you. Is it called when the reboot is called or when it is done rebooting?

After reboot it is called on each driver (and I think apps).