Tasmota: Rule Break Not Working as Expected

Created on 5 Sep 2020  路  16Comments  路  Source: arendst/Tasmota

PROBLEM DESCRIPTION

When there is "BREAK" on rules, they doesnt work as expected when you try to trigger a value between a maximun or minimum.

Please this is just an example but this applies on most of configurations on this type. For example turn on a fan (maximum power, switch 2) when the temperature is above 20掳C, turn on the same fan (minimum power, switch 1) when the temperature is between 10 and 20掳C and turn off the fan when the temperature is lower 10掳C.

Values are very floating so its necesary to set to Rule1 5 option, to just read it once, otherwise it will be trigger rules all time like crazy.
So reading the rules cookbook is just a simple rule, something like this.

Rule1
on DS18B20#Temperature>20 do Action "A" break
on DS18B20#Temperature>10 do Action "B" endon
on DS18B20#Temperature<=10 do Action "C" endon

just to simplify
Action "A" should be a backlog power1 0; power2 1 (maximum power)
Action "B" should be a backlog power1 1; power2 0 (minimum power)
Action "C" should be a backlog power1 0; power2 0 (all off)

THE ISSUE ITSELF
In the same example lets study what happen to the output if we input some values. Please follow the order, this is very important for the description of the issue.

Input: Sensor = 9掳C
Output: Action "C" (thats fine)

Input: Sensor = 14掳C
Output: Action "B" (thats fine)

Input: Sensor = 21掳C
Output: Action "A" (thats fine)

Input: Sensor = 17掳C
Output: Nothing happens (here is the issue, it should trigger Action "B")

Input: Sensor = 8掳C
Output: Action "C"

In summary there are 6 combinations from one to another action. With that configuration
From "C" to "B" works
From "C" to "A" works
From "B" to "A" works
From "A" to "B" (this is not trigger)
From "A" to "C" works

EXPERIMENTING
I didnt stop and tried to figure what happen if i try another order or combine endon and break seems interesting what happen with this configuration.

Rule1
on DS18B20#Temperature>20 do Action "A" break
on DS18B20#Temperature>10 do Action "B" break
on DS18B20#Temperature<=10 do Action "C" endon

To make it short this happens

From "C" to "B" works
From "C" to "A" works
From "B" to "A" (this is not trigger)
From "A" to "B" works
From "A" to "C" works

REQUESTED INFORMATION

_Make sure your have performed every step and checked the applicable boxes before submitting your issue. Thank you!_

  • [x] Read the Contributing Guide and Policy and the Code of Conduct
  • [x] Searched the problem in issues
  • [x] Searched the problem in the docs
  • [x] Searched the problem in the forum
  • [ ] Searched the problem in the chat
  • [x] Device used: Wemos D1 mini PRO
  • [x] Tasmota binary firmware version number used: 8.4.0(sensors) (Release branch) Core/SDK Version | 2_7_2_1/2.2.2-dev(38a443e)

    • [x] Pre-compiled 8.4.0(sensors) (Release branch)

    • [ ] Self-compiled

  Configuration output here:
