Tasmota: TuyaMCU: Total kWh value gets unknown value after reboot/power-cycle

Created on 28 Nov 2020  路  10Comments  路  Source: arendst/Tasmota

PROBLEM DESCRIPTION

Hiking DDS238-2 WIFI Din Rail Energy Meter with Tasmota, Version 9.1.0.2, reset to factory defaults, wifi config, config module as TuyaMCU, set TuyaRx and TuyaTx Gpio Right, config TuyaMCU with this:

Backlog TuyaMCU 33,20; TuyaMCU 32,18; TuyaMCU 31,19;

after this i now get a Value of e.g 5392. for the total energy value... i also tried the same under 9.1.0 there this seems only to happen after power-cyle

REQUESTED INFORMATION

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

  • [ ] 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
  • [x] Searched the problem in the chat
  • [x] Device used (e.g., Sonoff Basic): Hiking DDS238-2 WIFI Din Rail Energy Meter
  • [ ] Tasmota binary firmware version number used: 9.1.0.2 & 9.1.0

    • [x] Pre-compiled

    • [ ] Self-compiled

    • [ ] IDE / Compiler used: _____

  • [x] Flashing tools used: OTA
  • [x] Provide the output of command: Backlog Template; Module; GPIO 255:
  Configuration output here:
20:29:29 CMD: Backlog Template; Module; GPIO 255
20:29:29 SRC: WebConsole from 192.168.11.5
20:29:29 CMD: Group 0, Index 1, Command "BACKLOG", Data "Template; Module; GPIO 255"
20:29:29 SRC: Backlog
20:29:29 CMD: Group 0, Index 1, Command "TEMPLATE", Data ""
20:29:29 RSL: stat/tasmota_1225D1/RESULT = {"NAME":"Generic","GPIO":[1,1,1,1,1,1,1,1,1,1,1,1,1,1],"FLAG":0,"BASE":18}
20:29:30 SRC: Backlog
20:29:30 CMD: Group 0, Index 1, Command "MODULE", Data ""
20:29:30 RSL: stat/tasmota_1225D1/RESULT = {"Module":{"54":"Tuya MCU"}}
20:29:30 SRC: Backlog
20:29:30 CMD: Group 0, Index 1, Command "GPIO", Data "255"
20:29:30 RSL: stat/tasmota_1225D1/RESULT = {"GPIO0":{"0":"None"},"GPIO1":{"2272":"Tuya Tx"},"GPIO2":{"0":"None"},"GPIO3":{"2304":"Tuya Rx"},"GPIO4":{"0":"None"},"GPIO5":{"0":"None"},"GPIO9":{"0":"None"},"GPIO10":{"0":"None"},"GPIO12":{"0":"None"},"GPIO13":{"0":"None"},"GPIO14":{"288":"Led1"},"GPIO15":{"0":"None"},"GPIO16":{"32":"Button1"},"GPIO17":{"0":"None"}}
20:29:33 TYA: Send "55aa00000000ff"

  • [ ] If using rules, provide the output of this command: Backlog Rule1; Rule2; Rule3:
  Rules output here:


  • [x] Provide the output of this command: Status 0:
  STATUS 0 output here:
