Piston restriction between two dates Black Friday and New Years Day


#1

1) Give a description of the problem
I’m not sure who to restrict my piston so that it only executes between Black Friday and New Year’s Day. I’m sure this is going to have to be some kind of expression but I don’t have the first clue how to start it.

I know it’ll always be the fourth Friday of November but I’m not sure how to write it. I also want it to end so that the piston doesn’t execute past 1/1/20xx. I’d like it to be agnostic of the current year. I assume this is easy enough with $year.

Also, is my piston configured efficiently to mirror two switches? It works just fine for both on and off no matter which switch is changed. A smarter set of eyes is always helpful. I was also considering putting both switches in a variable and if one switch changed, the one that didn’t would take the first one’s action (on/off). I wasn’t sure how to write it so I just went with (if switch(if true{change}) elseif switch (if true{change}))

2) What is the expected behavior?
Restrict piston to only execute between Black Friday and New Year’s day. The piston will mirror two switches. These two outlets have Christmas lights attached during the time i want this restriction enforced. Outside of these dates, the outlets have different things attached and I don’t want them mirrored.

3) What is happening/not happening?
The action in the piston executes as desired. I need help designing the restriction.

4) Post a Green Snapshot of the pistonimage

5) Attach any logs (From ST IDE and by turning logging level to Full)
‘No logs required at this time’

REMOVE BELOW AFTER READING


#2

I’m not sure how to write “fourth Friday of November” into an expression… as a workaround I would just use a global variable (I called mine @BlackFriday).

Have one piston to set @BlackFriday to true / false at the right time:

And then reference @BlackFriday in whatever piston you like:

IF @BlackFriday IS True
Then
Do something
Else
Do something else


#3

Thanks. Are two pistons required for this? Would it be possible to have the IF / THEN statement below this and use a local variable? Either way is fine with me but I’m curious if combining them will be a conflict or have some other undesirable consequence.

On another topic, is it possible to run an if / then in the evaluation console? I tried and it help telling me ‘if’ isn’t a variable.

Thanks again Robin.


#4

See this topic:

(Changing from Thanksgiving to Black Friday should be simply changing “greater than or equal” to “greater than”).