$randomLevel Change When?

How often does the variable $randomLevel change?

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

And how do I request it?

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?

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

2 Likes

Thanks for the information!

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

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?