Rule sometimes does not stop by trigger

Hello, I have a problem with a feature in rule machine,
Most of the time it is not a problem, but sometimes the trigger for stopping a rule is not working
When I want to stop the rule using a trigger, the trigger is not visible in the log’s from the rule, so the rule is not stopped. I am sure the trigger was done.

This is the rule I use:

This is the rule log when everything is working in a normal situation, “door open” and “door closed” in less than 10 min. The rule is stopped by closing the Garage Door:

In this rule log where the problem exist, the message “Garage Door Sensor contact closed” is not present but the door was closed.
So the rule tels me the door is open for 10 min but it is not true. (The rule was manual stopped from a dasboard by me):

In the general log you can see the trigger was done, the Garage Door Sensor was closed:

I have the same issue with other rules when I use a trigger to stop the rule.
95% of the time it is working, but sometimes the rule is not stopped by due to a missing trigger in the rule log

Is this a bug or is it the rule containing a fault?

I think if you add Exit Rule after your cancel timed actions, that will give you what you're looking for.

1 Like

Hi @BrunoVoeten

I don't think your rule actions are correct. Try something like this instead:

IF (Garage door sensor open) THEN
    Delay 0:10:00 (cancelable)
    Repeat every 0:01:00 (stopable)
        Set Volume on Google Mini to 80
        Notify Mobile Bruno and Speak on Google Mini 'The door is open'
    END-REP
ELSE
    Canceled Delayed Actions
    Stop Repeating Actions
    Notify Mobile Bruno and Speak on Google Mini 'The door is closed'
END-IF
1 Like

guys, what I don't understand, more than 95% of the time the rule is working PERFECT.
It only does not work when I don't see the door closed trigger in the log's from the rule, but the log's
of the sensors shows me the trigger was there
My feeling is that not one rule will stop if it not sees a trigger...
Do I missing something?

Yes, your syntax is incorrect. The absence of an END-REP places the ELSE-IF block in the wrong place. Also Timed actions and Delayed actions are two different things. And you definitely want to be using "Cancel Delayed Actions".

https://docs.hubitat.com/index.php?title=Rule-4.0#Repeat_Actions

Try the rule actions that I posted. It will work correctly.

3 Likes

Hi, this rule you are propose does not work at all as I expect.
Each time the sensor is OPEN OR CLOSED the notification on my mobile and mini " OK, the garage door is closed" is played.

In my rule there is only an open door message if the door is open more than 10 min and a door closed message if there was an open door message
image

The rule as written looks to me like it should do what you expect, not what you're observing. [EDIT: I missed the different trigger, so that's probably it unless you're confident that they are the same...] Are you sure there isn't another rule that might still be acting on these events?

That being said, here is another pattern you could model your rule after. I usually refer people to this when they ask about repetitions in rules while certain conditions are met:

In related news, if @bravenel ever gets bored, adding repeated notifications like this (e.g., "keep notifying every X minutes" until the condition that created the event the original notification was sent for is no longer true) seems like it might be a useful feature request for the Notifications app. I see a lot of people struggling to write rules like the above, and the app could almost meet their needs except for this.

1 Like

Yes - because there's a mismatch between the Trigger and the Actions.

In the trigger, you look at the status of "Garage Door Sensor Virtual", but the conditionals for the Actions are evaluating the actual Garage Door Sensor.

Fix the trigger, and the error will go away.

1 Like

:man_facepalming: yes your right, It was a copy rule fault, but it is not yet what I expect. I only want a notification "OK, the door was closed" if there was an open door alarm, not each time when the door is closing

in my old (wrong) rule I used a local variable, is this the correct way to do?

Yes. That is one way to do it. Here is another that I think will do what you want.

IF (Garage door sensor open) THEN
    Delay 0:10:00 (cancelable)
    IF (Garage door open): Set Private Boolean False
    Repeat every 0:01:00 (stopable)
        Set Volume on Google Mini to 80
        Notify Mobile Bruno and Speak on Google Mini 'The door is open'
    END-REP
ELSE
    Canceled Delayed Actions
    Stop Repeating Actions
     IF (Private Boolean False): Notify Mobile Bruno and Speak on Google Mini 'The door is closed'
    Set Private Boolean True
END-IF

Note that both the IF statements "IF (Garage Door Open)" and "IF (Private Boolean False)" are Simple Conditionals.

4 Likes

Aaiyar, thank you very much for helping me, its working now. I think I need a closer look to the meaning of END-REP, END-IF,....

1 Like

Technically you should have and END-IF after the END-REP in this rule.

END-REP closes out the 'Repeat every' section and END-IF closes out an IF, ELSE-IF or ELSE.

You really don't need the second IF statement here at all. You already checked if the garage door is open in the previous IF statement. You really only need to set the private boolean, no need to check if the door is open again.

In @aaiyar rule he is checking two different sensors. In yours you're only checking one sensor.

2 Likes

Don't worry - we all had to once! Here's a link to the Rule 4.0 documentation:
https://docs.hubitat.com/index.php?title=Rule-4.0

3 Likes

Acutally, the IF before the Repeat is just a simple (one-line) conditional. This is apparent when you create the rule but harder to see after the fact except that you can see that there is no THEN, which is the clue I look for in such cases. (There's another one later in the rule, too.) END-IF is not valid for simple conditionals, so this is correct. :slight_smile:

3 Likes

You are correct, I stand corrected. They still don't need that IF statement though.

2 Likes

Yup. 100% correct. I was typing on my phone at a traffic light .....

1 Like

and... HE was driving?

1 Like

Before I die I want my driverless car. Don't think I'll last long enough for a flying car. But we're close to driverless!

2 Likes

Ok, I have removed the extra IF :-), thanks to all
The rule works perfect, but I am curious if the initial issue will stay away (the old wrong rule was not stopped in <5% of the time)

1 Like