Random Delays in RM

Hi guys, so I know how to add a time "Delay" with a "random" but is there a way to add a random to a delay when it's related to a device.

So basically if I want 1 or more lamps to turn off randomly can this be acheived in the delay part of the actual lamp?

See screenshots showing the random for a delayed action but not a random for a delay within a device. Hope this makes sense


Random is not currently an option available under device control in RM. I assume you are looking for a way to randomly turn on/off several devices instead of having them all change more or less together…

Hi Sebastien, that's exactly it! So for example

If X Then
Light 1 - turn off random 00:00:25
Light 2 - turn off random 00:12:00
Light 3 - turn off random 01:30:00

I'm surprised this functionality isn't available. Have you seen the request elsewhere in the forums?

It isn’t something I’ve seen requested yet, but will tag @bravenel so that he is aware of the ask.

Thanks for this, it basically ties in with my other post which you liked whereby, the randomness of my lights appears duplicitous towards burglars

Thanks to you and @bravenel

1 Like

You can create the same outcome by just chaining "standalone" Delay actions, right?

Hi Bert,

Can you elaborate in this I'm not sure what you mean but it sounds grwat and feasible?

Using "standalone" Delay Actions with random will not achieve actually the same effect, because that serializes the delays. Each delay could be for a random time, but serialization is not what you are looking for.

The request for adding random to the per action delay is noted, and will be considered for the next release. It's not particularly difficult to add. When individual actions have a delay, that action is schedule to run later, while the main rule execution continues. So if you put random delays on three successive actions, each action would run at some random time later, thus not being serialized.

2 Likes

Yeah, I didn't think that all the way through...a series of "standalone" delays would let you use a random delay for each, but the actions would always happen in the order written (though if that's not a concern, it would help with the particular need for random delay time). Since the "delay" option on an action just schedules the delayed action and then moves on to the next line, you do actually gain something by using that feature in this case.

@bravenel and @bertabcd1234 this is exactly what I'm looking to achieve, 3 separate actions all with their own random with are running simultaneously. I dont want to wait for a prior standalone random to timeout. Think we're talking the same language here guys.

2 Likes

As a workaround in the meantime, whose clunkiness would be proportional to how many devices you want to randomly control (or at least the ones you want to also be in necessarily random order), you could create a rule for each device with actions like:

Delay 0:10:00 (random)
Off: Switch 

Then simply call ("Run Rule Actions") that rule from your "main" rule. Do that for all these rules. Then each of these little rules will schedule these things with both random times and essentially random order because the delays aren't "blocking" the execution in that main rule.

But, as I said, that might get messy if you have a lot of devices. :slight_smile:

3 Likes

Actually, when looking into delays for another purpose, I thought of something that is much less awkward than what I suggested above. You can still use the "Delay?" option on the action and not the standalone "Delay" action as I suggested above, but choose "Variable" for the delay instead of specifying a (maximum) time and choosing "Random." You can make this variable random by creating a local variable (or using a hub variable if you have a reason to do so), then setting it to something random--with Rule Machine's normal variable operators, which allow you to do this--and use that variable as the delay. You can do this before each action, and each delayed action will be scheduled for a random time. (Once the delayed action gets scheduled, changing the value of the variable will not affect that schedule, so you can re-use a single variable for all of these.)

This still requires a bit more work, but it won't require multiple rules like I suggested above. Just an extra line or so per action--in the same rule. Of course, now that you know the feature is coming in some future release, maybe you'd rather just wait; otherwise, thought I'd suggest it now in case you need it. :slight_smile:

4 Likes

Could you elaborate on how to setup a random variable? There's 5 types of variables (number, decimal, string, boolean, datetime) and none of them supports random value. I'm currently running the latest version 2.3.0.124.

Thanks in advance.

I was interested in bertabcd1234's approach and believe this approach works. First, I created a variable called RandomVar which is a Number. Then I used Set Variable action with variable math that allows for random number generation. This example will provide a random number between 0 and 120 that can be used for the delay. Well done @bertabcd1234!

3 Likes

Got it. It is an action in app instead of an option in variable. Screenshot is really helpful. Thank you both @bertabcd1234 and @pseudonym for the workaround and explaining.

1 Like