Christmas Lights and Auto Flag


#1

This is my Christmas Lights Piston. It contains several code blocks - each performing different functions.

One the things I use throughout my pistons is the use of ‘flag’ switches. Pistons check against those flags to determine if they can run. In the case below, the “Xmas Light Flag” (Simulated Switch - #22 in this piston) is used to allow/disallow this piston - and therefore, the Christmas lights to run or not. I could have accomplished this with a variable but decided to use the ‘Flag’ because it gave me the added capability of manually controlling the piston and lights.

One of the things I was happy to find was the Java information here: [https://docs.oracle.com/javase/tutorial/i18n/format/simpleDateFormat.html]

This allows a very nice way to calculate dates, times, etc. and I’ve used it in several places in this piston.

  • The Auto Flag Block activates the Flag on Thanksgiving Day and deactivates it on 3 January. I can manually override it if desired.
  • The Set Lights Out Time Variable Block calculates the time the Christmas lights will go off - based on date
  • The Morning Block and Evening Block turn the Christmas Lights on and off appropriately based on date and time.

Hope this piston and some of it’s various parts can help someone.