[Note: edited Oct 2 to prevent coffee maker from turning on when we return from a trip. edited Nov 21 to use new Simple Automation Rules 1.1 released in the Hub 2.2.4 update]
Thought I'd describe a fairly simple automation that had to work reliably in the face of varying situations. Comments (and improvements) welcome.
Problem: My spouse likes to have her coffee brewing for her when she returns from her morning walks.
Challenges:
- She doesn't always take a walk, and if she does, her return time is unpredictable. She also leaves and returns for other chores, usually after her walk, and the coffee maker should not turn on for those returns.
- She may also brew coffee in the evening if friends come over. Of course, in these COVID-19 days, that's not happening, but I have to accommodate that in the future.
- In the evening, she sets up her coffee. If the wall switch were on, this would start brewing, which she does not want to happen.
- She wants things to "just work". Any extra steps added to her current process would be frowned upon and she has no patience to either detect or respond to automation failures.
Approach: I spent a week adjusting the automation without actually connecting it to the coffee maker so that I could observe its behavior before subjecting my spouse to it. This week was critical to success.
Materials:
- A very dumb cheap coffee maker that only has a mechanical on-off switch. This way, I could completely control it using a switched outlet. The switch is always left on (except in special circumstances—see below).
- A plug-in zigbee outlet that has a readily-accessible manual on/off button as well (and button is lit when it is on).
- A virtual switch in HE called "Virtual Coffee Done Today".
- A presence sensor (set-up not addressed here).
Simple automation rules
- Turn on Kitchen Coffee Maker when Spouse arrives, turn off after 65 minutes. Restrictions: only between 7 am and 11 am. Switch to disable Simple Automation Rule: Virtual Coffee Done Today. (Wow! Simple automation rules can do a lot of things if your needs match what it offers.)
- Turn off Virtual Coffee Done Today at 11:05 am, Turn on at 4:10 am. Only when Mode is Away, Day, Evening. (See discussion below—the 11:05 off resets the trigger for the next day and the 4:10 am on is a sneaky way of disabling the auto on when we're returning from a trip.)
Rule machine rule
- Mark coffee done and turn off coffee maker if it was turned on at wall switch.
- Trigger event: Kitchen Coffee Maker turns on.
- Actions to run:
- If (Time between 7:00 AM and 11:00AM) On: Virtual Coffee Done Today
- Cancel Delayed Actions
- Off: Kitchen Coffee Maker --> delayed 1:05 (cancelable)
How it works:
- If spouse leaves and returns in the morning, the coffee is brewed by the simple rule and the coffee done switch is set by the rule machine rule, preventing further responses to arrival status changes. The outlet resets to off after a reasonable time. This rule is only active 7-11 am, so arrivals outside that time range won't trigger the coffee maker. The coffee done switch is reset to off at 11:05 am, to be ready for the next day.
- If spouse doesn't want to take a walk, she presses the button on the outlet, starting the coffee, and the rule machine rule prevents further responses to arrival status changes. The outlet resets to off after a reasonable time.
- Likewise, if coffee is desired later in the day, the outlet switch is used to start brewing, and it resets to off quickly enough that she won't be setting up for the morning coffee while the outlet is on.
- The trickiest situation is when she doesn't want the coffee to start when she comes home after a walk (e.g., about to run a quick errand before breakfast). She (or I) has to set Virtual Coffee Done Today to on in the dashboard sometime after 11:05 am the day before (see simple rule #2). Then unset the Virtual Coffee Done Today when we want it to respond to the next return from away.
- Yes, the coffee maker is turned off twice if it is started by the simple rule: once by the simple rule, and a second time by the rule machine rule. I did this so that if I changed things later about how the rule machine rule runs, I wouldn't forget to turn off the coffee maker. The duplication seems harmless.
- Simple rule #2 doesn't run when the mode is Night. So, if we're at home, the rule does not turn on Virtual Coffee Done Today at 4:10 am. But, if we're away, the mode is Away and the switch is turned on. This is how we prevent it from triggering the coffee maker when we return from a trip.
Happiness ensued.