Too much of a Novice to understand

Good Day to all, and Thank You for reading this.

I am fairly new to Rule Machine, having only written a half dozen or so extremely simple rules.

The Rule below is suppose to wait for a specific time of the day, then kick off by turning LAMP1 Green and LAMP2 Red, waiting 1 minute and then switching the colors. This loop is suppose to continue until the time of day in the Conditional IF statement, and then Stop Repeating, Turn LAMP1 and LAMP2 Off, and Exit the Rule.

My testing shows the Rule executing at the appropriate time, and switching the colors of the lamps every minute. But even though the IF Condition becomes True, according to the logs, nothing within the IF/END-IF executes.

I would really appreciate your input to tell me why, This ask got to be something really stupid and I am just not seeing it.

Thanks again for your time
Bill

Your rule isn't structured right; END-REP is in the wrong place. And, you don't have a method to stop the repetition.

Probably should start over. For the repeat, you're basically doing a 'while' repeat, as long as it hasn't become the stop.

IF(NOT Time is 4:00PM) Repeat every 0:02:00
---set the lamps---
END-REP

But, probably not a good plan to test for a single minute in the while loop, because it could jump right over that time. So put in a range of at least 2 minutes, so that it's sure to hit the end.

I was working on testing a rule for you and came up with this. But Bruce has already responded with likely a better solution - a while loop. He's quick!

Thought I'd share at least so you could see the structure.

Here is Bruce's while repeat which is cleaner.

1 Like

Thanks @BRAVENEL and @AndyM -- Appreciated.

I took another stab at this from your direction(s). At least the way, I think, I am interpreting your information.

I seem to be having difficulties with the NOT logic in the IF THEN statement. Also, for the life of me, I was not able to find how you were able to put the Repeat every 2 minute condition on the same line as the IF THEN.

Would the below script run between 4:00PM and 11:00PM, swapping the light color, and then after 11:00PM turn off the lights?

You Help is GREATLY appreciated! Thanks

You want to use a Simple Conditional Action for the Repeat --> this is what turns it into a 'while' repeat. While the condition is true, repeat. As soon as the condition is false, stop repeating.

For the NOT on the condition itself, we're basically saying "repeat as long as it's not yet 11:00 pm".

So, we end up with this: Repeat these actions as long as it's not between 11:00 PM and 11:03 PM. Assuming we start this earlier in the day, it will repeat until one of the times around the loop the time is in that window, and then it will stop until the next day, when the whole thing starts over again.

The way you have it above does not provide for some way to stop the repeating. There are three ways to stop repeating:

  1. Use a 'while' repeat as shown above. It will repeat as long as the condition is true.
  2. Use a 'Repeat n times' counter. It will repeat n times and then stop.
  3. Use a 'stopable' repeat. It will repeat until the action Stop Repeating Actions is run.

The easiest of these for your case is the 'while' repeat.

Once again, probably you should make the time window for stopping the repeat larger so that it doesn't get skipped over. Like 11:00 PM to 11:59 PM. Then it doesn't matter if you're repeating every minute or every 30 minutes -- one of the repetitions will start during that window, and NOT Time Between 11:00 PM to 11:59 PM will be false (because it is between those two times), and once the condition is false, the repetition will stop.

Thanks again @bravenel

Am I any closer? Please see below. My Fingers are crossed.

Bill

Hi Bill,

Remove these:
image
Then start the rule (insert it before the first action) with a conditional action - I'm going to steal Bruce's pictures from above to help:

Note he has chosen a simple conditional action, not an if-then.
image
Set it to the time you want, such as not between 11PM and 11:59PM.
Then set the action for the simple conditional to the repeat every 2 minutes:

The rule works like this:
It is triggered at 4PM.

It checks the simple condition - as it is 4PM, it is not between 11 & 11:59, so it completes the actions from the simple condition to the end-rep line. It won't go past the end-rep. It then finishes waiting the 2 minutes, and then checks the condition again. If the simple condition is still true (not between 11 & 11:59), it repeats and does everything again between it and the end-rep.

