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.28k stars 4.82k forks source link

SDM630 with WeMoS D1 Pro can't provide Import Energy (on the WWW dashboard) #18446

Closed panciunio closed 1 year ago

panciunio commented 1 year ago

PROBLEM DESCRIPTION

A clear and concise description of what the problem is. SDM630 Power Meter connected to WeMoS D1 Pro doesn't provide Import Active on each phase.

REQUESTED INFORMATION

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

  Configuration output here:
13:05:33.622 CMD: Backlog Template; Module; GPIO 255`
13:05:33.662 MQT: stat/SDM630/RESULT = {"NAME":"WEMOS D1 PRO","GPIO":[0,0,0,0,1984,2016,0,0,0,0,0,0,0,0],"FLAG":0,"BASE":18}
13:05:33.875 MQT: stat/SDM630/RESULT = {"Module":{"0":"WEMOS D1 PRO"}}
13:05:34.081 MQT: stat/SDM630/RESULT = {"GPIO0":{"0":"None"},"GPIO1":{"0":"None"},"GPIO2":{"0":"None"},"GPIO3":{"0":"None"},"GPIO4":{"1984":"SDM630 Tx"},"GPIO5":{"2016":"SDM630 Rx"},"GPIO9":{"0":"None"},"GPIO10":{"0":"None"},"GPIO12":{"0":"None"},"GPIO13":{"0":"None"},"GPIO14":{"0":"None"},"GPIO15":{"0":"None"},"GPIO16":{"0":"None"},"GPIO17":{"0":"None"}}
- [ ] Provide the output of this command: `Status 0`:
```lua
  STATUS 0 output here:
