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.75k stars 4.72k forks source link

Cannot reset Energy Today/Total for external meter #6561

Closed rt400 closed 4 years ago

rt400 commented 4 years ago

GUIDE

This BUG issue template is meant to REPORT Tasmota software BUGS ONLY>

Please DO NOT OPEN AN ISSUE:

  • If your Tasmota version is not the latest from the development branch, please update your device before submitting your issue. Your problem might already be solved. The latest precompiled binaries of Tasmota can be downloaded from http://thehackbox.org/tasmota/
  • If your issue is a flashing issue, please address it to the Tasmota Support Chat
  • If your issue is compilation problem, please address it to the Tasmota Support Chat
  • If your issue has been addressed before (i.e., duplicated issue), please ask in the original issue
  • If your issue is a Wi-Fi problem or MQTT problem, please try the steps provided in the FAQ and troubleshooting wiki articles

Please take a few minutes to complete the requested information below. Our ability to provide assistance is greatly hampered without it. The details requested potentially affect which options to pursue. The small amount of time you spend completing the template will also help the volunteers providing the assistance to you to reduce the time required to help you.

BUG DESCRIPTION

I try to reset Energy Total/Today unsuccessfully, after I run the EnergyReset3 0 command, I get the same values but do not get 0. If I run the EnergyReset1 0 command then TODAY gets 0 and after a few seconds suddenly it gets a value that was previously. Also run Reset5 , still got the same values , flash again with "Erase All Sketch" got the same results.

REQUESTED INFORMATION

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

FAILURE TO COMPLETE THE REQUESTED INFORMATION WILL RESULT IN YOUR ISSUE BEING CLOSED

TO REPRODUCE

Steps to reproduce the behavior:

EXPECTED BEHAVIOUR

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

SCREENSHOTS

image

image

image

pablozg commented 4 years ago

If you are using an external meter, tasmota auto update the energy total to be in sincro with the hardware counter. If you want reset it you must reset the meter counter.

But if @arendst is agree, we can add a new "setoption" command to enable or disable the autoupdate function.

rt400 commented 4 years ago

If you are using an external meter, tasmota auto update the energy total to be in sincro with the hardware counter. If you want reset it you must reset the meter counter.

But if @arendst is agree, we can add a new "setoption" command to enable or disable the autoupdate function.

i used with PZEM04-T 3.0v , i think that he doesn't have a counter and don't have a reset button on board like version 1.0/2.0 . the "Total" isn't belong to tasmota code ???

pablozg commented 4 years ago

Hi, I have take a look to the pzem code and yes, it have a energy total counter, and is used to update the tasmota counter.

In a previous commit I made, I introduced an autoupdate function to get tasmota counter in sync with the hardware counter.

I have made a new PR to can choose between use the hardware counter or the tasmota counter, using the setoption72 command, but I'm waiting to Theo approval.

ascillato2 commented 4 years ago

Closing this issue as it has been added

rt400 commented 4 years ago

@pablozg sorry .. but still its not fixed.. i try the SetOption72 with no result. i got measure number that not real measure image with 2 days, also try to reset again but all the time he jump to number that i dont know from where he give it.

rt400 commented 4 years ago

image look what happen on every reset command

rt400 commented 4 years ago

look...maybe i have a Ghost in my PZEM...

