Need to add delay between sending on/off commands to Hue for blinking purposes

link to smartapp ->

How can I add a delay between the hue.on and commands? I’ve tried using delay(), wait(), await(), and runIn(), but the first three give me an error at runtime and the runIn() never seems to actually run.

Any input would be much appreciated!

If you don’t mind adding additional complexity, Simple Rules Engine (AKA, simpleRuleBuilder) can do that. Unfortunately it’s a Web-only oAuth app, so you can’t build the delay directly within SmartThings. It is quick executing though.

The runIn() delay is in seconds, not milliseconds like delay(). I just checked your code and the commented out example using runIn had 10000, which would equate to 2 hours 45 minutes or so. Maybe that’s why it never seemed to run? (Sorry if I just picked up on old code.)

Also, I’m not sure if the code block waits for runIn() before moving on to the next statements. I think it will continue to process the rest of the code, so keep that in mind.

Check out “The Flasher” in the code templates. I use a modification of that to flash a light when our doorbell rings.