I am writing a SmartApp to change modes under a very specific set of circumstances. I want for it to start monitoring specific combinations of presence sensor states during a certain window of time. Each instance of the SmartApp will have a single window of time, meaning only one start time, and only one stop time.
During each window of time is no problem, I can just subscribe to presence changes and check whether it’s within the window. But for the beginning/end of the window, I’m still a little unclear about limits on the schedule() method. I also have a question on how best to handle SmartApp updates.
I see from the documentation that I can call schedule(), which is where I’d check my presence sensors and see if a mode should change. However, I also see that there are limits to the number of schedules. Are these limits per hub, per smartapp, or per instance of the smartapp?
I also see there’s an unschedule() method, which is recommended in the updated() method. There’s also the warning about it being computationally expensive. Is the best way to simply call unschedule() first, and then the two schedule() methods to start and end the window?
Thank you!
RBoy
(www.rboyapps.com - Making SmartThings Easy!)
2
The limits are per instance of the SmartApp. Generally it’s an expensive call. If you call it too often the platform may end up timing out and it may lead to an unknown state. That’s why it’s recommended only use them in the install/update methods.
"Number of scheduled executions limit
The canSchedule() method returns false if four or more scheduled executions are created.
This currently does not actually impact the ability to create additional schedules, but such a limit may be imposed in the near future. A community post will be made in advance of any such change."
@slagle had earlier confirmed the limit was raised to 6 schedules. Is this still the case and the documentation dated? I didn’t quite understand the meaning of the last sentence. Does it mean you can schedule more than 6 schedules but canSchedule() will return false?
I have a smartapp that runs a scheduled execution once a minute. I changed the routine it called, but it won’t change. I did the unschedule in the update, I have tried the unschedule in the install area, update area, initialize area and nothing works. When I check what is scheduled it still shows the old routine. And using debug that is what is running. Not sure what else to do except maybe uninstall the app and redo it.