I am trying to learn Rule 4 and I have a simple task for it but it isn't working as I have it right now. I want the light to come on with motion and turn off after 2 minutes of no motion but stay on if there is still motion within the 2 minutes. What it is doing is coming on with motion and going off after two minutes. Not sure if I have the Wait command right.
I would change your trigger to if motion sensor changes.
In your IFS you also need another AND.
Motion sensor is active.
In your then I would have.
Cancel delayed actions
I would then use an else.
Off light. (delayed, cancel).
When you select cancel against any action all that means is that you have indicating that the action CAN be cancelled.
You have to specify somewhere there you want to cancel that action.
Also its good practice to finish with an END-IF.
Hope this all makes sense.
This is my living room light rule. It has a few more conditions, but it's exactly what you're looking for.
Change your motion sensor trigger to "changed"
I would go with @bobbles solution, it’s simple and requires the least amount of lines.
In the trigger part:
sensor becomes active
In the action part:
Turn light on
Turn light off, delayed 2 minutes, cancel
I have something similar in my hallway.
You don't have a "Wait," you have a "Delayed Action." (I'm sure you were just using generic terminology, but they are different in Rule Machine.) You set "Cancel" on it, but that does nothing without a "Cancel Delayed Actions" action. The above posts provide some solutions. The docs contain a motion lighting example that does the basics of what you want, sans the conditions, which you could add in as suggested. I'd highly recommend reading the docs before you dive into Rule Machine. If you've previously used Rule 3.0, something like your rule above could have worked there (the "Actions" sections were a bit different), but the 4.0 docs explain this difference.
Now, time to ask what I always ask. Is there a reason you're not using Motion Lighting instead? You'd need two apps (one for the weekdays and one for the weekends) if you keep the automation time-based like this. That is not a problem. If you did want to consolidate it into one, you could consider using mode instead of time (if you're not already using that for anything else; you could also use mode in other automations and change things globally manually or automatically when needed instead of specifying time in each rule). Rule Machine would work too; it's just a lot more work to set up and more prone to errors (like above) sine you have to think about the whole thing from scratch.
Good luck no matter which you choose!
That will not work. #1 your triggers are incorrect. #2 you don't have a cancel to the delayed action. Also, April's If's are separate so you're going to get multiple actions.
What you want is something like this:
Trigger: Motion sensor CHANGING Action: If (Motion is active) Then Cancel Delayed Actions If (Time is x and illuminence y) or (time is A and Illuminence is B) Then Turn on light. End-IF Else Delay actions by 2 minutes Subject to cancel Turn off light End-If
You need to make sure the only condition to the cancel taking place is motion active. You don't want that under ANY other conditions, otherwise it may not fire. You only want to restrict the Light turning off. Because in this scenario, if the light was turned on manually, it would still shut off by motion (not sure if you want to address that too). But because of that, you need to make sure the cancel is at the top and only conditional on the motion.
I forgot the cancel in the first IF
And your triggers are incorrect. It has to be triggered on Motion CHANGING not active.
Was typing on my phone with a half eye on my rule...
Thanks for the suggestions! I will try some of these and see how it goes. @bertabcd1234 I didn't think that Motion Lighting would accommodate all the conditions that I want. This is just the beginning of this rule. I might want to incorporate a couple of other conditions later. Also, I did have a rule like this using RM 2 but I wanted to make it more streamlined using RM4.
RM 4 will definitely give you the most flexibility and the most control over what happens when. But it also requires you to build that in yourself. So, it's a trade off. All depends on how complicated you want to make it and how much tinkering you're willing to do.
Plus it's a learning experience.
Figuring this out helps you creating other RM4 rules.
Another thing i have done is create a Day/Evening/Night rule. So based on time, the mode is changed to either Day, Evening or night depending on sunset/sunrise or time.
You can then use this mode in any of your other rules (in your IF) instead of tinkering with time in your IF
Here is my example. (Mind the Dutch names):
Exactly. Helps everyone. Figuring out what's going wrong (debugging) is just as much art (and luck) as it is skill.
How do I get the "Cancel Delayed Actions"? I can't seem to find it anywhere. I found it!
How is your rule coming along?
I think it is working ok. This is how I have it right now. However, even though I have Logging selected for everything in the rule, it is not logging anything in the Logs.
The only thing I would like to add now would be a way for the light to stay on when reading in bed. I have a virtual switch setup for our MB when we say "Alexa, I'm reading" it will turn on the virtual switch and keep the light on. I am wondering if I can use the same phrase in a different room and setup a different VS?
Unfortunately, using Alexa routines, there isn't a way to target routines based on the location of the device you are speaking to. I set up two different Alexa routines and virtual switches. "Alexa, I am reading in the den" and "Alexa, I am reading in the bedroom".
This is just a switch or is it a dimmer? I have a couple rooms set up so that motion turns the light on to a certain percentage, say 90%. If the dimmer is above that, the light will not turn off via motion. The dimmer level becomes another condition of the off part of the rule. If this is just a switch, then I think the easiest thing would be to have the virtual switch and change both expressions to "I'm reading in bed" or "I'm reading in the living room" to be able to distinguish between the two, like @bjcowles suggested.
This is an interesting concept. It is a dimmer. So do you just set the light above the % of the light with motion when you are reading?