Triggering a Morning Wake-Up Routine

I want to use RM to run a set of actions when I wake up each morning. On a workday this would be 5:30 a.m. If I've got the day off, it varies. My thought was to use a Periodic Trigger (Weekdays at 5:30 a.m.) with a Conditional Action using a virtual switch (TRUE if switch is ON, FALSE if OFF). That way I could use a dashboard tile to turn the switch off and prevent the routine from running. But on a day like tomorrow (Friday but don't have to work) I would want to trigger the routine using a button at whatever time I wake up. WIth the IF condition noted above, pushing the button would't cause the routine to run becuase the switch is still OFF. Is there an elegant way around this?

What I really need is an expression-like statement in the trigger: Button OR (Schedule AND Switch). Is something like this available?

UPDATE: I suppose I could write a second rule for the button. Trigger: Button Push; Actions: Turn switch ON, run Rule1 Actions, Turn switch OFF. It just seems like it should be possible to accomodate both scenarios in the same rule.

I had been using a keyword search on my Google Calendar with iFTTT integration so if it said "day off" it would turn on a virtual switch and make weekday morning automations run like the weekend however I still don't always get up or go to bed at the same time so it still wasn't ideal.

Last week I completed setting up and automating a bed presence sensor for my wife and I. It's great as I don't have the alarm arm to night mode until we have both been in bed for 5 minutes, that also turns off all the lights and locks doors. In the morning it disarms 5 minutes after the first person wakes up and turns on a few lights then after we are both up for 5 minutes it opens the bedroom shades.

If you use your phone as and alarm you could trigger off that through Tasker or iOS Automation’s.

I have a series of motion sensors i walk through to activate my day mode, so it only happens when I get up. Landing motion wait for livingroom motion, wait for kitchen motion, then day mode.
It also only looks for a time window 6am till 10

These are all great ideas, but I was hoping to find a simple solution within RM that didn't require additional software or hardware.

Why can't you do what you originally wanted, create a button for the dashboard, and use that in addition to the on/off switch to run the routine?

You would need to have both as triggers in the rule, and you would just have a touch more logic (maybe an OR or an AND) in the rule when you get to what you want to happen (actions).

I am not the best rule writer, but maybe we could come up with something. The best thing you could do is "sketch" out how you want this to work. Come up with a rough draft (ignore rule machine for a second here) of what, when, and how you want this to look and I think we could get you up and running.

Is this about right?

  • What - turn on bedroom light, and bathroom light.
  • How/when - time of day. Weekdays. 5:30 AM
  • Exceptions - button on dashboard pressed, manually run rule. Also switch on dashboard turned off stops rule.

@neonturbo I took your advice just sat down until I figured it out. It took a bit of trial and error, but here is where I landed so far.

Triggers are still the normal M-F @ 5:30 or pushing a virtual button (button 1, in this case). However, played around with variables, device states, and conditions until I hit on a combination that seems to work.

First, I created a local boolean (bool1) with an initial value of FALSE.

Then I evaluate my conditions to see if the rule should run or not. My virtual button stores the value of the last button that was pushed. If that button was #1, bool1 is set to TRUE. Basically, this condition will ALWAYS be true if the button is what triggers the rule. However, it may also be true in other cases...more on that later.

If the first statement is FALSE, the rule evaluates the second condition. This is a virtual switch that I can put on my dashboard. Switch ON will also set bool1 to TRUE.

The next portion of this rule a simple IF-ELSE that writes a log entry to let me know if the conditions are behaving as expected.

And at the end, there are two actions to "reset" the conditions of the rule. The first is fairly self-explanatory and just resets bool1 to FALSE. The second part needs a bit of explanation.

The state variable "pushed" of vButton stores the value of the last button pressed. Maybe it was 2 seconds ago...or maybe it was 2 weeks ago. So if I press button 1 on Sunday when I wake up at 7 a.m., the value of "pushed" will still be 1 on Monday. If Monday is a holiday and I've turned off my "Workday Alarm" switch, the first portion of the IF statement will still evaluate as TRUE and the rule will run. So, I added an action to change the "pushed" value to 0. That means that the first IF statement will only result in a TRUE condition if the button has just been pushed.

A possible downside is that the rule could be triggered and run multiple times in one day. One work around for this would be to move one or both of the "reset" actions at the end of the rule into a separate "End of Day" rule that resets things at midnight. I have a rule like this already but decided to keep this logic here for now. I can move it later if I need.

Right now the rule is just making log entries so I can evaluate it over the next couple of days. If it behaves, I'll start putting in some real actions.

[UPDATE]: As I've been thinking about this, I think using a virtual switch instead of a button for a manual trigger would be a better fit. Then I could evaluate the switch position for the first IF condition and simply turn it off at the end of the rule. The logic seems cleaner in my mind and it would have the benefit that I could trigger the rule from Alexa by turning the switch on. As I said, I'll see how it works over the next few days and post an update.

same here

and a 2nd rule to unlock certain doors on mode change

I had to think about this one. I would have done this differently. I don't think you need anything so complex as what you show.

Why not something like this? Virtual switch is your Run/Don't run, and Virtual Buton is the manual trigger to run rule. Buttons automatically reset themselves, so no problem there.

  • At 5:30 AM on weekdays, the rule will run from that trigger.
  • If you turn dashboard (virtual) switch on the rule does not run.
  • When dashboard (virtual) button pushed, the rule will run if you are between 5:30 and 1:00PM.
  • Reset the virtual switch to off via rule at 10 PM to get ready for next day.

I don't think this will work as intended. Use Thanksgiving holiday as an example.

Day of week is Thursday, but virtual switch is ON because I don't have to get up for work. At 5:30 the rule is triggered and evaluates the first condition as TRUE... rule exits. I wake up at 7 and push the button. Again, first condition evaluates as TRUE and rule exits. Am I reading it properly?

Also, the timing of your reset could be an issue. If I disable the next day's routine (turn virtual switch ON) at 9:30, it will reset at 10 and run at 5:30 anyway (assuming it's a weekday). Is that right? Easy fix is to just omit the reset for this switch. That way I wouldn't have to disable it multiple times if, say, I took a week off of work.

Although I am excited to see the "exit rule" action. I didn't know that existed... could be useful.

I did re write the rule using a virtual switch instead of a button as i noted above. Here is the current version.