22:49:17 CMD: SetOption72
22:49:17 MQT: stat/3PhazeMonitor/RESULT = {"SetOption72":"OFF"}
22:49:29 CMD: EnergyReset3 0
22:49:29 MQT: stat/3PhazeMonitor/RESULT = {"EnergyReset":{"Total":467.033,"Yesterday":0.000,"Today":467.033,"Usage":[0.000,3448.858],"Export":[0.000,0.000]}}
22:49:37 CMD: EnergyReset3 0
22:49:37 MQT: stat/3PhazeMonitor/RESULT = {"EnergyReset":{"Total":467.034,"Yesterday":0.000,"Today":467.034,"Usage":[0.000,3448.858],"Export":[0.000,0.000]}}
22:49:38 MQT: tele/3PhazeMonitor/STATE = {"Time":"2019-10-09T22:49:37","Uptime":"0T00:00:50","UptimeSec":50,"Heap":27,"SleepMode":"Dynamic","Sleep":0,"LoadAvg":999,"MqttCount":1,"POWER1":"OFF","POWER2":"OFF","POWER3":"OFF","POWER4":"OFF","POWER5":"OFF","Wifi":{"AP":1,"SSId":"Mejahez","BSSId":"80:2A:A8:54:8A:49","Channel":1,"RSSI":74,"LinkCount":1,"Downtime":"0T00:00:07"}}
22:49:38 MQT: tele/3PhazeMonitor/SENSOR = {"Time":"2019-10-09T22:49:38","ANALOG":{"A0":238},"ENERGY":{"TotalStartTime":"2019-10-09T00:00:00","Total":467.034,"Yesterday":0.000,"Today":467.034,"Period":7,"Power":[152,493,89],"ApparentPower":[241,501,177],"ReactivePower":[187,88,153],"Factor":[0.63,0.98,0.51],"Frequency":[50,50,50],"Voltage":[237,238,237],"Current":[1.016,2.108,0.744]},"AM2301":{"Temperature":30.2,"Humidity":47.8},"TSL2561":{"Illuminance":5.406},"TempUnit":"C"}
22:49:46 CMD: SetOption72 1
22:49:46 MQT: stat/3PhazeMonitor/RESULT = {"SetOption72":"ON"}
22:49:51 CMD: EnergyReset3 0
22:49:51 MQT: stat/3PhazeMonitor/RESULT = {"EnergyReset":{"Total":467.035,"Yesterday":0.000,"Today":467.035,"Usage":[0.000,3448.858],"Export":[0.000,0.000]}}
22:49:59 CMD: EnergyReset3 0
22:49:59 MQT: stat/3PhazeMonitor/RESULT = {"EnergyReset":{"Total":467.039,"Yesterday":0.000,"Today":467.039,"Usage":[0.000,3448.858],"Export":[0.000,0.000]}}
22:50:10 MQT: tele/3PhazeMonitor/STATE = {"Time":"2019-10-09T22:50:10","Uptime":"0T00:01:23","UptimeSec":83,"Heap":28,"SleepMode":"Dynamic","Sleep":0,"LoadAvg":999,"MqttCount":1,"POWER1":"OFF","POWER2":"OFF","POWER3":"OFF","POWER4":"OFF","POWER5":"OFF","Wifi":{"AP":1,"SSId":"Mejahez","BSSId":"80:2A:A8:54:8A:49","Channel":1,"RSSI":74,"LinkCount":1,"Downtime":"0T00:00:07"}}
22:50:10 MQT: tele/3PhazeMonitor/SENSOR = {"Time":"2019-10-09T22:50:10","ANALOG":{"A0":238},"ENERGY":{"TotalStartTime":"2019-10-09T00:00:00","Total":428.313,"Yesterday":0.000,"Today":467.040,"Period":6,"Power":[153,491,90],"ApparentPower":[243,499,180],"ReactivePower":[188,87,156],"Factor":[0.63,0.98,0.50],"Frequency":[50,50,50],"Voltage":[237,237,237],"Current":[1.023,2.102,0.757]},"AM2301":{"Temperature":30.0,"Humidity":47.8},"TSL2561":{"Illuminance":5.406},"TempUnit":"C"}
22:50:14 CMD: EnergyReset1 0
22:50:14 MQT: stat/3PhazeMonitor/RESULT = {"EnergyReset":{"Total":428.315,"Yesterday":0.000,"Today":0.000,"Usage":[0.000,3448.858],"Export":[0.000,0.000]}}
22:50:18 CMD: EnergyReset3 0
22:50:18 MQT: stat/3PhazeMonitor/RESULT = {"EnergyReset":{"Total":399.690,"Yesterday":0.000,"Today":399.690,"Usage":[0.000,3448.858],"Export":[0.000,0.000]}}
22:50:28 CMD: EnergyReset3 0
22:50:28 MQT: stat/3PhazeMonitor/RESULT = {"EnergyReset":{"Total":399.692,"Yesterday":0.000,"Today":399.692,"Usage":[0.000,3448.858],"Export":[0.000,0.000]}}
22:50:34 CMD: EnergyReset1 0
22:50:34 MQT: stat/3PhazeMonitor/RESULT = {"EnergyReset":{"Total":428.317,"Yesterday":0.000,"Today":0.000,"Usage":[0.000,3448.858],"Export":[0.000,0.000]}}
22:50:36 CMD: EnergyReset3 0
22:50:36 MQT: stat/3PhazeMonitor/RESULT = {"EnergyReset":{"Total":399.694,"Yesterday":0.000,"Today":399.694,"Usage":[0.000,3448.858],"Export":[0.000,0.000]}}
22:50:43 MQT: tele/3PhazeMonitor/STATE = {"Time":"2019-10-09T22:50:43","Uptime":"0T00:01:56","UptimeSec":116,"Heap":28,"SleepMode":"Dynamic","Sleep":0,"LoadAvg":999,"MqttCount":1,"POWER1":"OFF","POWER2":"OFF","POWER3":"OFF","POWER4":"OFF","POWER5":"OFF","Wifi":{"AP":1,"SSId":"Mejahez","BSSId":"80:2A:A8:54:8A:49","Channel":1,"RSSI":74,"LinkCount":1,"Downtime":"0T00:00:07"}}
22:50:43 MQT: tele/3PhazeMonitor/SENSOR = {"Time":"2019-10-09T22:50:43","ANALOG":{"A0":238},"ENERGY":{"TotalStartTime":"2019-10-09T22:50:42","Total":428.321,"Yesterday":0.000,"Today":399.696,"Period":0,"Power":[152,490,88],"ApparentPower":[240,498,174],"ReactivePower":[186,88,150],"Factor":[0.63,0.98,0.51],"Frequency":[50,50,50],"Voltage":[237,237,237],"Current":[1.012,2.101,0.733]},"AM2301":{"Temperature":30.2,"Humidity":47.8},"TSL2561":{"Illuminance":5.406},"TempUnit":"C"}
22:50:50 CMD: SetOption72 0
22:50:50 MQT: stat/3PhazeMonitor/RESULT = {"SetOption72":"OFF"}
22:50:56 CMD: EnergyReset1 0
22:50:56 MQT: stat/3PhazeMonitor/RESULT = {"EnergyReset":{"Total":428.322,"Yesterday":0.000,"Today":0.000,"Usage":[0.000,3448.858],"Export":[0.000,0.000]}}
22:50:58 CMD: W
22:50:58 MQT: stat/3PhazeMonitor/RESULT = {"Command":"Unknown"}
22:51:00 CMD: EnergyReset3 0
22:51:01 MQT: stat/3PhazeMonitor/RESULT = {"EnergyReset":{"Total":399.699,"Yesterday":0.000,"Today":399.699,"Usage":[0.000,3448.858],"Export":[0.000,0.000]}}
22:51:16 MQT: tele/3PhazeMonitor/STATE = {"Time":"2019-10-09T22:51:16","Uptime":"0T00:02:29","UptimeSec":149,"Heap":28,"SleepMode":"Dynamic","Sleep":0,"LoadAvg":999,"MqttCount":1,"POWER1":"OFF","POWER2":"OFF","POWER3":"OFF","POWER4":"OFF","POWER5":"OFF","Wifi":{"AP":1,"SSId":"Mejahez","BSSId":"80:2A:A8:54:8A:49","Channel":1,"RSSI":74,"LinkCount":1,"Downtime":"0T00:00:07"}}
22:51:16 MQT: tele/3PhazeMonitor/SENSOR = {"Time":"2019-10-09T22:51:16","ANALOG":{"A0":239},"ENERGY":{"TotalStartTime":"2019-10-09T22:51:00","Total":399.702,"Yesterday":0.000,"Today":399.702,"Period":0,"Power":[152,491,88],"ApparentPower":[240,498,177],"ReactivePower":[186,87,154],"Factor":[0.63,0.98,0.50],"Frequency":[50,50,50],"Voltage":[238,238,237],"Current":[1.010,2.096,0.745]},"AM2301":{"Temperature":30.1,"Humidity":47.8},"TSL2561":{"Illuminance":5.406},"TempUnit":"C"}
22:51:17 CMD: EnergyReset3 0
22:51:17 MQT: stat/3PhazeMonitor/RESULT = {"EnergyReset":{"Total":399.702,"Yesterday":0.000,"Today":399.702,"Usage":[0.000,3448.858],"Export":[0.000,0.000]}}
22:51:28 CMD: EnergyReset2 0
22:51:28 MQT: stat/3PhazeMonitor/RESULT = {"EnergyReset":{"Total":399.705,"Yesterday":0.000,"Today":399.705,"Usage":[0.000,3448.858],"Export":[0.000,0.000]}}
22:51:34 CMD: EnergyReset1 0
22:51:34 MQT: stat/3PhazeMonitor/RESULT = {"EnergyReset":{"Total":399.706,"Yesterday":0.000,"Today":0.000,"Usage":[0.000,3448.858],"Export":[0.000,0.000]}}
22:51:37 CMD: EnergyReset3 0
22:51:37 MQT: stat/3PhazeMonitor/RESULT = {"EnergyReset":{"Total":399.706,"Yesterday":0.000,"Today":399.706,"Usage":[0.000,3448.858],"Export":[0.000,0.000]}}
pablozg commented 4 years ago

