Holiday Lights w/ Variable

Is there a way to create a rule to define a variable to indicate which scene to turn on based on a date and then from a separate rule call that variable to turn on the scene without having to recreate the if statements to define the date periods?

Rule 1
If A set variable to "Christmas"
or if B set variable to "New Years"

Rule 2
At Sunset turn on Variable (which would be either Christmas of New Years scene)

It needs to be two rules because as part of Rule 1 I am also setting a Automation switch to ON so other automation don't run.

I have it working but basically repeated the if statements in both Rule 1 and 2 and was trying to see if I can somehow just define it in Rule 1 to determine which scene to execute in Rule 2 without recreating the If statements

Yes, you can create a Global Variable string and easily set it using a rule based on dates, all in Rule Machine. I use a simpler "on vacation" type of boolean. But I like the idea of an overall one like that so I could switch my Halloween set to my Christmas set, etc...

Any pointers on how to construct the string, that's the part I'm not sure how to proceed with.

So... Just my thinking, but I would:

  1. Go into Rule Machine
  2. Select the Create, Set or Delete Global Variables table.
  3. Select the "Add Another Global Variable" button.
  4. Enter a name for the new variable (since I want something similar I am naming mine "Time Of Year").
  5. Once the name is entered, hit the Enter button or click on a blank space (do not navigate away from the page) to get the field for "Variable Type for X Name" dropdown.
  6. Select the type, I am figuring on String.
  7. Set initial value of the string. I set mine to Normal (not sure all the possibles, but will definitely have things like Vacation, Halloween, Christmas...).
  8. Select somewhere and you can see the variable added to the table. From there you can just use it in your Rules to configure it how you want. Or to check on it as a condition for other Rules.