Sometime between 11 and 11:59 (you don't know when, because with the repeat delay of 2 minutes it may not land on an exact time - 11 to 11:59 is more than necessary, but as Bruce said this will allow you to use longer than a 2 minute repeat) the condition will no longer be true. It will then skip all the actions and pick up after the "end-rep" action in order to finish off the rule - turning off the lights.

Hi @AndyM ,
I am hitting my head against the wall here. As both of you have said, I have selected Simple Conditional Action and set the time between 11:00PM and 11:59PM. BUT, when I attempt to add the Repeat every 2 minute step, the between times from the Simple Condition disappear.

What could I possibly doing to delete the Simple Condition start and stop times?

Thanks
Bill

Not sure!
Here is a video of me creating one.
If this doesn't work for you, maybe try in a new clean rule, just to be sure. If not then I'm out of ideas.

WhileRepeat

3 Likes

I might have it.
I deleted the entire rule and start from scratch.

For some strange reason, after I created the Simple Conditional Rule, set the start and stop times, slid the NOT slider and clicked "Done With Condition" I was not taken to "select the type of Action". It took me back to Add a new Action and that was why I was only ending up with the Repeat 2 minutes and no Simple Condition.

I have the line as both you and Bruce have showed me in all your posts at the moment.

I am going to setup some phony times to test the rule. I'll get back to you in a couple. THANKS. I have a better feeling now than ever before.

Bill

1 Like

Sometimes things go a little wonky after messing with a rule. If you find bugs, definitely post them in the forums. The developers are great & responsive. But it's a little tough for them to diagnose if you can't tell them how to reproduce it. Sometimes you just need to start the rule again.

You bet. THANK YOU and Bruce for all your patience!

I'm waiting for 8:15PM to start the Rule. If all goes well, I'll know by 8:23PM

:slight_smile: Bill

Well Good News and Bad. When the time came to stop the loop, the Colors did stop swapping back and forth.

But, the lights never went off. They remain on in the last state.

What Next..?

Just a guess, but a simple one to test.

Change the end of your rule. Possibly your lights don't turn off at level 0. OR, maybe they are getting confused / messages out of order about turning on to daylight and also to off at level 0. If they get the level 0 command first, they go off, then they get the daylight command and would likely turn back on to 100%.

If you want them to go back to daylight and then off, put in a change to daylight (without a level, or a level greater than 0). Then a switch off command a few seconds later.

OK, will try - I think this is Take 7

Lucky #7

Well it is a little worse than we thought. Going back to the Apps page and looking at the Rule, it continues to report it is "Repeating"

OK, found the problem and it was directly related to Bruce's suggestion. I had only open the window for 2 minutes in the loop (i.e. 8:47, 8:49). changed things around to a 5 minutes windows of time and it is triggering the correct way every time.

Thank You for all your Help.

Bill :slight_smile:

1 Like

Now that you have it working, and since I've been thinking about this while helping you, and how I might implement it myself...

I'd probably make a virtual switch for the sequence.

I'd modify your rule so that it triggers on that virtual switch turning on. The repeat condition would be while the switch is on. So the switch goes on, the rule is triggered, and as long as the switch stays on it continues to repeat, the repeat would be broken by the switch going off.

Then you would be able to manually control the light sequence on/off via the switch. Which you could then add the switch to google, alexa, or a dashboard.

To keep your scheduling, in another simple rule (or 2 if it is easier, or possibly even simple lighting) you could turn the switch on at a certain time, and off at second time.

With the way the rule is written right now, I'm guessing it will be hard to manually stop the sequence once it begins. I'm guessing you would have to pause or disable the rule if it came on and you didn't want it to - hopefully that would cancel the repeat. But the switch would give you easier manual control. And it should be easy to schedule the switch on and off at certain times of the day.