Query SMA Energy Meter / Home Manager by UDP in

Hi,
I came across the possibility to query my home manager directly in Node Red with UDP in:

[{"id":"a14c0e39.6a108","type":"udp in","z":"4726af68.c62a98","name":"Home Manager","iface":"","port":"9522","ipv":"udp4","multicast":"true","group":"239.12.255.254","datatype":"buffer","x":310,"y":440,"wires":[["124446eb.e14ff9"]]},{"id":"76a01c62.9a89b4","type":"debug","z":"4726af68.c62a98","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":670,"y":440,"wires":[]},{"id":"124446eb.e14ff9","type":"function","z":"4726af68.c62a98","name":"","func":"var count = context.get('count')||0;\ncount += 1;\n\n\nvar msg1 = { payload:\"actual consumption\" };\nvar msg2 = { payload:\"actual gridfeed\" };\nvar msg3 = { payload:\"consumption counter\" };\nvar msg4 = { payload:\"gridfeed counter\" };\n\n\n/* to get the actual grid consumption in W we need the offset 0.1.4.0 */\noffset = msg.payload.indexOf(\"00010400\", 0, \"hex\")+ 4;\nvar consumption = parseInt((msg.payload[offset+0]*0x1000000 + \n                            msg.payload[offset+1]*0x10000 + \n                            msg.payload[offset+2]*0x100  +\n                            msg.payload[offset+3]) / 10);\n\n/* to get the actual grid consumption counter in Wh we need the offset 0.1.8.0 */\noffset = msg.payload.indexOf(\"00010800\", 0, \"hex\")+ 4;\nvar consumption_c = parseInt((msg.payload[offset+0]*0x100000000000000 + \n                              msg.payload[offset+1]*0x1000000000000 + \n                              msg.payload[offset+2]*0x10000000000  +\n                              msg.payload[offset+3]*0x100000000 +\n                              msg.payload[offset+4]*0x1000000 + \n                              msg.payload[offset+5]*0x10000 + \n                              msg.payload[offset+6]*0x100  +\n                              msg.payload[offset+7]) / 3600);\n\n/* to get the actual grid feed in W we need the offset 0.2.4.0 */\noffset = msg.payload.indexOf(\"00020400\", 0, \"hex\")+ 4;\nvar gridfeed = parseInt((msg.payload[offset+0]*0x1000000 + \n                         msg.payload[offset+1]*0x10000 + \n                         msg.payload[offset+2]*0x100  +\n                         msg.payload[offset+3]) / 10);\n\n/* to get the actual grid feed counter in Wh we need the offset 0.2.8.0 */\noffset = msg.payload.indexOf(\"00020800\", 0, \"hex\")+ 4;\nvar gridfeed_c = parseInt((msg.payload[offset+0]*0x100000000000000 + \n                           msg.payload[offset+1]*0x1000000000000 + \n                           msg.payload[offset+2]*0x10000000000  +\n                           msg.payload[offset+3]*0x100000000 +\n                           msg.payload[offset+4]*0x1000000 + \n                           msg.payload[offset+5]*0x10000 + \n                           msg.payload[offset+6]*0x100  +\n                           msg.payload[offset+7]) / 3600);\n\n\nif (consumption >= 0 && consumption < 100000 ) {\n    msg1.payload = consumption.toString();    \n} else msg1 = null;\n\nif (consumption_c >= 0 && consumption_c < 50000000 ) {\n    msg2.payload = consumption_c.toString();   \n} else msg2 = null;\n\nif (gridfeed >= 0 && gridfeed < 100000 ) {\n    msg3.payload = gridfeed.toString();    \n} else msg3 = null;\n\nif (gridfeed_c >= 0 && gridfeed_c < 5000000 ) {\n    msg4.payload = gridfeed_c.toString();   \n} else msg4 = null;\n\n\nreturn [msg1, msg2, msg3, msg4 ];","outputs":1,"noerr":0,"initialize":"","finalize":"","x":500,"y":440,"wires":[["76a01c62.9a89b4"]]}]

to get the raw data is very easy, but to extract all the values is difficult. The example flow doesn´t work correct.

Here is an explanation of what is queried:
http://www.eb-systeme.de/wp-content/uploads/2019/12/EMETER-Protokoll-TI-de-10.pdf

this query program also works:

SMA-EM/speedwiredecoder.py at master · datenschuft/SMA-EM · GitHub (decoder)
grafik

I would like to decrypt all data and output it every second, for this I need a tip on how I can proceed in principle, as @Steve-Mcl showed me the buffer parser for the Modbus query back then.

Maybe a Buffer Parser could work ?

This is the raw input vom UDP in:

[83,77,65,0,0,4,2,160,0,0,0,1,2,76,0,16,96,105,1,116,113,89,181,228,88,186,142,41,0,1,4,0,0,0,0,74,0,1,8,0,0,0,0,6,140,178,168,168,0,2,4,0,0,0,0,0,0,2,8,0,0,0,0,7,253,178,78,24,0,3,4,0,0,0,0,0,0,3,8,0,0,0,0,0,16,235,94,240,0,4,4,0,0,0,22,30,0,4,8,0,0,0,0,12,168,135,222,48,0,9,4,0,0,0,22,30,0,9,8,0,0,0,0,12,28,154,227,224,0,10,4,0,0,0,0,0,0,10,8,0,0,0,0,9,97,63,42,104,0,13,4,0,0,0,0,13,0,14,4,0,0,0,195,82,0,21,4,0,0,0,0,0,0,21,8,0,0,0,0,3,125,229,248,40,0,22,4,0,0,0,5,89,0,22,8,0,0,0,0,7,95,110,238,0,0,23,4,0,0,0,0,0,0,23,8,0,0,0,0,0,25,7,4,144,0,24,4,0,0,0,10,18,0,24,8,0,0,0,0,4,201,201,10,64,0,29,4,0,0,0,0,0,0,29,8,0,0,0,0,5,52,51,139,248,0,30,4,0,0,0,11,103,0,30,8,0,0,0,0,7,216,157,153,232,0,31,4,0,0,0,6,73,0,32,4,0,0,3,136,221,0,33,4,0,0,0,1,213,0,41,4,0,0,0,6,77,0,41,8,0,0,0,0,2,143,16,39,40,0,42,4,0,0,0,0,0,0,42,8,0,0,0,0,0,212,170,232,136,0,43,4,0,0,0,0,0,0,43,8,0,0,0,0,0,11,51,114,184,0,44,4,0,0,0,5,74,0,44,8,0,0,0,0,2,21,225,52,240,0,49,4,0,0,0,8,58,0,49,8,0,0,0,0,3,115,86,47,64,0,50,4,0,0,0,0,0,0,50,8,0,0,0,0,0,229,93,153,200,0,51,4,0,0,0,4,5,0,52,4,0,0,3,139,244,0,53,4,0,0,0,2,254,0,61,4,0,0,0,0,0,0,61,8,0,0,0,0,1,193,39,152,200,0,62,4,0,0,0,0,170,0,62,8,0,0,0,0,1,11,3,142,8,0,63,4,0,0,0,0,0]

full debug:

{"payload":[83,77,65,0,0,4,2,160,0,0,0,1,2,76,0,16,96,105,1,116,113,89,181,228,88,187,136,25,0,1,4,0,0,0,0,0,0,1,8,0,0,0,0,6,140,178,168,168,0,2,4,0,0,0,0,92,0,2,8,0,0,0,0,7,253,178,79,128,0,3,4,0,0,0,0,0,0,3,8,0,0,0,0,0,16,235,94,240,0,4,4,0,0,0,22,5,0,4,8,0,0,0,0,12,168,136,108,56,0,9,4,0,0,0,0,0,0,9,8,0,0,0,0,12,28,155,35,40,0,10,4,0,0,0,22,5,0,10,8,0,0,0,0,9,97,63,121,40,0,13,4,0,0,0,0,16,0,14,4,0,0,0,195,86,0,21,4,0,0,0,0,0,0,21,8,0,0,0,0,3,125,229,248,40,0,22,4,0,0,0,5,230,0,22,8,0,0,0,0,7,95,111,18,144,0,23,4,0,0,0,0,0,0,23,8,0,0,0,0,0,25,7,4,144,0,24,4,0,0,0,10,13,0,24,8,0,0,0,0,4,201,201,74,240,0,29,4,0,0,0,0,0,0,29,8,0,0,0,0,5,52,51,139,248,0,30,4,0,0,0,11,167,0,30,8,0,0,0,0,7,216,157,227,8,0,31,4,0,0,0,6,105,0,32,4,0,0,3,135,98,0,33,4,0,0,0,1,250,0,41,4,0,0,0,6,64,0,41,8,0,0,0,0,2,143,16,79,240,0,42,4,0,0,0,0,0,0,42,8,0,0,0,0,0,212,170,232,136,0,43,4,0,0,0,0,0,0,43,8,0,0,0,0,0,11,51,114,184,0,44,4,0,0,0,5,70,0,44,8,0,0,0,0,2,21,225,86,176,0,49,4,0,0,0,8,46,0,49,8,0,0,0,0,3,115,86,100,176,0,50,4,0,0,0,0,0,0,50,8,0,0,0,0,0,229,93,153,200,0,51,4,0,0,0,4,5,0,52,4,0,0,3,139,30,0,53,4,0,0,0,2,252,0,61,4,0,0,0,0,0,0,61,8,0,0,0,0,1,193,39,152,200,0,62,4,0,0,0,0,182,0,62,8,0,0,0,0,1,11,3,147,168,0,63,4,0,0,0,0,0,0,63,8,0,0,0,0,0,11,43,32,64,0,64,4,0,0,0,6,177,0,64,8,0,0,0,0,5,231,88,0,96,0,69,4,0,0,0,0,0,0,69,8,0,0,0,0,6,18,102,145,104,0,70,4,0,0,0,6,187,0,70,8,0,0,0,0,1,52,69,76,192,0,71,4,0,0,0,3,201,0,72,4,0,0,3,132,175,0,73,4,0,0,0,0,106,144,0,0,0,2,6,6,82,0,0,0,0],"fromip":"192.168.168.23:58874","ip":"192.168.168.23","port":58874,"_msgid":"b43d1ee5.26a5f"}

