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
22.12k stars 4.79k forks source link

SI7021 temperature in rules directly after start #3811

Closed simonCor closed 6 years ago

simonCor commented 6 years ago

When a rule like "on si7021#Temperature<5 do Power1 1 endon" is used, the action is always executed after start although the temperature is around 20°C.

I assume that the sensor has a default value (0?) which is used at the first run before a valid value is read.

Also, make sure these boxes are checked [x] before submitting your issue - Thank you!

To Reproduce

Expected behavior The device should not switch on.

Additional context I assume, that the sensor has a default value (0 maybe?) set before the first communication with the sensor is established.

ascillato2 commented 6 years ago

Hi,

I could not reproduce it.

Please, can you share your output of your Tasmota console at startup? May be, your power on cames from another thing and not from your rule.

ascillato2 commented 6 years ago

Hi,

Please, when you have time, share the requested information. Thanks.

simonCor commented 6 years ago

Sorry that this took this long @ascillato2. The week was very busy.

Here is the requested output:

00:00:00 Project sonoff HeizungKeller (Topic sonoff, Fallback DVES_4295F8, GroupTopic sonoffs) Version 6.2.1-2_3_0 00:00:00 WIF: Connecting to AP2 lan in mode 11N as sonoff-5624... 00:00:00 RUL: SI7021#TEMPERATURE<5 performs "Power1 1" 00:00:00 RSL: RESULT = {"POWER":"ON"} 00:00:00 RSL: POWER = ON 00:00:06 RSL: INFO1 = {"Module":"Sonoff TH","Version":"6.2.1","FallbackTopic":"DVES_4295F8","GroupTopic":"sonoffs"} 00:00:06 RSL: INFO2 = {"WebServerMode":"Admin","Hostname":"sonoff-5624","IPAddress":"192.168.28.193"} 00:00:06 RSL: INFO3 = {"RestartReason":"Software/System restart"} 00:00:06 RSL: RESULT = {"POWER":"ON"} 00:00:06 RSL: POWER = ON 00:00:07 WIF: Connected 00:00:07 DNS: Initialized 00:00:07 HTP: Web server active on sonoff-5624.local with IP address 192.168.28.193 20:16:40 RSL: STATE = {"Time":"2018-09-25T20:16:40","Uptime":"0T00:00:15","Vcc":3.245,"POWER":"ON","Wifi":{"AP":2,"SSId":"lan","RSSI":100,"APMac":"08:96:D7:0E:99:02"}} 20:16:40 RSL: SENSOR = {"Time":"2018-09-25T20:16:40","SI7021":{"Temperature":21.8,"Humidity":46.7},"TempUnit":"C"}

Also note that there was a small error in the description

Insert command "Rule 1 on si7021#Temperature<5 do Power1 1 endon"

had a space between Rule and 1. The corrected one is:

Insert command "Rule1 on si7021#Temperature<5 do Power1 1 endon"

With just copy and pasting the rule did not change.

ascillato2 commented 6 years ago

Hi,

I'm sorry. I recheck on my device and yes, it is happening the issue you reported. I was not seeing that because I had another rule on system boot that was turning off the relay.

So, I could reproduce your issue. It is a Bug.

My console output at startup:

