ShuffleWeekdays (for timers) #12743
Replies: 1 comment
-
I have implemented this feature for my own use. Syntax of the imlpemented command is:
meaning that all weekdays except Friday should be shuffled for timers 1-3,5,7-9 (this form of timerlist as a "bitmask" simplifies argument parsing). There is now an additional timer mode "previous" which indicates that this timer should be kept together with timers of the previous day. Use this if you want to switch lights on at 23:50 and off at 00:10. The code is not ready for pull, it still needs some refinement, especially presentation in the webserver. tasmota/i18n.h | 1 + |
Beta Was this translation helpful? Give feedback.
-
If you use timers for presence simulation , you might want to change your schedules from time to time. Shuffling weekdays in timers can break the weekly pattern and hinder schedule recognition by observers.
Instead of maintaining a weekday permutation status for each timer, I suggest a command that effectively changes the xtimer.days field. This lets users see the permutation in the User Interface and reduces code complexity.
ShuffleWeekdays <timerlist> <weekdays>
where
<timerlist>
takes the form of a comma-seperated list with ranges allowedand
<weekdays>
takes the form of the<Days>
field in the JSON payload (SMTWTFS with 0 or - exempting that day from the shuffle, everything else enabling shuffle for this day)The command would randomly select a permutation of all weekdays enabled in
<weekdays>
and then apply this permutation to all timers in<timerlist>
. Shuffling On/Off pairs (or any other group of timers) in a single command keeps their weeksdays identical by applying the same permutation to all of them.To change your Mo-Fr schedule, you would create a
Rule<x> ON Clock#Timer15 DO ShuffleWeekdays 1-4 -MTWTF- ENDON
and let Timer15 fire this rule on Sunday. In general, it is a good idea to not include the current day in the shuffle. If you need to shuffle all 7 weekdays, you could do so with two rules on different days.Another modification with possibly low memory impact could make this functionality even more useful by allowing On/Off-pairs (in general: any group of timers) that span midnight to belong to the same weekday, and thus keeping this pair or group together. Timer.time is encoded in 11 bits but currently uses only values 0-1439. If we allow values 0-2039 and add some logic to TimerEverySecond(), we can encode Tuesday 09:59 as
Timer.days == 0b1000000 && Timer.time == 2039
. This will trigger on Tuesday, but the timer will be shuffled along with other timers on monday.A minimum effort implementation would allow hours in the range from 0 - 33 in the timer JSON. In order not to confuse users to much, the web interface presentation can be different with a checkbox "execute on following day" and restricting hours to 0-9 if this is checked.
Beta Was this translation helpful? Give feedback.
All reactions