December 30, 2025Dec 30 I have a basic program where I wait Random minutes, turn on Light X then wait Random minutes turn on Light Y, ... etc.I modified this program to create a random value for a variable that serves as the permutation order so that the order of lights coming on differs each day. But once you have more than say 3 lights, the list of permutations gets a bit out of control.I would prefer not to have a set of programs (one program for each light) where they all trigger off of sunset, wait X minutes, do Action Y, because doing this could cause, in theory anyway, all lights to come at the exact same (or even close to) time.Image you have a set of lights, you want to randomly iterate over them one by one, waiting X random minutes before turning it on. You want this to happen sequentially. Edited December 30, 2025Dec 30 by raymondjiii
December 30, 2025Dec 30 I do something similar for irrigation control so minutes per zone can be varied using inline waits. See if this helps $Minute_Counter_I = random number 1 Repeat While $Minute_Counter_I > 0 Wait 1 minute $Minute_Counter_I -= 1 Repeat 1 times Turn light 1 on $Minute_Counter_I = random number 2 Repeat While $Minute_Counter_I > 0 Wait 1 minute $Minute_Counter_I -= 1 Repeat 1 times Turn light 2 on...repeat pattern for light 3
December 30, 2025Dec 30 The following would generate a random order of lights turning on with each turning on between 10 and 40 seconds apart. There is a 1 in 30 chance that two lights will turn on at the same time the way I wrote it, otherwise always a min of 10 seconds, max of 40 seconds and always random order. I don't know a way to stop this. If you increase your random wait time portion, you reduce the chance of two being the same. This is for 4 lights (w, x, y, z)1) put the 4 programs in a folder that is only active for the time that this is happening (ie sunset minus 1 to sunset plus 4 minutes)2) create 4 programs, one for each light, as follows but make the obvious changesProgram wIftime is sunsetor if status of light x is not some percentage that it would never be on (ie not the percent you have it set to default come on to) <the point of this status line is to use the change in status to reset the program when one of the others turns on>or if status of light y . . .or if status of light z. . . .thenwait 10 secondswait 30 second randomturn on light wdisable program w3) finally, a 5th program that re-enables all of these programs shortly before the run time.If time is sunset minus 30 secondsthenenable program wenable program xenable program yenable program z Edited December 30, 2025Dec 30 by apostolakisl
December 30, 2025Dec 30 I did think of a way to eliminate the risk of two lights coming on at same time, but it is involved. You would need 4 variables. Set the 4 to random values. Then you would need to compare the values to make sure none are equal and if so regenerate values. Once all 4 are different you use those values in the above programs. However, a wait can not be assigned a variable. You need to use "repeat while variable greater than 0" and a 1 second wait. Each repeat subtracts 1 from the variable until it hits 0 at which point the program continues.
December 30, 2025Dec 30 Author Hi there, I understand your second message - the repeat while greater than 0 - I do that now. But your first message...the randomness of the order is caused by the conditional? But if everything is currently off then I think nothing would ever activate (deadlock) ? The other thing that I was never sure of is the "IF time is sunset" - what if the other programs have to run multiple times and let's say it's now 5 minutes past sunset - will they ever run again past their first time (does the "IF time is sunset" conditional still stay TRUE if it's 1 minute past sunset ?Would it be:If (time is sunset) AND (if light x OR if light y OR if light z)Maybe not....because the "master" program is enabling them so it's close to sunset...hmmI want to think about this...you apparently have it working so I want to understand the logic (timing of events)Thanks for your response.
December 30, 2025Dec 30 Author 10 hours ago, hart2hart said:I do something similar for irrigation control so minutes per zone can be varied using inline waits. See if this helps$Minute_Counter_I = random number 1Repeat While $Minute_Counter_I > 0Wait 1 minute$Minute_Counter_I -= 1Repeat 1 timesTurn light 1 on$Minute_Counter_I = random number 2Repeat While $Minute_Counter_I > 0Wait 1 minute$Minute_Counter_I -= 1Repeat 1 timesTurn light 2 on...repeat pattern for light 3Hi, that's what I have now, but it keeps the order static (light 1, light 2, light 3) and not random. So I created multiple of these programs changing the permutation in each one, then in a main program - use a random value (1, 2, 3) (the number of permutations) then call that one of the programs based on the random value and exit. This way only 1 program ever runs. This works. But if you increase the number of lights beyond 3 then the fan-out of the number of possible permutations grows to be quite large. The key is that I want to randomly iterate over the set of lights - the order of lights activated is random. Edited December 30, 2025Dec 30 by raymondjiii
December 30, 2025Dec 30 Solution 45 minutes ago, raymondjiii said:Hi there, I understand your second message - the repeat while greater than 0 - I do that now. But your first message...the randomness of the order is caused by the conditional? But if everything is currently off then I think nothing would ever activate (deadlock) ? The other thing that I was never sure of is the "IF time is sunset" - what if the other programs have to run multiple times and let's say it's now 5 minutes past sunset - will they ever run again past their first time (does the "IF time is sunset" conditional still stay TRUE if it's 1 minute past sunset ?Would it be:If (time is sunset) AND (if light x OR if light y OR if light z)Maybe not....because the "master" program is enabling them so it's close to sunset...hmmI want to think about this...you apparently have it working so I want to understand the logic (timing of events)Thanks for your response.I wrote this program and can confirm it works. Every time I do a "run then" command on it, the 4 variables get randomly assigned a 1,2,3,or 4 with no two being the same. I used 4 here because it proves it works. But you can just as easily make it 30 or whatever.Since you already get the countdown method, then that shouldn't be an issue.Regarding the time allotted. Just figure out what the max possible is. So for example wait 10 plus some random amount between 0 and 30, then the max for each run is roughly 40 times 4 or 160 seconds. So give yourself 3 minutes.Finally, you need a program to do a "run then" on the program "Random" I wrote below. Like If time is sunset minus 10, run then program Random.Random - [ID 0089][Parent 0093]If $i.zW is $i.zX Or $i.zW is $i.zY Or $i.zW is $i.zZ Or $i.zX is $i.zY Or $i.zX is $i.zZ Or $i.zY is $i.zZ Then $i.zW = Random 4 $i.zX = Random 4 $i.zY = Random 4 $i.zZ = Random 4 Run Program 'Random' (If) Else - No Actions - (To add one, press 'Action')
December 30, 2025Dec 30 55 minutes ago, raymondjiii said:Would it be:If (time is sunset) AND (if light x OR if light y OR if light z)Maybe not....because the "master" program is enabling them so it's close to sunset...hmmI want to think about this...you apparently have it working so I want to understand the logic (timing of events)Thanks for your response.The whole purpose of having the light status in there is because CHANGES in light status will then retrigger the program. That is what you want, as soon as any of the 4 lights finishes its countdown it will change the light status and then disable itself taking it out of the mix. But when its light changes status, it will retrigger the remaining programs that haven't finished and start them over. You will start with 4 programs running, then 3, then 2, then 1 then none.If you really want to be 100% sure this works, use two status clauses for each light since the light can't be two status' at the same time, it will always trigger true.ieIflight x is not 1%or light x is not 0%The above if clause will always run true any time the status of light x changes.EDIT:Another way to do this is to use the true/false status as a retrigger. Have each program where the countdown runs to zero, run its own else clause to change it from true to false. Then the other programs will all retrigger on it.Program WIftime is sunsetor program x is trueor prgram x is falseor program y is trueor program y is falseor program z is tureor program z is falsethenwait 10 secondsrepeat while $iW is > 0$iW = $iW - 1wait 1 secondrepeat 1 timeturn on light wrun else program WElsedisable program wSo the above program would be duplicated changing out the variables as appropriate for each of the 4 (or more) lights.All 4 programs would run at sunset. The program that finishes first will become false and disable itself. The other 3 will retrigger when this program turns false. Then the process repeats starting with the 3 remaining programs . . .then 2 . . then the last one.EDIT: I actually wrote the program in ISY and copied it to here.Program W - [ID 0001][Parent 0093]IfTime Is SunsetOr Program 'Program X' is FalseOr Program 'Program X' is TrueOr Program 'Program Y' is FalseOr Program 'Program Y' is TrueOr Program 'Program Z' is FalseOr Program 'Program Z' is TrueThenWait 10 secondsRepeat While $i.zW > 0$i.zW -= 1Wait 1 secondRepeat 1 timesSet 'Light W' OnRun Program 'Program W' (Else Path)ElseDisable Program 'Program W'The above program will run at sunset (making itself true). wait 10 seconds, count down the variable, turn on its light, change itself to false, and disable itself. UNLESS, one of the other 3 programs beats it, in which case the other program will turn false before this finishes. That will re-trigger this program and it will start all over from the beginning. Edited December 30, 2025Dec 30 by apostolakisl
December 31, 2025Dec 31 Author 12 hours ago, apostolakisl said:I wrote this program and can confirm it works. Every time I do a "run then" command on it, the 4 variables get randomly assigned a 1,2,3,or 4 with no two being the same. I used 4 here because it proves it works. But you can just as easily make it 30 or whatever.Since you already get the countdown method, then that shouldn't be an issue.Regarding the time allotted. Just figure out what the max possible is. So for example wait 10 plus some random amount between 0 and 30, then the max for each run is roughly 40 times 4 or 160 seconds. So give yourself 3 minutes.Finally, you need a program to do a "run then" on the program "Random" I wrote below. Like If time is sunset minus 10, run then program Random.Random - [ID 0089][Parent 0093]If$i.zW is $i.zXOr $i.zW is $i.zYOr $i.zW is $i.zZOr $i.zX is $i.zYOr $i.zX is $i.zZOr $i.zY is $i.zZThen$i.zW = Random 4$i.zX = Random 4$i.zY = Random 4$i.zZ = Random 4Run Program 'Random' (If)Else- No Actions - (To add one, press 'Action')This is awesome, thanks!
Create an account or sign in to comment