What code will be executed when HE starts up?

I am planning to move my garden-watering-app to HE.
The app consists of 6 cycles turning a tap on and off resp. (a Gardena-device switches to another hose / garden-sector when water-pressure goes to 0) Currently, the app has to be restartable because of spontaneous reboots of the current server. To realize that, after each state-change the app saves a state-code in a reboot-proof location. After a reboot, in the server-startup-file the actual state is read back from the reboot-proof location and the app is started again (correction for time is done when the server was gone for too long a period).
For HE I learned that the reboot-proof location is a construction named 'state'.
Always, at startup the actual state has to be read back and - if not in final state - the app has to be started again. What I don't know yet is: what file and/or app-code is executed by HE at startup?

A HE-startup file ?

Some special app-procedure ? installed() ?

Thanks in advance.

Welcome to the Hubitat Community!

You might get more of the right eyes on this question if you move it to the developers category.


I believe what you most likely want, if writing your own custom groovy App, is to subscribe to an event that is triggered when the hub starts up. This subscription can call whatever function you'd like to handle hub startup events. I am tagging @bravenel and @chuck.schwer who will know exactly what event to subscribe your app to.

In general though, Apps ride through hub restarts fairly well without special handling. Since they are typically awoken by events anyway, and they maintain state through a reboot, they usually pick back up where they left off. However, I understand your desire to ensure everything is in the correct state after a hub restart.

Update: I think I found the answer in an older thread... be sure to read the rest of the thread as the syntax shown in the post linked may have some extraneous double quotes in it.

UPDATE: I believe this post shows the correct syntax...


I could be wrong but I believe Rule Machine also allows you to build rules around the systemStart event so no programming skills are needed.


You are correct. systemStart is under Location. I use it for Hub startup events.

1 Like