00:00:00 Proyecto sonoff Riego (Topic riego, Fallback DVES_8A64E6, GroupTopic sonoffs) Versión 6.2.1.6-2_4_2
00:00:00 WIF: Connectando a AP2 NetWireless en modo 11N como riego-1254...
00:00:00 RUL: SI7021#TEMPERATURE<5 performs "Power1 1"
00:00:00 RSL: stat/riego/RESULT = {"POWER1":"ON"}
00:00:00 RSL: stat/riego/POWER1 = ON
00:00:04 WIF: Conectado
00:00:04 HTP: Servidor web activo en riego-1254 con dirección IP 192.168.1.21
00:00:05 MQT: Intentando conectar...
20:16:06 MQT: Conectado
20:16:06 MQT: tele/riego/LWT = Online (Grabado)
20:16:06 MQT: cmnd/riego/POWER = 
20:16:06 MQT: tele/riego/INFO1 = {"Module":"Generic","Version":"6.2.1.6","FallbackTopic":"DVES_8A64E6","GroupTopic":"sonoffs"}
20:16:06 MQT: tele/riego/INFO2 = {"WebServerMode":"Admin","Hostname":"riego-1254","IPAddress":"192.168.1.21"}
20:16:06 MQT: tele/riego/INFO3 = {"RestartReason":"Software/System restart"}
20:16:06 MQT: stat/riego/RESULT = {"POWER1":"ON"}
20:16:06 MQT: stat/riego/POWER1 = ON
20:16:06 MQT: stat/riego/RESULT = {"POWER2":"OFF"}
20:16:06 MQT: stat/riego/POWER2 = OFF
20:16:06 MQT: stat/riego/RESULT = {"POWER3":"OFF"}
20:16:06 MQT: stat/riego/POWER3 = OFF
20:16:06 MQT: stat/riego/RESULT = {"POWER4":"OFF"}
20:16:06 MQT: stat/riego/POWER4 = OFF
20:16:06 MQT: stat/riego/RESULT = {"POWER5":"OFF"}
20:16:06 MQT: stat/riego/POWER5 = OFF
20:16:06 MQT: stat/riego/RESULT = {"POWER6":"OFF"}
20:16:06 MQT: stat/riego/POWER6 = OFF
20:16:06 MQT: stat/riego/RESULT = {"POWER7":"OFF"}
20:16:06 MQT: stat/riego/POWER7 = OFF
20:16:06 RUL: SYSTEM#BOOT performs "backlog power1 off;power2 off;power3 off;power4 off; power5 off; power6 off; power7 off"
20:16:06 MQT: stat/riego/RESULT = {"POWER1":"OFF"}
20:16:06 MQT: stat/riego/POWER1 = OFF
20:16:07 MQT: stat/riego/RESULT = {"POWER2":"OFF"}
20:16:07 MQT: stat/riego/POWER2 = OFF
20:16:07 MQT: stat/riego/RESULT = {"POWER3":"OFF"}
20:16:07 MQT: stat/riego/POWER3 = OFF
20:16:07 MQT: stat/riego/RESULT = {"POWER4":"OFF"}
20:16:07 MQT: stat/riego/POWER4 = OFF
20:16:08 MQT: stat/riego/RESULT = {"POWER5":"OFF"}
20:16:08 MQT: stat/riego/POWER5 = OFF
20:16:08 MQT: stat/riego/RESULT = {"POWER6":"OFF"}
20:16:08 MQT: stat/riego/POWER6 = OFF
20:16:08 MQT: stat/riego/RESULT = {"POWER7":"OFF"}
20:16:08 MQT: stat/riego/POWER7 = OFF
20:16:15 MQT: tele/riego/STATE = {"Time":"2018-09-25T20:16:15","Uptime":"0T00:00:17","POWER1":"OFF","POWER2":"OFF","POWER3":"OFF","POWER4":"OFF","POWER5":"OFF","POWER6":"OFF","POWER7":"OFF","Wifi":{"AP":2,"SSId":"NetWireless","BSSId":"18:D6:C7:80:38:2C","Channel":1,"RSSI":26}}
20:16:15 KNX: Temperatura enviada a 4.1.1 
20:16:15 KNX: Humedad enviada a 4.1.2 
20:16:15 MQT: tele/riego/SENSOR = {"Time":"2018-09-25T20:16:15","COUNTER":{"C1":0},"ANALOG":{"A0":2},"SI7021":{"Temperature":20.0,"Humidity":18.2},"TempUnit":"C"}

My status 0:

