Would like to change the state of a switch based on the odd/even numeric sequence of the days of the year.
For example, on Jan 1 (Day #1 ) an odd day, I would like that switch ON for that entire day until crossing past midnight when I would like it to go OFF.
In this particular case I would be changing a Virtual Switch which I would use in one or more other applications or rules.
I have some medication I am meant to take on alternate days, but because the dosage regime wasn't critical I actually take it on 4 set days of the week. I guess the criticality of irrigation interval might depend on how sensitive your plants were.
It sounds like you need a daily toggle, not the actual calculation based on date. How about making a virtual switch with a rule that toggles it every day at sunrise, then using the state of that switch in any other logic as needed?
It does indeed. Thanks for that. You consistently do great work...
But refer to my now deleted discussion about where the flip a new user should choose to learn & do the myriad of things one wants to do; paying particular attention to the concern about the support and longevity of any one of the more helpful yet functionally complex community add-ons to HE.
With ALL due respect, as I continue to use some of what you've written
I suppose it could. The system would have to be down when the trigger point was crossed. But I guess the same could come about if a driver or app trigger happened at the same time. Either way, the transition would happen once per trigger (midnight, or sunrise, or whatever). The advantage of actually calculating it rather than just toggling would be that it would eventually 'correct' itself in phase, if that really mattered.
Just to make sure... using odd and even days of the month will also cause issues at the end of every month with 31 days in it... You'll have two ODD days in a row... 7 to 8 months of the year (depending on leap years)
Thus, I like @tomw's idea of simply toggling a virtual switch once per day. It should provide a much better 'every other day' result, if that is important.
Ah, good catch. Depending on the power supply, etc, reliability for your hub, this one seems a lot more likely to bite you regularly than an occasional hiccup on toggling.
No problem, I’ll add a switch to handle the day 365 to day 1 issue either tonight or tomorrow - it’s a simple matter of reversing the even-odd switch behaviour for the year.
Had to rebuild a broken/corrupted rule today that uses your Even/Odd Day switch (got myself into a bad edit pickle and couldn't get back in to the rule past a reoccurring error I somehow introduced, nothing to do with your stuff).
It's been awhile, I had forgotten how this was a simple yet elegant solution.
Want to reiterate that this was a REALLY helpful add to HE and your ability to produce this kinda stuff, seemingly at the drop of a hat, is appreciated.