Jump to content

Random number in Java code


BrianM

Recommended Posts

Posted

I have an ISY994i/IR running 4.3.26.
One of the main functions it provides is to give my house a lived in look
when I'm away. I'd like to be able to turn the outside lights on & off a random
number of minutes before & after sunrise & sunset.
I figured out how to create a random number and store it in a variable but I can't
incorporate the variable into the code of the program that controls the
outside lights.
Anyone know how to do this?
Thanks,
Brian

Posted

I'm uncertain why you want the variable?  I do a similar thing without...

Front Bedroom Light - [ID 0006][Parent 0001][Run At Startup]

If
        From    Sunset  -  1 hour 
        To      10:00:00PM (same day)
     Or From    Sunrise
        To      Sunrise +  2 hours  (same day)
 
Then
        Repeat 2 times
           Wait  50 minutes 
           Wait  20 minutes  (Random)
           Set 'Light Front Bedroom' On
           Wait  5 minutes  (Random)
           Set 'Light Front Bedroom' Off
           Wait  1 hour and 15 minutes 
           Wait  15 minutes  (Random)
           Set 'Light Front Bedroom' On
           Wait  7 minutes  (Random)
           Set 'Light Front Bedroom' Off
 
Else
        Set 'Light Front Bedroom' Off
 


Jon...

Posted

Jon...

Thanks...I've not used the Wait command often and wasn't aware there's a Random option. Your solution suits me fine.

Thanks.

Brian

Posted (edited)

When you "wait 15 minutes (random)", does that mean 15 minutes is the maximum or minimum?

Edited by roblombardo
Posted

When you "wait 15 minutes (random)", does that mean 15 minutes is the maximum or minimum?

 

15 would be the maximum.. anywhere between 0 and 15

 

 

Jon...

Guest
This topic is now closed to further replies.

×
×
  • Create New...