Help creating a conditional rule with delay per mode


I am trying to create a Rule where: If All Doors are closed AND all Doors are locked then set my alarm to home mode after a delay based on the mode.

I created the below rule but it does not seem to work properly. It arms the home intermittently when the doors are unlocked.

I am open to suggestions on a better way to implement this logic.

Do the logs show anything? If you haven't already, I would turn on all the logging options and the test the rule until you see the bad behavior. The logs should show the culprit.

And the obsessive side of me wants to see an END-IF in that rule...

The logs don’t show anything and that got me to wonder if it is my rule logic. Also, ill add the EndIF if you help me figure it out :grin:

The logs should show the triggers, evaluation of the conditions, and the resulting actions. You should be able to see which condition is evaluating correctly. But you have to turn the logging options on in the rule.

I would suggest you add a “Cancel delayed actions” at the beginning. Otherwise, the rule will re-trigger if say a lock was locked, it triggered a delay, then before the delay is over, someone opened one of the doors, closed it and locked it again.

Also, not required, but a good practice to add an “End-if” at the end of the rule.

Hey @Sebastien thank you! I actually came here to type exactly that. I looked at the log and it looks like once the delay has started if someone unlocks it does not cancel. Could you please guide me on how to add the "Cancel delayed actions" to avoid this. I see the Cancel delayed action but don't know how to add it to the logic

1 Like

@Sebastien is probably best to guide you through it, but I'll have a go and offer a couple of suggestions along the way....

I would expect the delay action to have a cancelable option, you need to turn that on.

Next insert a new action in before the delay to cancel actions from this rule.

My suggestion would be to introduce an else at the end to cater for when any of the doors are opened or unlocked. You should also cancel the delay in that case as well. Would you also want to adjust the mode in this situation as well?

One thing I am not sure about is what happens to the mode change, whether cancelling just means the rule moves on to the next action. Hopefully someone can offer some insight or you can test it and find out.

1 Like

Ok, so the mode change now has me thinking as well. Not sure how that will work, hopefully someone can chime in.

Is this what you were thinking?

You shouldn't need the extra IF inside the ELSE block, but essentially yes. That cancel action should also appear above the delay.

So not sure if I should use Else or Else-If like below. How would I add the cancel action above the delay, would it be part of the If block? I thought it is - If, Then, Else in that order

I don't think you need an IF as part of the ELSE. With the triggers you have and the IF condition at the beginning, there are essentially two main scenarios:

Rule triggers when something changes with your doors or locks:

  • Scenario 1 - IF condition is true when doors are all locked and closed
  • Scenario 2 - when the IF condition is false, then the rules drops into the ELSE block, so you know that either a door is open or unlocked, so you don't need to re-check this. It's not incorrect, just not necessary, but could lead to problems if you change the criteria for some reason earlier in the rule, better to define that once in the IF condition.

Okay, I will change it to else and remove the else-if block but how do I add the cancel delay command above the delay command when it is part of the Else block?

Sorry, forgot that bit, when you add the action you can choose to insert before, select this option and click the Delay action as the one to insert the cancel action before.

I know how to actually add it before but since the delay is part of the If block I don't know what you mean by add the cancel delay (part of the else block) above the delay? Here is what I have so far.

I meant you need to add an additional Cancel action above the Delay, so as the first action in the IF block, leaving the ELSE block as it is.

Is this what you mean? I guess I don't understand how it would work but will have to take your word for it and try it out :smiley:

That's what I meant.

Thinking about it now, you don't actually need that one... :slight_smile: The cancel in the ELSE caters for the house being opened up and then closed / locked again. Still not a bad idea to just leave it in there now that you have it.

okay, it seems to be working but will only know when I test it over the next few weeks. Also will wait for @Sebastien to chime in with any recommendations.


What you have should definitively work.

If you want to simplify it, you could move the first “Cancel Delayed Actions” to the very top (before the “IF”) and then eliminate the else and the second “Cancel Delayed Action”. The result will be the same since it is currently called regardless of the condition.

1 Like

Thanks! Changed it and will test over the next week.

1 Like