greetings

here is the explanation in English:
https://translate.google.com/translate?sl=de&tl=en&u=http://www.eb-systeme.de/?page_id%3D3005

that manual is terrible - not nearly enough info to decode that protocol.

Fortunately, the python code gave me plenty of clues.

I was going to give you clues and pointers but TBF, this was a fun challenge so I did the lions share. It may not be 100% complete (or even accurate) but it should be close enough to progress...

[{"id":"9763dc2c.40756","type":"inject","z":"b872cb4b.5a6448","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":300,"y":580,"wires":[["97dec846.ffc208"]]},{"id":"97dec846.ffc208","type":"function","z":"b872cb4b.5a6448","name":"fake udp msg","func":"return { \n    \"payload\": Buffer.from([83, 77, 65, 0, 0, 4, 2, 160, 0, 0, 0, 1, 2, 76, 0, 16, 96, 105, 1, 116, 113, 89, 181, 228, 88, 186, 142, 41, 0, 1, 4, 0, 0, 0, 0, 74, 0, 1, 8, 0, 0, 0, 0, 6, 140, 178, 168, 168, 0, 2, 4, 0, 0, 0, 0, 0, 0, 2, 8, 0, 0, 0, 0, 7, 253, 178, 78, 24, 0, 3, 4, 0, 0, 0, 0, 0, 0, 3, 8, 0, 0, 0, 0, 0, 16, 235, 94, 240, 0, 4, 4, 0, 0, 0, 22, 30, 0, 4, 8, 0, 0, 0, 0, 12, 168, 135, 222, 48, 0, 9, 4, 0, 0, 0, 22, 30, 0, 9, 8, 0, 0, 0, 0, 12, 28, 154, 227, 224, 0, 10, 4, 0, 0, 0, 0, 0, 0, 10, 8, 0, 0, 0, 0, 9, 97, 63, 42, 104, 0, 13, 4, 0, 0, 0, 0, 13, 0, 14, 4, 0, 0, 0, 195, 82, 0, 21, 4, 0, 0, 0, 0, 0, 0, 21, 8, 0, 0, 0, 0, 3, 125, 229, 248, 40, 0, 22, 4, 0, 0, 0, 5, 89, 0, 22, 8, 0, 0, 0, 0, 7, 95, 110, 238, 0, 0, 23, 4, 0, 0, 0, 0, 0, 0, 23, 8, 0, 0, 0, 0, 0, 25, 7, 4, 144, 0, 24, 4, 0, 0, 0, 10, 18, 0, 24, 8, 0, 0, 0, 0, 4, 201, 201, 10, 64, 0, 29, 4, 0, 0, 0, 0, 0, 0, 29, 8, 0, 0, 0, 0, 5, 52, 51, 139, 248, 0, 30, 4, 0, 0, 0, 11, 103, 0, 30, 8, 0, 0, 0, 0, 7, 216, 157, 153, 232, 0, 31, 4, 0, 0, 0, 6, 73, 0, 32, 4, 0, 0, 3, 136, 221, 0, 33, 4, 0, 0, 0, 1, 213, 0, 41, 4, 0, 0, 0, 6, 77, 0, 41, 8, 0, 0, 0, 0, 2, 143, 16, 39, 40, 0, 42, 4, 0, 0, 0, 0, 0, 0, 42, 8, 0, 0, 0, 0, 0, 212, 170, 232, 136, 0, 43, 4, 0, 0, 0, 0, 0, 0, 43, 8, 0, 0, 0, 0, 0, 11, 51, 114, 184, 0, 44, 4, 0, 0, 0, 5, 74, 0, 44, 8, 0, 0, 0, 0, 2, 21, 225, 52, 240, 0, 49, 4, 0, 0, 0, 8, 58, 0, 49, 8, 0, 0, 0, 0, 3, 115, 86, 47, 64, 0, 50, 4, 0, 0, 0, 0, 0, 0, 50, 8, 0, 0, 0, 0, 0, 229, 93, 153, 200, 0, 51, 4, 0, 0, 0, 4, 5, 0, 52, 4, 0, 0, 3, 139, 244, 0, 53, 4, 0, 0, 0, 2, 254, 0, 61, 4, 0, 0, 0, 0, 0, 0, 61, 8, 0, 0, 0, 0, 1, 193, 39, 152, 200, 0, 62, 4, 0, 0, 0, 0, 170, 0, 62, 8, 0, 0, 0, 0, 1, 11, 3, 142, 8, 0, 63, 4, 0, 0, 0, 0, 0]),\n    \"fromip\": \"192.168.168.23:58874\", \"ip\": \"192.168.168.23\", \"port\": 58874, \"_msgid\": \"b43d1ee5.26a5f\" \n    }\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":460,"y":580,"wires":[["d31802c3.e2aef"]]},{"id":"d31802c3.e2aef","type":"buffer-parser","z":"b872cb4b.5a6448","name":"","data":"payload","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"string","name":"sma","offset":0,"length":3,"offsetbit":0,"scale":"1","mask":""},{"type":"uint32be","name":"Tag=>Tag0","offset":4,"length":1,"offsetbit":0,"scale":">> 4","mask":"0xff0"},{"type":"uint32be","name":"Tag=>Version","offset":4,"length":1,"offsetbit":0,"scale":"0","mask":"0xf"},{"type":"uint32be","name":"Group","offset":8,"length":1,"offsetbit":0,"scale":"0","mask":""},{"type":"uint32be","name":"item10","offset":25,"length":1,"offsetbit":0,"scale":">> 4","mask":"0xFFF0"},{"type":"uint16be","name":"ProtocolID","offset":16,"length":1,"offsetbit":0,"scale":"0","mask":""},{"type":"uint32be","name":"meter_identifier=>SusyID","offset":18,"length":1,"offsetbit":0,"scale":">> 4","mask":"0xFFF0"},{"type":"uint32be","name":"meter_identifier=>SerNo","offset":21,"length":1,"offsetbit":0,"scale":">> 4","mask":"0xFFF0"},{"type":"buffer","name":"data","offset":28,"length":-1,"offsetbit":0,"scale":"1","mask":""}],"swap1":"","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload","msgPropertyType":"str","resultType":"keyvalue","resultTypeType":"output","multipleResult":false,"fanOutMultipleResult":false,"setTopic":true,"outputs":1,"x":650,"y":580,"wires":[["6c5f3651.e1e838"]]},{"id":"6c5f3651.e1e838","type":"buffer-parser","z":"b872cb4b.5a6448","name":"","data":"payload.data","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"int16be","name":"measurement","offset":0,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"uint8","name":"datatype","offset":2,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"buffer","name":"data","offset":0,"length":-1,"offsetbit":0,"scale":"1","mask":""}],"swap1":"","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload","msgPropertyType":"str","resultType":"keyvalue","resultTypeType":"output","multipleResult":false,"fanOutMultipleResult":false,"setTopic":true,"outputs":1,"x":310,"y":680,"wires":[["35f7b433.19293c"]]},{"id":"35f7b433.19293c","type":"switch","z":"b872cb4b.5a6448","name":"8-counter, 4-actual, 0-version, other","property":"payload.datatype","propertyType":"msg","rules":[{"t":"eq","v":"8","vt":"num"},{"t":"eq","v":"4","vt":"num"},{"t":"eq","v":"0","vt":"num"},{"t":"else"}],"checkall":"true","repair":false,"outputs":4,"x":560,"y":680,"wires":[["99493b53.093878"],["701afb7c.a29b14"],["2518624f.84d29e"],["2518624f.84d29e"]]},{"id":"701afb7c.a29b14","type":"buffer-parser","z":"b872cb4b.5a6448","name":"","data":"payload.data","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"uint32be","name":"value","offset":4,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"buffer","name":"data","offset":8,"length":-1,"offsetbit":0,"scale":"1","mask":""}],"swap1":"","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload2","msgPropertyType":"str","resultType":"keyvalue","resultTypeType":"output","multipleResult":false,"fanOutMultipleResult":false,"setTopic":true,"outputs":1,"x":830,"y":700,"wires":[["fa42d9d5.faa708"]]},{"id":"99493b53.093878","type":"buffer-parser","z":"b872cb4b.5a6448","name":"","data":"payload.data","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"biguint64be","name":"value","offset":4,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"buffer","name":"data","offset":12,"length":-1,"offsetbit":0,"scale":"1","mask":""}],"swap1":"","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload2","msgPropertyType":"str","resultType":"keyvalue","resultTypeType":"output","multipleResult":false,"fanOutMultipleResult":false,"setTopic":true,"outputs":1,"x":830,"y":660,"wires":[["fa42d9d5.faa708"]]},{"id":"fa42d9d5.faa708","type":"function","z":"b872cb4b.5a6448","name":"more data available?","func":"var sma_units = {\n    \"W\": 10,\n    \"VA\": 10,\n    \"VAr\": 10,\n    \"kWh\": 3600000,\n    \"kVAh\": 3600000,\n    \"kVArh\": 3600000,\n    \"A\": 1000,\n    \"V\": 1000,\n    \"°\": 1000,\n    \"Hz\": 1000,\n};\nvar sma_channels = {\n    //# totals\n    1: ['pconsume', 'W', 'kWh'],\n    2: ['psupply', 'W', 'kWh'],\n    3: ['qconsume', 'VAr', 'kVArh'],\n    4: ['qsupply', 'VAr', 'kVArh'],\n    9: ['sconsume', 'VA', 'kVAh'],\n    10: ['ssupply', 'VA', 'kVAh'],\n    13: ['cosphi', '°'],\n    14: ['frequency', 'Hz'],\n    //# phase 1\n    21: ['p1consume', 'W', 'kWh'],\n    22: ['p1supply', 'W', 'kWh'],\n    23: ['q1consume', 'VAr', 'kVArh'],\n    24: ['q1supply', 'VAr', 'kVArh'],\n    29: ['s1consume', 'VA', 'kVAh'],\n    30: ['s1supply', 'VA', 'kVAh'],\n    31: ['i1', 'A'],\n    32: ['u1', 'V'],\n    33: ['cosphi1', '°'],\n    //# phase 2\n    41: ['p2consume', 'W', 'kWh'],\n    42: ['p2supply', 'W', 'kWh'],\n    43: ['q2consume', 'VAr', 'kVArh'],\n    44: ['q2supply', 'VAr', 'kVArh'],\n    49: ['s2consume', 'VA', 'kVAh'],\n    50: ['s2supply', 'VA', 'kVAh'],\n    51: ['i2', 'A'],\n    52: ['u2', 'V'],\n    53: ['cosphi2', '°'],\n    //# phase 3\n    61: ['p3consume', 'W', 'kWh'],\n    62: ['p3supply', 'W', 'kWh'],\n    63: ['q3consume', 'VAr', 'kVArh'],\n    64: ['q3supply', 'VAr', 'kVArh'],\n    69: ['s3consume', 'VA', 'kVAh'],\n    70: ['s3supply', 'VA', 'kVAh'],\n    71: ['i3', 'A'],\n    72: ['u3', 'V'],\n    73: ['cosphi3', '°'],\n    //# common\n    36864: ['speedwire-version', ''],\n};\n\nmsg.result = msg.result || {};\n\nfunction decode_item_header(datatype, measurement) {\n    if (datatype == 4)\n        return 'actual'\n    else if (datatype == 8)\n        return 'counter';\n    else if (datatype == 0 && measurement == 36864)\n        return 'version'\n    else\n        return 'unknown_' + measurement;\n}\n\n// @ts-ignore\nvar pl2 = msg.payload2;\nvar pl = msg.payload;\n\nvar measurement = pl.measurement;\nvar datatype = pl.datatype;\nvar ch = sma_channels[measurement] || [];\nvar valuename = ch[0], unit = ch[1];\n\nvar hasValue = pl2.hasOwnProperty('value');\nif (valuename && hasValue) {\n    var value = pl2.value;\n    var typeName = decode_item_header(datatype, measurement);\n    msg.result[valuename] = msg.result[valuename] || {};\n    msg.result[valuename][typeName] = {};\n    if (typeName == \"actual\"){\n        msg.result[valuename][typeName].unit = unit;\n    }\n    var t = typeof value;\n    if (t===\"number\") {\n        msg.result[valuename][typeName].value = value / (sma_units[unit] || 1);\n    } else if (t === \"bigint\") {\n        msg.result[valuename][typeName].value = value / BigInt(sma_units[unit] || 1);\n    } else {\n        msg.result[valuename][typeName].value = value;\n    }\n}\n\n\n/** @type {Buffer} */ var buf = pl2.data;\nif (buf && buf.length >= 8) {\n    msg.payload = {\n        data: pl2.data\n    };\n    return [msg,null];\n}\nmsg.payload = msg.result;\nreturn [null, msg];\n","outputs":2,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1060,"y":700,"wires":[["4924e0b.c55cc2"],["214e43d8.b9817c"]]},{"id":"2518624f.84d29e","type":"buffer-parser","z":"b872cb4b.5a6448","name":"","data":"payload.data","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"buffer","name":"data","offset":8,"length":-1,"offsetbit":0,"scale":"1","mask":""}],"swap1":"","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload2","msgPropertyType":"str","resultType":"keyvalue","resultTypeType":"output","multipleResult":false,"fanOutMultipleResult":false,"setTopic":true,"outputs":1,"x":830,"y":740,"wires":[["fa42d9d5.faa708"]]},{"id":"197fcf94.b189b","type":"link in","z":"b872cb4b.5a6448","name":"","links":["4924e0b.c55cc2"],"x":175,"y":680,"wires":[["6c5f3651.e1e838"]]},{"id":"4924e0b.c55cc2","type":"link out","z":"b872cb4b.5a6448","name":"","links":["197fcf94.b189b"],"x":1215,"y":700,"wires":[]},{"id":"214e43d8.b9817c","type":"debug","z":"b872cb4b.5a6448","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1130,"y":760,"wires":[]}]
1 Like

