I’m trying to turn on a virtual switch based on a date range. Originally, I had a rule that turned the switch on from the 4th Friday in November, then another rule that turned the switch off starting with the first Saturday in January. The issue is that my Pi rebooted and the switch then turns off, so my rule won’t trigger because the switch is now off.
Is there a way to test if a date is between x and y, turn on a switch?
I’ve searched for “between time cron” to see if I could find examples and couldn’t find anything that fit my scenario.
Here is another way to do this: You have to make a new item-switch, which is powered on with a cron job on the day your timerange starts and powered of at the end of your timerange.
This is what I have today. It turns on after Thanksgiving and then turns off the switch after the first Saturday in January. The problem is that we had a power outage and it rebooted my Pi, so the virtual switch turned off.
I manually had to turn the switch back on, but I was trying to find a more permanent way to set the switch.
Then set persistence with restoreOnStartup on this virtual switch-item and it works even after a power outage.
The only way, when you can get an error in this case is, when the power outage is exactly at this moment the cron-job rule should fire. In this case your switch will stay with the old value, because the cron-job rule only fires at exactly the defined time.