Application doesn't start automatically after reboot

Your app has an "initialize()" function in it, correct? Can you copy/paste that function here please? In your initialize function, you have to subscribe to the devices you want the app to listen to. Otherwise, it will not subscribe to any events to publish any events from those devices.

Gavin - I understand where you are both coming from and both solutions could work for me. Naively I thought initialize() would be automatically called at restart of the hub.

I need to either move code that is in my initialize() function into a new function , or arrange for initialize() to be triggered by an event from my device driver , or use Gavins' suggestion.

It is really long - 500 lines - lots of subscribes and device loops to get attributes. I think I understand now what I have to do but will post back if I can't sort it.

Many thanks to both for your help

UGH....if you aren't willing to share any of your code then it's impossible to help you figure out what you are doing wrong. Your app does start when the hub does. But if it doesn't subscribe to any events then it isn't going to do anything.

Ryan , I know you're keen to help.

initialize() calls loads of methods in the app and in several device drivers and kicks off a load of runin methods. It's not going to make sense without lots of posted code.

I am subscribing to over 30 events - but I think I've missed out some key ones... gonna add them and try your suggestions

I'm currently running an 'invitation' alpha for the MQTT app and I'm quite happy to include you in that so you can see the whole code if you're willing to do that , but I'm not ready to post code here just 'yet'. I will be releasing the app shortly.

I didn't ask you to post the entire app. I asked for the initialize function. And if your function is really that large, then why isn't it just calling to other functions for the devices you want? If your initialize is running into an error and escaping, that could be why none of your devices are subscribed to. After your hub reboots, you should be able to see your subscriptions in the app properties page (cog wheel).

If there is nothing there, then you've found your problem.

Actually I have identified my issue through Gavins and your responses. Thank you. I know how to proceed now I think. I have 30+ subscriptions, just need a couple more I realise now.

There are no 'errors' being thrown and the code is not escaping. It was just never running after the reboot. I understand why now

You said your initialize function was quite long and subscribed to a ton of devices. I don't see that here at all. So, where are all these subscriptions?

Also, are you calling initialize from your "updated" and "installed" functions?

I mistakenly thought initialize() was called automatically after a restart. I now understand it isn't.
To establish the simplest scenario I created a new snippet of an initialize() function which is what you have quoted..

I have about 100 active subscriptions - here's the first few - I just didn't have a couple of essential ones handling a restart correctly. I do call initialize() from both updated() and installed() .

I know what to do to get this working as required now - the issue, as I said above, was my initial misconception that initialize() would be automatically called upon a restart , even as in your snippet above i.e. with no subscriptions.

Update: The suggestions in this topic fixed my issues . Thanks. I don’t know of any document that really describes this after life of an application in the sense of reboots .. maybe worth adding or maybe I can create such a thing for the WiKi.

1 Like