Rule Help Needed Please

Could someone help please. I'm not good at writing the If Then rules other than the basic ones. I want the coffee maker to turn on/off at one set of times M-F and another set of times S/S when mode is Day and notify our phones/speaker. I could write two separate If Then rules as I did for afternoon and evening but wanted to combine the morning rule into one rule. The first part of the rule M-F works but S/S doesn't. I added an Else and another End If. Doesn't work. I tested with Else disabled then End If disabled then with both disabled and the S/S didn't work so triggered both back on. What am I doing wrong?



1 Like

The very last If statement has the Off: Bunn my cafe before the wait until 11:30. So the off happens immediately.
You have away too many conditions in your If statement, it makes your rule way to complicated.
May I suggest:

Change "Bar spot 1" to "Bunn My Cafe"
Change "Kitchen Sonos" to your speakers.
I don't believe you need the Mode is day at all but I put it in anyway.

2 Likes

My guess on the mode would be so it doesn't trigger when Mode is Away.

1 Like

Good point

Thanks so much! I will make the changes. Appreciate your help.

I just wanted to add that automating your coffee is totally rad. Carry on!

Remove the first END-IF before the wait for 11AM. that END-IF removes the conditional, so everything else is happening. Make it something like:

IF (Mode is Day AND Day in [M-F]) THEN
	On: coffee
	Notify all the stuff
	Wait for event: time is 11AM
	Off: coffee
ELSEIF (Mode is Day AND Day in [Sat-Sun]) THEN
	On: coffee
	Speak
	Wait for event: 1130AM
	Off: coffee
END-IF

(you can remove the time since it's part of your trigger)

Alternatively if you did want to make your conditions a bit more easier to manage, you could do:

IF (Mode is Day) THEN
	On: coffee
	IF (Day in [M-F]) THEN
		Notify all the stuff
		Wait for event: time is 11AM
		Off: coffee
	ELSEIF (Day in [Sat-Sun]) THEN
		Speak
		Wait for event: 1130AM
		Off: coffee
	END-IF
END-IF

This accomplishes the same thing, but if you ever did want to run it while the mode isn't Day, you won't have to change multiple conditions, just the first one

Hopefully you've got this working with the comments above, but i just wanted to help with some general tips...

Sometimes separate rules is the best way. This is especially true (for me) when I've tried to have multiple triggers and then use IF systems to try and figure out which trigger actually initiated the rule. Bruce actually steered me this way a few years back. His philosophy is (IIRC) is to try using the Basic Rules app for everything, and only move on to Rule Machine when necessary.

In your first post, your second conditional is an ELSE followed immediately by more IF statements. This is normally where an ELSE-IF is used.

If there are only two possible outcomes for any given evaluation, IF and ELSE (with no conditions) are sufficient. The IF statement includes any conditions you choose to evaluate and the resulting actions to execute if the conditions are true. The ELSE statement is intended to cover every other possible outcome and typically should not include any "nested" IF statements.

If your evaluation has more than two outcomes, you should start with an IF statement and subsequent evaluations should be ELSE-IF statements. ELSE-IF is functionally identical to IF, except that proper structure requires that the first evaluation is an IF followed by the necessary number of ELSE-IF statements. It is also important to understand that there will be only one statement that will be evaluated as TRUE. If the conditions of multiple statements are satisfied, only the first one evaluated will be acted upon. Evaluation of the entire IF-ELSIF-ELSE stops with the first TRUE evaluation.

Technically, neither the IF nor the IF-ELSEIF requires an ELSE at the end. If your desired ELSE action is to do nothing, or you've covered every possible outcome with ELSE-IF statements, you can skip the ELSE. Many times I include an ELSE with an action to create a log entry just in case i missed something in my evaluations. However, you should always include a single END-IF to close things out.

NOTE: "Simple Conditionals" in Rule Machine are a special case and are "self-contained." There can be no following ELSE-IF or ELSE statements, and END-IF is not used. In traditional form, a Simple Conditional would look like this...

IF (TRUE) THEN
	Do stuff
ELSE 
	Do Nothing
END-IF
2 Likes

Thank-you for explaining this for me. I'm trying to clean up my rules as well as make some of the complicated ones more efficient. The learning curve with Rule Machine is a bit steeper for me but I'm determined to get a few of those rules working!

Expensive but dumb always on coffee brewer that make excellent coffee. It's always using hydro even in sleep mode so needs a bit of smartening up :wink:

1 Like

What brewer? I'm looking to up my coffee game... really need a decent grinder first...

1 Like

I got myself a Niche Zero grinder a few months back and really like it. It only grinds enough for a double shot but I like that as I can switch between different coffees/grinds easily between shots. It made a larger hole in my wallet than I wanted

3 Likes

damn! that's aerospace level grinding!

:laughing:I know. I watched some YouTube reviews and read all the info on their website and had to have it. I’m a salesman’s dream

1 Like

Years ago, I considered anything besides my braun grinder overkill. After talking to a barista that could make magic shots, I understood that consistency and uniformity can make a HUGE difference in the taste of an espresso or coffee. You Sir, have the Ferrari of grinders! Well done.

1 Like

I'm using a Bunn My Cafe single brew system and Cuisinart grinder.

1 Like