FAQ: Can I schedule events less than a minute apart?

Quite often on the forums people have use cases where they want events to occur very quickly, sometimes just two or three seconds apart. Or they may want a particular pattern of events, again very close together, where “very close” means anything under one minute.

There are multiple factors that play into answering this question for any specific use case.

Device Limits

First, can the specific device that you are using respond that quickly? For example, many motion sensors have inactivity or rest of at least 2 to 3 minutes before events or reports. Sometimes there are parameters you can change, but not always.

When blinking a light, some devices have a specific limit on how quickly the device can be blinked. Others have parameters that can be adjusted for ramp rates or blink patterns.

Cloud Limits

Almost all SmartThings automations run in the cloud. This includes all custom code. Right now the only stuff that can run without making a round trip over the Internet are some of the automations from the official smartlights feature. But not even all of those.

The time it takes for cloud communication varies a lot, and is affected by multiple factors including your own Internet, traffic at the cloud server, Etc. so it becomes very hard to predict precisely how much cloud latency there will be.

Protocol Limits

When coding into SmartThings, developers are told not to schedule events closer together than one minute. And when scheduling a timed event, to allow for some leeway in the exact moment of execution.

http://docs.smartthings.com/en/latest/smartapp-developers-guide/scheduling.html

SmartThings will try to execute your scheduled job at the specified time, but cannot guarantee it will execute at that exact moment. As a general rule of thumb, you should expect that your job will be called within the minute of scheduled execution. For example, if you schedule a job at 5:30:20 (20 seconds past 5:30) to execute in five minutes, we expect it to be executed at some point in the 5:35 minute.

The one minute limit is based on the reality that any mesh network, including the zigbee and Z wave that SmartThings uses, does not provide forced sequencing and messages can and do bounce around the network a little bit. So there’s really no way to guarantee that a limit of under a minute will actually happen. Particularly when you throw cloud latency into the mix.

Wi-Fi devices use a different topology and generally are much better at both forced sequencing and precise timing, but of course if you have to use the cloud as well, then you still have to deal with cloud latency.

Smartapp Limitations

In order to avoid disappointment, the official features will generally limit you to scheduling events no closer together than one minute.

People can and do write custom code which tries to schedule events more closely together. Sometimes this works, sometimes it doesn’t, sometimes it works for a while and then stops working.

Core will allow you to schedule events with just a few seconds in between, but again, there’s no guarantee that will actually work every time. But you can try it and see.

Alternatives

If you can find a device which can produce the results that you want locally from one sent command, you can remove a lot of the latency.

For example, many people have attempted to create a smartapp which would allow for a double tap on a switch by trying to time the taps. This hardly ever works because of the variability and how long it takes the cloud to process the information.

Instead, there are switches which are capable of recognizing a double tap at the switch and then send a single code to tell the hub that it was a double tap. This generally works much better than trying to do it all with code.

Similarly, executing a Hue scene through the hue bridge Will usually produce much less of a “popcorn” effect than trying to send individual commands to a group of zigbee bulbs from the SmartThings hub.

So the first step is to see if there is a device that can produce the desired result from a single command.

The next alternative, as was mentioned above, is to use Wi-Fi devices rather than mesh devices. This can be particularly helpful if you need forced sequencing.

Other than that, use core or other custom code that allows for sub minute scheduling and just try it and see if the results meet your needs. But do expect some variability depending on how busy your own network is and how busy the Internet route to the cloud is at any given moment. :sunglasses:

4 Likes

I take pride in the fact that I managed to get webCoRE to run a schedule every 30s for a whole week with no parent supervision (no other app kicking it if it ever stopped). I will try and get that down to 10 seconds and see how it works.

ST has become a lot more stable in the recent months, I have to give the ST team that!

6 Likes

That’s great, but there are still the issues of cloud latency and local mesh to contend with. There will be variability from one household to another in how precisely they can time events.

I’m all in favor of people trying it to see if it works, but if someone really needs precise very fast timing, I’d look for noncloud options every time. And if they need forced sequencing, WiFi over any mesh topology. Just sayin’…

1 Like

Oh yeah. You can get every 30s with a pretty high error margin. Few seconds +/- at times. Definitely not for time critical processes.

2 Likes