C8 pro fw 2.5.0.156
I have a rule that detects when I have left my home, that sets my curtains at a random position.
I want the position to be random between 50% and 20% open, and not close.
In my current rule, they can close since random can select 0%.
Here is my rule:
How can I restrict the range of random numbers?
Alan_F
June 28, 2026, 12:11pm
2
Create 2 local variables: range (=30) and position (=any number).
Then do this:
You could also use a third local variable (“minimum”) and use that in the second action (increase ‘position’ by ‘minimum’) if you want everything controlled by variables.
random(25) + 25 would get you 25 to 50, if that is close enough.
Thank you!
I tried both methods but went with yours, and it was just what the doctor ordered!
The position when I am gone, is not critical. I just want the “gone” position to be different each time to give the “is he really gone” look.
I set my range to 50 and the addition to 5 so the minimum open could be 5 and the max could be 55.
I don’t want the curtains to be open all the way to 65 when gone, but just enough of a difference.
Thank you both for your inputs!