datenschuft / SMA-EM

SMA Energymeter measurement
GNU General Public License v2.0
92 stars 38 forks source link

Exception Unknown datatype raw_type with a unknown serial #66

Closed SirRenix closed 2 years ago

SirRenix commented 2 years ago

Im testing the sma-em-measurement,py to get data for monitoring, My SHM20 has the actual firmware 2.7.5. . When I start the script then comes correct data, but after some updates failure. With the script sma-em-capture-package I have no problems.

When you need the original data stream output of the udp then write me here and I send you a Email. PS.: I have modify the output a little bit at line 80 to get the data stream.

Version: 2.7.5.R|020705
unknown datatype: measurement 29697 datatype unknown raw_type 228
unknown datatype: measurement 0 datatype unknown raw_type 0
unknown datatype: measurement 0 datatype unknown raw_type 0
unknown datatype: measurement 0 datatype unknown raw_type 0
b'SMA\x00\x00\x04\x02\xa0\x00\x00\x00\x01\x00&\x00\x10`e\t\xa0\xff\xff\xff\xff\xff\xff\x00\x00t\x01\xe4\x11\x95\xb3\x00\x00\x00\x00\x00\x00\xcb\x94\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'

SMA-EM Serial:4294967295
----sum----
Traceback (most recent call last):
  File "/opt/smaemd/sma-em-measurement.py", line 87, in <module>
    print ('P: consume:{}W {}kWh supply:{}W {}kWh'.format(emparts['pconsume'],emparts['pconsumecounter'],emparts['psupply'],emparts['psupplycounter']))
KeyError: 'pconsume'
SirRenix commented 2 years ago

Today I found the Issue why the SMA-EM program become wrong data. The SMA-SHM20 send in ~30seconds a UDP bytecode over the port 9522 from the IP 192.168.x.x. The Bytecode(length 58) is ffffffffffff00d09356b7970800450000562f414000401188a2c0a80064c0a800ff25322532004297b9534d4100000402a00000000100260010606509a0ffffffffffff00007401e41195b3000000000000aba100020000000000000000000000000000 Better readable: "\xff\xff\xff\xff\xff\xff\x00\xd0\x93\x56\xb7\x97\x08\x00\x45\x00" \ "\x00\x56\x2f\x41\x40\x00\x40\x11\x88\xa2\xc0\xa8\x00\x64\xc0\xa8" \ "\x00\xff\x25\x32\x25\x32\x00\x42\x97\xb9\x53\x4d\x41\x00\x00\x04" \ "\x02\xa0\x00\x00\x00\x01\x00\x26\x00\x10\x60\x65\x09\xa0\xff\xff" \ "\xff\xff\xff\xff\x00\x00\x74\x01\xe4\x11\x95\xb3\x00\x00\x00\x00" \ "\x00\x00\xab\xa1\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" \ "\x00\x00\x00\x00"

The bytecode changes with every cycle.

sellth commented 2 years ago

I've also noticed this problem. Not sure how much trouble it actually creates. My attempt at an hotfix: #69

sla004 commented 2 years ago

I have this same problem. Can someone approve above mentioned pull request?

datenschuft commented 2 years ago

I think this are some Speedwire device discovery packages. SMA has published some documents, how the Speedwire Device Discovery works. You can find the term "534d4100000402a000000001002" in the documentation The measurement-packeages should have a size over 580 Bytes. So we ignore smaller packages. I hope this works for everyone.