I have a couple of switches that I need to turn on at different times based on days of the week and I have a virtual switch that overrides those days. Here's the setup: on M, W, F they need to come on at 6:45; T, H at 6:15 and on the weekend at 7:30. However, I have a virtual switch that I call Later that will override all days to 7:30.
I've done this with three simple automation rules that run at the specified times on the matching days, but the first two don't execute if the Later switch is on. The one that runs at 7:30 runs on all days.
I did this fast and dirty with the multiple automations but I would like to combine this logic into a single Rule Machine rule. However, got stumped as how to do this with the Later switch. Any ideas would be much appreciated.
There is no advantage to using a single rule, in fact it just complicates things. I would suggest using two rules that both have a Required Expression based on the state of Later. One runs when Later is on, and one runs when Later is off -- each with the appropriate times in the triggers.
Here's a single rule option
When time is 6:00 AM
Actions to Run:
IF (Later is off AND NOT Day in [Sat, Sun]) THEN
IF (Day in [Mon, Tues, Wed])Wait for event: When time is 6:45 AM
IF (Day in [Thu, Fri])Wait for event: When time is 6:15 AM
Wait for event: When time is 7:30 AM
On: Switch1, Switch2
Thanks so much for this Code, bravenel might be right about simplicity, but I like having all the code for the related actions in one spot. It looks solid and I've added the single rule option that you suggested.