$randomLevel Change When?


#1

How often does the variable $randomLevel change?


( I hate Mondays) #2

It does not change per se. It’s a new random value every time you request it.


#3

And how do I request it?


#4

I am comparing the variable for a random light automation. So

If $randomLevel is less then 50 turn lights A.

If $randomLevel is greater or equal to 50 turn lights B.

Will that comparison cause a value change?


( I hate Mondays) #5

yes, each will get a new value. use:

if
   $randomLevel is less than 50
then
   turn on a
else
   turn on b
end if;

or store the random value into a variable first and use the variable - though the if then else is the better, more efficient way


#6

Thanks for the information!


(Robin) #7

Here is the ultimate random light setup… triggered every 30 minutes whilst alarm is on, it randomly waits 1-29 minutes for each light in the list individually, and then performs a random toggle.


(Jon) #8

With this will only one bulb be on at a time?


(Robin) #9

Completely random, any of the selected devices can be on or off at any time.


(Jon) #10

Thanks, one other question, if device is on at end of time restriction, how does it get switched off, I assume you dont want a light left on all night? Do you have another piston to switch everything off?


(Robin) #11

Yep, another piston turns everything off at bedtime, but only if the alarm is still armed.