best man on earth Steve!

I don´t understand your flow, but it works.

I would like to minimize it to the payloads.
the units in each object are not necessary.

Just tweak the "more data avail" function.

Example...

[{"id":"188e0eac.1b7f21","type":"inject","z":"b872cb4b.5a6448","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":280,"y":840,"wires":[["363953ea.936d8c"]]},{"id":"363953ea.936d8c","type":"function","z":"b872cb4b.5a6448","name":"fake udp msg","func":"return { \n    \"payload\": Buffer.from([83, 77, 65, 0, 0, 4, 2, 160, 0, 0, 0, 1, 2, 76, 0, 16, 96, 105, 1, 116, 113, 89, 181, 228, 88, 186, 142, 41, 0, 1, 4, 0, 0, 0, 0, 74, 0, 1, 8, 0, 0, 0, 0, 6, 140, 178, 168, 168, 0, 2, 4, 0, 0, 0, 0, 0, 0, 2, 8, 0, 0, 0, 0, 7, 253, 178, 78, 24, 0, 3, 4, 0, 0, 0, 0, 0, 0, 3, 8, 0, 0, 0, 0, 0, 16, 235, 94, 240, 0, 4, 4, 0, 0, 0, 22, 30, 0, 4, 8, 0, 0, 0, 0, 12, 168, 135, 222, 48, 0, 9, 4, 0, 0, 0, 22, 30, 0, 9, 8, 0, 0, 0, 0, 12, 28, 154, 227, 224, 0, 10, 4, 0, 0, 0, 0, 0, 0, 10, 8, 0, 0, 0, 0, 9, 97, 63, 42, 104, 0, 13, 4, 0, 0, 0, 0, 13, 0, 14, 4, 0, 0, 0, 195, 82, 0, 21, 4, 0, 0, 0, 0, 0, 0, 21, 8, 0, 0, 0, 0, 3, 125, 229, 248, 40, 0, 22, 4, 0, 0, 0, 5, 89, 0, 22, 8, 0, 0, 0, 0, 7, 95, 110, 238, 0, 0, 23, 4, 0, 0, 0, 0, 0, 0, 23, 8, 0, 0, 0, 0, 0, 25, 7, 4, 144, 0, 24, 4, 0, 0, 0, 10, 18, 0, 24, 8, 0, 0, 0, 0, 4, 201, 201, 10, 64, 0, 29, 4, 0, 0, 0, 0, 0, 0, 29, 8, 0, 0, 0, 0, 5, 52, 51, 139, 248, 0, 30, 4, 0, 0, 0, 11, 103, 0, 30, 8, 0, 0, 0, 0, 7, 216, 157, 153, 232, 0, 31, 4, 0, 0, 0, 6, 73, 0, 32, 4, 0, 0, 3, 136, 221, 0, 33, 4, 0, 0, 0, 1, 213, 0, 41, 4, 0, 0, 0, 6, 77, 0, 41, 8, 0, 0, 0, 0, 2, 143, 16, 39, 40, 0, 42, 4, 0, 0, 0, 0, 0, 0, 42, 8, 0, 0, 0, 0, 0, 212, 170, 232, 136, 0, 43, 4, 0, 0, 0, 0, 0, 0, 43, 8, 0, 0, 0, 0, 0, 11, 51, 114, 184, 0, 44, 4, 0, 0, 0, 5, 74, 0, 44, 8, 0, 0, 0, 0, 2, 21, 225, 52, 240, 0, 49, 4, 0, 0, 0, 8, 58, 0, 49, 8, 0, 0, 0, 0, 3, 115, 86, 47, 64, 0, 50, 4, 0, 0, 0, 0, 0, 0, 50, 8, 0, 0, 0, 0, 0, 229, 93, 153, 200, 0, 51, 4, 0, 0, 0, 4, 5, 0, 52, 4, 0, 0, 3, 139, 244, 0, 53, 4, 0, 0, 0, 2, 254, 0, 61, 4, 0, 0, 0, 0, 0, 0, 61, 8, 0, 0, 0, 0, 1, 193, 39, 152, 200, 0, 62, 4, 0, 0, 0, 0, 170, 0, 62, 8, 0, 0, 0, 0, 1, 11, 3, 142, 8, 0, 63, 4, 0, 0, 0, 0, 0]),\n    \"fromip\": \"192.168.168.23:58874\", \"ip\": \"192.168.168.23\", \"port\": 58874, \"_msgid\": \"b43d1ee5.26a5f\" \n    }\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":440,"y":840,"wires":[["77d070b3.56a4d"]]},{"id":"77d070b3.56a4d","type":"buffer-parser","z":"b872cb4b.5a6448","name":"","data":"payload","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"string","name":"sma","offset":0,"length":3,"offsetbit":0,"scale":"1","mask":""},{"type":"uint32be","name":"Tag=>Tag0","offset":4,"length":1,"offsetbit":0,"scale":">> 4","mask":"0xff0"},{"type":"uint32be","name":"Tag=>Version","offset":4,"length":1,"offsetbit":0,"scale":"0","mask":"0xf"},{"type":"uint32be","name":"Group","offset":8,"length":1,"offsetbit":0,"scale":"0","mask":""},{"type":"uint32be","name":"item10","offset":25,"length":1,"offsetbit":0,"scale":">> 4","mask":"0xFFF0"},{"type":"uint16be","name":"ProtocolID","offset":16,"length":1,"offsetbit":0,"scale":"0","mask":""},{"type":"uint32be","name":"meter_identifier=>SusyID","offset":18,"length":1,"offsetbit":0,"scale":">> 4","mask":"0xFFF0"},{"type":"uint32be","name":"meter_identifier=>SerNo","offset":21,"length":1,"offsetbit":0,"scale":">> 4","mask":"0xFFF0"},{"type":"buffer","name":"data","offset":28,"length":-1,"offsetbit":0,"scale":"1","mask":""}],"swap1":"","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload","msgPropertyType":"str","resultType":"keyvalue","resultTypeType":"output","multipleResult":false,"fanOutMultipleResult":false,"setTopic":true,"outputs":1,"x":630,"y":840,"wires":[["37ba08ed.6e5ca8"]]},{"id":"37ba08ed.6e5ca8","type":"buffer-parser","z":"b872cb4b.5a6448","name":"","data":"payload.data","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"int16be","name":"measurement","offset":0,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"uint8","name":"datatype","offset":2,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"buffer","name":"data","offset":0,"length":-1,"offsetbit":0,"scale":"1","mask":""}],"swap1":"","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload","msgPropertyType":"str","resultType":"keyvalue","resultTypeType":"output","multipleResult":false,"fanOutMultipleResult":false,"setTopic":true,"outputs":1,"x":290,"y":940,"wires":[["d4c97129.71892"]]},{"id":"d4c97129.71892","type":"switch","z":"b872cb4b.5a6448","name":"8-counter, 4-actual, 0-version, other","property":"payload.datatype","propertyType":"msg","rules":[{"t":"eq","v":"8","vt":"num"},{"t":"eq","v":"4","vt":"num"},{"t":"eq","v":"0","vt":"num"},{"t":"else"}],"checkall":"true","repair":false,"outputs":4,"x":540,"y":940,"wires":[["d9cf07f4.4a1338"],["f7179628.d22528"],["552bc3cc.e73e9c"],["552bc3cc.e73e9c"]]},{"id":"f7179628.d22528","type":"buffer-parser","z":"b872cb4b.5a6448","name":"","data":"payload.data","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"uint32be","name":"value","offset":4,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"buffer","name":"data","offset":8,"length":-1,"offsetbit":0,"scale":"1","mask":""}],"swap1":"","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload2","msgPropertyType":"str","resultType":"keyvalue","resultTypeType":"output","multipleResult":false,"fanOutMultipleResult":false,"setTopic":true,"outputs":1,"x":810,"y":960,"wires":[["6afaa888.d96168"]]},{"id":"d9cf07f4.4a1338","type":"buffer-parser","z":"b872cb4b.5a6448","name":"","data":"payload.data","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"biguint64be","name":"value","offset":4,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"buffer","name":"data","offset":12,"length":-1,"offsetbit":0,"scale":"1","mask":""}],"swap1":"","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload2","msgPropertyType":"str","resultType":"keyvalue","resultTypeType":"output","multipleResult":false,"fanOutMultipleResult":false,"setTopic":true,"outputs":1,"x":810,"y":920,"wires":[["6afaa888.d96168"]]},{"id":"6afaa888.d96168","type":"function","z":"b872cb4b.5a6448","name":"more data available?","func":"var sma_units = {\n    \"W\": 10,\n    \"VA\": 10,\n    \"VAr\": 10,\n    \"kWh\": 3600000,\n    \"kVAh\": 3600000,\n    \"kVArh\": 3600000,\n    \"A\": 1000,\n    \"V\": 1000,\n    \"°\": 1000,\n    \"Hz\": 1000,\n};\nvar sma_channels = {\n    //# totals\n    1: ['pconsume', 'W', 'kWh'],\n    2: ['psupply', 'W', 'kWh'],\n    3: ['qconsume', 'VAr', 'kVArh'],\n    4: ['qsupply', 'VAr', 'kVArh'],\n    9: ['sconsume', 'VA', 'kVAh'],\n    10: ['ssupply', 'VA', 'kVAh'],\n    13: ['cosphi', '°'],\n    14: ['frequency', 'Hz'],\n    //# phase 1\n    21: ['p1consume', 'W', 'kWh'],\n    22: ['p1supply', 'W', 'kWh'],\n    23: ['q1consume', 'VAr', 'kVArh'],\n    24: ['q1supply', 'VAr', 'kVArh'],\n    29: ['s1consume', 'VA', 'kVAh'],\n    30: ['s1supply', 'VA', 'kVAh'],\n    31: ['i1', 'A'],\n    32: ['u1', 'V'],\n    33: ['cosphi1', '°'],\n    //# phase 2\n    41: ['p2consume', 'W', 'kWh'],\n    42: ['p2supply', 'W', 'kWh'],\n    43: ['q2consume', 'VAr', 'kVArh'],\n    44: ['q2supply', 'VAr', 'kVArh'],\n    49: ['s2consume', 'VA', 'kVAh'],\n    50: ['s2supply', 'VA', 'kVAh'],\n    51: ['i2', 'A'],\n    52: ['u2', 'V'],\n    53: ['cosphi2', '°'],\n    //# phase 3\n    61: ['p3consume', 'W', 'kWh'],\n    62: ['p3supply', 'W', 'kWh'],\n    63: ['q3consume', 'VAr', 'kVArh'],\n    64: ['q3supply', 'VAr', 'kVArh'],\n    69: ['s3consume', 'VA', 'kVAh'],\n    70: ['s3supply', 'VA', 'kVAh'],\n    71: ['i3', 'A'],\n    72: ['u3', 'V'],\n    73: ['cosphi3', '°'],\n    //# common\n    36864: ['speedwire-version', ''],\n};\n\nmsg.result = msg.result || {};\n\nfunction decode_item_header(datatype, measurement) {\n    if (datatype == 4)\n        return 'actual'\n    else if (datatype == 8)\n        return 'counter';\n    else if (datatype == 0 && measurement == 36864)\n        return 'version'\n    else\n        return 'unknown_' + measurement;\n}\n\n// @ts-ignore\nvar pl2 = msg.payload2;\nvar pl = msg.payload;\n\nvar measurement = pl.measurement;\nvar datatype = pl.datatype;\nvar ch = sma_channels[measurement] || [];\nvar valuename = ch[0], unit = ch[1];\n\nvar hasValue = pl2.hasOwnProperty('value');\nif (valuename && hasValue) {\n    var value = pl2.value;\n    var typeName = decode_item_header(datatype, measurement);\n    //msg.result[valuename] = msg.result[valuename] || {};\n    //msg.result[valuename][typeName] = {};\n    //msg.result[valuename][typeName].unit = unit;\n    var t = typeof value;\n    if (t===\"number\") {\n        msg.result[valuename + \"_\" + typeName] = value / (sma_units[unit] || 1)\n    } else if (t === \"bigint\") {\n        msg.result[valuename + \"_\" + typeName] = value / BigInt(sma_units[unit] || 1)\n    } else {\n        msg.result[valuename + \"_\" + typeName] = value / BigInt(sma_units[unit] || 1)\n    }\n}\n\n\n/** @type {Buffer} */ var buf = pl2.data;\nif (buf && buf.length >= 8) {\n    msg.payload = {\n        data: pl2.data\n    };\n    return [msg,null];\n}\nmsg.payload = msg.result;\nreturn [null, msg];\n","outputs":2,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1040,"y":960,"wires":[["561b29e6.13e888"],["f11f82ad.11629"]]},{"id":"552bc3cc.e73e9c","type":"buffer-parser","z":"b872cb4b.5a6448","name":"","data":"payload.data","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"buffer","name":"data","offset":8,"length":-1,"offsetbit":0,"scale":"1","mask":""}],"swap1":"","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload2","msgPropertyType":"str","resultType":"keyvalue","resultTypeType":"output","multipleResult":false,"fanOutMultipleResult":false,"setTopic":true,"outputs":1,"x":810,"y":1000,"wires":[["6afaa888.d96168"]]},{"id":"f185b99c.b81488","type":"link in","z":"b872cb4b.5a6448","name":"","links":["561b29e6.13e888"],"x":155,"y":940,"wires":[["37ba08ed.6e5ca8"]]},{"id":"561b29e6.13e888","type":"link out","z":"b872cb4b.5a6448","name":"","links":["f185b99c.b81488"],"x":1195,"y":960,"wires":[]},{"id":"f11f82ad.11629","type":"debug","z":"b872cb4b.5a6448","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1110,"y":1020,"wires":[]}]

