u9n / dlms-cosem

A Python library for DLMS/COSEM
Other
79 stars 39 forks source link

VisibleStringData have not implemented byte conversion #60

Closed pfassberg closed 1 year ago

pfassberg commented 1 year ago

I did a test as requested on https://hanporten.se/norska/protokollet/ with a live Kamstrup meter and got "NotImplementedError: VisibleStringData have not implemented byte conversion".

The HDLC data is here:

7ea0e22b2113239ae6e7000f000000000c07e60c1c03170100ff80000002190a0e4b616d73747275705f563030303109060101000005ff0a103537303635363731393633383234383509060101600101ff0a1236383431313331424e31343331303130393009060101010700ff060000092609060101020700ff060000000009060101030700ff060000000009060101040700ff06000000df090601011f0700ff060000005c09060101330700ff060000008d09060101470700ff060000037209060101200700ff1200e609060101340700ff1200e609060101480700ff1200e49a187e

This is the included data:

{
  "obis_list_version": "Kamstrup_V0001",
  "meter_ID": "5706567196382485",
  "meter_model": "6841131BN143101090",
  "act_pow_pos": 2342,
  "act_pow_neg": 0,
  "react_pow_pos": 0,
  "react_pow_neg": 223,
  "curr_L1": 92,
  "curr_L2": 141,
  "curr_L3": 882,
  "volt_L1": 230,
  "volt_L2": 230,
  "volt_L3": 228
}
Krolken commented 1 year ago

Cool, I have not seen a meter with the data type VisibleStringData before. That is why it is not implemented.

Is the data you posted from your own meter? Then I can use it for my tests when I add the functionality. I prefer to have data from real meters when I add features to test against instead of just trying to read the standard documentation.

Some notes to myself:

https://www.oss.com/asn1/resources/asn1-made-simple/asn1-quick-reference/visiblestring.html Visible string is an ordered sequence of ASCII characters

pfassberg commented 1 year ago

Yes, from my own meter. It's a Kamstrup OmniPower DK-8660 684-11-31B-N14-3101-090.

I can see that it also send date/time and energy counters every full hour.

pfassberg commented 1 year ago

Thank you!

Unfortunately I now get another error with the same input:

Traceback (most recent call last):
  File "/home/pi/proj/dlms/parse2.py", line 20, in <module>
    clock_obis = Obis.from_bytes(date_row[0])
  File "/home/pi/.local/lib/python3.9/site-packages/dlms_cosem/cosem/obis.py", line 48, in from_bytes
    data = bytearray(source_bytes)
TypeError: string argument without an encoding
Krolken commented 1 year ago

If you are using the example at https://hanporten.se/norska/protokollet/, that will not work with your meter.

The meter in the example sends a structure of data, but you meter just sends and array of data.

The array is built like [push_list_version, value, obis-bytes, value, obis-bytes ...]

['Kamstrup_V0001', bytearray(b'\x01\x01\x00\x00\x05\xff'), '5706567196382485', bytearray(b'\x01\x01`\x01\x01\xff'), '6841131BN143101090', bytearray(b'\x01\x01\x01\x07\x00\xff'), 2342, bytearray(b'\x01\x01\x02\x07\x00\xff'), 0, bytearray(b'\x01\x01\x03\x07\x00\xff'), 0, bytearray(b'\x01\x01\x04\x07\x00\xff'), 223, bytearray(b'\x01\x01\x1f\x07\x00\xff'), 92, bytearray(b'\x01\x013\x07\x00\xff'), 141, bytearray(b'\x01\x01G\x07\x00\xff'), 882, bytearray(b'\x01\x01 \x07\x00\xff'), 230, bytearray(b'\x01\x014\x07\x00\xff'), 230, bytearray(b'\x01\x01H\x07\x00\xff'), 228]

Compare to the examples data:

[[bytearray(b'\x00\x00\x01\x00\x00\xff'), bytearray(b'\x07\xe3\x0c\x10\x01\x07;(\xff\x80\x00\xff')], [bytearray(b'\x01\x00\x01\x07\x00\xff'), 1122, [0, 27]], [bytearray(b'\x01\x00\x02\x07\x00\xff'), 0, [0, 27]], [bytearray(b'\x01\x00\x03\x07\x00\xff'), 1507, [0, 29]], [bytearray(b'\x01\x00\x04\x07\x00\xff'), 0, [0, 29]], [bytearray(b'\x01\x00\x1f\x07\x00\xff'), 0, [-1, 33]], [bytearray(b'\x01\x003\x07\x00\xff'), 75, [-1, 33]], [bytearray(b'\x01\x00G\x07\x00\xff'), 0, [-1, 33]], [bytearray(b'\x01\x00 \x07\x00\xff'), 2307, [-1, 35]], [bytearray(b'\x01\x004\x07\x00\xff'), 2499, [-1, 35]], [bytearray(b'\x01\x00H\x07\x00\xff'), 2308, [-1, 35]], [bytearray(b'\x01\x00\x15\x07\x00\xff'), 0, [0, 27]], [bytearray(b'\x01\x00\x16\x07\x00\xff'), 0, [0, 27]], [bytearray(b'\x01\x00\x17\x07\x00\xff'), 0, [0, 29]], [bytearray(b'\x01\x00\x18\x07\x00\xff'), 0, [0, 29]], [bytearray(b'\x01\x00)\x07\x00\xff'), 1122, [0, 27]], [bytearray(b'\x01\x00*\x07\x00\xff'), 0, [0, 27]], [bytearray(b'\x01\x00+\x07\x00\xff'), 1506, [0, 29]], [bytearray(b'\x01\x00,\x07\x00\xff'), 0, [0, 29]], [bytearray(b'\x01\x00=\x07\x00\xff'), 0, [0, 27]], [bytearray(b'\x01\x00>\x07\x00\xff'), 0, [0, 27]], [bytearray(b'\x01\x00?\x07\x00\xff'), 0, [0, 29]], [bytearray(b'\x01\x00@\x07\x00\xff'), 0, [0, 29]], [bytearray(b'\x01\x00\x01\x08\x00\xff'), 10049926, [0, 30]], [bytearray(b'\x01\x00\x02\x08\x00\xff'), 8, [0, 30]], [bytearray(b'\x01\x00\x03\x08\x00\xff'), 6614347, [0, 32]], [bytearray(b'\x01\x00\x04\x08\x00\xff'), 5, [0, 32]]]