Replies: 11 comments 14 replies
-
Break is meant to be used with same trigger |
Beta Was this translation helpful? Give feedback.
-
@barbudor This is an excerpt from documentation about BREAK statement:
But the correct wording should be:
Is that correct? |
Beta Was this translation helpful? Give feedback.
-
But when this is the behaviour of BREAK, how to stop execution of further rules in a ruleset by condition? |
Beta Was this translation helpful? Give feedback.
-
@barbudor Regarding what I want to achieve I'll explain my code step by step: Rule1
on event#t1 do ruletimer endon
on event#t1 do Backlog var5 %value%; mult5 0.75; <T1=%value%>; <T1_75=%var5%> endon
on event#t1<%mem1% do backlog var3 1; "rule1-3 T1 unter Schwellwert Pumpe immer EIN" break <== BREAK RULE
on Tele-DS18B20-2#Temperature DO event t2=%Value% endon
on event#t2>%var5% DO backlog var3 0; "rule1-1 T2 > Grenzwert Pumpe AUS" endon <== this is executed in spite of break
on event#t2<%var5% DO backlog var3 1; "rule1-2 T2 < Grenzwert Pumpe EIN" endon
My question is: Is it possible to achieve a real BREAK in a ruleset regardless if there are more triggers |
Beta Was this translation helpful? Give feedback.
-
When performing an event command the rules using the event as a trigger is executed right after. Event are often used for triggering rules from outide (mqtt command for example) or as some kind of 'subroutine' if you a multiple commands (backlog) that you want to be executed from different triggers A "real break" means nothing for Rules that are trigger based. You may need to go for IF to prevent some executions. I'll look more in details in your goal later today and may be able to suggest something |
Beta Was this translation helpful? Give feedback.
-
When all is event driven and there is no real BREAK possible, I think the approach could be to move each control situation to a separate ruleset and activate rule1/2/3 as required. My current approach was different: Rule1 (on and off):
Rule2 (always on):
Rule3 (always on):
Algorithm should provide this behaviour of Power output:
I think when dispatching different jobs (the BREAK situation) to different rulesets this could provide a break-similar behaviour? |
Beta Was this translation helpful? Give feedback.
-
My current version:
I'll try to explain the goal of my code: The code always has to switch on power if temperature 1 (T1) is lower than limit in MEM1. |
Beta Was this translation helpful? Give feedback.
-
@barbudor Example with my Rule1:
equivalent with
Are they having the same result and command sequence? Or are all rules in a rule set depending from one trigger executed |
Beta Was this translation helpful? Give feedback.
-
As I follow the discussion related this issue here I see that existing documentation related RULES is not as accurate as it needs to be to understand the real behavior! It's mandatory to distinguish between PLC programming or any sequence like approach many programmers know. The event driven mechanism, the three rule sets and their dependencies needs to have an own part in documentation! |
Beta Was this translation helpful? Give feedback.
-
A call to the core maintainers: All which have this knowledge should assist ! |
Beta Was this translation helpful? Give feedback.
-
@csb0730 I also agree the documentation is ambiguous and 3 years later this hasn't changed. It actually only applies to the next rule in the series, as you pointed! Thanks |
Beta Was this translation helpful? Give feedback.
-
Hello guys,
I'm trying to get following ruleset to work properly and have read all documentation I can find. But regardless what I'm doing I cannot get the BREAK working as expected (the following rules shouldn't be executed).
This is the ruleset:
Rule1
on Tele-DS18B20-1#Temperature DO event t1=%Value% endon
on event#t1 do ruletimer endon
on event#t1 do Backlog var5 %value%; mult5 0.75; <T1=%value%>; <T1_75=%var5%> endon
on event#t1<%mem1% do backlog var3 1; "rule1-3 T1 unter Schwellwert Pumpe immer EIN" break <=== break rule
on Tele-DS18B20-2#Temperature DO event t2=%Value% endon
on event#t2>%var5% DO backlog var3 0; "rule1-1 T2 > Grenzwert Pumpe AUS" endon <== this is executed in spite of break
on event#t2<%var5% DO backlog var3 1; "rule1-2 T2 < Grenzwert Pumpe EIN" endon
This is console output:
12:11:09.442 RUL: TELE-DS18B20-1#TEMPERATURE performs "backlog event t1=38.8"
12:11:09.456 RUL: TELE-DS18B20-2#TEMPERATURE performs "backlog event t2=34.7"
12:11:09.492 RSL: RESULT = {"Event":"Done"}
12:11:09.523 RUL: EVENT#T1 performs "ruletimer"
12:11:09.528 RSL: RESULT = {"T1":170,"T2":0,"T3":0,"T4":0,"T5":0,"T6":0,"T7":0,"T8":0}
12:11:09.542 RUL: EVENT#T1 performs "Backlog var5 38.8; mult5 0.75; <T1=38.8>; <T1_75=29.100>"
12:11:09.557 RUL: EVENT#T1<%MEM1% performs "backlog var3 1; "rule1-3 T1 unter Schwellwert Pumpe immer EIN""
12:11:09.600 RSL: RESULT = {"Event":"Done"}
==> This next rule should not be executed because of the BREAK in the rule before
12:11:09.640 RUL: EVENT#T2>%VAR5% performs "backlog var3 0; "rule1-1 T2 > Grenzwert Pumpe AUS"" <== NOK
12:11:09.659 RSL: RESULT = {"Var5":"38.8"}
12:11:09.909 RSL: RESULT = {"Mult5":"29.100"}
12:11:10.286 RSL: RESULT = {"Var3":"1"}
12:11:10.340 RUL: VAR3#STATE performs "backlog Power 1; "Rule 2 schaltet Ausgang auf 1""
12:11:10.400 RSL: RESULT = {"Var3":"0"}
12:11:10.449 RUL: VAR3#STATE performs "backlog Power 0; "Rule 2 schaltet Ausgang auf 0""
12:11:10.511 RSL: RESULT = {"POWER":"ON"}
12:11:10.514 RSL: POWER = ON
12:11:10.811 RSL: RESULT = {"POWER":"OFF"}
12:11:10.813 RSL: POWER = OFF
What can I do to get it work as expected? I mean to let break not execute any rule afterwards in a ruleset?
Am I doing something wrong?
Is there a relation between BREAK behaviour and event triggering after a break?
Background about device:
I'm using a Shelly 1.
Tasmota Version is 12.0.2
Version date and Time 2022.06.20 12:45:11
Core / SDK Version 2_7_4_9/2.2.2-dev(38a443e)
Beta Was this translation helpful? Give feedback.
All reactions