I've been trying to implement my own apps and devices to manage my home devices and automation.
I ran into this error message
java.lang.IllegalStateException: app 1344 has 76 scheduled jobs already on line 13235 (method updated)
From the error message it appears that we can only schedule 76 jobs per app or there's some other limits I'm hitting on my hub. I however couldn't find any documentation about this limit.
There is a limit of 75 per app or driver as a sort of guard against runaways, as this is way higher than most apps or drivers would ever need to do. (I'd say typical usage involves maybe a few at a time, if any at all, but obviously, it depends on exactly what your code is doing.)
Along those lines, if you explain your use case/what you're doing, someone can probably suggest an alternative that will work.
I would be interested to hear what your use case is for that as well, I can't even imagine the need for so many jobs. Maybe you need to use a repeating cron expression schedule instead of scheduling individual events?
I mostly have a lot of time-based events that I'm hoping to schedule for my home, for example, I have a controller for the mode like this:
def night = toDate(getGlobalVar("Start Time: Night")?.value)
def dawn = toDate(getGlobalVar("Start Time: Dawn")?.value)
def day = toDate(getGlobalVar("Start Time: Day")?.value)
def lateAfternoon = toDate(getGlobalVar("Start Time: Late Afternoon")?.value)
def dusk = toDate(getGlobalVar("Start Time: Dusk")?.value)
def earlyEvening = toDate(getGlobalVar("Start Time: Early Evening")?.value)
def lateEvening = toDate(getGlobalVar("Start Time: Late Evening")?.value)
def bedtime = toDate(getGlobalVar("Start Time: Bedtime")?.value)
Ideally I'd like to be able to schedule that the next mode change with some runIn all together; due to the limitation, I now have to calculate manually the next one. With this trick I got it down to about 50. It'd be great if there's a way to bypass this limit with some settings / configs.
The ultimate workaround I have in mind is just to implement my own event queue (with a heap) and then always push events into my own queue instead of using the hubitat's runIn.
Hubitat Scheduling is all based on the Quartz Cron Trigger expressions.
I use schedules for some scene changes in my scene controllers
// Scene Schedules
schedule('0 30 6 * * ?', dawnScheduleHandler) // also set with sunrise
schedule('0 0 7 * * ?', morningScheduleHandler) // also set with lowLight
schedule('0 0 09 * * ?', dayScheduleHandler) // also set with dayLight
schedule('0 30 17 * * ?', cookingScheduleHandler)
schedule('0 0 18 * * ?', dinnerScheduleHandler)
schedule('0 0 20 * * ?', afterDinnerScheduleHandler) // choose mode based on light conditions
// Device Schedules
schedule('0 00 18 * * ?', fireplaceOnScheduleHandler)
schedule('0 30 21 * * ?', fireplaceOffScheduleHandler)
Edit: The cron expression is just a string, so you could store the cron expressions in a variable, and you can build the cron strings from variable values, and then use the string var in the schedule command.
Wouldn't you just use the system triggers for Sunrise and Sunset, instead of scheduling them?
My scenes are triggered from schedules, or by outside lux level (I don't use sunrise/sunset, as that does not define a light level, depending on cloudiness). Like when I change scene to Day, it normally changes based on lux rising over "daylight" levels I set, but if it is really cloudy or something, a schedule backs that up in case lux never gets to normal daylight levels.
I've been trying to set them based on the sunrise / sunset +/- a few minutes. A few other times are not sunset sunrise dependent.
Thanks for sharing the tip! I suppose using "schedule" I have quite a few of them as well and they also still counts toward the 75 limit so it might not solve the issue entirely