Random off delay

I want to move PLEG logics to REACTOR.

In PLEG it is possible to work with random off delay. I use this to not always switch off the light in the evening at the same time. Is this also possible in REACTOR?

In Reactor, you use a delayed activity, similar to the way that you would delay an action in a Vera scene, but in Reactor, the delayed action will always execute, even if your Vera reloads or reboots (the action is run on schedule after, or immediately if the delay expired during the reload/reboot).

So the Reactor analogue for your screen shot would be:


  • Group “Light On” – AND operator
    • Day of Week M, T, W, Th, Su
    • Sunrise/sunset after sunset + 300 seconds (5 minutes)
    • Date/time before 22:25

rand = random(1,15)

Activity “Light On is TRUE”:

  • Device action, turn light on

Activity “Light On is FALSE”

  • Delay {rand}
  • Device action, turn light off

Theory of operation: the condition group “Light On” will be true on the selected week days and after sunset + 5 minutes and before 22:25 (because sunset is usually much earlier in much of the world, that will be true as well). The expression “rand” generates a random number between 1 and 15 inclusive when evaluated. When that “LIght On” group goes true, the “Light On is TRUE” activity is run and turns on the light. The group remains true until 22:25, and then that date/time condition goes false, so the entire group goes false and makes the “Light On is FALSE” activity run. This activity starts with a delay, using “rand” by substitution (that’s why “rand” is in curly braces as {rand}) as the delay. When the delay expires, the light is turned off the by remaining action.

Edit/note: as of version 3.5, you will not need to create a separate “rand” variable, you can just put {random(1,15)} into the delay field directly.

Thanks again for the quick response. I don’t always have time to try your answer immediately.

I have created a number of reactor sensors and started immediately. Today I wanted to go further and a number of reactor sensors are empty (no conditions and activities) while they were still at the start of the week. Is this a memory problem of my vera?

What FW are you running? Any other devices missing? Some people have seen devices or roll backs happening for no (as far as I know) discovered reason)

Plenty backups…


I use FW reactor 3.4. I have indeed removed a light that was used in the reactor sensor. Could that be the cause?

That might well do it…

I was more asking about the Vera FW though.


I’m running the latest version 1.7.4453 (VeraPlus)

Pretty sure if you only have one device in a Reactor instance, and you delete that device, you will lose the Reactor as well.
If there are other devices that the Reactor can’t find, it’ll go into a safety lockout.

Patrick will correct me, as ever :slight_smile:

I’m missing something very obvious here. When I attempt this, my delay doesn’t work and my logs show "delay at group 2 did not resolve to number; no delay! " and then the light turns on or off.

My ultimate mission is to randomly delay both the On and Off of a light by 1-15 minutes.
Running v3.4 on Vera Plus

My setup:

  • Group “Evening”-AND operator
    • Day of Week - all days checked
    • Sunrise/sunset after sunset +0
    • Date/time before 22:15

randomdelay = random(1,15)

Activity “Evening TRUE”
Delay {randomdelay} From This Point
Device Action, turn light on

Activity “Evening FALSE”
Delay {randomdelay} From This Point
Device Action, turn light off

Light turns on or off, but immediately (no delay). Log file implies that {randomdelay} is not evaluating to a number. I’ve tried forcing it with tonumber() in the expression.

What am I missing?

Make sure you’ve installed the 3.4 hotfixes. One of the hotfixes corrects a problem with variables in Delay actions.

KNEW it was obvious! Thank you!

In Reactor, the delay function is in seconds. I want this in minutes
I have adjusted the randomdelay variable

randomdelay = random (1,15) * 60