Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RULES: Added BREAK as an alternative ENDON #4500

Merged
merged 2 commits into from
Dec 1, 2018

Conversation

ascillato
Copy link
Contributor

RULES: Added BREAK as an alternative ENDON that will stop the execution for the rules that follows it.

If a rule that ends with BREAK, is triggered, then, the following rules of that set will not be executed. This is useful for cases like: #4477

Example:

With the actual rules, if we use a set like the following:

rule1
on event#temp>85 do VAR1 more85 endon
on event#temp>83 do VAR1 more83 endon
on event#temp>81 do VAR1 more81 endon
on event#temp=81 do VAR1 equal81 endon
on event#temp<81 do VAR1 less81 endon

We will have this output in the console :

19:43:18 CMD: rule
19:43:18 MQT: stat/living/RESULT = {"Rule1":"ON","Once":"ON","StopOnError":"OFF","Free":322,"Rules":"on event#temp>85 do VAR1 more85 endon on event#temp>83 do VAR1 more83 endon on event#temp>81 do VAR1 more81 endon on event#temp=81 do VAR1 equal81 endon on event#temp<81 do VAR1 less81 endon"}

19:43:24 CMD: event temp=10
19:43:24 MQT: stat/living/RESULT = {"Event":"Done"}
19:43:24 RUL: EVENT#TEMP<81 performs "VAR1 less81"
19:43:24 MQT: stat/living/RESULT = {"Var1":"less81"}

19:43:36 CMD: event temp=100
19:43:36 MQT: stat/living/RESULT = {"Event":"Done"}
19:43:36 RUL: EVENT#TEMP>85 performs "VAR1 more85"
19:43:36 MQT: stat/living/RESULT = {"Var1":"more85"}
19:43:36 RUL: EVENT#TEMP>83 performs "VAR1 more83"
19:43:36 MQT: stat/living/RESULT = {"Var1":"more83"}
19:43:36 RUL: EVENT#TEMP>81 performs "VAR1 more81"
19:43:36 MQT: stat/living/RESULT = {"Var1":"more81"}

So, all the rules where TEMP>100, are being triggered. If this scenario is not the desired one, now with this PR the rule set can be changed to:

rule
on event#temp>85 do VAR1 more85 break
on event#temp>83 do VAR1 more83 break
on event#temp>81 do VAR1 more81 endon
on event#temp=81 do VAR1 equal81 endon
on event#temp<81 do VAR1 less81 endon

So, you can have the following output:

18:00:17 CMD: rule
18:00:17 RSL: RESULT = {"Rule1":"ON","Once":"OFF","StopOnError":"OFF","Free":321,"Rules":"on event#temp>85 do VAR1 more85 break on event#temp>83 do VAR1 more83 break on event#temp>81 do VAR1 more81 endon on event#temp=81 do VAR1 equal81 endon on event#temp<81 do VAR1 less81 endon"}

18:00:25 CMD: event temp=10
18:00:25 RSL: RESULT = {"Event":"Done"}
18:00:25 RUL: EVENT#TEMP<81 performs "VAR1 less81"
18:00:25 RSL: RESULT = {"Var1":"less81"}

18:00:36 CMD: event temp=100
18:00:36 RSL: RESULT = {"Event":"Done"}
18:00:36 RUL: EVENT#TEMP>85 performs "VAR1 more85"
18:00:36 RSL: RESULT = {"Var1":"more85"}

18:01:05 CMD: event temp=83
18:01:05 RSL: RESULT = {"Event":"Done"}
18:01:05 RUL: EVENT#TEMP>81 performs "VAR1 more81"
18:01:05 RSL: RESULT = {"Var1":"more81"}

RULES: Added BREAK as an alternative ENDON that will stop the execution of the following rules.

If a rule that ends with BREAK, is triggered, then the following rules of that set will not be executed. This is useful for cases like: arendst#4477
@arendst
Copy link
Owner

arendst commented Dec 1, 2018

Compile fails.

pls chk the use of function min. It fails often. Search for min/max solutions within tasmota

@ascillato
Copy link
Contributor Author

Fixed 👍

Under core 2.3.0 there is no min command !!!! I didn't know that.
Under core 2.4.2 and stage min command is there and compiles fine.

@arendst arendst merged commit 4ced9c0 into arendst:development Dec 1, 2018
@ascillato ascillato deleted the patch-1 branch December 1, 2018 22:06
gemu2015 pushed a commit to gemu2015/Sonoff-Tasmota that referenced this pull request Jan 27, 2019
RULES: Added BREAK as an alternative ENDON
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants