Random Number / Random Time in Rule Engine

Hello! I there a “random number” that i can use on the rule engine to program some sort of “away lights”?

I want some chosen lights to turn on and off at random times when im not home. If the random number is from 0 to 9 it is ok with me, becase i can add a 15 plus that random number and i have a perfect time.

Thanks!

Hi @An_Dres, random time trigger is not currently supported, but sounds like a great idea to be added to my list. Other than random time trigger, do you need something like “random” duration to turn the lights off? This sounds to be a great feature but I need to think about the design how users can create “away light” automation easily but with some flexibility. But thanks for the great suggestion.

2 Likes

Thanks for your quick response James! Yes, i need the random trigger only for my away lights…

My away lights would be:

Turn light 1, light 2 and light 3.
2 at a time
For a random number between 10 and 25 minutes.

1 Like

I would also be interested in being able to turn lights on/off randomly. I envision this as being a random offset of sunset/sunrise. This is what I am currently doing with WebCore as a vacation/away crime deterrent.

@Steve_Jackson, thanks for the inputs on random offset of sunset/sunrise. I will need to include that in the design. :wink:

1 Like

I would also find this very useful. I was able to create the rule in sharptools but am missing the random turn offs… I am more than happy to share my rules and webore pistons if it would help.

1 Like

@Terri, it’d be great if you can share your setup and describe the use cases to help give more context about this feature request.

I currently use webcore to randomize my lights cycling on/off at random ti.es between 5-29 minutes when I’m away at night. I like using randomized times vs set intervals because it is more reflective of someone being home. Also, if you are away for an extended period, it is easy to catch on to set intervals and know Noone is home.
Here is my current webcore piston. Is it quite complex and uses variables. I am aware it could be simplified! Actually I did simplify it nicely in the rule engine EXCEPT the lack of randomized times which is why I’m still using webcore (until ST ends groovy).


1 Like

Hi friends, I think that could be a great feature, because the only SmartApp I had found is Vacation Light Director but is not total “random”, only for picking up which lights turns on, but after that the only function is turn them on/off to a predefined time in a cycle. I think a great function could be about:

  1. Set a time frame (specific or from sunset to sunrise, b.e. from 20:00 to 01:00)
  2. Set a time cycle (every X minutes, b.e 60 minutes)
  3. For each cycle, pickup a random light(s) from a group of devices to turn it/them on (b.e 2 random lights from a group of 10)
  4. For each device pickup random time between a min-max to keep each light on (b.e. random time between 10-30 minutes)

So random feature could be:

  • To pick a random device from a group of devices.
  • To set a random time delay between a time frame after random devices were switched on.

The rest of cycle could be programmed as usual in an IF bucle.

1 Like

Hi friends, I had found this old post and I would like to update. For users in Smartthings, there is an Smart App named Random Lights on-off. That creates a switch, also you can set for which devices and timing that randomly ON-OFF. Its enough for a vacation, I had used it by a year and it works sharply, I will cancel my vote on this feature because the need its solved. I hope this can help everybody.

I too am in the same predicament with the impending withdrawal of webcore support and also have been.using a randomised lighting piston for a number of years now. I’m looking at Sharp Tools as a replacement for Webcore but I’ve hit my first stumbling block with the lack of a randomiser - hence another vote from me.

Thanks for posting, Ian. Can you share more details about where you would use the random number within your randomized lighting rule? Would you want to use it in the Wait/Delay command or somewhere else?

Using the /math endpoint on our Lab Server, you can pass in a formula of randomInt(max) to get a random number back. I suspect the next key part of this is extending the Delay action to accept a variable. :wink:

Thanks for the quick response. The way this works for me in webcore is that a random number of lights (between user defined min/max values) turn on randomly for a random period of time (again between a min/max value).

I hope this helps and thanks again for your interest in my feature request.

I also need this feature, both for triggers and delays.

I also have this need and my use case is exactly like Ian_Burgess. It would be great is this was available before webCore goes away in SmartThings.

Make sure to scroll up and cast a vote at the top of the post! :slight_smile:

I would also note that this particular request is for being able to use random numbers on the time side of things (eg. using a random number in a delay).

Ian also mentioned a random number of lights (random selection of lights?) which is not covered by the original feature request and I’m not sure if I’ve seen a separate feature request submitted for that before. Feel free to create a request if one doesn’t already exist.

The use case for a random time in the Rule engine which would be the most beneficial to me would be where instead of turning on random lights it would follow my family’s normal habits when we are away. For us when I think about it we tend to have events that happen within a range of times. For example, we start eating dinner between 5:45-6:15 and finish roughly 30-45min later. We put kids to bed around 7:30-8pm. My wife and I go to bed between 10:30-11:30 etc. All of those habits have fairly predictable lighting patterns depending on the activity. And also there’s a couple different automations which we would run during those events. So to be able to use a “random time” within the between time condition of a flow to turn on a specific device or the ability to select multiple devices or automations would be great. This way, because we are creatures of habit, the automations would mimic those habits, but have some randomization so it’s not the same every time.

In the interim of full support for this, it would be wonderful if Delay could take a variable. That way you could send in a variable and random seed yourself, or via the Math Endpoint. No you have to do an extremely ugly if statement.

1 Like

The Dynamic Delay feature is now available in beta:

https://community.sharptools.io/t/beta-dynamic-wait-delay-in-rule-engine/11171

If you are part of the beta group, you should be able to access the link above.