Restrictions cancel the rule mid-run?

Set up basic rule like this:

When activates ...
Turn on
Wait until stays inactive for 30 seconds, then ...
Turn off

Pretty basic rule, right. Now, you of course don't want to run this when you are away, or when there is enough natural lighting in that room. So you put restriction to run it in all modes except away, and another restriction on illuminance (aqara motion sensor has also illuminance sensor in it). But now everything stops working. You go in the room, light turns on, which then trigger the restriction and cancel the rule, so it never turns off. The same if you put this rule in place in your entry hall. You go to the hall, lights turn on. You put your coat on and leave house. House now changes mode to "away", canceling this basic rule.

Shouldnt the restrictions take place only when firing off the basic rule? When the basic rule already started, it has to finish..

If you have a wait and the rule triggers again, everything after the wait is canceled and nothing after that will be executed.

I saw the same issue using ML a while ago and moved my rules with restrictions to RM. In RM, restrictions can be implemented using an IF-THEN paired with Exit Rule. Using a Wait within the rule is a great way to execute an off command even outside of the restriction. Works very well if you're using a single sensor for the rule trigger. It gets a little more complicated with multiple sensors because you need to keep the rule "active" but I do it with a local boolean.

Weird; Motion Lighting generally has separate sets of options for the "on" and "off" halves of the automation, which should avoid the problem the OP describes. (That being said, there are a ton of options in ML and probably one that would do that, too...) In this case, the "Turn on only if lux is less than this value" option on the "Options for turn-on, disable, and enable lights-on" page/section (this app isn't famous for clear wording) would probably do it; if not, I'd consider it a a bug you may want to report.

This would also be my recommendation for the OP, though a Rule would, of course, work too! In either case, you should be able to get the more specific level of control you need. Both this and Simple Automation Rules may not always work as you expect when you want to "restrict" different sides of the same automation in different ways.

1 Like

@tomas1 realize that this old and I ran into this same concern today. @bravenel (Basic rule thoughts)

I would expect a rule to complete end to end before implementing a restriction. In other words it would not stop midway.

In my use case I have a basic rule that flips on the foyer lights when the house is unlocked. It then waits and turns off the lights. Yesterday I had some folks working on the house and I turned on the foyer lights for them but every time that they unlocked the house the lights turned off after 2 minutes so I quickly added the restriction.

Unfortunately, the rule now "self restricts" instead of only restricting when the foyer lights were on before the triggering event of the door unlocking.

In short, I believe that a restriction should not stop a rule until all of the actions in flight have been completed.

I will look into this...

1 Like

Thank you!

We are going to add this as an option, to allow a Restricted rule to continue to run once it's been triggered. Next release.