The post about piston operating bottom up mostly makes sense.
So the piston state business is what was hanging me up. I’m not even sure what the purpose of it was for. The example I robbed this code from was a lot more complicated than I needed. Multiple switches and ways to override.
I imported your example and set the time window for a near time and the on/off delays short enough to watch. The contents of the async with statement will continue to loop as long as the time is within the window above it seems. Actually not my intended behavior, but makes sense since the original example was to turn lights on and off at random intervals.
I just want to turn them on near sunset and off near 10:00pm. (Near to allow a little randomness.)
I feel like there’s a much easier way to accomplish this.