Definition of an execution and the approach of handling multiple devices


I have a question regarding these Rate limits and especially the execution count limit. What exactly is the definition of an execution?
Is it as simple as an execution of a method in the SmartApp?

Let me describe a potential scenario:
Let’s say we have 40 different devices connected to one hub. As I see it, we have two different ways of approach here:

  1. We can either subscribe to every sensor and on each fired event we execute a method, for example firing an async post request every time a motion sensor changes its state. It takes approximately 10 seconds for a motion sensor before it changes its state from active to inactive. This means that it hypothetically can raise the event handler (40 sensors * 7 times/min) 280 times a minute, and that only includes raising the event handler. Then we have making a post request for each fired event. But is that included in the “execution count” or is it ONLY raising the event handler that will count as an “execution”?
    This mean we risk exceeding the rate limit but in the return each post request will be very light.

  2. We use scheduling and for example every 1 or 5 min we run this one single method that collects every event for each device that has occurred the in the past 5 minutes and builds this potential massive JSON object containing all the events for the past five minutes. This way we only execute once (?) every 1 or 5 minutes, but we loose the near realtime experience and we risk other limits such as execution time limits and there might be some data heavy requests. In that case we can always chop the JSON into smaller bits and make multiple async http post requests.

So, what is the definition of an execution and which approach do you think is the preferred way in the described scenario?

Thanks in advance!

If you have an environment where a single SmartApp instance is being invoked 280 times per minute, then SmartThings isn’t an appropriate platform for you at this time. The new API (in Beta) doesn’t run SmartApps but provides event subscriptions with callbacks and there will be different but likely more generous rate limits.

Yes… You could batch up events, but it shouldn’t be required.

ActionTiles has customers with over 100 subscribed Devices and has not run into rate limits. We do sometimes run into execution timeout (20 real-time) seconds while establishing subscriptions of over 120 or so Things.