20:30:07 SRC: WebConsole from 192.168.11.5
20:30:07 CMD: Group 0, Index 1, Command "STATUS", Data "0"
20:30:07 RSL: stat/tasmota_1225D1/STATUS = {"Status":{"Module":54,"DeviceName":"Tasmota","FriendlyName":["Tasmota"],"Topic":"tasmota_1225D1","ButtonTopic":"0","Power":1,"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}}
20:30:07 RSL: stat/tasmota_1225D1/STATUS1 = {"StatusPRM":{"Baudrate":9600,"SerialConfig":"8N1","GroupTopic":"tasmotas","OtaUrl":"http://ota.tasmota.com/tasmota/release/tasmota.bin.gz","RestartReason":"Software/System restart","Uptime":"0T00:10:06","StartupUTC":"2020-11-28T19:20:01","Sleep":50,"CfgHolder":4617,"BootCount":4,"BCResetTime":"2020-11-28T20:17:43","SaveCount":18,"SaveAddress":"FA000"}}
20:30:07 RSL: stat/tasmota_1225D1/STATUS2 = {"StatusFWR":{"Version":"9.1.0(tasmota)","BuildDateTime":"2020-11-07T11:57:45","Boot":31,"Core":"2_7_4_5","SDK":"2.2.2-dev(38a443e)","CpuFrequency":80,"Hardware":"ESP8266EX","CR":"366/699"}}
20:30:07 RSL: stat/tasmota_1225D1/STATUS3 = {"StatusLOG":{"SerialLog":0,"WebLog":4,"MqttLog":0,"SysLog":0,"LogHost":"","LogPort":514,"SSId":["www.krikkit.net",""],"TelePeriod":300,"Resolution":"558180C0","SetOption":["00008009","2805C8000100060000005A00000000000000","00000000","00006000","00000000"]}}
20:30:07 RSL: stat/tasmota_1225D1/STATUS4 = {"StatusMEM":{"ProgramSize":600,"Free":400,"Heap":26,"ProgramFlashSize":1024,"FlashSize":2048,"FlashChipId":"1540C8","FlashFrequency":40,"FlashMode":3,"Features":["00000809","8FDAE797","04368001","000000CF","010013C0","C000F981","00004004","00000000"],"Drivers":"1,2,3,4,5,6,7,8,9,10,12,16,18,19,20,21,22,24,26,27,29,30,35,37","Sensors":"1,2,3,4,5,6"}}
20:30:07 RSL: stat/tasmota_1225D1/STATUS5 = {"StatusNET":{"Hostname":"tasmota_1225D1-1489","IPAddress":"192.168.11.80","Gateway":"192.168.11.1","Subnetmask":"255.255.255.0","DNSServer":"192.168.11.1","Mac":"D8:BF:C0:12:25:D1","Webserver":2,"WifiConfig":4,"WifiPower":17.0}}
20:30:07 RSL: stat/tasmota_1225D1/STATUS6 = {"StatusMQT":{"MqttHost":"","MqttPort":1883,"MqttClientMask":"DVES_%06X","MqttClient":"DVES_1225D1","MqttUser":"DVES_USER","MqttCount":0,"MAX_PACKET_SIZE":1200,"KEEPALIVE":30}}
20:30:07 RSL: stat/tasmota_1225D1/STATUS7 = {"StatusTIM":{"UTC":"2020-11-28T19:30:07","Local":"2020-11-28T20:30:07","StartDST":"2020-03-29T02:00:00","EndDST":"2020-10-25T03:00:00","Timezone":"+01:00","Sunrise":"08:19","Sunset":"16:57"}}
20:30:07 RSL: stat/tasmota_1225D1/STATUS9 = {"StatusPTH":{"PowerDelta":[0,0,0],"PowerLow":0,"PowerHigh":0,"VoltageLow":0,"VoltageHigh":0,"CurrentLow":0,"CurrentHigh":0}}
20:30:07 RSL: stat/tasmota_1225D1/STATUS10 = {"StatusSNS":{"Time":"2020-11-28T20:30:07","ENERGY":{"TotalStartTime":"2020-11-28T20:19:34","Total":0.000,"Yesterday":0.000,"Today":0.000,"Power":6,"ApparentPower":9,"ReactivePower":7,"Factor":0.68,"Voltage":236,"Current":0.039}}}
20:30:07 RSL: stat/tasmota_1225D1/STATUS11 = {"StatusSTS":{"Time":"2020-11-28T20:30:07","Uptime":"0T00:10:06","UptimeSec":606,"Heap":26,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":24,"MqttCount":0,"POWER":"ON","Wifi":{"AP":1,"SSId":"www.krikkit.net","BSSId":"DC:39:6F:10:FB:30","Channel":1,"RSSI":88,"Signal":-56,"LinkCount":1,"Downtime":"0T00:00:03"}}}
20:30:10 RSL: tele/tasmota_1225D1/STATE = {"Time":"2020-11-28T20:30:10","Uptime":"0T00:10:09","UptimeSec":609,"Heap":26,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":19,"MqttCount":0,"POWER":"ON","Wifi":{"AP":1,"SSId":"www.krikkit.net","BSSId":"DC:39:6F:10:FB:30","Channel":1,"RSSI":88,"Signal":-56,"LinkCount":1,"Downtime":"0T00:00:03"}}
20:30:10 RSL: tele/tasmota_1225D1/SENSOR = {"Time":"2020-11-28T20:30:10","ENERGY":{"TotalStartTime":"2020-11-28T20:19:34","Total":0.000,"Yesterday":0.000,"Today":0.000,"Period":0,"Power":6,"ApparentPower":9,"ReactivePower":7,"Factor":0.68,"Voltage":236,"Current":0.039}}

  • [x] Provide the output of the Console log output when you experience your issue; if applicable:
    _(Please use_ weblog 4 _for more debug information)_
  Console output here:
00:00:00 CFG: Loaded from flash at F7, Count 13
00:00:00 QPC: Count 1
00:00:00 CFG: CR 366/699, Busy 0
00:00:00 SNS: Hardware Serial
00:00:00 TYA: Request MCU configuration at 9600 bps
00:00:00 TYA: Send "55aa0001000000"
00:00:00 SRC: Restart
00:00:00 TYA: Send "55aa0006000501010001010e"
00:00:00 Project tasmota Tasmota Version 9.1.0(tasmota)-2_7_4_5
00:00:00 TYA: Set WiFi LED 2 (-1)
00:00:00 TYA: Send "55aa000300010205"
00:00:00 {"TuyaReceived":{"Data":"55AA0301002A7B2270223A227377396173796A6A386A343466726A6C222C2276223A22312E302E30222C226D223A307DEB","Cmnd":1,"CmndData":"7B2270223A227377396173796A6A386A343466726A6C222C2276223A22312E302E30222C226D223A307D"}}
00:00:00 TYA: MCU Product ID: {"p":"sw9asyjj8j44frjl","v":"1.0.0","m":0}
00:00:00 TYA: Send "55aa0002000001"
00:00:00 WIF: Checking connection...
00:00:00 WIF: Attempting connection...
00:00:00 WIF: Connecting to AP1 www.krikkit.net Channel 1 BSSId DC:39:6F:10:FB:30 in mode 11N as tasmota_1225D1-1489...
00:00:00 {"TuyaReceived":{"Data":"55AA03070005010100010112","Cmnd":7,"CmndData":"0101000101","DpType1Id1":1,"1":{"DpId":1,"DpIdType":1,"DpIdData":"01"}}}
00:00:00 TYA: fnId=11 is set for dpId=1
00:00:00 TYA: RX Relay-1 --> MCU State: On Current State:On
00:00:00 {"TuyaReceived":{"Data":"55AA03070005010100010112","Cmnd":7,"CmndData":"0101000101","DpType1Id1":1,"1":{"DpId":1,"DpIdType":1,"DpIdData":"01"}}}
00:00:00 TYA: fnId=11 is set for dpId=1
00:00:00 TYA: RX Relay-1 --> MCU State: On Current State:On
00:00:00 {"TuyaReceived":{"Data":"55AA030200020E1024","Cmnd":2,"CmndData":"0E10"}}
00:00:00 TYA: RX MCU configuration Mode=2
00:00:00 TYA: Read MCU state
00:00:00 TYA: Send "55aa0008000007"
00:00:00 {"TuyaReceived":{"Data":"55AA03070005010100010112","Cmnd":7,"CmndData":"0101000101","DpType1Id1":1,"1":{"DpId":1,"DpIdType":1,"DpIdData":"01"}}}
00:00:00 TYA: fnId=11 is set for dpId=1
00:00:00 TYA: RX Relay-1 --> MCU State: On Current State:On
00:00:00 {"TuyaReceived":{"Data":"55AA03070008090200040000000020","Cmnd":7,"CmndData":"0902000400000000","DpType2Id9":0,"9":{"DpId":9,"DpIdType":2,"DpIdData":"00000000"}}}
00:00:00 TYA: fnId=0 is set for dpId=9
00:00:00 TYA: RX value 0 from dpId 9 
00:00:00 {"TuyaReceived":{"Data":"55AA030700086502000400000025A1","Cmnd":7,"CmndData":"6502000400000025","DpType2Id101":37,"101":{"DpId":101,"DpIdType":2,"DpIdData":"00000025"}}}
00:00:00 TYA: fnId=0 is set for dpId=101
00:00:00 TYA: RX value 37 from dpId 101 
00:00:00 {"TuyaReceived":{"Data":"55AA0307000812020004000000264F","Cmnd":7,"CmndData":"1202000400000026","DpType2Id18":38,"18":{"DpId":18,"DpIdType":2,"DpIdData":"00000026"}}}
00:00:00 TYA: fnId=32 is set for dpId=18
00:00:00 TYA: RX value 38 from dpId 18 
00:00:00 TYA: Rx ID=18 Current=38
00:00:00 {"TuyaReceived":{"Data":"55AA0307000813020004000000406A","Cmnd":7,"CmndData":"1302000400000040","DpType2Id19":64,"19":{"DpId":19,"DpIdType":2,"DpIdData":"00000040"}}}
00:00:00 TYA: fnId=31 is set for dpId=19
00:00:00 TYA: RX value 64 from dpId 19 
00:00:00 TYA: Rx ID=19 Active_Power=64
00:00:01 {"TuyaReceived":{"Data":"55AA03070008140200040000092B5F","Cmnd":7,"CmndData":"140200040000092B","DpType2Id20":2347,"20":{"DpId":20,"DpIdType":2,"DpIdData":"0000092B"}}}
00:00:01 TYA: fnId=33 is set for dpId=20
00:00:01 TYA: RX value 2347 from dpId 20 
00:00:01 TYA: Rx ID=20 Voltage=2347
00:00:01 WIF: Checking connection...
00:00:01 WIF: Attempting connection...
00:00:02 WIF: Checking connection...
00:00:02 WIF: Attempting connection...
00:00:03 WIF: Checking connection...
00:00:03 WIF: Connected
00:00:03 HTP: Web server active on tasmota_1225D1-1489 with IP address 192.168.11.80
00:00:03 HTP: Main Menu
20:18:45 NTP: UTC 2020-11-28T19:18:44, DST 2020-03-29T02:00:00, STD 2020-10-25T03:00:00
20:18:45 TYA: Set WiFi LED 3 (0)
20:18:45 TYA: Send "55aa000300010306"
20:18:45 RSL: tele/tasmota_1225D1/INFO1 = {"Module":"Tuya MCU","Version":"9.1.0(tasmota)","FallbackTopic":"cmnd/DVES_1225D1_fb/","GroupTopic":"cmnd/tasmotas/"}
20:18:45 RSL: tele/tasmota_1225D1/INFO2 = {"WebServerMode":"Admin","Hostname":"tasmota_1225D1-1489","IPAddress":"192.168.11.80"}
20:18:45 RSL: tele/tasmota_1225D1/INFO3 = {"RestartReason":"Software/System restart"}
20:18:45 RSL: stat/tasmota_1225D1/RESULT = {"POWER":"ON"}
20:18:45 RSL: stat/tasmota_1225D1/POWER = ON
20:18:46 HTP: Main Menu
20:18:47 QPC: Reset
20:18:47 RSL: tasmota/discovery/D8BFC01225D1/config = {"ip":"192.168.11.80","dn":"Tasmota","fn":["Tasmota",null,null,null,null,null,null,null],"hn":"tasmota_1225D1-1489","mac":"D8BFC01225D1","md":"Tuya MCU","ty":1,"if":0,"ofln":"Offline","onln":"Online","state":["OFF","ON","TOGGLE","HOLD"],"sw":"9.1.0","t":"tasmota_1225D1","ft":"%prefix%/%topic%/","tp":["cmnd","stat","tele"],"rl":[1,0,0,0,0,0,0,0],"swc":[-1,-1,-1,-1,-1,-1,-1,-1],"swn":[null,null,null,null,null,null,null,null],"btn":[0,0,0,0],"so":{"4":0,"11":0,"13":0,"17":0,"20":0,"30":0,"68":0,"73":0,"82":0,"114":0},"lk":1,"lt_st":0,"ver":1}
20:18:47 RSL: tasmota/discovery/D8BFC01225D1/sensors = {"sn":{"Time":"2020-11-28T20:18:47","ENERGY":{"TotalStartTime":"2020-11-28T20:17:43","Total":8389.890,"Yesterday":0.000,"Today":8389.890,"Power":0,"ApparentPower":0,"ReactivePower":0,"Factor":0.00,"Voltage":0,"Current":0.000}},"ver":1}
20:18:49 APP: Boot Count 3
20:18:50 CFG: Saved to flash at F6, Count 14, Bytes 4096
20:18:50 RSL: tele/tasmota_1225D1/STATE = {"Time":"2020-11-28T20:18:50","Uptime":"0T00:00:11","UptimeSec":11,"Heap":27,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":23,"MqttCount":0,"POWER":"ON","Wifi":{"AP":1,"SSId":"www.krikkit.net","BSSId":"DC:39:6F:10:FB:30","Channel":1,"RSSI":90,"Signal":-55,"LinkCount":1,"Downtime":"0T00:00:05"}}
20:18:50 RSL: tele/tasmota_1225D1/SENSOR = {"Time":"2020-11-28T20:18:50","ENERGY":{"TotalStartTime":"2020-11-28T20:17:43","Total":8389.890,"Yesterday":0.000,"Today":8389.890,"Period":0,"Power":0,"ApparentPower":0,"ReactivePower":0,"Factor":0.00,"Voltage":0,"Current":0.000}}
20:18:50 TYA: Send "55aa00000000ff"
20:18:50 {"TuyaReceived":{"Data":"55AA030000010104","Cmnd":0,"CmndData":"01"}}
20:18:50 TYA: Heartbeat

TO REPRODUCE

reset to factory defaults, wifi config, config module as TuyaMCU, set TuyaRx and TuyaTx Gpio Right, config TuyaMCU with this:

Backlog TuyaMCU 33,20; TuyaMCU 32,18; TuyaMCU 31,19;

EXPECTED BEHAVIOUR

the Total kWh value should be 0 after reset

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)

bug fixed

All 10 comments

updated with finding that this seems to happen also after power-cycle on 9.1.0.0

Issuing a `backlog energyreset1 0; energyreset2 0; energyreset3 0 to reset all to zero or choose what you want to reset nromally will do the trick, but since is a Tuya MCU device you will be fine just until an update from the MCU comes in.
Have a look if you can reset your device data in nand if not . there is no way to do a reset.

Closing this issue as it has been answered.


Support Information

See Docs for more information.
See Chat for more user experience.
See Community for forum.
See Code of Conduct

sorry, but i think you missunderstand my issue, i know the energyreset command and i did use this i did even to a complete device reset with reset 1, which should purge all data, but even after purging alle the energy data with

Backlog EnergyReset1 0; EnergyReset2 0; EnergyReset3 0; 

after powercycl/reboot i still have a "energy today" value of e.g. 3000 kWh (a completly wrong an unrealistic value), directly after reset and reboot... so this seems to be an issue for me...

I think the issue is caused by the fact that at the time Tuya reports it's active power the RealTimeClock is not in sync.

I'll change the tuyamcu driver and add a test for valid RTC before active power will be calculated.

Give it a try.

Could be, but on my last update I moved the TUYA_CMD_QUERY_PRODUCT under FUNC_MQTT_INIT and at this time the RTC should be already in sync. Since is a less than 24h change I doubt the OP has already tested it.
Let's call it as additional fail-safe! :)
As a side note on next update there will be the support for external Total Energy (and SetOption72 for Tuya too).

OK. You're right. I didn't know. At least it doesn't hurt to test for valid time anyway.

Let's see what OP comes up with.

just did an update to current build (9.1.0.2 Timestamp 20201130 18:17) and could not reproduce the issue ...so big thanks to @arendst / @effelle for fixing this issue!

...still hoping for the Tolal Energy Support :)

Perfect, thanks for reporting.
Closing this issue as it has been fixed.

Support Information
See Docs for more information.
See Chat for more user experience.
See Code of Conduct

Was this page helpful?
0 / 5 - 0 ratings

Related issues

wirelesssolution picture wirelesssolution  路  3Comments

luisfpinto picture luisfpinto  路  3Comments

smadds picture smadds  路  3Comments

esp32x picture esp32x  路  3Comments

belidzs picture belidzs  路  3Comments