Help to setup a Good Night Routine

I would like to setup a Good Night Routine to turn all the lights off and set the Mode to Night and Ecobee to Sleep when there is no motion from a number of motion sensors. The restrictions are that if the Mode has already been changed to "sleepin" from another rule then it would not change the Mode but if the mode is any of "Home, Tom's Bedtime" then it would do the routine. Also if the time is between 8:30pm-2:00am(in case the kids are up watching TV) then want it to say "Good Night everyone, the house is in night mode". I also only want it to run once. The problem that I was having in WC was that it would run more than once and we would be told "Good Night everyone....." more than once. Here is the piston that I have.

Here is what I have in RM for this. Can someone tell me if this looks right? I have done two apps to accommodate the different modes. I am not sure how to make the app wait 10 minutes of inactivity in all motion sensors before running the rule. In this one I chose "Turn Off Switches After a Delay pending cancellation".

In the second one I did Delay Actions 10 minutes and selected Cancel on Truth Change.

Not sure what the difference is or which way is correct. I also made another app that turns Good Night Switch on at 7:00am so that it is ready for the next night.

Delay actions does just what the name says. Delay before OFF (or ON if you flip the switch in Rule Machine) is a delay before turning the particular switch, dimmer or bulb you turned on (or off if you're doing the reverse).

If you want the rule to wait for inactivity and then wait ten minutes before doing the actions, then you want to use Delay these Actions. Cancel on Truth change would be, your rule evaluates a condition, their conditions are either true or false (since both can be what make the rule itself true or false, depends on how you set it up, but True conditions is typically what you will set), and then if there is a truth change before that action occurs, it is canceled and nothing happens.

So if motion starts again from one of the motion sensors within the 10 minutes it will cancel and start over waiting for the conditions to go True?

Yes, but in your first rule posted, you are changing the mode as soon as the rule is true, and then the rule cannot evaluate as true again, because you've changed the mode away from one of the conditions required to make your rule true.

In the second rule, I think you're going to get what you're looking for, but I would remove the cancel on truth change. Otherwise, every time someone trips a motion sensor, you have to wait for the conditions to create a rule truth again, and then the rule will start the count down all over again. Unless that's what you want. Also curious why you used a different mode for the condition in the second rule vs the first.

But doesn't it wait until the delay is over? So if there is no activity for 10 minutes it will then do the rest of the rule?

Yes, this is what I want to happen. So when we all go up to bed the house will go through it's Night time routine. But if someone is still up and watching TV then the house will not turn all the lights off and turn the heat down, etc. until they have also gone to bed and there is no motion detected anymore.

This part was tricky because say my husband goes to bed at 9:00 and he says to Alexa "I want to sleepin tomorrow". Alexa changes the mode to Sleepin and then his morning lights don't turn on at 4:50am. and the heat doesn't come on yet. But I didn't want this mode to change when the Good Night Routine ran if the mode was already Sleepin.

Also I had to setup a Virtual Switch (Good Night Switch) so that it wouldn't keep doing this all night and telling us that the house is in night mode.

Maybe I'm reading your rule wrong. It looks like that's not part of the delay off.

The chances of this working the way you want a low, since people tend to sit very still when watching TV.

This I believe you can solve very simply with an additional small rule that will not trigger the Goodnight Switch unless the mode is anything but night mode.

You can tie rules together with virtual switches and I do this myself, but you can also tie them together with Private Boolean. So if you haven't used that, it's done by creating an action that sets the Private Boolean of another rule to True. Then in the other rule, your condition is when the Private Boolean is set to true.

So do I have to have a delay for each Action?

You are correct. I will have to incorporate my smart plugs that I have connected to the TV's also

Is this not the same thing as what I have done with setting up a small rule to turn the switch to On in the morning?
So, Private Boolean's carry across to other rules?

The first rule is delay before OFF. The mode change is just going to happen when the rule is true. That cannot be part of the delay before off unless you put that mode change in another rule and used a virtual switch to trigger it. Same with the pushover notification.

:rofl: I'm not quesitoning everything you're doing. Just trying to help with anything that isn't working as you expect. Many ways to arrive at the same destination. If it works, it's fine. Bruce can do these things much simpler that I can. Maybe in time I'll get better at it too.

Here's how Private Boolean works.

  1. Rule with which you want to trigger another rule: You will set this in the actions:

  2. Rule you want to be triggered or have the condition become true based on the action of another rule. Note that false is also a possibility for a trigger or condition. Depends on what you need:

Believe me...I appreciate all the help you have given me!:smile: @destructure00 is saying that ALL the Actions are delayed and therefore if there is motion detected in the 10 minutes it will cancel the Actions because it Cancels on Truth Change. The Private Boolean might be a bit over my head but I will look at it and see if I can figure it out. I might need to see one being used to fully understand.

Cancel on Truth Change is coupled to a Delay. Without the delay, there's nothing to cancel. It's "under the umbrella" of the Delay ticking away, that a change in truth occurs, then the Delay is restarted.

You have a Delay ticking away.. let's say for 10 mins.

Tick tick tick.. and then at minute #8 Motion fires, Truth Changes. The entire delay is canceled as if it had never happened. Then 30 seconds later, Motion ends. (Whatever your Motion Sensor is set to.) Now you're going to wait 10 mins. At minute #2, Truth Changes again. The entire delay is canceled as if it had never happened. Then 30 seconds later, Motion ends. Now you're going to wait 10 mins. And so on until One Entire 10 min Delay gets to zero without a truth change.

Private Boolean (PB) is a different animal. There's one PB per Rule and it's initialized to True on creation of the Rule, power cycle, etc.

All PB's are "visible" to all other Rules. They can be set True or False as @SmartHomePrimer has shown in his screen caps.

It is one of several mechanisms for coupling Rules into ... dunno what to call it.. into a... I KNOW.. a PISTON. An "imaginary container" of Rules. :slight_smile: There's a whole selection area called "Set Rule Boolean, Run Rules, Rule Actions" and each of them facilitates some form of Rule coupling (into a Piston :slight_smile:)

Therefore, you can imagine a Rule running, testing things, deciding true/false and on True, set another Rule's Boolean to False. That rule now does what it's built to do on PB = False. Which can include setting it's own PB back to True.

3 Likes

This is what I want to happen.:grin:

Your explanation of Private Boolean shines some light on it but still sounds confusing. I will keep it in mind though as I move my WC pistons over to RM. Can RM incorporate variables?

No, but we do use Virtual Dimmers as storage, when the need arises. Anything that can fit in the range of 0 to 99, is a candidate. Name your Virtual Dimmer "var_something" and it's actually easy to read. :slight_smile:

1 Like

OK, got it! One last question, maybe:wink: doubt it. What if you have rules that overlap? For instance, I have one rule that turns the living room lights on and sets them to 80% when time is sunset to 9:00pm. I have another rule that will dim the same lights to 30% if a TV Plug detects power over 10W. (meaning we are watching TV) Will the first rule fire the lights back on to 80%?

Yes
Good place for a Boolean :slight_smile:

1 Like

How would I do this? Last night we went downstairs and the lights came on as they should but then when we were watching TV the lights went off and they shouldn't. I had to add to the TRUE to put the lights on.
Here is the first rule. I have a restriction that you can't see for only certain Modes.

Here is the second rule:

In Basement Lights Rule, scroll to the bottom of Restrictions and find:
50%20AM
click that to be Enabled.

In Watching TV in Basement Rule:
in Actions for True, add
44%20AM
pick Basement Lights as the Rule.

Do the same for Actions for False, but set that boolean to True.

The boolean starts/initializes as True. Therefore your Basement Lights Rule operates normally. When you turn on the TV, the Watching TV in Basement detects the Power and sets the lights and disables your Basement Lights Rule. Turn the TV off, the power is detected and the Basement Lights Rule is enabled once again.

Is this correct? Do I still need to set the lights "ON" in the "True" Action? I took them out.

Also just reading about the Motion Lighting App and it might be possible to do this using that built-in app as well. Actually, no I don't think so as I need to use the Power from the plug not just its on/off.

Right, but I thought you were trying to learn Booleans ? :smiley:

As to "is this correct?" Only you can say. I don't know what "Basement TV Watch Switch" does... If the lights are the way you want them for TV, then no, you don't need them in this Watching TV Rule. If they need to be set into a different scene, dimmer brighter, different color, then this is the rule to do that.

As to the False state, I'm thinking that basement lights will reset the lights as it sees motion BUT only you will know if turning off the TV triggers all the motion sensors. Because if that happens, before the power reaches zero and the boolean changes to True, then the freshly enabled Basement Light Rule will see no event(s). You can "fix that" by putting the lights back the way you want them in Watching TV: Action for False.