By your logs, I see you have three pzem, the "resetEnergy" issue is fixed with the "setOption72", but @arendst did some changes to the pzem code, see issue #6585.

arovak commented 4 years ago

I recently build a setup with 3 PZEM004T-V3 modules and also have the issue that EnergyTotal is not reset when using EnergyReset3. So I updated the device today to 6.6.0.20 but this version does not seem to fix the weird values. Furthermore, it look to me that after every restart the EnergyTotal of the PZEM modules is added to the EnergyToday and EnergyTotal value.

Image below is just after restart with SetOption72 = OFF and EnergyReset1/2/3 = 0 image

When I restart the values are multiplied. image

I run this setup on a sonoff basic module. Below is the Status 0 of my device.

13:48:11 MQT: stat/pzem/STATUS = {"Status":{"Module":0,"FriendlyName":["pzem"],"Topic":"pzem","ButtonTopic":"0","Power":0,"PowerOnState":3,"LedState":1,"LedMask":"FFFF","SaveData":1,"SaveState":1,"SwitchTopic":"0","SwitchMode":[0,0,0,0,0,0,0,0],"ButtonRetain":0,"SwitchRetain":0,"SensorRetain":0,"PowerRetain":0}}
13:48:11 MQT: stat/pzem/STATUS1 = {"StatusPRM":{"Baudrate":9600,"GroupTopic":"sonoffs","OtaUrl":"http://10.4.0.5/esp8266/tasmota/6.6.0.20/tasmota.bin","RestartReason":"Software/System restart","Uptime":"0T00:04:37","StartupUTC":"2019-10-19T11:43:34","Sleep":50,"CfgHolder":4617,"BootCount":133,"SaveCount":675,"SaveAddress":"F5000"}}
13:48:11 MQT: stat/pzem/STATUS2 = {"StatusFWR":{"Version":"6.6.0.20(sonoff)","BuildDateTime":"2019-10-19T11:35:59","Boot":31,"Core":"STAGE","SDK":"2.2.2-dev(38a443e)"}}
13:48:11 MQT: stat/pzem/STATUS3 = {"StatusLOG":{"SerialLog":0,"WebLog":2,"MqttLog":0,"SysLog":3,"LogHost":"10.4.0.8","LogPort":514,"SSId":["skarenet","SecIOT"],"TelePeriod":300,"Resolution":"558180C0","SetOption":["00C08009","2805C8000100060000005A00000000000000","00000000"]}}
13:48:11 MQT: stat/pzem/STATUS4 = {"StatusMEM":{"ProgramSize":563,"Free":440,"Heap":24,"ProgramFlashSize":1024,"FlashSize":1024,"FlashChipId":"14405E","FlashMode":3,"Features":["00000809","8FDAE397","043683A0","22B617CD","01001BC0","00007081"],"Drivers":"1,2,3,4,5,6,7,8,9,10,12,16,18,19,20,21,22,24,26","Sensors":"1,2,3,4,5,6,7,8,9,10,14,15,17,18,20,22,26,34"}}
13:48:11 MQT: stat/pzem/STATUS5 = {"StatusNET":{"Hostname":"pzem-2146","IPAddress":"10.4.0.180","Gateway":"10.4.0.1","Subnetmask":"255.255.255.0","DNSServer":"10.4.0.7","Mac":"5C:CF:7F:7A:68:62","Webserver":2,"WifiConfig":4}}
13:48:11 MQT: stat/pzem/STATUS6 = {"StatusMQT":{"MqttHost":"10.4.0.8","MqttPort":1883,"MqttClientMask":"DVES_%06X","MqttClient":"DVES_7A6862","MqttUser":"sonoff5","MqttCount":1,"MAX_PACKET_SIZE":1000,"KEEPALIVE":30}}
13:48:11 MQT: stat/pzem/STATUS7 = {"StatusTIM":{"UTC":"Sat Oct 19 11:48:11 2019","Local":"Sat Oct 19 13:48:11 2019","StartDST":"Sun Mar 31 02:00:00 2019","EndDST":"Sun Oct 27 03:00:00 2019","Timezone":99,"Sunrise":"08:16","Sunset":"18:54"}}
13:48:11 MQT: stat/pzem/STATUS9 = {"StatusPTH":{"PowerDelta":0,"PowerLow":0,"PowerHigh":0,"VoltageLow":0,"VoltageHigh":0,"CurrentLow":0,"CurrentHigh":0}}
13:48:11 MQT: stat/pzem/STATUS10 = {"StatusSNS":{"Time":"2019-10-19T13:48:11","ENERGY":{"TotalStartTime":"2019-10-19T13:39:53","Total":170.446,"Yesterday":0.000,"Today":170.446,"Power":[125,24,414],"ApparentPower":[133,135,569],"ReactivePower":[44,132,391],"Factor":[0.94,0.18,0.73],"Frequency":[50,50,50],"Voltage":[237,236,235],"Current":[0.560,0.571,2.422]}}}
13:48:11 MQT: stat/pzem/STATUS11 = {"StatusSTS":{"Time":"2019-10-19T13:48:11","Uptime":"0T00:04:37","UptimeSec":277,"Heap":27,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":19,"MqttCount":1,"POWER":"OFF","Wifi":{"AP":1,"SSId":"SecIOT","BSSId":"F0:9F:C2:FD:2E:72","Channel":11,"RSSI":78,"LinkCount":1,"Downtime":"0T00:00:06"}}}
arendst commented 4 years ago

I cannot reproduce but I have only one PZEM004T v2 (I think).

What happens when you connect just one PZEM?

On the other hand, what is your GPIO configuration? As far as I know the PZEM004T does not do Frequency but your display shows frequency. Pls report output of command gpio.

arendst commented 4 years ago

Ah just googled the V3 and it seems it now supports modbus protocol so must be using the PzemAc driver. That explains the frequency.

I will have to dig up my Pzem014 for testing.

arendst commented 4 years ago

Pls try the latest commit and report back.

arovak commented 4 years ago

First, thank you for the quick response and great software!

What happens when you connect just one PZEM?

With just 1 PZEM v3 connected value is still correct after energyreset1/2/3 0 and reboot.

image

Pls report output of command gpio.

13:45:21 CMD: gpio
13:45:21 MQT: stat/pzem/RESULT = {"GPIO2":{"0":"None"},"GPIO4":{"0":"None"},"GPIO14":{"0":"None"}}

The template I am using on this sonoff basic is

13:48:34 MQT: stat/pzem/RESULT = {"NAME":"PZEM","GPIO":[17,62,255,98,255,0,0,0,21,56,255,0,0],"FLAG":0,"BASE":1}

Pls try the latest commit and report back.

With the new build results are the same. After reconnectiong the 3 PZEM values it loads a weird value for EnergyToday and EnergyTotal and these are still multiplied after a reboot

image

After reboot image

arendst commented 4 years ago

Thx for testing. Could you pls try with just two connected.

arendst commented 4 years ago

Ah don't bother. I think what's going on. Now I have to find a way to solve it.

arendst commented 4 years ago

Do you compile yourself?

arendst commented 4 years ago

And another possible fix. Pls report back.

arovak commented 4 years ago

Yes I use Platformio to compile, and it looks like you have fixed the problem!

Energyreset1/2/3 0, setoption72 OFF and after multiple reboots I do not have the weird values anymore.

image

Again, thank you for the quick response and fix!

arendst commented 4 years ago

Great! Thx for your feedback.

rt400 commented 4 years ago

@arendst is that fix add to the code ? cause didn't see this in _changelog.ino.. anyway i thinks that i have one defect module. i log it with SysLog and upload it , hope you can understand the HEX Data cause i am not https://paste.ofcode.org/dG8guTQRnaLvpz6BSeuaS5 thanks...

rt400 commented 4 years ago

@arendst look here https://github.com/mandulaj/PZEM-004T-v30 it's look that he made a Energy reset by sending serial command (cause in 3.0v there is no reset button) so maybe you can add this to tasmota command so we can reset the hardware enregy..

rt400 commented 4 years ago

@arendst It still gets worse and brings crazy values Have an idea what to do with it? You may be able to add a reset command to these modules because version 3 does not have a reset button and reset is through software. Thanks so much for all the much appreciated help

gromar88 commented 4 years ago

Is there a possibility to split energy for each phase?