END-REP not working

Hi all- just diving into RM a bit and learning the intricacies of it.

I started with something somewhat simple, but it isn't ending like I would expect it to, any ideas? Info below:

I have a few Z-WAVE bulbs in my lanterns next to my garage, they don't always turn on so I'll have a random 1 or 2 nightly that isn't lit, the code simply checks for off and repeats until all are on, however, the problem I'm having is that even after they are all on (and the state info says the same) the rule continues to run every minute.

CODE:

LOGS:
app:4372021-01-25 03:00:28.753 pm infoAction: END-REP (waiting for next)

app:4372021-01-25 03:00:28.728 pm infoAction: On: Garage Light 3, Garage Light 2, Garage Light 1

app:4372021-01-25 03:00:28.712 pm infoOutdoor Lights at Sunset1: Repeating Actions

app:4372021-01-25 02:59:28.633 pm infoAction: END-REP (waiting for next)

app:4372021-01-25 02:59:28.605 pm infoAction: On: Garage Light 3, Garage Light 2, Garage Light 1

app:4372021-01-25 02:59:28.589 pm infoOutdoor Lights at Sunset1: Repeating Actions

app:4372021-01-25 02:58:28.478 pm infoAction: END-REP (waiting for next)

app:4372021-01-25 02:58:28.454 pm infoAction: On: Garage Light 3, Garage Light 2, Garage Light 1

app:4372021-01-25 02:58:28.438 pm infoOutdoor Lights at Sunset1: Repeating Actions

app:4372021-01-25 02:57:28.357 pm infoAction: END-REP (waiting for next)

app:4372021-01-25 02:57:28.333 pm infoAction: On: Garage Light 3, Garage Light 2, Garage Light 1

app:4372021-01-25 02:57:28.316 pm infoOutdoor Lights at Sunset1: Repeating Actions

app:4372021-01-25 02:56:28.211 pm infoAction: END-REP (waiting for next)

app:4372021-01-25 02:56:28.187 pm infoAction: On: Garage Light 3, Garage Light 2, Garage Light 1

app:4372021-01-25 02:56:28.171 pm infoOutdoor Lights at Sunset1: Repeating Actions

app:4372021-01-25 02:55:28.095 pm infoAction: END-REP (waiting for next)

app:4372021-01-25 02:55:28.043 pm infoAction: On: Garage Light 3, Garage Light 2, Garage Light 1

app:4372021-01-25 02:55:28.025 pm infoOutdoor Lights at Sunset1: Repeating Actions

app:4372021-01-25 02:55:28.005 pm infoAction: ELSE-IF (Garage Light 3, Garage Light 2, Garage Light 1(off, on, on) any is off(T) [TRUE]) THEN

app:4372021-01-25 02:55:27.987 pm infoAction: Exit Rule (skipped)

app:4372021-01-25 02:55:27.985 pm infoAction: Stop Repeating Actions (skipped)

app:4372021-01-25 02:55:27.983 pm infoAction: IF (Garage Light 3, Garage Light 2, Garage Light 1(off, on, on) all is on(F) [FALSE]) THEN (skipping)

app:4372021-01-25 02:49:48.255 pm infoAction: END-IF

What is your trigger that will evaluate the rule again?

1 Like

Agree with @bobbles that knowing the trigger is necessary to properly debug, but I would like to add another idea for your repeat:
Why don't you add a 5 second wait (just to make sure the on command worked) and then an "if all Lights are on", stop repeating actions?
It would look like this:

Repeat every 1 minute
On garage lights 1,2,3
Wait for elapsed time 5 seconds
If garage Lights 1,2, 3 all is on
Stop repeating actions

End if
End rep

Edit: as @bertabcd1234 mentioned, no point in using exit rule, so I removed it.

I'll "third" the idea that we need to see the full rule, including triggers. :slight_smile: But if you feel like figuring this out on your own, I often refer people to this post for repeats. It was really intended to create repeated notifications, but the idea is the same for all repeats and it's just the actions inside that would differ in your case. You may find something helpful there:

On a related note, I don't think the "Exit Rule" in either the original rule or the above suggestion will have any effect. It just stops executing additional actions after that point in the rule, should there be any (and there aren't any "real" actions after either case). It doesn't cancel repeats, delays, waits, or subscriptions/schedules of any kind, which I think some people assume it might from its name. But it's also harmless to keep and wouldn't be causing any problems.

1 Like

The trigger is time based at sunset +30...

So the rule will only trigger at this time. Not again.
If so, how can it evaluate the conditions again.

Lets start with one or more of the garage lights being off. The rule runs and immediately goes to the ELSE-IF, (the first IF is ignored since it doesn't evaluate as true). The actions that you define happen, specifically a command to turn the lights on is sent every one minute. This will happen forever, and the only way to stop this is to have the rule run again. This can only happen if the rule is "triggered" once again.

If this is the only trigger, the rule will keep sending the command to turn on the lights until the next time it triggers (the following day at sunset +30), at this time the rule will run once again and the first IF will evaluate true and stop the repeating actions.

It is working as it should, but not how you want. Consider remaking the rule.

2 Likes

Or if you add the conditional inside the repeat like I wrote above

In that case, your repeat will be set in motion but the "Stop Repeating Actions" will never be reached. Rule actions run when triggered, so without another trigger, you'll never get back to that particular code path.

In this case, I think something like the second paradigm suggested in the post I linked to above would work for you:

Trigger: Time is sunset + 30

Actions:

   REPEAT Every 0:00:10 (stoppable)
      IF (Light 1, Light 2, Light 3 all off) THEN
         Stop Repeating Actions
      ELSE
         Off: Light 1, Light 2, Light 3
      END-IF
   END-REP
3 Likes

@bertabcd1234, just for the sake of keeping it consistent, op wants to set the lights to on, not off. I know it's the same idea, but just to be precise. Sorry for nit-picking :joy:

Oops. So...opposite of everything I just did, but hopefully the same pattern. :rofl:

2 Likes

I should also note that this is likely a device problem and I'd prefer to look into a solution on that end before resorting to a rule or other workaround. But if it works...

2 Likes

I would never write the rule like the OP. My post was meant to explain what is happening in the OP's rule as it is written. IMHO, it is best to understand why a rule you created is not working as you want. Developing a better understanding of how the features of RM work will help him in the future.

On another note, I am curious as to why you included a "Wait for elapsed time 5 seconds" in your example above. You state that it is "just to make sure the on command worked", but how does a wait of 5 seconds, as opposed to some other time or no time at all make a difference?

My thinking was that sometimes in a weak mesh messages take longer than expected. I had a switch in the past that took up to 2 seconds to report as on after I switched it on.
I said 5 seconds as a fail safe. No time at all, especially if its a mesh issue, would probably evaluate before the lights had a chance to report their state change

Thanks for all your help, I think I have a better understanding of this for sure and I'll continue to review the guide as I work through it. I've looked it over once already, but for me at least, doing it is the best way for me to learn it.

As far as the devices and "why" they don't always respond, I'm not overly concerned with that. The are located outside my house which is stucco and stone. My mesh is actually pretty strong as I have about 30 or so Z-WAVE PLUS devices spread about, including a couple of repeaters in the garage. I think in this case the rule should solve my issue.

Thanks again.