So in resume this piston turns on the light in the best room at 6h02 AM during the week and at 9h30 AM during the weekend if the location mode is night.
My issue tho is i do not want that piston to run during my vacations or during holidays.
Next holidays for us are
May 21
June 25
July 2nd
September 3
And our vaction are from June 29 to July 15 inclusively.
So I made the only when to filter the dates, is this a good way to do this or is there a better way to do this?
Could you just create a virtual switch called vacation. Then set the piston to not run when vacation switch is on.
Then it would be usable and you wouldnât have to edit it any more. Just turn on the switch.
You could possibly get the Gcal app set up. Have events in your Google calendar that say on vacation, or vacation mode, or this switch. Grab those events in Gcal then use Webcore to say when the gacal event switch is on donât do lights. Similar to a virtual switch you toggle yourself.
Not sure this will work⌠What is triggering the code for lines 19-35?
I see the triggers/timers for the âevery day atâŚâ but nothing for the first block of code.
I agree with this as an overall plan for any pistons that may need to be adjusted due to temporarily changing schedules, etc. I write pistons that need it, to use virtual switches or variables that either allow or disallow certain actions. You could also call them override switches or flags.
For example, I have many of my lights throughout the house running on a mixture of schedule, lux and motion. Each of the controlling pistons looks at the state of a âPrevent Lights Flagâ virtual switch. If that switch is on, no automations run. I can turn that switch on manually, by voice or programmatically. For Halloween, I have another piston that turns the âPrevent Lights Flagâ switch on if no one is home on Halloween around sunset. This lets trick-or-treaters know that weâre not home to hand out candy. Then, if we come back home or at 22:00, the flag switch is turned off so that the automations can restart.
So, in short, pistons automate and virtual switches or global variables allow override capabilities.
BTW, as kinda mentioned above, an added added advantage of virtual (simulated) switches is that theyâre voice controllable via Alexa or Google Home too.
This is a section of one of my pistons that calculates the time to turn off the Christmas lights based on certain dates.
In your case, you can change the dates, add as many others as you like and also make date ranges too. Then instead of setting a time variable, have the piston that has these statements in it either pause (or not) your piston above.
It ran because there are no dates between the 21st and 21st. If you set it to âbetween the 21st and 22ndâ it would not run on the 21st and it would resume on the 22nd.
Using âbetweenâ statements you have to imagine there is an âat midnightâ suffix on your date. Then itâll work the way you want it to.