13:07:20.362 CMD: status 0
13:07:20.371 MQT: stat/SDM630/STATUS = {"Status":{"Module":0,"DeviceName":"SDM630","FriendlyName":["SDM630"],"Topic":"SDM630","ButtonTopic":"0","Power":0,"PowerOnState":3,"LedState":1,"LedMask":"FFFF","SaveData":0,"SaveState":1,"SwitchTopic":"0","SwitchMode":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"ButtonRetain":0,"SwitchRetain":0,"SensorRetain":0,"PowerRetain":0,"InfoRetain":0,"StateRetain":0,"StatusRetain":0}}
13:07:20.405 MQT: stat/SDM630/STATUS1 = {"StatusPRM":{"Baudrate":115200,"SerialConfig":"8N1","GroupTopic":"tasmotas","OtaUrl":"http://ota.tasmota.com/tasmota/release/tasmota.bin.gz","RestartReason":"Hardware Watchdog","Uptime":"0T00:00:45","StartupUTC":"2023-04-18T12:06:35","Sleep":50,"CfgHolder":4617,"BootCount":495,"BCResetTime":"2021-06-06T16:00:29","SaveCount":532,"SaveAddress":"FB000"}}
13:07:20.441 MQT: stat/SDM630/STATUS2 = {"StatusFWR":{"Version":"12.5.0(sensors)","BuildDateTime":"2023-04-17T08:03:55","Boot":4,"Core":"2_7_4_9","SDK":"2.2.2-dev(38a443e)","CpuFrequency":80,"Hardware":"ESP8266EX","CR":"362/699"}}
13:07:20.460 MQT: stat/SDM630/STATUS3 = {"StatusLOG":{"SerialLog":2,"WebLog":2,"MqttLog":0,"SysLog":0,"LogHost":"","LogPort":514,"SSId":["Kameleon2_MiWiFi2",""],"TelePeriod":300,"Resolution":"558180C0","SetOption":["40028009","2805C80001000600003C5A0A002800000000","00000288","00006000","00004000","00000000"]}}
13:07:20.502 MQT: stat/SDM630/STATUS4 = {"StatusMEM":{"ProgramSize":699,"Free":304,"Heap":14,"ProgramFlashSize":1024,"FlashSize":16384,"FlashChipId":"1840EF","FlashFrequency":40,"FlashMode":"DOUT","Features":["00000809","8F9A8787","0415A005","B7F7BFCF","05DA9BC4","64367CC7","00084052","20000000","54000020","0008C081"],"Drivers":"1,2,3,4,5,6,7,8,9,10,12,14,16,17,20,21,24,29,34,62,65,66","Sensors":"1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,17,18,19,20,21,22,26,31,34,37,39,40,42,43,45,51,52,55,56,58,59,62,64,66,67,74,98,103,105","I2CDriver":"7,8,9,10,11,12,13,14,15,17,18,20,24,29,31,36,41,42,44,46,48,69,76"}}
13:07:20.553 MQT: stat/SDM630/STATUS5 = {"StatusNET":{"Hostname":"SDM630","IPAddress":"192.168.200.10","Gateway":"192.168.200.254","Subnetmask":"255.255.255.0","DNSServer1":"192.168.200.2","DNSServer2":"0.0.0.0","Mac":"84:CC:A8:A6:18:1E","Webserver":2,"HTTP_API":1,"WifiConfig":0,"WifiPower":17.0}}
13:07:20.577 MQT: stat/SDM630/STATUS6 = {"StatusMQT":{"MqttHost":"192.168.200.2","MqttPort":1883,"MqttClientMask":"DVES_%06X","MqttClient":"DVES_A6181E","MqttUser":"DVES_USER","MqttCount":1,"MAX_PACKET_SIZE":1200,"KEEPALIVE":30,"SOCKET_TIMEOUT":4}}
13:07:20.600 MQT: stat/SDM630/STATUS7 = {"StatusTIM":{"UTC":"2023-04-18T12:07:20","Local":"2023-04-18T13:07:20","StartDST":"2023-03-26T02:00:00","EndDST":"2023-10-29T03:00:00","Timezone":"+01:00","Sunrise":"05:53","Sunset":"19:45"}}
13:07:20.618 MQT: stat/SDM630/STATUS9 = {"StatusPTH":{"PowerDelta":[0,0,0],"PowerLow":0,"PowerHigh":0,"VoltageLow":0,"VoltageHigh":0,"CurrentLow":0,"CurrentHigh":0}}
13:07:20.643 MQT: stat/SDM630/STATUS10 = {"StatusSNS":{"Time":"2023-04-18T13:07:20","ENERGY":{"TotalStartTime":"2021-06-06T16:00:29","Total":85.485,"Yesterday":12.352,"Today":0.106,"TodaySumImport":0.000,"TodaySumExport":0.000,"ExportActive":[2468.866,2143.309,1667.846],"Power":[166,-475,-219],"ApparentPower":[505,545,369],"ReactivePower":[-436,-225,-251],"Factor":[0.33,-0.91,-0.68],"Frequency":50,"Voltage":[235,238,236],"Current":[2.150,2.295,1.566]}}}
13:07:20.681 MQT: stat/SDM630/STATUS11 = {"StatusSTS":{"Time":"2023-04-18T13:07:20","Uptime":"0T00:00:45","UptimeSec":45,"Heap":14,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":19,"MqttCount":1,"Wifi":{"AP":1,"SSId":"Kameleon2_MiWiFi2","BSSId":"18:E8:29:A1:00:07","Channel":1,"Mode":"11n","RSSI":84,"Signal":-58,"LinkCount":1,"Downtime":"0T00:00:09"}}}

### TO REPRODUCE
_Steps to reproduce the behavior:_

### EXPECTED BEHAVIOUR
_A clear and concise description of what you expected to happen._
Read Import values

### 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)**

Hi All,
I my country anybody saying "Better is the enemy of good one!". It's mean if someone working properly - don't touch it!

I decided to upgrade my all Tasmota's network and of course, my Wemos D1 Pro connected to SDM630 stopped provide an information regarding Import Energy at all. 

I started with official tasmota-sensors firmware and what I can see:

![Screenshot from 2023-04-18 12-30-44](https://user-images.githubusercontent.com/9402700/232758568-f4876640-c711-4ff7-92d1-cb4811e49d9d.png)

Okay... nothing happened... I had the same situation with Tasmota 8(9).x... 

I downloaded newest development source archive and checked   'xnrg_10_sdm630.ino' file which contains section:

//#ifdef SDM630_IMPORT 0x015A, // + + + kWh Phase 1 import active energy 0x015C, // + + + kWh Phase 2 import active energy 0x015E, // + + + kWh Phase 3 import active energy //#endif // SDM630_IMPORT


I assume, that's ok... I checked cases into SDM630Every250ms():
    case 19:
      Energy->import_active[0] = value;
      break;

    case 20:
      Energy->import_active[1] = value;
      break;

    case 21:
      Energy->import_active[2] = value;
      break;


look's good as well...

Compiled, flashed... result? the same...
![Screenshot from 2023-04-18 12-27-20](https://user-images.githubusercontent.com/9402700/232760061-1a4d4632-bbf5-4c0e-812e-112920d66256.png)

No Import Active visible...

I tried to dig deeper... found 'configurations.md' file into 'energy_modbus_config' branch. Very interesting file which contains JSON structure for each data from energy measurement device, I founf SDM630 section and discovered that ImportActive variable is hidden into "User" section:

`SDM630             {"Name":"SDM630","Baud":9600,"Config":"8N1","Address":1,"Function":4,"Voltage":[0,2,4],"Current":[6,8,10],"Power":[12,14,16],"ApparentPower":[18,20,22],"ReactivePower":[24,26,28],"Factor":[30,32,34],"Frequency":70,"Total":342,"ExportActive":[352,354,356],**"User":{"R":[346,348,350],"J":"ImportActive","G":"Import Active","U":"kWh","D":24}**}`

The question is... how to check data from table "User" under Tasmota console and how to provide these information to MQTT if these are available?

Best Regards,
panciunio
arendst commented 1 year ago

SDM630 ImportActive =Energy Total.

If you want more registers you will need to start using the new user configurable modbus driver. See https://github.com/arendst/Tasmota/pull/18413#issuecomment-1510131402

This is also more future proof where dedicated modbus drivers will be removed someday.

panciunio commented 1 year ago

Hi. Thanks for quick reply,

Yes.. I agree but I want to see Import Active for each phase... Thanks for tip I will write my own modbus .json dedicated to SDM630 but I thought, the section:

SDM630 {"Name":"SDM630","Baud":9600,"Config":"8N1","Address":1,"Function":4,"Voltage":[0,2,4],"Current":[6,8,10],"Power":[12,14,16],"ApparentPower":[18,20,22],"ReactivePower":[24,26,28],"Factor":[30,32,34],"Frequency":70,"Total":342,"ExportActive":[352,354,356],"User":{"R":[346,348,350],"J":"ImportActive","G":"Import Active","U":"kWh","D":24}}

from configurations.md file means the same... but I'm not sure how to inform compiler that should use this particular section.

arendst commented 1 year ago

Read the docs: SetOption129 0/1

When you use new modbus driver you do not need to tell the compiler any config data. It's entered at runtime. Again, see link above.

panciunio commented 1 year ago

Okay, because I'm using small 8266 device I decided to use 'rule' method. So in case I added Rule3 as follow:

on file#modbus do
    {"Name":"SDM630","Baud":9600,"Config":"8N1","Address":1,"Function":4,"Voltage":[0,2,4],"Current":[6,8,10],"Power":[12,14,16],"ApparentPower":[18,20,22],"ReactivePower":[24,26,28],"Factor":[30,32,34],"Frequency":70,"Total":342,"ExportActive":[346,348,350],"User":{"R":[346,348,350],"J":"ImportActive","G":"Import Active","U":"kWh","D":24}}
endon

This is exactly the same configuration which is into 'configurations.md' file for SDM630 There is part reflecting to ImportActive for each phase and as I understood correctly - should be visible on dashboard ("G": "Import Active"). I'm sorry, I'm trying to follow documentation and do what is required but i still have lack of knowledge... Could you please explain more with more details what I'm doing wrong?

One interesting thing... when I added rule using console, the system added rule wilt escapes chars - it's normal?

[20:27:06] cmnd/SDM630/rule3 on file#modbus do {"Name":"SDM630","Baud":9600,"Config":"8N1","Address":1,"Function":4,"Voltage":[0,2,4],"Current":[6,8,10],"Power":[12,14,16],"ApparentPower":[18,20,22],"ReactivePower":[24,26,28],"Factor":[30,32,34],"Frequency":70,"Total":342,"ExportActive":[352,354,356],"User":{"R":[346,348,350],"J":"ImportActive","G":"Import Active","U":"kWh","D":24}}
endon
19:31:41.421 MQT: stat/SDM630/RESULT = {"Rule3":{"State":"ON","Once":"OFF","StopOnError":"OFF","Length":362,"Free":149,"Rules":"on file#modbus do {\"Name\":\"SDM630\",\"Baud\":9600,\"Config\":\"8N1\",\"Address\":1,\"Function\":4,\"Voltage\":[0,2,4],\"Current\":[6,8,10],\"Power\":[12,14,16],\"ApparentPower\":[18,20,22],\"ReactivePower\":[24,26,28],\"Factor\":[30,32,34],\"Frequency\":70,\"Total\":342,\"ExportActive\":[352,354,356],\"User\":{\"R\":[346,348,350],\"J\":\"ImportActive\",\"G\":\"Import Active\",\"U\":\"kWh\",\"D\":24}} endon"}}

I used official tasmota-sensors v12.5.0 for above

Edit 1: I missed your comment according: SetOption129 0/1 - It's definitively changing situation:

Screenshot from 2023-04-18 20-50-28

but Energy Total not reflecting real state:

19:52:18.539 NRG: EnergyTotal[0] 7380.4106 kWh
19:52:18.541 NRG: EnergyTotal[1] 2926.9280 kWh
19:52:18.542 NRG: EnergyTotal[2] 7965.1777 kWh

Edit 2: Solved!

I read deeper according to given by you SetOption129... and I foung another one which is very interesting:

**SetOption72 | Set reference used for total energy 0 = use firmware counter (default)1 = use energy monitor (e.g., PZEM-0xx, SDM120, SDM630, DDS238, DDSU666) hardware counter** set to 1 solving problem with bad calculation :-)

Screenshot from 2023-04-18 21-06-07

Many thanks for help, I hope it will be good lesson for other!

jeroenst commented 1 day ago

Same issue for Shelly 3EM missing Import Active, does SetOption72 also work for shelly 3em?