Turn off lights one by one after X minutes


#1

Here’s an exciting challenge.

My piston does turn the lights off after 1 minute goes by (1 is for testing instead of waiting 15), but the challenge is to have them cascade off when X minutes goes off for that light. I tried switch stays on for 1 minute, but it seems to turn off all lights, even if they were turned on at 45 seconds. I believe it’s due to the fact that the STAYS is intended as IF ANY LIGHTS ON IN THE PAST 1 MINUTE, as opposed to IF A LIGHT WAS ON FOR AT LEAST 1 MINUTE. This way as each light reaches one minute on, it will be turned off, then the next one after it too reaches one minute.

My IF does remember the matching lights, but if I turn on a light after 45 seconds has passed, it will add that new light to the variable since it’s also STAYED ON IN THE PAST 1 MINUTE. :frowning:

I have a feeling this would actually be some kind of complicated loop, instead of a simple STAYS statement.


#2

What exactly is it you’re trying to do? Let’s stick with the 1 minute for your test, then we can roll it up to 15 after it’s proven out.

If Lights 1, 2, and 3 are turned on, leave them on for one minute then turn them off? For example, light 1 is turned on 1:00:00pm, light 2 at 1:00:20pm and light 3 at 1:00:30pm.

You want them to turn off at 1:01:00, 1:01:20, and 1:01:30, respectively?


#3

Holy crap… I think I got it.

It works and switches off in the order I switched stuff on. If the last light turns on too close to the end, it’ll take a bit longer than a minute, but it does turn off. It seems to loop around for a least 2 minutes, but then they start turning off at the allotted time intervals as when I turned them on.

More tweaking, but the basics are there!


#4

The short times are for testing purposes only.

Sorry, I wasn’t ignoring you @michicago… I was in a “coding moment”. LOL


#5

No worries, the “for each device” loop is what I was going to recommend.

Good work!