Help request for 'Good Morning' once a day

If I understand your situation correctly, you are trying to use the variable SaidGoodMorning to ensure that the action only happens once per day. You may need two rules. One rule could trigger at 7:30 and simply set the variable to false. The other rule would trigger at either 8:00 or your motion criteria. The actions of the second rule should have an if statements that tests a combination of things:

  1. SaidGoodMorning is false
  2. time between 8:00 and 10:00 and
  3. your motion criteria

Between the if and the end-if, you should do you good morning action and set SaidGoodMorning to true.

In the context of April's input can you elaborate?

Is the trigger the same? Do I add the boolean as another AND? Were would I initialize the boolean the very first time?


Triggers can never be AND because it would only trigger if they both became active at the exact same time which is virtually impossible.

I think if you take April's suggestion and say IF (Kitchen Multi active AND Bedroom Multi active AND Time between 8am - 10am then....., it would trigger when you want.

Then, do what @aaiyar suggested or this will run every time that both sensors are active between 8am-10am and I assume you only want it to run the 1st time.


I follow. I was wondering if I needed a second rule to set the this variable as a global.

Edit - changed the trigger to Kitchen motion, which I now get. Next is to add the variable part. Thanks all

Clicking "Run Actions" will not do anything right now with your rule because your IF (aka conditional) evaluates to false, so it will skip the contents (BTW, to have proper syntax, I'd close this with an END-IF, though at the end of the rule RM will infer one for you regardless so it doesn't matter here). Do you need both kitchen and bedroom motion to be active at the same time? If you normally walk right from one to the other and they have a timeout that's long enough to do this--for many it's 30-60 seconds by default--longer for some other sensors, then this should work, but it's worth asking.

In that case, I'd keep something like what you have. Assuming kitchen is the second sensor to become active, two rules like this should work:

Rule 1

Trigger Events: Motion Kitchen active

Actions to Run:

IF (Motion Master Bedroom active AND
 Motion Kitchen Active AND
 Time between 8 AM and 10 AM AND
 Private Boolean is True) THEN
   sayGood Morning() on Echo - Rick
   Set Private Boolean False (for this rule)

Rule 2

Trigger Events: Time is 7:59 AM

Actions to Run:

Set Private Boolean True: Rule 1

To give credit where due, the second rule is just what @aaiyar suggested, and the first is similar to what you and April already came up with, just with the addition of using Private Boolean to "track" this and resetting that variable in the morning, which you need the second rule to make work fully.

Thanks all, I'm pretty sure I got it now! I have a 'Good Night' RM rule to turn lots of stuff off, I added to that rule to reset the variable 'SaidGoodMorning' to false.

Now my GoodMorning2 rule is working, only once a day! The screen shot is from AFTER it said it for the day. Also will change from PM to AM :slight_smile:

I have a good morning routine triggered from a motion sensor downstairs, and the status of our sleep pads and a guest mode. Basically in the middle of the night some switches get reset ready for action, by checking we are present and if a guest is here or not. Then in the morning, with the motion triggered, a randomised message is made on a Google Home Mini. The rule reads a message appropriate to the person (eg. if our sleep pads say we are still in bed then the message is for the guest, or if mine is deactivated then it's for me, etc). These messages are fun ("good morning Superman.... La la la"). They also read out the weather forecast. It works pretty reliably every morning which is nice.

Is SaidGoodMorning a global variable? Or a local variable? How are you going to set it to be false again so it works the next day?

Also, you need an END-IF to finish your rule.

It is a global variable, and I'm setting it to false every night as part of a 'GoodNight' rule. It said a Good Morning phase today!
I'm confused about how to add the End-If. I tried editing the expression, and I keep seeing Insert before as the option. It need to be inserted after. How do I add it?

1 Like

That is slick! I'm going to add the weather forecast to this. I think I'll also try to grab the existing volume level, set it to where I want it, then restore the volume level.

1 Like

Add it as the next action.

Ok thanks, I'll try that when I get home.

1 Like

Yeah, for me this is done with a little rule that fires each night at 5am if I remember correctly, to reset the switches according to who is at home so that they get their message when they head downstairs :slight_smile:

1 Like

Does this have to be via RM4? I have the same thing setup via the in-built Notifications app and makes this task soooo much easier. I would recommend you give it a go.

Welcome to the Community!

I couldn't figure out with the built in notifier to do the "Echo Speaks" actions. I could get it to say a phrase, but not run them.
No multiple conditions available (both motions), no limit of once per day, and no Echo Speaks actions of random Good Morning,and weather update.

I did look at that first, but what I wanted was a little more demanding :slight_smile:

1 Like

The End-IF added :slight_smile:
Thanks for that. Also added the weather update.

Final results! Hope others can use this!

1 Like

I always prefer using RM because I can achieve exactly what I want with full transparency. I usually find when I use an app that either I don't properly understand what's happening or it won't do exactly what I want. Choices!

Updated - with back to back echo speaks commands, it was skipping the good morning message. Added a delay, and it is now working! (Updated Time end in order to test :slight_smile: )

This community is second to none! Thanks all

Sorry for the delay - busy week.

One refinement you might consder here is to create self-contained code. Rather than having a second rule, you can instead use a slightly massaged version of this one rule:

I've chosen to use the private boolean rather than a named variable, but the effect is the same. The important part is to have a nested pair of if/then/else clauses like this:

IF (within time range to run once)  THEN

    # Use a gate variable to only do it once
    IF (gate-variable is true) THEN
        set gate-variable false
         # do your actual stuff here

ELSE # not within time range...
    # reset our gate. 
    set gate-variable true

There are advantages to using a second rule to clean things up (for example as you describe above, if you need to change a lot of things at the same cadence) but my experience has been that putting things in one place as described here tends to make them easier to maintain in the long term. As things get more involved, you may have more and more rules with more and more complicated interactions, and that can get pretty confusing.


1 Like