20:22:49 CMD: status 0
20:22:49 MQT: stat/riego/STATUS = {"Status":{"Module":18,"FriendlyName":["Riego","Riego2","Riego3","Riego4"],"Topic":"riego","ButtonTopic":"0","Power":0,"PowerOnState":3,"LedState":1,"SaveData":1,"SaveState":1,"ButtonRetain":0,"PowerRetain":0}}
20:22:49 MQT: stat/riego/STATUS1 = {"StatusPRM":{"Baudrate":115200,"GroupTopic":"sonoffs","OtaUrl":"http://sonoff.maddox.co.uk/tasmota/sonoff.ino.bin","RestartReason":"Software/System restart","Uptime":"0T00:06:51","StartupUTC":"2018-09-25T23:15:58","Sleep":0,"BootCount":199,"SaveCount":888,"SaveAddress":"3FB000"}}
20:22:49 MQT: stat/riego/STATUS2 = {"StatusFWR":{"Version":"6.2.1.6","BuildDateTime":"2018-09-24T10:37:07","Boot":31,"Core":"2_4_2","SDK":"2.2.1(cfd48f3)"}}
20:22:49 MQT: stat/riego/STATUS3 = {"StatusLOG":{"SerialLog":0,"WebLog":2,"SysLog":0,"LogHost":"","LogPort":514,"SSId":["NetWireless","NetWireless"],"TelePeriod":60,"SetOption":["0A008009","55818000","00000001"]}}
20:22:49 MQT: stat/riego/STATUS4 = {"StatusMEM":{"ProgramSize":489,"Free":2580,"Heap":19,"ProgramFlashSize":4096,"FlashSize":4096,"FlashMode":3,"Features":["00002C0A","1F80A984","0C0003B0","23021794","000000C0"]}}
20:22:49 MQT: stat/riego/STATUS5 = {"StatusNET":{"Hostname":"riego-1254","IPAddress":"192.168.1.21","Gateway":"192.168.1.1","Subnetmask":"255.255.255.0","DNSServer":"192.168.1.1","Mac":"68:C6:3A:8A:64:E6","Webserver":2,"WifiConfig":5}}
20:22:49 MQT: stat/riego/STATUS6 = {"StatusMQT":{"MqttHost":"192.168.1.2","MqttPort":1883,"MqttClientMask":"DVES_%06X","MqttClient":"DVES_8A64E6","MqttUser":"homeassistant","MqttType":2,"MAX_PACKET_SIZE":1000,"KEEPALIVE":15}}
20:22:49 MQT: stat/riego/STATUS7 = {"StatusTIM":{"UTC":"Tue Sep 25 23:22:49 2018","Local":"Tue Sep 25 20:22:49 2018","StartDST":"Sun Mar 25 02:00:00 2018","EndDST":"Sun Oct 28 03:00:00 2018","Timezone":-3,"Sunrise":"07:16","Sunset":"19:30"}}
20:22:49 MQT: stat/riego/STATUS10 = {"StatusSNS":{"Time":"2018-09-25T20:22:49","COUNTER":{"C1":0},"ANALOG":{"A0":2},"SI7021":{"Temperature":19.8,"Humidity":18.2},"TempUnit":"C"}}
20:22:49 MQT: stat/riego/STATUS11 = {"StatusSTS":{"Time":"2018-09-25T20:22:49","Uptime":"0T00:06:51","POWER1":"OFF","POWER2":"OFF","POWER3":"OFF","POWER4":"OFF","POWER5":"OFF","POWER6":"OFF","POWER7":"OFF","Wifi":{"AP":2,"SSId":"NetWireless","BSSId":"18:D6:C7:80:38:2C","Channel":1,"RSSI":24}}}

rules:

20:23:44 CMD: rule
20:23:44 MQT: stat/riego/RESULT = {"Rule1":"ON","Once":"OFF","StopOnError":"OFF","Free":317,"Rules":"on System#Boot do backlog power1 off;power2 off;power3 off;power4 off; power5 off; power6 off; power7 off endon on tele-counter#c1>0 do counter1 0 endon on si7021#Temperature<5 do Power1 1 endon"}

Thanks for report it.

We will investigate it.

arendst commented 6 years ago

@ascillato could you try to test if this solves the problem.

Replace line 428 in file xdrv_10_rules.ino from

  if (Settings.rule_enabled) {            // Any rule enabled

in to

  if (Settings.rule_enabled && (uptime > 4)) {  // Any rule enabled

This will stall rule sensor processing just after restart for the first 5 seconds.

ascillato2 commented 6 years ago

Tested.

Now works perfect.

Thanks :+1: