I’m trying to troubleshoot a SmartApp that I wrote and have been using every day since last year. Someone was having trouble with it, so I completely uninstalled and then re-installed the app. Now the app is not working for me either.
It looks like the app is not initializing correctly. Below is how I initialized the app when it was installed or updated:
def installed()
{
initialize()
}
def updated()
{
initialize()
}
def initialize()
{
unsubscribe()
subscribe (switch1, “power”, eventHandler)
log.debug “Subscribed to power event for $switch1”
}
I never see the log message from the initialize() function, and the app does not work. I.e. I don’t see any of the other log messages from the eventHandler, etc.
Well, turned out it was a problem with the code . Still learning… I was missing an “install: true” parameter on the settings page, which, in retrospect, looks pretty obvious.
Since I never uninstalled my app before, it kept the original subscription that I set up, so happily kept working…
I have noticed that log messages don’t work during a smart apps’s install and update phrase. I’m sure it’s executing but you can’t debug msg it.
It looks like you are subscribing to a power event on a switch. Switches do not have a power event. Perhaps that is why you are not seeing any subscription messages.
I’ve not seen this before. I’ve always had debug messages show up in Live Logging during update and install.
As mentioned above, the problem with the code was a missing parameter on the settings page, which, by the looks of it, directs the platform to actually call the smart app installed() function when the page is submitted. After adding the parameter, the app works fine, log messages and all.