[Released] Rule 4.0

I take it there is no way to stop 4.0 rules running via the time restrictions now unless we build it into the rule. It was handy to have as it would save rules from even running, as now they have to part run each time it's triggered before it gets to the time element.

If anyone knows a better way please let me know thanks.

I believe they did actually run before but skipped all actions if the restriction was active.

Restrictions were removed, in favor of Conditional Actions that implement them, because every rule was paying the price to check them. For every trigger event, the rule would load, check the restrictions and exit. By making this change, rules that don't have restrictions became more efficient while rules with restrictions are not penalized.

Use a form like this:

IF(Time Between y and x) Exit Rule

That would be for a Restriction of "Only Between x and y". Notice the negation of the time frame, as the new action exits the rule.

3 Likes

Instead of using If/Then in the restricted rule itself, you could set up a separate rule that would run at certain times of day with the action being "pause rule" and "resume rule" on the original rule.

1 Like

Hi,
I'm trying to set the value of a local variable from the temperature of one of my devices using Rule 4.0. In the field to select the temperature sensor, the selection panel doesn't open.
FYI, that's the only place I noticed such behavior.
Does anyone know what I may have done wrong or is it a glitch to be corrected in one of the future updates?
Thanks

It should, I do notice that your variable has the % signs around it. I don't think those should be there. When I select a variable global or local it does not have those around it, it should just show the variable name.

Don't know if that has any thing to do with why your sensor list won't drop, but it looks odd to me.

1 Like

Do you have any local or global variables created?

Thanks! you are right the % signs were the problem

1 Like

Is there a way to test strings without putting them into variables first?

Use case is I have some rules triggered by local/cloud endpoints that accept post/get data, and the only thing I’ve figured out is (1) set the value of a local variable from the post/get data (using Set String and RM’s standard double-percent-sign notation, like “%http_form_field_name%”) and then (2) check the value of the local variable against the test string. Would prefer just to check “%field%” against the test string in a single step, as the local variable serves no other purpose. As in, a single condition for “IF %field% = test_string”.

Note that the rule is invoked by the local/cloud endpoint, so while I’m aware RM has actions that allow me to initiate new http requests, I don’t want to use those, as I already have the post/get data as a result of having been originally triggered by the local/cloud endpoint.

I hope I’m explaining clearly(?).

All comparisons in RM are based on capabilities, for example comparing a temperature against a decimal number. There is no capability for "string". RM has variables, and in effect a variable becomes another capability for conditions, and one variable type is "string". So, for a string comparison, one side of it has to be in a variable. The other side can be a string constant, or one of the %device% type things that is evaluated into a string, or another variable.

1 Like

Took me a little while to get used to it, I now actually find it really methodical :+1:

Probably the biggest “Aha” moment comes when you realize that multiple concurrent threads can be executing in a rule due to retriggering. Most programmers are only accustomed to single-threaded execution. I’m not sure the documentation is clear on this point.

5 Likes

Agreed. It would be nice if there was a way to restrict a rule to a single instance at a time. It could help us novice programmers avoid runaway race conditions. Make that the default, with an advanced switch to allow concurrent instances only when specified.

God no. It's fine as it is. I can imagine many people posting saying why didn't my rule trigger? Well, it's because it ran and is sat at a wait condition and now it won't run again until that is completed. No thanks. I want to know that the rule will trigger reliably every time and there are already sufficient methods available to stop rule execution when needed.

7 Likes

It doesn't sound intuitive to me. I would likely not realize it was stopped and be stumped as to how to proceed.
Besides looking a the logs will give you an indication some rule has "left the reservation"

2 Likes

Hi all

I am having trouble wrapping my head around RM 4.0. I've looked at the examples but can't get my rule to do what I want. This is what Im trying to achieve:

If a dimmer is set to below 10%;
Delay 30 seconds, then turn off dimmer and send notification

If the the dimmer switch is turned off, or the level is set to 10 or higher, during the 30 second delay, cancel the 30 second delay and the off and notification actions.

Here is what I have so far. The problem is that the actions under "IF private Boolean is TRUE" always execute, even when the first IF is no longer true. I think my issue is that the ELSE is attached to the second IF, but I want it attached to the first IF. I can't figure out how to outdent the ELSE to make it apply to the first IF, not the second IF.

Anyone able to help please?

Thanks.

Screen Shot 2021-01-04 at 5.17.22 PM

Correct you need to add a END IF before the ELSE and then another at the end. They are in the same place that you found the IF THEN.

Edit you also need to make the delay "cancelable".

Also I can't see what the PB is doing here, I don't believe it will do anything/ not needed.

2 Likes

This is what you need:


You need to have both the dimmer changing level and the switch turning off as trigger events since either can affect the outcome.

We know that if the first IF is false, that the switch is on and its level is less than 10, since if either the switch was turned off or its level set to 10 or higher, that the IF would be true.

4 Likes

Thank you @bravenel appreciate you replying. You flipped the IF and ELSE around from what I had, which seems counterintuitive to me. Is that necessary or just personal preference?

I started the way you did, but ran into the issue about the switch being turned off. So, it could be done that way too, just testing that the switch is on.

Notice that a light can have a positive dimmer level and be off.

1 Like