My first application is quite large at 3000 lines and I think I've followed the guidelines OK. It has the required installed() updated() uninstalled() and initialize() methods. Everything seems fine I can install, run, re-run the app from within the UI but after a reboot the app doesn't run. The initialize() method is never called. I even reduced it to a single log statement , it doesn't appear in the log. What could be wrong ?
I have totally uninstalled the app and code and then re-installed it with no change.
After a restart it can be run successfully from the UI where it immediately displays it's preferences configuration.
Just as background there's an associated driver with this - that does startup OK after a reboot. It generates a lot of events and could be doing so for handlers in the main app that have not yet been setup. Indeed I can see some log statements (from my main app that never initialized) and so it seems they are processed in the main app ..seems the code is running as such in that respect. The application uses atomicState extensively
I have also tried disabling the device driver so events didn't arrive early but again my main app does not run initialize() after a reboot.
So what am I missing and what could cause this ? I realise you're going to say .. post your code but there's a lot of it ... I can dig out the preferences and definitions sections if they might be contributing to this ? There are no errors logged on a UI start of the application.
I've experienced a similar issue with Envisalink Integration. I never figured out why, but it started working properly all by itself, or so it seemed. I'm sorry I don't have more valuable info for you only commiseration.
It all depends on what you are doing. If you are using schedule or runevery to run methods they will continue after a reboot. If you use runin to do loops then in a reboot they may be lost.
This is a way of having something execute on a system reboot.
Yes....but that isn't required to initialize your app after a reboot. You're talking about subscribing to reboot events. The OP is saying his app isn't running after reboot, which I don't understand.
So initialize() is not routinely called on a reboot (but would be if I added Gavins' subscribe) ?
After initialisation my app is purely event driven. So an alternative is to generate a 'reinitialize' event from my device driver ? Which in my case is used to connect to & create subscriptions to the MQTT topics the driver needs.
For drivers, initialize is execute after a reboot if they have the initialize capability.
For apps, you need to subscribe to have a method of your choosing execute after a reboot.
Without knowing exactly what is going on in his code, I'm guessing he wants something to start executing on a reboot. Maybe has a loop running that doesn't continue after. That is why I'm suggesting this.
It basically goes out and connects to an MQTT broker and publishes enabled HE devices for MQTT status and control. It also subscribes to MQTT topics that are mapped to HE virtual devices. Lastly it tries to discover any new devices on MQTT that use the HomeAssistant or homie3 discovery protocols. It's quite arduous as it does a lot of work building all these subscriptions