22:50:10 CMD: status 0
22:50:10 MQT: stat/estanque/STATUS = {"Status":{"Module":18,"DeviceName":"Estanque","FriendlyName":["Estanque"],"Topic":"estanque","ButtonTopic":"0","Power":0,"PowerOnState":3,"LedState":0,"LedMask":"FFFF","SaveData":1,"SaveState":1,"SwitchTopic":"0","SwitchMode":[0,0,0,0,0,0,0,0],"ButtonRetain":0,"SwitchRetain":0,"SensorRetain":0,"PowerRetain":1}}
22:50:10 MQT: stat/estanque/STATUS1 = {"StatusPRM":{"Baudrate":115200,"SerialConfig":"8N1","GroupTopic":"tasmotas","OtaUrl":"http://thehackbox.org/tasmota/release/tasmota-sensors.bin","RestartReason":"Power On","Uptime":"1T10:34:21","StartupUTC":"2020-09-08T15:15:49","Sleep":50,"CfgHolder":4617,"BootCount":9,"BCResetTime":"2020-08-24T22:38:36","SaveCount":757,"SaveAddress":"FA000"}}
22:50:10 MQT: stat/estanque/STATUS2 = {"StatusFWR":{"Version":"8.4.0(sensors)","BuildDateTime":"2020-07-29T12:08:32","Boot":31,"Core":"2_7_2_1","SDK":"2.2.2-dev(38a443e)","CpuFrequency":80,"Hardware":"ESP8266EX","CR":"382/699"}}
22:50:10 MQT: stat/estanque/STATUS3 = {"StatusLOG":{"SerialLog":2,"WebLog":2,"MqttLog":0,"SysLog":0,"LogHost":"","LogPort":514,"SSId":["NETGEAR",""],"TelePeriod":180,"Resolution":"558180C0","SetOption":["00008029","2805C8000100060000005A00000000000000","00000000","00006000"]}}
22:50:10 MQT: stat/estanque/STATUS4 = {"StatusMEM":{"ProgramSize":621,"Free":380,"Heap":19,"ProgramFlashSize":1024,"FlashSize":16384,"FlashChipId":"1840EF","FlashFrequency":40,"FlashMode":3,"Features":["00000809","8FDA8787","0415A005","B7FFBFCD","01DA9BC4","64367CC7","00084052"],"Drivers":"1,2,3,4,5,6,7,8,9,10,12,14,16,17,20,21,24,29,34","Sensors":"1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,26,28,31,34,37,39,40,42,43,51,52,55,56,58,59,62,64,66,67,74"}}
22:50:10 MQT: stat/estanque/STATUS5 = {"StatusNET":{"Hostname":"estanque-6001","IPAddress":"192.168.1.54","Gateway":"192.168.1.1","Subnetmask":"255.255.255.0","DNSServer":"192.168.1.1","Mac":"CC:50:E3:63:77:71","Webserver":2,"WifiConfig":4,"WifiPower":17.0}}
22:50:10 MQT: stat/estanque/STATUS6 = {"StatusMQT":{"MqttHost":"192.168.1.51","MqttPort":1883,"MqttClientMask":"DVES_%06X","MqttClient":"DVES_637771","MqttUser":"MQTTadmin","MqttCount":1,"MAX_PACKET_SIZE":1200,"KEEPALIVE":30}}
22:50:10 MQT: stat/estanque/STATUS7 = {"StatusTIM":{"UTC":"2020-09-10T01:50:10","Local":"2020-09-09T22:50:10","StartDST":"2020-09-06T00:00:00","EndDST":"2020-04-05T00:00:00","Timezone":99,"Sunrise":"07:49","Sunset":"19:33"}}
22:50:10 MQT: stat/estanque/STATUS10 = {"StatusSNS":{"Time":"2020-09-09T22:50:10","DHT11":{"Temperature":12.7,"Humidity":53.0,"DewPoint":3.3},"SR04":{"Distance":31.965},"TempUnit":"C"}}
22:50:10 MQT: stat/estanque/STATUS11 = {"StatusSTS":{"Time":"2020-09-09T22:50:10","Uptime":"1T10:34:21","UptimeSec":124461,"Heap":19,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":26,"MqttCount":1,"Wifi":{"AP":1,"SSId":"NETGEAR","BSSId":"DC:EF:09:B0:FD:21","Channel":3,"RSSI":62,"Signal":-69,"LinkCount":1,"Downtime":"0T00:02:38"}}}

  • [x] If using rules, provide the output of this command: Backlog Rule1; Rule2; Rule3:
22:53:18 CMD: Backlog Rule1; Rule2; Rule3
22:53:18 MQT: stat/estanque/RESULT = {"Rule1":"ON","Once":"ON","StopOnError":"OFF","Length":226,"Free":285,"Rules":"on SR04#distance>133 do backlog LedPower1 0; LedPower2 0; LedPower3 1 break on SR04#distance>74 do backlog LedPower1 0; LedPower2 1; LedPower3 0 endon on SR04#distance<=74 do backlog LedPower1 1; LedPower2 0; LedPower3 0 endon"}
22:53:19 MQT: stat/estanque/RESULT = {"Rule2":"OFF","Once":"OFF","StopOnError":"OFF","Length":0,"Free":511,"Rules":""}
22:53:19 MQT: stat/estanque/RESULT = {"Rule3":"OFF","Once":"OFF","StopOnError":"OFF","Length":0,"Free":511,"Rules":""}

##Just to see more clear the real rule, as the example, is the same as "action A, B, C"
Rule1
on SR04#distance>133 do backlog LedPower1 0; LedPower2 0; LedPower3 1 break
on SR04#distance>74 do backlog LedPower1 0; LedPower2 1; LedPower3 0 endon
on SR04#distance<=74 do backlog LedPower1 1; LedPower2 0; LedPower3 0 endon

  • [x] Provide the output of this command: Status 0:
22:50:10 CMD: status 0
22:50:10 MQT: stat/estanque/STATUS = {"Status":{"Module":18,"DeviceName":"Estanque","FriendlyName":["Estanque"],"Topic":"estanque","ButtonTopic":"0","Power":0,"PowerOnState":3,"LedState":0,"LedMask":"FFFF","SaveData":1,"SaveState":1,"SwitchTopic":"0","SwitchMode":[0,0,0,0,0,0,0,0],"ButtonRetain":0,"SwitchRetain":0,"SensorRetain":0,"PowerRetain":1}}
22:50:10 MQT: stat/estanque/STATUS1 = {"StatusPRM":{"Baudrate":115200,"SerialConfig":"8N1","GroupTopic":"tasmotas","OtaUrl":"http://thehackbox.org/tasmota/release/tasmota-sensors.bin","RestartReason":"Power On","Uptime":"1T10:34:21","StartupUTC":"2020-09-08T15:15:49","Sleep":50,"CfgHolder":4617,"BootCount":9,"BCResetTime":"2020-08-24T22:38:36","SaveCount":757,"SaveAddress":"FA000"}}
22:50:10 MQT: stat/estanque/STATUS2 = {"StatusFWR":{"Version":"8.4.0(sensors)","BuildDateTime":"2020-07-29T12:08:32","Boot":31,"Core":"2_7_2_1","SDK":"2.2.2-dev(38a443e)","CpuFrequency":80,"Hardware":"ESP8266EX","CR":"382/699"}}
22:50:10 MQT: stat/estanque/STATUS3 = {"StatusLOG":{"SerialLog":2,"WebLog":2,"MqttLog":0,"SysLog":0,"LogHost":"","LogPort":514,"SSId":["NETGEAR",""],"TelePeriod":180,"Resolution":"558180C0","SetOption":["00008029","2805C8000100060000005A00000000000000","00000000","00006000"]}}
22:50:10 MQT: stat/estanque/STATUS4 = {"StatusMEM":{"ProgramSize":621,"Free":380,"Heap":19,"ProgramFlashSize":1024,"FlashSize":16384,"FlashChipId":"1840EF","FlashFrequency":40,"FlashMode":3,"Features":["00000809","8FDA8787","0415A005","B7FFBFCD","01DA9BC4","64367CC7","00084052"],"Drivers":"1,2,3,4,5,6,7,8,9,10,12,14,16,17,20,21,24,29,34","Sensors":"1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,26,28,31,34,37,39,40,42,43,51,52,55,56,58,59,62,64,66,67,74"}}
22:50:10 MQT: stat/estanque/STATUS5 = {"StatusNET":{"Hostname":"estanque-6001","IPAddress":"192.168.1.54","Gateway":"192.168.1.1","Subnetmask":"255.255.255.0","DNSServer":"192.168.1.1","Mac":"CC:50:E3:63:77:71","Webserver":2,"WifiConfig":4,"WifiPower":17.0}}
22:50:10 MQT: stat/estanque/STATUS6 = {"StatusMQT":{"MqttHost":"192.168.1.51","MqttPort":1883,"MqttClientMask":"DVES_%06X","MqttClient":"DVES_637771","MqttUser":"MQTTadmin","MqttCount":1,"MAX_PACKET_SIZE":1200,"KEEPALIVE":30}}
22:50:10 MQT: stat/estanque/STATUS7 = {"StatusTIM":{"UTC":"2020-09-10T01:50:10","Local":"2020-09-09T22:50:10","StartDST":"2020-09-06T00:00:00","EndDST":"2020-04-05T00:00:00","Timezone":99,"Sunrise":"07:49","Sunset":"19:33"}}
22:50:10 MQT: stat/estanque/STATUS10 = {"StatusSNS":{"Time":"2020-09-09T22:50:10","DHT11":{"Temperature":12.7,"Humidity":53.0,"DewPoint":3.3},"SR04":{"Distance":31.965},"TempUnit":"C"}}
22:50:10 MQT: stat/estanque/STATUS11 = {"StatusSTS":{"Time":"2020-09-09T22:50:10","Uptime":"1T10:34:21","UptimeSec":124461,"Heap":19,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":26,"MqttCount":1,"Wifi":{"AP":1,"SSId":"NETGEAR","BSSId":"DC:EF:09:B0:FD:21","Channel":3,"RSSI":62,"Signal":-69,"LinkCount":1,"Downtime":"0T00:02:38"}}}

  • [x] Provide the output of the Console log output when you experience your issue; if applicable:
    _(Please use_ weblog 4 _for more debug information)_
### on the Rule1 when on SR04#distance>133 change to SR04#distance>74 nothing happen
### A real case

Input: SR04#distance = 140
Output: backlog LedPower1 0; LedPower2 0; LedPower3 1

Input: SR04#distance = 120
Output: nothing happen (it should do backlog LedPower1 0; LedPower2 1; LedPower3 0)

TO REPRODUCE

Set Rule1 5
Make a rule with 3 fields:
A > X
X > B > Y
C < Y

While X is the maximum value and Y is the minimum value
A, B, C are the triggers

EXPECTED BEHAVIOUR

The expectation is to have a fluid trigger depending the value.
In the same example is Rule1 should trigger the condition in both directions.

From A to B // from B to C // from C to B // from B to A
A -> B -> C -> B -> A

And exeptional cases
From A to C // from C to A
A -> C
C -> A

SCREENSHOTS

ADDITIONAL CONTEXT

This is maybe a bug that have the function BREAK, it seems that it doesnt refresh values to trigger because at a big change of values, it should trigger if the value reach to the field that correspond.

(Please, remember to close the issue when the problem has been addressed)

bug fixed

All 16 comments

Do you have set to trigger as ONE SHOOT in the rule?

I mean rule1 5?

Besides, please, could you be so kind to complete the troubleshooting template in order to have more information to debug this issue? Thanks.

@ascillato2 Thank you for handle this.

I completed the template as requested.
And yes... rule1 5 is setted. Otherwise rule is triggered every 2 seconds

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Updated at latest version, issue still remaining

I can confirm the same behavior, I wondered the whole time what I was doing wrong.

Yes! the break function is bugged when you try with three or more fields to trigger, no matter the order or the direcion.

I'll try to understand the issue...

The good thing is I can reproduce with the following rule and only with ONCE enabled:

on var1#state>20 do dimmer 50 break on var1#state>10 do dimmer 30 endon on var1#state<=10 do dimmer 10 endon

It's ONCE related so I think I can solve this...

I am not so sure, I will test, but in my case, it was not related with ONCE. I had the rule running on normally.

I'll wait till the 9.0.0.3 release is available to test the changes

Tested with http://ota.tasmota.com/tasmota/
tasmota-sensors.bin | http://ota.tasmota.com/tasmota/tasmota-sensors.bin | 631k | 9.1.0.1 | 20201112 15:17

The issue persists, but different.
My Rule

Rule1
on SR04#distance>133 do backlog LedPower1 0; LedPower2 0; LedPower3 1 break
on SR04#distance>74 do backlog LedPower1 0; LedPower2 1; LedPower3 0 endon
on SR04#distance<=74 do backlog LedPower1 1; LedPower2 0; LedPower3 0 endon

When a value above 133cm it triggers the first action, but then inmidiatly triggers the second action.

Example change from 85cm to 167cm and stay on 167cm
Output:

12:34:01 RUL: SR04#DISTANCE>133 performs "backlog LedPower1 0; LedPower2 0; LedPower3 1"
12:34:01 MQT: stat/estanque/RESULT = {"LedPower1":"OFF"}
12:34:02 MQT: stat/estanque/RESULT = {"LedPower2":"OFF"}
12:34:02 MQT: stat/estanque/RESULT = {"LedPower3":"ON"}
12:34:06 RUL: SR04#DISTANCE>74 performs "backlog LedPower1 0; LedPower2 1; LedPower3 0"
12:34:06 MQT: stat/estanque/RESULT = {"LedPower1":"OFF"}
12:34:06 MQT: stat/estanque/RESULT = {"LedPower2":"ON"}
12:34:06 MQT: stat/estanque/RESULT = {"LedPower3":"OFF"}

Cannot reproduce. Using the rule shown before:

on var1#state>20 do dimmer 50 break on var1#state>10 do dimmer 30 endon on var1#state<=10 do dimmer 10 endon

it still works as designed.

What you may encounter is a retrigger from the rule within 4 seconds which reports several distances due to "not so stable" sensor.

You may emulate by entering different values on var1 on this case the most high value from break. (remember set rule1 5, to ONCE)
Try to enter random values above 20 in your case, 25-31-28-23, you should trigger dimmer 50 then a few seconds after that it triggers dimmer 30.

For stability its ok for integer values, but for decimal, it is very floating on a range +/- 0.3
32.372
32.563
32.428

for me "break" doesn't work with this rule too

Rule1
ON system # boot DO Backlog RuleTimer1 10; Var1 255 ENDON
ON rules # timer! = 1 BREAK
ON BME280 # Humidity <65 DO Backlog SUB1 1 ENDON
ON BME280 # Humidity> 70 DO Backlog ADD1 1 ENDON
ON Var1 # State <0 DO Var1 0 ENDON
ON Var1 # State> 1023 DO Var1 1023 ENDON
ON rules # timer = 1 DO Backlog PWM5% Var1%; Ruletimer1 5 ENDON

the humidity is triggered 2 times a second ...

22:27:58 CMD: Rule1 ON system#boot DO Backlog RuleTimer1 10; Var1 255 ENDON ON rules#timer!=1 BREAK ON BME280#Humidity<65 DO Backlog SUB1 1 ENDON ON BME280#Humidity>70 DO Backlog ADD1 1 ENDON ON Var1#State < 0 DO Var1 0 ENDON ON Var1#State > 1023 DO Var1 1023 ENDON ON rules#timer=1 DO Backlog PWM5 %Var1%; Ruletimer1 5 ENDON
22:27:58 RUL: Stored uncompressed, would compress from 328 to 197 (-40%)
22:27:58 MQT: stat/tasmota_GB1_FCDDF0/RESULT = {"Rule1":"ON","Once":"OFF","StopOnError":"OFF","Length":328,"Free":183,"Rules":"ON system#boot DO Backlog RuleTimer1 10; Var1 255 ENDON ON rules#timer!=1 BREAK ON BME280#Humidity<65 DO Backlog SUB1 1 ENDON ON BME280#Humidity>70 DO Backlog ADD1 1 ENDON ON Var1#State < 0 DO Var1 0 ENDON ON Var1#State > 1023 DO Var1 1023 ENDON ON rules#timer=1 DO Backlog PWM5 %Var1%; Ruletimer1 5 ENDON "}
22:27:58 RUL: BME280#HUMIDITY<65 performs "Backlog SUB1 1"
22:27:58 MQT: stat/tasmota_GB1_FCDDF0/RESULT = {"Sub1":"122.000"}
22:27:59 RUL: BME280#HUMIDITY<65 performs "Backlog SUB1 1"
22:27:59 MQT: stat/tasmota_GB1_FCDDF0/RESULT = {"Sub1":"121.000"}
22:27:59 RUL: BME280#HUMIDITY<65 performs "Backlog SUB1 1"
22:27:59 MQT: stat/tasmota_GB1_FCDDF0/RESULT = {"Sub1":"120.000"}
22:27:59 RUL: RULES#TIMER=1 performs "Backlog PWM5 120.000; Ruletimer1 5"
22:28:00 MQT: stat/tasmota_GB1_FCDDF0/RESULT = {"PWM":{"PWM1":1023,"PWM2":1023,"PWM3":1023,"PWM4":1023,"PWM5":120}}
22:28:00 RUL: PWM#PWM5 performs "VAR5 120"
22:28:00 MQT: stat/tasmota_GB1_FCDDF0/RESULT = {"Var5":"120"}
22:28:00 MQT: stat/tasmota_GB1_FCDDF0/RESULT = {"T1":5,"T2":0,"T3":0,"T4":0,"T5":0,"T6":0,"T7":0,"T8":0}
22:28:00 RUL: BME280#HUMIDITY<65 performs "Backlog SUB1 1"
22:28:00 MQT: stat/tasmota_GB1_FCDDF0/RESULT = {"Sub1":"119.000"}
22:28:00 RUL: BME280#HUMIDITY<65 performs "Backlog SUB1 1"
22:28:01 MQT: stat/tasmota_GB1_FCDDF0/RESULT = {"Sub1":"118.000"}
22:28:01 RUL: BME280#HUMIDITY<65 performs "Backlog SUB1 1"
22:28:01 MQT: stat/tasmota_GB1_FCDDF0/RESULT = {"Sub1":"117.000"}
22:28:02 RUL: BME280#HUMIDITY<65 performs "Backlog SUB1 1"
22:28:02 MQT: stat/tasmota_GB1_FCDDF0/RESULT = {"Sub1":"116.000"}
22:28:02 RUL: BME280#HUMIDITY<65 performs "Backlog SUB1 1"

or do i have a mistake in my rule or do i understand the break function incorrectly?

Before I wanted to send this I thought to myself, I'd rather test again with the current develop version, so off to gitpod :) but I can't compile the current dev version with my config for esp32cam, the master version compiles without problems.

Indexing .pio/build/tasmota32/libFrameworkArduino.a
Linking .pio/build/tasmota32/firmware.elf
/home/gitpod/.platformio/packages/toolchain-xtensa32/bin/../lib/gcc/xtensa-esp32-elf/5.2.0/../../../../xtensa-esp32-elf/bin/ld: .pio/build/tasmota32/firmware.elf section .iram0.text' will not fit in regioniram0_0_seg'
/home/gitpod/.platformio/packages/toolchain-xtensa32/bin/../lib/gcc/xtensa-esp32-elf/5.2.0/../../../../xtensa-esp32-elf/bin/ld: IRAM0 segment data does not fit.
/home/gitpod/.platformio/packages/toolchain-xtensa32/bin/../lib/gcc/xtensa-esp32-elf/5.2.0/../../../../xtensa-esp32-elf/bin/ld: region `iram0_0_seg' overflowed by 18212 bytes
collect2: error: ld returned 1 exit status
* [.pio/build/tasmota32/firmware.elf] Error 1

@j0seph1387

your rules have syntax errors, that is why they don't work. You have spaces where they shouldn't be and you have missing some DO.

for example ON system # boot DO Backlog RuleTimer1 10; Var1 255 ENDON, should be ON system#boot DO Backlog RuleTimer1 10; Var1 255 ENDON

then, ON rules # timer! = 1 BREAK should be ON rules#timer=1 do [some command] BREAK

Please, re check the docs for syntax. Thanks.

Sorry, I can not reproduce it either using the rule shown before. Seems that your sensor value is fluctuating.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

wirelesssolution picture wirelesssolution  路  3Comments

TylerDurden23 picture TylerDurden23  路  3Comments

j4k3 picture j4k3  路  3Comments

Ndrinta picture Ndrinta  路  3Comments

smadds picture smadds  路  3Comments