Here is another piston I have that uses the global variables from my (Astronomical Data API) piston:
It shows how you can use the globals to take actions that are more refined than just sunrise and sunset.
/* Turn on living room lighting at sunset. */ starts at sunset but doesn’t just turn on those two lamps, it starts them at 10% and ramps them up to 100% evenly based on however long it takes to get from sunset to dusk. The time automatically adjusts based on the time of the year rather than a routine that would always take a set number of minutes.
_/* Close the master bedroom shades when it gets dark. */ automatically closes the roller shades in the bedroom (they appear as Dimmer 27 and Dimmer 28 here) when it’s actually dark rather than a set time of day. I’ll take all the sunlight I can. As soon as it’s actually dark out (astronomical_twilight_end) they close for privacy.
BTW – A picture is worth a thousand words so here’s a picture that helps show the different twilight levels and why I have things set up this way.
Enjoy!