Persistent interval scheduling?


(Anders) #1


I’m doing polling over HTTP (n seconds > 15) in a SmartApp via the runIn(pollInterval, checkMethod) after every check. I’ve made sure the runIn call is being done even though the HTTP call might fail.

But it seems the scheduling goes missing every once in a while. I don’t know if that’s because of an aborted run or the ST cloud or it clearing all scheduled events? The SmartApp is “live” again after I go in and edit the settings (since I do a runIn scheduling on config changes).

Is there some better way to do the scheduling to get it to persist, or is this just something we’ll have to live with… I hope not… :slight_smile:

This is the code if anyone’s interested:

(Marc) #2

This is a common issue of the platform. A work around is to create CoRE or WebCoRE piston that runs every 15 minutes that calls another piston that actually performs the HTTP call. This is what I do for Sonos/Harmony/SimpliSafe polling and refreshes and has been reliable.

(Anders) #3

I see now that I’m doing something that’s not recommended: chained runIn calls.

I was wanting to use a cron expression like “0/30 * * * * *” (to run every 30 seconds), but that doesn’t seem to work. I know agressive polling is discouraged, but for something like the alarm (which links directly to the HSM) you need pretty fast updates. So runEveryXMinutes will not be goo enough.

(Anders) #4

Neeeever mind. I should really learn these cron expressions one day. :wink: Seems like “0/30 * * * * ?” works. :slight_smile:

(Anders) #5

Or it doesn’t. It only executes every minute anyways. It just locks into 30 seconds. I’ve tried with */30 and 0/30 for the seconds. Anyone got updates more frequently?