Closed nagyrobi closed 3 years ago
I tried various workarounds like setting "tele_period": 0
from config.sys at boot, and add delay and teleperiod restore to the script:
>BS
delay(10000)
tper=30
But no success. A tele is sent immediately after boot with lots of zeros.
The smart meter code has to be written in that it not responds to the teleperiod request if it has not yet received valid data.
Over to the smartmeter code writer @gemu2015 ....
Thanks for this. It's not perfect yet, it only works once. So after I freshly upgraded the firmware to a build containing this patch, at the first boot it indeed skipped the first tele. But after subsequent restarts from the web gui, a null mqtt is sent after boot... :(
meanwhile I rewired my sml test system and if no serial data comes in no MQTT is generated. i made several restarts of sml and rebooting and could not observe a null mqtt. please test in console with sensor53 r and check if a null mqtt is generated. the valid flags are always reset on restart and once a serial datagram is received the valid flag is set and only then mqtt is sent.
i also did implement a global sml mqtt disable where you can disable sml mqtt from scripts. the script variable is smlj you may read and write it. a 1 enables mqtt from script, a zero disables it.
i also implemented the bracket skipping. here is a new version. now that i can check with my simulator i found a bug in the previous version.
please test
Unfortunately still not good:
0:00:00.008 UFS: FlashFS mounted with 1984 kB free
00:00:00.056 CFG: Loaded from File, Count 6
00:00:00.062 QPC: Count 1
00:00:00.068 Project tasmota Bal (Normál) Version 9.3.0.1(tasmota)-2_7_4_9(2021-02-20T20:41:15)
00:00:00.069 UFILESYSTEM OK!
00:00:00.075 Script: nv=0, tv=0, vns=0, ram=16
00:00:00.085 SNS: Hardware Serial
00:00:04.475 WIF: Connecting to AP1 ZACUT Channel 6 BSSId F0:9F:C2:A4:1A:28 in mode 11n as elmu_bal-3514...
00:00:05.801 WIF: Connected
00:00:06.004 HTP: Web server active on elmu_bal-3514 with IP address XXXXXXXX
00:00:06.503 QPC: Reset
20:45:16.013 MQT: Attempting connection...
20:45:16.069 MQT: Connected
20:45:16.072 MQT: tele/elmu_bal/LWT = Online (retained)
20:45:16.075 MQT: cmnd/elmu_bal/POWER =
20:45:16.083 MQT: tele/elmu_bal/INFO1 = {"Module":"Generic","Version":"9.3.0.1(tasmota)","FallbackTopic":"cmnd/DVES_7CCDBA_fb/","GroupTopic":"cmnd/tasmotas/"}
20:45:16.086 MQT: tele/elmu_bal/INFO2 = {"WebServerMode":"Admin","Hostname":"bal-3514","IPAddress":"XXXXXXXX"}
20:45:16.089 MQT: tele/elmu_bal/INFO3 = {"RestartReason":"Software/System restart"}
20:45:20.487 MQT: tele/elmu_bal/STATE = {"Time":"2021-02-20T20:45:20","Uptime":"0T00:00:13","UptimeSec":13,"Heap":14,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":19,"MqttCount":1,"Wifi":{"AP":1,"SSId":"AAA","BSSId":"F0:9F:C2:A4:1A:28","Channel":6,"RSSI":50,"Signal":-75,"LinkCount":1,"Downtime":"0T00:00:07"}}
20:45:20.494 MQT: tele/elmu_bal/SENSOR = {"Time":"2021-02-20T20:45:20","N":{"enrg_imp":0.000,"enrg_exp":0.000,"telj_imp":0.000,"telj_exp":0.000,"fesz_l1":0.0,"fesz_l2":0.0,"fesz_l3":0.0,"freq":0.00,"enrg_imp_med":0.000,"enrg_imp_med":0.000}}
Maybe it's not too good to rely solely on serial dataflow detection. I assume in my case that if reboot happens in the middle of the data being pushed, only part of the information will be decoded, rest of it will remain zero. For instance I noticed several times that the last values were populated, the first ones were still at zero.
Can you suggest how to use smlj
in my script above?
I imagine something like set it to 0 at boot.
Then wait 2 subsequent serial data pushes (because the first one may be incomplete) and then set smlj
to 1.
Tried this, without success:
>D
>B
smlj 0
->sensor53 r
>BS
delay(15000)
smlj 1
Solution: https://github.com/arendst/Tasmota/discussions/11052#discussioncomment-389123 (for those directed here by a search engine)
PROBLEM DESCRIPTION
After reboot or power cycle, the first tele message on MQTT is sent with all the values at zero. Supposedly because Smart Meter interface didn't receive values from the meter yet. P1 serial meters usually send values at every 10 seconds. Tasmota boots and sends the first tele faster, and the zeros disturb the accuracy on the database.
Seems like I'm not the only one experiencing this:
REQUESTED INFORMATION
Make sure your have performed every step and checked the applicable boxes before submitting your issue. Thank you!
Backlog Template; Module; GPIO 255
:Backlog Rule1; Rule2; Rule3
:weblog
to 4 and then, when you experience your issue, provide the output of the Console log:TO REPRODUCE
Reboot the module.
EXPECTED BEHAVIOUR
Do not send a tele until values are filled.
SCREENSHOTS
None.
ADDITIONAL CONTEXT
The script: