arendst / Tasmota

Alternative firmware for ESP8266 and ESP32 based devices with easy configuration using webUI, OTA updates, automation using timers or rules, expandability and entirely local control over MQTT, HTTP, Serial or KNX. Full documentation at
https://tasmota.github.io/docs
GNU General Public License v3.0
21.93k stars 4.76k forks source link

Multiple rules triggered unexpectedly with temperature conditions #20719

Closed sxx1314 closed 6 months ago

sxx1314 commented 6 months ago

PROBLEM DESCRIPTION

A clear and concise description of what the problem is.

Description:

I have configured several rules based on temperature ranges in Tasmota, expecting them to be mutually exclusive. However, the issue is that multiple rules are being triggered simultaneously, even when the temperature only satisfies one condition.

Steps to reproduce:

- [ ] If using rules, provide the output of this command: `Backlog Rule1; Rule2; Rule3`:
```lua
  Rules output here:
Rule1
  ON Tele-DHT11#Temperature<20 DO Dimmer 0 ENDON
  ON Tele-DHT11#Temperature>=20 AND Tele-DHT11#Temperature<25 DO Dimmer 1 ENDON
  ON Tele-DHT11#Temperature>=25 AND Tele-DHT11#Temperature<28 DO Dimmer 2 ENDON
  ON Tele-DHT11#Temperature>=28 AND Tele-DHT11#Temperature<31 DO Dimmer 3 ENDON
  ON Tele-DHT11#Temperature>=31 AND Tele-DHT11#Temperature<34 DO Dimmer 4 ENDON
  ON Tele-DHT11#Temperature>=34 AND Tele-DHT11#Temperature<37 DO Dimmer 5 ENDON
  ON Tele-DHT11#Temperature>=37 AND Tele-DHT11#Temperature<40 DO Dimmer 6 ENDON
  ON Tele-DHT11#Temperature>=40 AND Tele-DHT11#Temperature<43 DO Dimmer 7 ENDON
  ON Tele-DHT11#Temperature>=43 AND Tele-DHT11#Temperature<46 DO Dimmer 10 ENDON
  ON Tele-DHT11#Temperature>=46 AND Tele-DHT11#Temperature<50 DO Dimmer 20 ENDON
  ON Tele-DHT11#Temperature>=55 DO Dimmer 100 ENDON
ELSE DO ENDON
- [ ] Set `weblog` to 4 and then, when you experience your issue, provide the output of the Console log:
```lua
  Console output here:
23:45:22.321 MQT: tele/tasmota_xxxx/SENSOR = {"Time":"2024-02-13T23:45:22","ANALOG":{"A0":816},"DHT11":{"Temperature":26.0,"Humidity":39.0,"DewPoint":11.0},"TempUnit":"C"}
23:45:22.347 RUL: TELE-DHT11#TEMPERATURE>=20 AND TELE-DHT11#TEMPERATURE<25 performs "Dimmer 1"
23:45:22.355 MQT: stat/tasmota_xxxx/RESULT = {"POWER":"ON","Dimmer":1}
23:45:22.371 RUL: TELE-DHT11#TEMPERATURE>=25 AND TELE-DHT11#TEMPERATURE<28 performs "Dimmer 2"
23:45:22.378 MQT: stat/tasmota_xxxx/RESULT = {"POWER":"ON","Dimmer":2}

TO REPRODUCE

Steps to reproduce the behavior:

EXPECTED BEHAVIOUR

A clear and concise description of what you expected to happen.

SCREENSHOTS

If applicable, add screenshots to help explain your problem.

ADDITIONAL CONTEXT

Add any other context about the problem here.

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

sfromis commented 6 months ago

Please do not be so creative as to assuming that rules supports things you'd like to have, but not part of how it works. Specifically that AND in the trigger part. Have you been getting horrible advice from ChatGPT? That "ELSE" part at the end looks like the type of hallucinations it is liable to have.

In your case, it might work to drop the AND part, and then use break instead of endon

And do read the docs. https://tasmota.github.io/docs/Rules/

sxx1314 commented 6 months ago

Please do not be so creative as to assuming that rules supports things you'd like to have, but not part of how it works. Specifically that AND in the trigger part. Have you being getting horrible advice from ChatGPT? That "ELSE" part at the end looks like the type of hallucinations it is liable to have.

In your case, it might work to drop the AND part, and then use break instead of endon

And do read the docs. https://tasmota.github.io/docs/Rules/

If I use the following rules, none of the conditions will be triggered anymore.

Rule1
ON Tele-DHT11#Temperature>=55 DO Dimmer 100; BREAK ENDON
ON Tele-DHT11#Temperature>=46 DO Dimmer 20; BREAK ENDON
ON Tele-DHT11#Temperature>=43 DO Dimmer 10; BREAK ENDON
ON Tele-DHT11#Temperature>=40 DO Dimmer 7; BREAK ENDON
ON Tele-DHT11#Temperature>=37 DO Dimmer 6; BREAK ENDON
ON Tele-DHT11#Temperature>=34 DO Dimmer 5; BREAK ENDON
ON Tele-DHT11#Temperature>=31 DO Dimmer 4; BREAK ENDON
ON Tele-DHT11#Temperature>=28 DO Dimmer 3; BREAK ENDON
ON Tele-DHT11#Temperature>=25 DO Dimmer 2; BREAK ENDON
ON Tele-DHT11#Temperature>=20 DO Dimmer 1; BREAK ENDON
ON Tele-DHT11#Temperature<20 DO Dimmer 0; BREAK ENDON
barbudor commented 6 months ago

Read again the syntax around BREAK

You have extra ; and ENDON

sxx1314 commented 6 months ago

Rule1 ON Tele-DHT11#Temperature>=55 DO Dimmer 100; BREAK ENDON ON Tele-DHT11#Temperature>=46 DO Dimmer 20; BREAK ENDON ON Tele-DHT11#Temperature>=43 DO Dimmer 10; BREAK ENDON ON Tele-DHT11#Temperature>=40 DO Dimmer 7; BREAK ENDON ON Tele-DHT11#Temperature>=37 DO Dimmer 6; BREAK ENDON ON Tele-DHT11#Temperature>=34 DO Dimmer 5; BREAK ENDON ON Tele-DHT11#Temperature>=31 DO Dimmer 4; BREAK ENDON ON Tele-DHT11#Temperature>=28 DO Dimmer 3; BREAK ENDON ON Tele-DHT11#Temperature>=25 DO Dimmer 2; BREAK ENDON ON Tele-DHT11#Temperature>=20 DO Dimmer 1; BREAK ENDON ON Tele-DHT11#Temperature<20 DO Dimmer 0; BREAK ENDON

Thank you for your help, it is working now.