I have two different applications within one piston that I think using list variables will streamline the coding. This is in my front exterior lighting piston:
Application Inquiry No 1
The first item is in the assignment of lighting colors to individual bulbs. I have 7 hue bulbs across the front of my house and normally they are set to 3100k (100%) in the evening and 2700k (70%) overnight. For holidays, I manually change these to colors in the Hue App. I would like to fold this into my Front Exterior Lighting Piston.
The first item is the actual assignment of colors. Currently, I have 7 variables for light color, one for each light and currently setup like this:
String Lighting_Color_1 = â#DD1FFâ
String Lighting_Color_2 = â#DD2FEâ
String Lighting_Color_3 = â#DD3FDâ
âŚ
with Front Garage Right do Set Color to {Lighting_Color_1}
with Front Garage Left do Set Color to {Lighting_Color_2}
with Front Porch Light do Set Color to {Lighting_Color_3}
âŚ
What I would like to see is can I instead make this a single string list type variable called Lighting_Color_Set and set it equal to (#001AB, #002AC, #071FD, etc)? I could then seasonally change this variable manuallyâŚor do it automatically (see below). My question is then within the Action statements, how do I retrieve the item in the list?
String Lighting_Color_Set = â#DD1FFââ#DD2FEââ#DD3FDâ
âŚ
with Front Garage Right do Set Color to {Lighting_Color_Set [1]}
with Front Garage Left do Set Color to {Lighting_Color_Set [2]}
with Front Porch Light do Set Color to {Lighting_Color_Set [3]}
âŚ
Is this the correct syntax and would you all agree this is more streamlined?
Application Inquiry No 2
Same piston (or maybe its own), the actual assignment of the colors in the lighting set, these colors would be assigned by holiday. So I will need a string variable for holiday (ie âChristmasâ, âMardi Grasâ, âValentinesâ, âEasterâ, âFlag Dayâ, âHalloweenâ and then âNormalâ).
String Home_Holiday = âNormalâ (perhaps this needs to be global, ânormalâ by default)
If Time Happens Daily at $midnight (trigger)
If Date is between 01/01/2018 and 01/05/2018 Then Set @Home_Holiday as âChristmasâ
If Date is between 01/06/2018 and 02/13/2018 Then Set @Home_Holiday as âMardi Grasâ
If Date is 02/14/2018 Then Set @Home_Holiday as âValentinesâ
If Date is between 02/15/2018 and XXXX Then Set @Home_Holiday as âMardi Grasâ (most years spans past Valentines, just not this year)
If Date is between 03/30/2018 and 04/01/2018 Then âEasterâ
If Date is 05/28/2018 Then âFlag Dayâ (memorial day, same color theme)
If Date is 06/14/2018 Then âFlag Dayâ
If Date is 07/04/2018 Then âFlag Dayâ (independence day, same color theme)
If Date is between 10/01/2018 and 10/31/2018 Then âHalloweenâ
My thinking here was instead of having nine different If Then Else ElseIf End statements, I could some how simplify this with two lists fields. The first list would be the first calendar day of a holiday and the second list would be the name of the holiday. I would use the current day to return the list position and this use that list position to obtain the holiday name and assign the variable. I can do this very easily in Excel, but no idea how to here. Indexing exact dates would be easy, the question becomes how do I poll/index 12/5/2018, which is clearly falls in Christmas. I would need to search the list with an âapproximate matchâ or last date less than current value some kind of way.
Any ideas?
The color string list above would then be populated based on the holiday variable.
And finally, the reason I want to assign a holiday variable based on date, then separately assign the light colors based on the holiday variable is to just organize the piston for annual updates to change the dates since Mardi Gras and Easter float. I donât have to go through all the color assignments to update these dates. Then if I ever want to tweak the colors, those are all in their own section, instead of mixed in with date assignments.
As stated before, I may do this in its own separate piston and create the variable globally - I just prefer not to as they wont be used anywhere else in my house.
Thanks!