Another Example...

[{"id":"9763dc2c.40756","type":"inject","z":"b872cb4b.5a6448","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":300,"y":580,"wires":[["97dec846.ffc208"]]},{"id":"97dec846.ffc208","type":"function","z":"b872cb4b.5a6448","name":"fake udp msg","func":"return { \n    \"payload\": Buffer.from([83, 77, 65, 0, 0, 4, 2, 160, 0, 0, 0, 1, 2, 76, 0, 16, 96, 105, 1, 116, 113, 89, 181, 228, 88, 186, 142, 41, 0, 1, 4, 0, 0, 0, 0, 74, 0, 1, 8, 0, 0, 0, 0, 6, 140, 178, 168, 168, 0, 2, 4, 0, 0, 0, 0, 0, 0, 2, 8, 0, 0, 0, 0, 7, 253, 178, 78, 24, 0, 3, 4, 0, 0, 0, 0, 0, 0, 3, 8, 0, 0, 0, 0, 0, 16, 235, 94, 240, 0, 4, 4, 0, 0, 0, 22, 30, 0, 4, 8, 0, 0, 0, 0, 12, 168, 135, 222, 48, 0, 9, 4, 0, 0, 0, 22, 30, 0, 9, 8, 0, 0, 0, 0, 12, 28, 154, 227, 224, 0, 10, 4, 0, 0, 0, 0, 0, 0, 10, 8, 0, 0, 0, 0, 9, 97, 63, 42, 104, 0, 13, 4, 0, 0, 0, 0, 13, 0, 14, 4, 0, 0, 0, 195, 82, 0, 21, 4, 0, 0, 0, 0, 0, 0, 21, 8, 0, 0, 0, 0, 3, 125, 229, 248, 40, 0, 22, 4, 0, 0, 0, 5, 89, 0, 22, 8, 0, 0, 0, 0, 7, 95, 110, 238, 0, 0, 23, 4, 0, 0, 0, 0, 0, 0, 23, 8, 0, 0, 0, 0, 0, 25, 7, 4, 144, 0, 24, 4, 0, 0, 0, 10, 18, 0, 24, 8, 0, 0, 0, 0, 4, 201, 201, 10, 64, 0, 29, 4, 0, 0, 0, 0, 0, 0, 29, 8, 0, 0, 0, 0, 5, 52, 51, 139, 248, 0, 30, 4, 0, 0, 0, 11, 103, 0, 30, 8, 0, 0, 0, 0, 7, 216, 157, 153, 232, 0, 31, 4, 0, 0, 0, 6, 73, 0, 32, 4, 0, 0, 3, 136, 221, 0, 33, 4, 0, 0, 0, 1, 213, 0, 41, 4, 0, 0, 0, 6, 77, 0, 41, 8, 0, 0, 0, 0, 2, 143, 16, 39, 40, 0, 42, 4, 0, 0, 0, 0, 0, 0, 42, 8, 0, 0, 0, 0, 0, 212, 170, 232, 136, 0, 43, 4, 0, 0, 0, 0, 0, 0, 43, 8, 0, 0, 0, 0, 0, 11, 51, 114, 184, 0, 44, 4, 0, 0, 0, 5, 74, 0, 44, 8, 0, 0, 0, 0, 2, 21, 225, 52, 240, 0, 49, 4, 0, 0, 0, 8, 58, 0, 49, 8, 0, 0, 0, 0, 3, 115, 86, 47, 64, 0, 50, 4, 0, 0, 0, 0, 0, 0, 50, 8, 0, 0, 0, 0, 0, 229, 93, 153, 200, 0, 51, 4, 0, 0, 0, 4, 5, 0, 52, 4, 0, 0, 3, 139, 244, 0, 53, 4, 0, 0, 0, 2, 254, 0, 61, 4, 0, 0, 0, 0, 0, 0, 61, 8, 0, 0, 0, 0, 1, 193, 39, 152, 200, 0, 62, 4, 0, 0, 0, 0, 170, 0, 62, 8, 0, 0, 0, 0, 1, 11, 3, 142, 8, 0, 63, 4, 0, 0, 0, 0, 0]),\n    \"fromip\": \"192.168.168.23:58874\", \"ip\": \"192.168.168.23\", \"port\": 58874, \"_msgid\": \"b43d1ee5.26a5f\" \n    }\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":460,"y":580,"wires":[["d31802c3.e2aef"]]},{"id":"d31802c3.e2aef","type":"buffer-parser","z":"b872cb4b.5a6448","name":"","data":"payload","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"string","name":"sma","offset":0,"length":3,"offsetbit":0,"scale":"1","mask":""},{"type":"uint32be","name":"Tag=>Tag0","offset":4,"length":1,"offsetbit":0,"scale":">> 4","mask":"0xff0"},{"type":"uint32be","name":"Tag=>Version","offset":4,"length":1,"offsetbit":0,"scale":"0","mask":"0xf"},{"type":"uint32be","name":"Group","offset":8,"length":1,"offsetbit":0,"scale":"0","mask":""},{"type":"uint32be","name":"item10","offset":25,"length":1,"offsetbit":0,"scale":">> 4","mask":"0xFFF0"},{"type":"uint16be","name":"ProtocolID","offset":16,"length":1,"offsetbit":0,"scale":"0","mask":""},{"type":"uint32be","name":"meter_identifier=>SusyID","offset":18,"length":1,"offsetbit":0,"scale":">> 4","mask":"0xFFF0"},{"type":"uint32be","name":"meter_identifier=>SerNo","offset":21,"length":1,"offsetbit":0,"scale":">> 4","mask":"0xFFF0"},{"type":"buffer","name":"data","offset":28,"length":-1,"offsetbit":0,"scale":"1","mask":""}],"swap1":"","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload","msgPropertyType":"str","resultType":"keyvalue","resultTypeType":"output","multipleResult":false,"fanOutMultipleResult":false,"setTopic":true,"outputs":1,"x":650,"y":580,"wires":[["6c5f3651.e1e838"]]},{"id":"6c5f3651.e1e838","type":"buffer-parser","z":"b872cb4b.5a6448","name":"","data":"payload.data","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"int16be","name":"measurement","offset":0,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"uint8","name":"datatype","offset":2,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"buffer","name":"data","offset":0,"length":-1,"offsetbit":0,"scale":"1","mask":""}],"swap1":"","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload","msgPropertyType":"str","resultType":"keyvalue","resultTypeType":"output","multipleResult":false,"fanOutMultipleResult":false,"setTopic":true,"outputs":1,"x":310,"y":680,"wires":[["35f7b433.19293c"]]},{"id":"35f7b433.19293c","type":"switch","z":"b872cb4b.5a6448","name":"8-counter, 4-actual, 0-version, other","property":"payload.datatype","propertyType":"msg","rules":[{"t":"eq","v":"8","vt":"num"},{"t":"eq","v":"4","vt":"num"},{"t":"eq","v":"0","vt":"num"},{"t":"else"}],"checkall":"true","repair":false,"outputs":4,"x":560,"y":680,"wires":[["99493b53.093878"],["701afb7c.a29b14"],["2518624f.84d29e"],["2518624f.84d29e"]]},{"id":"701afb7c.a29b14","type":"buffer-parser","z":"b872cb4b.5a6448","name":"","data":"payload.data","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"uint32be","name":"value","offset":4,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"buffer","name":"data","offset":8,"length":-1,"offsetbit":0,"scale":"1","mask":""}],"swap1":"","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload2","msgPropertyType":"str","resultType":"keyvalue","resultTypeType":"output","multipleResult":false,"fanOutMultipleResult":false,"setTopic":true,"outputs":1,"x":830,"y":700,"wires":[["fa42d9d5.faa708"]]},{"id":"99493b53.093878","type":"buffer-parser","z":"b872cb4b.5a6448","name":"","data":"payload.data","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"biguint64be","name":"value","offset":4,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"buffer","name":"data","offset":12,"length":-1,"offsetbit":0,"scale":"1","mask":""}],"swap1":"","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload2","msgPropertyType":"str","resultType":"keyvalue","resultTypeType":"output","multipleResult":false,"fanOutMultipleResult":false,"setTopic":true,"outputs":1,"x":830,"y":660,"wires":[["fa42d9d5.faa708"]]},{"id":"fa42d9d5.faa708","type":"function","z":"b872cb4b.5a6448","name":"more data available?","func":"var sma_units = {\n    \"W\": 10,\n    \"VA\": 10,\n    \"VAr\": 10,\n    \"kWh\": 3600000,\n    \"kVAh\": 3600000,\n    \"kVArh\": 3600000,\n    \"A\": 1000,\n    \"V\": 1000,\n    \"°\": 1000,\n    \"Hz\": 1000,\n};\nvar sma_channels = {\n    //# totals\n    1: ['pconsume', 'W', 'kWh'],\n    2: ['psupply', 'W', 'kWh'],\n    3: ['qconsume', 'VAr', 'kVArh'],\n    4: ['qsupply', 'VAr', 'kVArh'],\n    9: ['sconsume', 'VA', 'kVAh'],\n    10: ['ssupply', 'VA', 'kVAh'],\n    13: ['cosphi', '°'],\n    14: ['frequency', 'Hz'],\n    //# phase 1\n    21: ['p1consume', 'W', 'kWh'],\n    22: ['p1supply', 'W', 'kWh'],\n    23: ['q1consume', 'VAr', 'kVArh'],\n    24: ['q1supply', 'VAr', 'kVArh'],\n    29: ['s1consume', 'VA', 'kVAh'],\n    30: ['s1supply', 'VA', 'kVAh'],\n    31: ['i1', 'A'],\n    32: ['u1', 'V'],\n    33: ['cosphi1', '°'],\n    //# phase 2\n    41: ['p2consume', 'W', 'kWh'],\n    42: ['p2supply', 'W', 'kWh'],\n    43: ['q2consume', 'VAr', 'kVArh'],\n    44: ['q2supply', 'VAr', 'kVArh'],\n    49: ['s2consume', 'VA', 'kVAh'],\n    50: ['s2supply', 'VA', 'kVAh'],\n    51: ['i2', 'A'],\n    52: ['u2', 'V'],\n    53: ['cosphi2', '°'],\n    //# phase 3\n    61: ['p3consume', 'W', 'kWh'],\n    62: ['p3supply', 'W', 'kWh'],\n    63: ['q3consume', 'VAr', 'kVArh'],\n    64: ['q3supply', 'VAr', 'kVArh'],\n    69: ['s3consume', 'VA', 'kVAh'],\n    70: ['s3supply', 'VA', 'kVAh'],\n    71: ['i3', 'A'],\n    72: ['u3', 'V'],\n    73: ['cosphi3', '°'],\n    //# common\n    36864: ['speedwire-version', ''],\n};\n\nmsg.result = msg.result || {};\n\nfunction decode_item_header(datatype, measurement) {\n    if (datatype == 4)\n        return 'actual'\n    else if (datatype == 8)\n        return 'counter';\n    else if (datatype == 0 && measurement == 36864)\n        return 'version'\n    else\n        return 'unknown_' + measurement;\n}\n\n// @ts-ignore\nvar pl2 = msg.payload2;\nvar pl = msg.payload;\n\nvar measurement = pl.measurement;\nvar datatype = pl.datatype;\nvar ch = sma_channels[measurement] || [];\nvar valuename = ch[0], unit = ch[1];\n\nvar hasValue = pl2.hasOwnProperty('value');\nif (valuename && hasValue) {\n    var value = pl2.value;\n    var typeName = decode_item_header(datatype, measurement);\n    msg.result[valuename] = msg.result[valuename] || {};\n    msg.result[valuename][typeName] = {};\n    //msg.result[valuename][typeName].unit = unit;\n    var t = typeof value;\n    if (t===\"number\") {\n        msg.result[valuename][typeName] = value / (sma_units[unit] || 1)\n    } else if (t === \"bigint\") {\n        msg.result[valuename][typeName] = value / BigInt(sma_units[unit] || 1)\n    } else {\n        msg.result[valuename][typeName] = value / BigInt(sma_units[unit] || 1)\n    }\n}\n\n\n/** @type {Buffer} */ var buf = pl2.data;\nif (buf && buf.length >= 8) {\n    msg.payload = {\n        data: pl2.data\n    };\n    return [msg,null];\n}\nmsg.payload = msg.result;\nreturn [null, msg];\n","outputs":2,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1060,"y":700,"wires":[["4924e0b.c55cc2"],["214e43d8.b9817c"]]},{"id":"2518624f.84d29e","type":"buffer-parser","z":"b872cb4b.5a6448","name":"","data":"payload.data","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"buffer","name":"data","offset":8,"length":-1,"offsetbit":0,"scale":"1","mask":""}],"swap1":"","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload2","msgPropertyType":"str","resultType":"keyvalue","resultTypeType":"output","multipleResult":false,"fanOutMultipleResult":false,"setTopic":true,"outputs":1,"x":830,"y":740,"wires":[["fa42d9d5.faa708"]]},{"id":"197fcf94.b189b","type":"link in","z":"b872cb4b.5a6448","name":"","links":["4924e0b.c55cc2"],"x":175,"y":680,"wires":[["6c5f3651.e1e838"]]},{"id":"4924e0b.c55cc2","type":"link out","z":"b872cb4b.5a6448","name":"","links":["197fcf94.b189b"],"x":1215,"y":700,"wires":[]},{"id":"214e43d8.b9817c","type":"debug","z":"b872cb4b.5a6448","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1130,"y":760,"wires":[]}]

