[Released] Rule Machine 3.0


I can't help with the first part (or not sure if I understand). As I understand, say you set it to repeat 5 times, with a time of 1 second. So it completes the action, 1 second delay, repeats the action, 1 second delay, etc. You would like it to immediately complete the action 5 times without a delay between?

Admittedly, that's a bit vague but I got one working... will have to look to find it though. Can't remember which rule. When I find it, I'll post.


I also think I found a bug in Global Variables. When I went to create a number variable, it did not require me to set an initial value. Now I can't do anything inside global variables. I can't set them, create a new one or delete any. And when i select that variable to set it within a rule it doesn't proceed past choosing the variable. I think i might have to remove global variables to recover. Anyone else have any ideas? @bravenel?
When i go into variables, this is what I get:

Can't edit or set or anything.

When I try to set that global variable in a rule, this is what I get:


But you can only choose to repeat every so many seconds., minutes or hours. Not just until the condition isn't met anymore. This is what you get:

It won't let me save until i enter some amount of time.


If you put in repeat every second, does the option come up to instead of "n" times stop on truth change?

Looking at your picture again, what if you put the if up in the main rule as a condition?
What you are doing does look like you need the while loop if you are trying to put the condition in an action versus the rule. I'll keep looking for how I used it.


I created a new while loop - couldn't find the old one. Once run, this toggles the living room lights every two seconds until the picture frame is turned off.

The key is to use the simple condition versus the if then. I couldn't get it to work with an if then.


But I don't want it to repeat every so many seconds. The delays are in the action. For example, I am fading a bulb over 3 seconds, then fading it again over 3 seconds. I want to repeat that 6 seconds of fades 5 times. I shouldn't have to put in repeat every 6 seconds. It should just need N times.


I'm starting to understand what you are trying to do, but I'm not 100% there yet. You probably know this - but I don't believe the while loop (or any repeat) is going to wait for the action to complete before repeating itself. So I would think, without adding the delay, the system would nearly instantaneously send 10 three second dim commands to your bulb. Is that what we are trying to do? - all 10 dim commands as fast as Hubitat can process the repeat?

For example - my while loop I created last post was actually going to fast for my hue bridge to process. It skipped a couple of the commands because 2 seconds wasn't enough of a delay for the hue system to react before getting the next command.

So I believe, with 3.0 at least, the script will start that 3 second transition, and continue to run the rest of the script while that 3 second transition is happening. Bruce might be able to help more, but I believe you are going to have to put in manual delays to pause the script. Likely a 3 second delay between your two dims (assuming you have 2 dims inside the repeat as described) and then the overall repeat action would need another 3 second delay.

While X repeat every 3 seconds (I believe 3 is the correct choice, but it could be 6)
dim bulb over 3 seconds
delay 3 seconds (Stops script for 3 seconds)
dim bulb over 3 seconds
end repeat


In case anyone was wondering -- I think I figured out what my issue was. I think the logic was mostly ok, the problem was that when I would walk out of the room the motion sensor over the doorway went to inactive before the motion sensor on my desk. I added a delay prior to evaluating the false condition to give time for both the motion sensors to go inactive. Now the light turns off.

I instead just added my desk motion sensor to the conditions, but did not define it as part of the rule. I think this will cause the rule to be evaluated when the desk motion sensor state changes. @bravenel, is this correct? and does this rule make sense to you?


This is correct. State change for any condition causes rule evaluation, whether or not the condition is used in the rule. This is true only for a Rule, not for Triggered Rule.


@bravenel, how about my question about repeats. It seems that a time is required for a repeat. What if i just want an action to repeat a specific number of times because the delay is built into the actions? It seems I still have to put a time in.


Yes, you have to put a time in. You can put in 0.001 it you want. Better would be to put in the minimum time from your delays, and remove that much time from the delays.


But the delays are happening in a specific order within the actions. It seems that being able to run a set of actions a specific number of times is the definition of a loop. These are timed repeats. Why should there be a restriction on the amount of time between repeats?


Repeats are designed to happen with a timer, not back to back. You can set a small timer value that won't affect your timing. For most applications, this is a desirable feature.


Okay, let me see if I can articulate my question better.

If i have a set of actions that i have repeating every second, does that timer start when the actions within that repeat start or when the actions within that repeat complete? Because if there are any fades over time or delays within that set of actions, if you repeat every second, then the actions would take place over top of each other. Let's use an example.

I have a fade to a level over 3 seconds, and i want that to repeat basically as soon as it's over, would a timer of 1 second start after the 3 seconds are up or immediately after starting the 3 second fade.


Far be it from me to wonder why you want to do such a thing. You can set a repeat timer of a single millisecond if you want. No time; in fact it would start the next repetition before the first one had even finished most likely.

The way it works is this: When a Repeat is encountered, it schedules a job in x seconds (or milliseconds) in the future to run the repeated actions again. Then it immediately proceeds to the first action after the Repeat. If it encounters and End Repetition it just exits, waiting for the timer to start the next repetition. This continues until the repetition is stopped (if ever) by whatever means.


I'm getting the:

groovy.lang.MissingPropertyException: No such property: key for class: java.lang.Boolean (allHandler)

error also. It's a Rule 3.0 that I just created and it's pretty simple:


What build are you on?


Currently running version:


Try deleting that rule and creating it again. See what happens.


Did that and ran the rule manually, no error