happy birthday by the way. :partying_face:

I´ve translated it for me in german, sorry:

the counters are not correct, the have to be devides :360.000
I think they should be devided : 3 600 000 in the function ? but they do not

P Verbrauch Zähler: 2813049756 --> 7.814,02kWh is right.

the actually values are correct :+1:

the 36864: ['speedwire-version', ''], is missing in debug

Like I said, it's not a complete solution. There are some bits for you to do.

Thank you.

yeah I want !

    var t = typeof value;
    if (t==="number") {
        msg.result[valuename + " " + typeName] = value / (sma_units[unit] || 1)
    } else if (t === "bigint") {
        msg.result[valuename + " " + typeName] = value / BigInt(sma_units[unit] || 1)
    } else {
        msg.result[valuename + " " + typeName] = value / BigInt(sma_units[unit] || 1)

I think this part is responsible for dividing the counter value by 3600000 - but it does´t, only for the actually values.
Because a BigInt can´t be divided ? I need some help here.


the next question is: I want to show the values in the dashboard, but it don´t like BigInt.

How can I convert all actually values to "number" in a 2nd function ?
Like this:
msg.payload = Number(msg.payload["P Verbrauch momentan"]);
return msg;

Yes it can...
image

BitInt is not widely supported. To avoid loss of precision, wrap the whole equation with Number(equation) e.g...

    var t = typeof value;
    if (t==="number") {
        msg.result[valuename + "_" + typeName] = value / (sma_units[unit] || 1)
    } else if (t === "bigint") {
        msg.result[valuename + "_" + typeName] = Number(value / BigInt(sma_units[unit] || 1));
    } else {
        msg.result[valuename + "_" + typeName] = value 
    }

PS, I recommend you avoid spaces in object property names (just makes things difficult).

Are the counters supposed to be divided by 3600000?

If so, then you need to split that calc out. e.g...

    var t = typeof value;
    if(typeName == "counter") {
        if (t==="number") {
            msg.result[valuename + "_" + typeName] = value / 3600000; 
        } else if (t === "bigint") {
            msg.result[valuename + "_" + typeName] = Number(value / 3600000n);
        } else {
            msg.result[valuename + "_" + typeName] = value; 
        }
    } else {
        if (t==="number") {
            msg.result[valuename + "_" + typeName] = value / (sma_units[unit] || 1);
        } else if (t === "bigint") {
            msg.result[valuename + "_" + typeName] = Number(value / BigInt(sma_units[unit] || 1));
        } else {
            msg.result[valuename + "_" + typeName] = value ;
        }
    }

number is running :+1:


I think we're talking past each other with the counter values:
I can type in whatever I want here (yellow), the counter output values always remain the same.

grafik

there must be a fault inside the function, so that the factor is being ignored.


is it possible to delete the unnecessary part with 0-version & other ?


I also would like to unterstand the loop and all the buffers with strange things like length -1:


I don't even begin to see what this is all about. :woozy_face: :fearful:

maybe after your birthday you have some time & pleasure for explanation :nerd_face:

What are the counter values supposed to be?

Are they supposed to be divided by the same unit divisor? or divided by 3600000? Like I said, that manual was terrible.

They are reading and converting the bytes from the data buffer into usable values.

The -1 means read to the end of the buffer.
the loop is designed to reduce the buffer by the size of each found record (otherwise it would loop forever)

Did you try the modified function?

    var t = typeof value;
    if(typeName == "counter") {
        if (t==="number") {
            msg.result[valuename + "_" + typeName] = value / 3600000; 
        } else if (t === "bigint") {
            msg.result[valuename + "_" + typeName] = Number(value / 3600000n);
        } else {
            msg.result[valuename + "_" + typeName] = value; 
        }
    } else {
        if (t==="number") {
            msg.result[valuename + "_" + typeName] = value / (sma_units[unit] || 1);
        } else if (t === "bigint") {
            msg.result[valuename + "_" + typeName] = Number(value / BigInt(sma_units[unit] || 1));
        } else {
            msg.result[valuename + "_" + typeName] = value ;
        }
    }

↑ that would replace ↓

they should be divided by the number shown here, just like the actually values:
grafik

If I change "W" or "VA" or "A" or "V" or "Hz" to 50 or 25, the output is wrong, as the way it should be...

If I change "kWh" to 1 or 360000 - it is always the same output.

/360000 is right.

yes, but there comes an error with BigInt at line

Number(value / 3600000n);

That is not an error. The ace editor is just not "up to speed" - ignore it.


I missed a slight difference when translating the python code.

this is the updated function code (with english descriptions - you will have to replace those)...

var sma_units = {
    "W": 10,
    "VA": 10,
    "VAr": 10,
    "kWh": 3600000,
    "kVAh": 3600000,
    "kVArh": 3600000,
    "A": 1000,
    "V": 1000,
    "°": 1000,
    "Hz": 1000,
};
var sma_channels = {
    //# totals
    1: ['pconsume', 'W', 'kWh'],
    2: ['psupply', 'W', 'kWh'],
    3: ['qconsume', 'VAr', 'kVArh'],
    4: ['qsupply', 'VAr', 'kVArh'],
    9: ['sconsume', 'VA', 'kVAh'],
    10: ['ssupply', 'VA', 'kVAh'],
    13: ['cosphi', '°'],
    14: ['frequency', 'Hz'],
    //# phase 1
    21: ['p1consume', 'W', 'kWh'],
    22: ['p1supply', 'W', 'kWh'],
    23: ['q1consume', 'VAr', 'kVArh'],
    24: ['q1supply', 'VAr', 'kVArh'],
    29: ['s1consume', 'VA', 'kVAh'],
    30: ['s1supply', 'VA', 'kVAh'],
    31: ['i1', 'A'],
    32: ['u1', 'V'],
    33: ['cosphi1', '°'],
    //# phase 2
    41: ['p2consume', 'W', 'kWh'],
    42: ['p2supply', 'W', 'kWh'],
    43: ['q2consume', 'VAr', 'kVArh'],
    44: ['q2supply', 'VAr', 'kVArh'],
    49: ['s2consume', 'VA', 'kVAh'],
    50: ['s2supply', 'VA', 'kVAh'],
    51: ['i2', 'A'],
    52: ['u2', 'V'],
    53: ['cosphi2', '°'],
    //# phase 3
    61: ['p3consume', 'W', 'kWh'],
    62: ['p3supply', 'W', 'kWh'],
    63: ['q3consume', 'VAr', 'kVArh'],
    64: ['q3supply', 'VAr', 'kVArh'],
    69: ['s3consume', 'VA', 'kVAh'],
    70: ['s3supply', 'VA', 'kVAh'],
    71: ['i3', 'A'],
    72: ['u3', 'V'],
    73: ['cosphi3', '°'],
    //# common
    36864: ['speedwire-version', ''],
};

msg.result = msg.result || {};

function decode_item_header(datatype, measurement) {
    if (datatype == 4)
        return 'actual'
    else if (datatype == 8)
        return 'counter';
    else if (datatype == 0 && measurement == 36864)
        return 'version'
    else
        return 'unknown_' + measurement;
}

// @ts-ignore
var pl2 = msg.payload2;
var pl = msg.payload;

var measurement = pl.measurement;
var datatype = pl.datatype;
var ch = sma_channels[measurement] || [];
var valuename = ch[0], unit = ch[1], unitForCounter = ch[2];

var hasValue = pl2.hasOwnProperty('value');
if (valuename && hasValue) {
    var value = pl2.value;
    var typeName = decode_item_header(datatype, measurement);
    var t = typeof value;
    var divisor = 1;
    if (typeName == "counter" && unitForCounter ) {
        divisor = sma_units[unitForCounter] || 1;
        msg.result[valuename + "_" + typeName + "_unit"] = unitForCounter;
    } else {
        divisor = sma_units[unit] || 1;
        msg.result[valuename + "_" + typeName + "_unit"] = unit;
    }
    
    if (t === "number") {
        msg.result[valuename + "_" + typeName] = value / divisor;
    } else if (t === "bigint") {
        msg.result[valuename + "_" + typeName] = Number(value / BigInt(divisor));
    } else {
        msg.result[valuename + "_" + typeName] = value;
    }
}


/** @type {Buffer} */ var buf = pl2.data;
if (buf && buf.length >= 8) {
    msg.payload = {
        data: pl2.data
    };
    return [msg,null];
}
msg.payload = msg.result;
return [null, msg];

This is the output - does it look better?

1 Like

yeah you did it :+1: :grinning:

this is my "german" function:

var sma_units = {
    "W": 10,
    "VA": 10,
    "var": 10,
    "kWh": 3600000,
    "kVAh": 3600000,
    "kvarh": 3600000,
    "A": 1000,
    "V": 1000,
    "-": 1000,
    "Hz": 1000,
};
var sma_channels = {
    //# gesamt
    1: ['P Bezug', 'W', 'kWh'],
    2: ['P Einspeisung', 'W', 'kWh'],
    3: ['Q induktiv', 'var', 'kvarh'],
    4: ['Q kapazitiv', 'var', 'kvarh'],
    9: ['S Bezug', 'VA', 'kVAh'],
    10: ['S Einspeisung', 'VA', 'kVAh'],
    13: ['cosphi', '-'],
    14: ['Frequenz', 'Hz'],
    //# L1
    21: ['P1 Bezug', 'W', 'kWh'],
    22: ['P1 Einspeisung', 'W', 'kWh'],
    23: ['Q1 ind.', 'var', 'kvarh'],
    24: ['Q1 kap.', 'var', 'kvarh'],
    29: ['S1 Bezug', 'VA', 'kVAh'],
    30: ['S1 Einspeisung', 'VA', 'kVAh'],
    31: ['I L1', 'A'],
    32: ['U L1', 'V'],
    33: ['cosphi L1', '-'],
    //# L2
    41: ['P2 Bezug', 'W', 'kWh'],
    42: ['P2 Einspeisung', 'W', 'kWh'],
    43: ['Q2 ind.', 'var', 'kvarh'],
    44: ['Q2 kap.', 'var', 'kvarh'],
    49: ['S2 Bezug', 'VA', 'kVAh'],
    50: ['S2 Einspeisung', 'VA', 'kVAh'],
    51: ['I L2', 'A'],
    52: ['U L2', 'V'],
    53: ['cosphi L2', '-'],
    //# L3
    61: ['P3 Bezug', 'W', 'kWh'],
    62: ['P3 Einspeisung', 'W', 'kWh'],
    63: ['Q3 ind.', 'var', 'kvarh'],
    64: ['Q3 kap.', 'var', 'kvarh'],
    69: ['S3 Bezug', 'VA', 'kVAh'],
    70: ['S3 Einspeisung', 'VA', 'kVAh'],
    71: ['I L3', 'A'],
    72: ['U L3', 'V'],
    73: ['cosphi L3', '-'],
};

msg.result = msg.result || {};

function decode_item_header(datatype, measurement) {
    if (datatype == 4)
        return 'momentan'
    else if (datatype == 8)
        return 'Zähler';
}


var pl2 = msg.payload2;
var pl = msg.payload;

var measurement = pl.measurement;
var datatype = pl.datatype;
var ch = sma_channels[measurement] || [];
var valuename = ch[0], unit = ch[1]; unitForCounter = ch[2];

var hasValue = pl2.hasOwnProperty('value');
if (valuename && hasValue) {
    var value = pl2.value;
    var typeName = decode_item_header(datatype, measurement);
    var t = typeof value;
    var divisor = 1;
    if (typeName == "Zähler" && unitForCounter ) {
        divisor = sma_units[unitForCounter] || 1;
        msg.result[valuename + " " + typeName + "_unit"] = unitForCounter;
    } else {
        divisor = sma_units[unit] || 1;
        msg.result[valuename + " " + typeName + "_unit"] = unit;
    }
    
    if (t === "number") {
        msg.result[valuename + "_" + typeName] = value / divisor;
    } else if (t === "bigint") {
        msg.result[valuename + "_" + typeName] = Number(value / BigInt(divisor));
    } else {
        msg.result[valuename + "_" + typeName] = value;
    }
}


/** @type {Buffer} */ var buf = pl2.data;
if (buf && buf.length >= 8) {
    msg.payload = {
        data: pl2.data
    };
    return [msg,null];
}
msg.payload = msg.result;
return [null, msg];

how can I disable the output of the units ?

...I conjured up another version, not as fancy as the one from @Steve-Mcl ...still not complete, only splitting the parts into different messages for now.

[{"id":"51f68a48.7e6574","type":"tab","label":"SMA Decode","disabled":false,"info":""},{"id":"b62d475a.7bcb58","type":"inject","z":"51f68a48.7e6574","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":120,"y":60,"wires":[["7d873b83.e74644"]]},{"id":"7d873b83.e74644","type":"function","z":"51f68a48.7e6574","name":"fake udp msg","func":"return { \n    \"payload\": Buffer.from([83,77,65,0,0,4,2,160,0,0,0,1,2,76,0,16,96,105,1,116,113,89,181,228,88,187,136,25,0,1,4,0,0,0,0,0,0,1,8,0,0,0,0,6,140,178,168,168,0,2,4,0,0,0,0,92,0,2,8,0,0,0,0,7,253,178,79,128,0,3,4,0,0,0,0,0,0,3,8,0,0,0,0,0,16,235,94,240,0,4,4,0,0,0,22,5,0,4,8,0,0,0,0,12,168,136,108,56,0,9,4,0,0,0,0,0,0,9,8,0,0,0,0,12,28,155,35,40,0,10,4,0,0,0,22,5,0,10,8,0,0,0,0,9,97,63,121,40,0,13,4,0,0,0,0,16,0,14,4,0,0,0,195,86,0,21,4,0,0,0,0,0,0,21,8,0,0,0,0,3,125,229,248,40,0,22,4,0,0,0,5,230,0,22,8,0,0,0,0,7,95,111,18,144,0,23,4,0,0,0,0,0,0,23,8,0,0,0,0,0,25,7,4,144,0,24,4,0,0,0,10,13,0,24,8,0,0,0,0,4,201,201,74,240,0,29,4,0,0,0,0,0,0,29,8,0,0,0,0,5,52,51,139,248,0,30,4,0,0,0,11,167,0,30,8,0,0,0,0,7,216,157,227,8,0,31,4,0,0,0,6,105,0,32,4,0,0,3,135,98,0,33,4,0,0,0,1,250,0,41,4,0,0,0,6,64,0,41,8,0,0,0,0,2,143,16,79,240,0,42,4,0,0,0,0,0,0,42,8,0,0,0,0,0,212,170,232,136,0,43,4,0,0,0,0,0,0,43,8,0,0,0,0,0,11,51,114,184,0,44,4,0,0,0,5,70,0,44,8,0,0,0,0,2,21,225,86,176,0,49,4,0,0,0,8,46,0,49,8,0,0,0,0,3,115,86,100,176,0,50,4,0,0,0,0,0,0,50,8,0,0,0,0,0,229,93,153,200,0,51,4,0,0,0,4,5,0,52,4,0,0,3,139,30,0,53,4,0,0,0,2,252,0,61,4,0,0,0,0,0,0,61,8,0,0,0,0,1,193,39,152,200,0,62,4,0,0,0,0,182,0,62,8,0,0,0,0,1,11,3,147,168,0,63,4,0,0,0,0,0,0,63,8,0,0,0,0,0,11,43,32,64,0,64,4,0,0,0,6,177,0,64,8,0,0,0,0,5,231,88,0,96,0,69,4,0,0,0,0,0,0,69,8,0,0,0,0,6,18,102,145,104,0,70,4,0,0,0,6,187,0,70,8,0,0,0,0,1,52,69,76,192,0,71,4,0,0,0,3,201,0,72,4,0,0,3,132,175,0,73,4,0,0,0,0,106,144,0,0,0,2,6,6,82,0,0,0,0]),\n    \"fromip\": \"192.168.168.23:58874\", \"ip\": \"192.168.168.23\", \"port\": 58874, \"_msgid\": \"b43d1ee5.26a5f\" \n    }","outputs":1,"noerr":0,"initialize":"","finalize":"","x":320,"y":60,"wires":[["e96481ab.71bcc"]]},{"id":"d5e9a03c.b188b","type":"buffer-parser","z":"51f68a48.7e6574","name":"OBIS-Codes","data":"payload.rest","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"byte","name":"OBIS-B","offset":0,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"byte","name":"OBIS-C","offset":1,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"byte","name":"OBIS-D","offset":2,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"byte","name":"OBIS-E","offset":3,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"buffer","name":"rest","offset":4,"length":-1,"offsetbit":0,"scale":"1","mask":""}],"swap1":"","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload","msgPropertyType":"str","resultType":"keyvalue","resultTypeType":"output","multipleResult":false,"fanOutMultipleResult":false,"setTopic":true,"outputs":1,"x":290,"y":220,"wires":[["7129c8e7.e61be8"]]},{"id":"1dfc498c.4c83a6","type":"switch","z":"51f68a48.7e6574","name":"OBIS-D","property":"payload.OBIS-D","propertyType":"msg","rules":[{"t":"else"},{"t":"eq","v":"4","vt":"str"},{"t":"eq","v":"8","vt":"str"}],"checkall":"true","repair":false,"outputs":3,"x":460,"y":380,"wires":[["7cda1812.c38d78"],["21f425a5.5bf23a"],["3f524c46.e2e104"]]},{"id":"e0428357.2af8f","type":"debug","z":"51f68a48.7e6574","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":850,"y":320,"wires":[]},{"id":"78e9b1e8.5429b","type":"debug","z":"51f68a48.7e6574","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":863,"y":500,"wires":[]},{"id":"7cda1812.c38d78","type":"debug","z":"51f68a48.7e6574","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":630,"y":320,"wires":[]},{"id":"21f425a5.5bf23a","type":"buffer-parser","z":"51f68a48.7e6574","name":"Messwert 4","data":"payload.rest","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"uint32be","name":"messwert","offset":0,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"buffer","name":"rest","offset":4,"length":-1,"offsetbit":0,"scale":"1","mask":""}],"swap1":"","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload","msgPropertyType":"str","resultType":"keyvalue","resultTypeType":"output","multipleResult":false,"fanOutMultipleResult":false,"setTopic":true,"outputs":1,"x":690,"y":380,"wires":[["e0428357.2af8f","4e34675c.15f9e8"]]},{"id":"3f524c46.e2e104","type":"buffer-parser","z":"51f68a48.7e6574","name":"Zähler 8","data":"payload.rest","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"biguint64be","name":"zaehlerwert","offset":0,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"buffer","name":"rest","offset":8,"length":-1,"offsetbit":0,"scale":"1","mask":""}],"swap1":"","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload","msgPropertyType":"str","resultType":"keyvalue","resultTypeType":"output","multipleResult":false,"fanOutMultipleResult":false,"setTopic":true,"outputs":1,"x":688,"y":440,"wires":[["78e9b1e8.5429b","4e34675c.15f9e8"]]},{"id":"e96481ab.71bcc","type":"buffer-parser","z":"51f68a48.7e6574","name":"Header","data":"payload","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"buffer","name":"Kopf","offset":0,"length":28,"offsetbit":0,"scale":"1","mask":""},{"type":"buffer","name":"rest","offset":28,"length":-1,"offsetbit":0,"scale":"1","mask":""}],"swap1":"","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload","msgPropertyType":"str","resultType":"keyvalue","resultTypeType":"output","multipleResult":false,"fanOutMultipleResult":false,"setTopic":true,"outputs":1,"x":500,"y":60,"wires":[["f3665edf.5a785","d5e9a03c.b188b"]]},{"id":"f3665edf.5a785","type":"debug","z":"51f68a48.7e6574","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":690,"y":60,"wires":[]},{"id":"da62e3c1.a4d4d","type":"change","z":"51f68a48.7e6574","name":"setze OBIS-C","rules":[{"t":"move","p":"payload.OBIS-C","pt":"msg","to":"OBIS-C","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":260,"y":380,"wires":[["1dfc498c.4c83a6"]]},{"id":"4e34675c.15f9e8","type":"change","z":"51f68a48.7e6574","name":"lösche OBIS-C","rules":[{"t":"delete","p":"OBIS-C","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":893,"y":409,"wires":[["fe456fba.8915c"]]},{"id":"7129c8e7.e61be8","type":"switch","z":"51f68a48.7e6574","name":"OBIS-B","property":"payload.OBIS-B","propertyType":"msg","rules":[{"t":"else"},{"t":"eq","v":"144","vt":"str"},{"t":"eq","v":"0","vt":"str"}],"checkall":"true","repair":false,"outputs":3,"x":470,"y":220,"wires":[["1c4cac0b.c56ae4"],["a2601093.8ba6f"],["da62e3c1.a4d4d"]]},{"id":"1c4cac0b.c56ae4","type":"debug","z":"51f68a48.7e6574","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":630,"y":140,"wires":[]},{"id":"a2601093.8ba6f","type":"buffer-parser","z":"51f68a48.7e6574","name":"Software-Version","data":"payload.rest","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"int16be","name":"Major","offset":0,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"Minor","offset":2,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"Build","offset":4,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"Revision","offset":6,"length":1,"offsetbit":0,"scale":"1","mask":""}],"swap1":"","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload","msgPropertyType":"str","resultType":"keyvalue","resultTypeType":"output","multipleResult":false,"fanOutMultipleResult":false,"setTopic":true,"outputs":1,"x":690,"y":220,"wires":[["9fda010a.8a328"]]},{"id":"9fda010a.8a328","type":"debug","z":"51f68a48.7e6574","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":930,"y":220,"wires":[]},{"id":"fe456fba.8915c","type":"link out","z":"51f68a48.7e6574","name":"","links":["b419ce11.5f9e1"],"x":1028,"y":400,"wires":[]},{"id":"b419ce11.5f9e1","type":"link in","z":"51f68a48.7e6574","name":"","links":["fe456fba.8915c"],"x":95,"y":220,"wires":[["d5e9a03c.b188b"]]}]

Edit: @Becker : I also copied the full message from your initial post (608 bytes buffer) into the fake/dummy ...now the software version shows as well, as it is at the end of the buffer (OBIS-Channel/OBIS-B with value "144").
Also the Documentation in the PDF is misleading, as normally the Channel for these OBIS-Codes should be "1", but the dump here SMA Homemanager 2.0 >= 2.03.4.R – smart charging + smart home + smart tesla clearly shows, that they are zero/"0"....as in your demo/captured mesg.
The OBIS-Index/OBIS-C is the one to determine on how to further manipulate the value (divert by 1000, 360000, ...) and to determine the unit.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.