rellit / resol-vbus-python

Python Script to read RESOL VBUS Data over LAN
MIT License
14 stars 12 forks source link

KeyError: 'mask' error #2

Closed nmaas87 closed 7 years ago

nmaas87 commented 7 years ago

Thanks a lot for the great program, however, I can't seem to get it working. I got an Resol DeltaSol BS Plus V2, which I - for whatever reason, always need to read out as DeltaSol BS 2009 (0x427B) - at least that it what it says it is in the Resol Service Center (I use it via the VBUS/LAN adapter).

So I grabbed the VBusSpecificationResolBS2009.xml, converted it into JSON and tried running the program with Debug enabled. Only an error was shown, that it could not read the spec file. I found out, that was due to the fact that this file only contains this one system and so the json file has no arrays for devices and packets, but only the values of this one package. I rewrote it into an array:

{
  "vbusSpecification": {
    "device": [
      {
        "address": "0x427B",
        "name": "DeltaSol BS 2009",
        "isMaster": "true"
      }    
    ],
    "packet": [
    {
      "destination": "0x0010",
      "source": "0x427B",
      "command": "0x0100",
      "field": [
        {
          "offset": "0",
          "name": [
            "Temperatur Sensor 1",
            {
              "-lang": "en",
              "#text": "Temperature sensor 1"
            }
          ],
          "bitSize": "15",
          "factor": "0.1",
          "unit": " °C"
        },
        {
          "offset": "2",
          "name": [
            "Temperatur Sensor 2",
            {
              "-lang": "en",
              "#text": "Temperature sensor 2"
            }
          ],
          "bitSize": "15",
          "factor": "0.1",
          "unit": " °C"
        },
        {
          "offset": "4",
          "name": [
            "Temperatur Sensor 3",
            {
              "-lang": "en",
              "#text": "Temperature sensor 3"
            }
          ],
          "bitSize": "15",
          "factor": "0.1",
          "unit": " °C"
        },
        {
          "offset": "6",
          "name": [
            "Temperatur Sensor 4",
            {
              "-lang": "en",
              "#text": "Temperature sensor 4"
            }
          ],
          "bitSize": "15",
          "factor": "0.1",
          "unit": " °C"
        },
        {
          "offset": "8",
          "name": [
            "Drehzahl Relais 1",
            {
              "-lang": "en",
              "#text": "Pump speed 1"
            }
          ],
          "bitSize": "8",
          "unit": " %"
        },
        {
          "offset": "12",
          "name": [
            "Drehzahl Relais 2",
            {
              "-lang": "en",
              "#text": "Pump speed 2"
            }
          ],
          "bitSize": "8",
          "unit": " %"
        },
        {
          "offset": "10",
          "name": [
            "Betriebsstunden Relais 1",
            {
              "-lang": "en",
              "#text": "Operating hours relais 1"
            }
          ],
          "bitSize": "16",
          "factor": "1",
          "unit": " h"
        },
        {
          "offset": "14",
          "name": [
            "Betriebsstunden Relais 2",
            {
              "-lang": "en",
              "#text": "Operating hours relais 2"
            }
          ],
          "bitSize": "16",
          "factor": "1",
          "unit": " h"
        },
        {
          "offset": "16",
          "name": "UnitType",
          "factor": "1",
          "bitSize": "8"
        },
        {
          "offset": "17",
          "name": "System",
          "bitSize": "8"
        },
        {
          "offset": "20",
          "name": "ErrorMask",
          "bitSize": "16"
        },
        {
          "offset": "22",
          "name": "Systemzeit",
          "bitSize": "15",
          "format": "t",
          "timeRef": "1"
        },
        {
          "offset": "20",
          "name": "Sensor 1 defekt",
          "bitSize": "1",
          "bitPos": "0"
        },
        {
          "offset": "20",
          "name": "Sensor 2 defekt",
          "bitSize": "1",
          "bitPos": "1"
        },
        {
          "offset": "20",
          "name": "Sensor 3 defekt",
          "bitSize": "1",
          "bitPos": "2"
        },
        {
          "offset": "20",
          "name": "Sensor 4 defekt",
          "bitSize": "1",
          "bitPos": "3"
        },
        {
          "offset": "24",
          "name": "Statusmask",
          "bitSize": "32"
        },
        {
          "name": [
            "Wärmemenge",
            {
              "-lang": "en",
              "#text": "Heat amount"
            }
          ],
          "unit": " Wh",
          "offset": "28",
          "bitSize": "32",
          "factor": "1"
        },
        {
          "offset": "32",
          "name": "SV Version",
          "bitSize": "16",
          "factor": "0.01"
        },
        {
          "offset": "34",
          "name": "Variante",
          "bitSize": "16"
        }
      ]
    }
    ]
  }
}

After that, I got around the error and specs seemed to be parsed correctly. However, I always get this error. Any idea :)?

{u'source': u'0x427B', u'destination': u'0x0010', u'command': u'0x0100', u'field': [{u'bitSize': u'15', u'factor': u'0.1', u'name': [u'Temperatur Sensor 1', {u'-lang': u'en', u'#text': u'Temperature sensor 1'}], u'unit': u' \xb0C', u'offset': u'0'}, {u'bitSize': u'15', u'factor': u'0.1', u'name': [u'Temperatur Sensor 2', {u'-lang': u'en', u'#text': u'Temperature sensor 2'}], u'unit': u' \xb0C', u'offset': u'2'}, {u'bitSize': u'15', u'factor': u'0.1', u'name': [u'Temperatur Sensor 3', {u'-lang': u'en', u'#text': u'Temperature sensor 3'}], u'unit': u' \xb0C', u'offset': u'4'}, {u'bitSize': u'15', u'factor': u'0.1', u'name': [u'Temperatur Sensor 4', {u'-lang': u'en', u'#text': u'Temperature sensor 4'}], u'unit': u' \xb0C', u'offset': u'6'}, {u'bitSize': u'8', u'name': [u'Drehzahl Relais 1', {u'-lang': u'en', u'#text': u'Pump speed 1'}], u'unit': u' %', u'offset': u'8'}, {u'bitSize': u'8', u'name': [u'Drehzahl Relais 2', {u'-lang': u'en', u'#text': u'Pump speed 2'}], u'unit': u' %', u'offset': u'12'}, {u'bitSize': u'16', u'factor': u'1', u'name': [u'Betriebsstunden Relais 1', {u'-lang': u'en', u'#text': u'Operating hours relais 1'}], u'unit': u' h', u'offset': u'10'}, {u'bitSize': u'16', u'factor': u'1', u'name': [u'Betriebsstunden Relais 2', {u'-lang': u'en', u'#text': u'Operating hours relais 2'}], u'unit': u' h', u'offset': u'14'}, {u'bitSize': u'8', u'factor': u'1', u'name': u'UnitType', u'offset': u'16'}, {u'bitSize': u'8', u'name': u'System', u'offset': u'17'}, {u'bitSize': u'16', u'name': u'ErrorMask', u'offset': u'20'}, {u'bitSize': u'15', u'format': u't', u'timeRef': u'1', u'name': u'Systemzeit', u'offset': u'22'}, {u'bitSize': u'1', u'bitPos': u'0', u'name': u'Sensor 1 defekt', u'offset': u'20'}, {u'bitSize': u'1', u'bitPos': u'1', u'name': u'Sensor 2 defekt', u'offset': u'20'}, {u'bitSize': u'1', u'bitPos': u'2', u'name': u'Sensor 3 defekt', u'offset': u'20'}, {u'bitSize': u'1', u'bitPos': u'3', u'name': u'Sensor 4 defekt', u'offset': u'20'}, {u'bitSize': u'32', u'name': u'Statusmask', u'offset': u'24'}, {u'bitSize': u'32', u'factor': u'1', u'name': [u'W\xe4rmemenge', {u'-lang': u'en', u'#text': u'Heat amount'}], u'unit': u' Wh', u'offset': u'28'}, {u'bitSize': u'16', u'factor': u'0.01', u'name': u'SV Version', u'offset': u'32'}, {u'bitSize': u'16', u'name': u'Variante', u'offset': u'34'}]}
  {u'bitSize': u'15', u'factor': u'0.1', u'name': [u'Temperatur Sensor 1', {u'-lang': u'en', u'#text': u'Temperature sensor 1'}], u'unit': u' \xb0C', u'offset': u'0'}
  {u'bitSize': u'15', u'factor': u'0.1', u'name': [u'Temperatur Sensor 2', {u'-lang': u'en', u'#text': u'Temperature sensor 2'}], u'unit': u' \xb0C', u'offset': u'2'}
  {u'bitSize': u'15', u'factor': u'0.1', u'name': [u'Temperatur Sensor 3', {u'-lang': u'en', u'#text': u'Temperature sensor 3'}], u'unit': u' \xb0C', u'offset': u'4'}
  {u'bitSize': u'15', u'factor': u'0.1', u'name': [u'Temperatur Sensor 4', {u'-lang': u'en', u'#text': u'Temperature sensor 4'}], u'unit': u' \xb0C', u'offset': u'6'}
  {u'bitSize': u'8', u'name': [u'Drehzahl Relais 1', {u'-lang': u'en', u'#text': u'Pump speed 1'}], u'unit': u' %', u'offset': u'8'}
  {u'bitSize': u'8', u'name': [u'Drehzahl Relais 2', {u'-lang': u'en', u'#text': u'Pump speed 2'}], u'unit': u' %', u'offset': u'12'}
  {u'bitSize': u'16', u'factor': u'1', u'name': [u'Betriebsstunden Relais 1', {u'-lang': u'en', u'#text': u'Operating hours relais 1'}], u'unit': u' h', u'offset': u'10'}
  {u'bitSize': u'16', u'factor': u'1', u'name': [u'Betriebsstunden Relais 2', {u'-lang': u'en', u'#text': u'Operating hours relais 2'}], u'unit': u' h', u'offset': u'14'}
  {u'bitSize': u'8', u'factor': u'1', u'name': u'UnitType', u'offset': u'16'}
  {u'bitSize': u'8', u'name': u'System', u'offset': u'17'}
  {u'bitSize': u'16', u'name': u'ErrorMask', u'offset': u'20'}
  {u'bitSize': u'15', u'format': u't', u'timeRef': u'1', u'name': u'Systemzeit', u'offset': u'22'}
  {u'bitSize': u'1', u'bitPos': u'0', u'name': u'Sensor 1 defekt', u'offset': u'20'}
  {u'bitSize': u'1', u'bitPos': u'1', u'name': u'Sensor 2 defekt', u'offset': u'20'}
  {u'bitSize': u'1', u'bitPos': u'2', u'name': u'Sensor 3 defekt', u'offset': u'20'}
  {u'bitSize': u'1', u'bitPos': u'3', u'name': u'Sensor 4 defekt', u'offset': u'20'}
  {u'bitSize': u'32', u'name': u'Statusmask', u'offset': u'24'}
  {u'bitSize': u'32', u'factor': u'1', u'name': [u'W\xe4rmemenge', {u'-lang': u'en', u'#text': u'Heat amount'}], u'unit': u' Wh', u'offset': u'28'}
  {u'bitSize': u'16', u'factor': u'0.01', u'name': u'SV Version', u'offset': u'32'}
  {u'bitSize': u'16', u'name': u'Variante', u'offset': u'34'}
Traceback (most recent call last):
  File "./resol.py", line 232, in <module>
    load_data()
  File "./resol.py", line 58, in load_data
    print format_message_pv1(msg)
  File "./resol.py", line 145, in format_message_pv1
    parsed += "    QUELLE".ljust(15,'.')+": " + get_source(msg) + " " + get_source_name(msg) + "\n"
  File "./resol.py", line 194, in get_source_name
    if src[:get_compare_length(device['mask'])] == device['address'][:get_compare_length(device['mask'])]:
KeyError: 'mask'

Thanks a lot! :)

adbuerger commented 7 years ago

@nmaas87 You are probably missing the entry mask in your json file, I hand the same problem. Though I do not know what it exactly does to be honest, try to change your specification to

{
  "vbusSpecification": {
    "device": [
      {
        "address": "0x427B",
        "name": "DeltaSol BS 2009",
        "mask": "0xFFFF",
        "isMaster": "true"
      }    
    ],
....

for me it's working that way. Cf. the entry in https://github.com/rellit/resol-vbus-python/blob/master/spec/DeltaSolBXPlus.json

nmaas87 commented 7 years ago

Thanks a lot for your answer @adbuerger :)! That helped a lot - the error is now gone and it loads - but somehow never gives back any data :/. Dunno why :/

However, I found out that these masks are to select/address a specific device from the communication bus :)! This list should be very useful and contains the valid masks: https://danielwippermann.github.io/resol-vbus/vbus-packets.html - also, this tool works with my controller - however, I would really enjoy this python solution more than the nodejs stuff :(. Well, maybe I find the problem somehow - thanks a lot :)!

adbuerger commented 7 years ago

Yes, I also had to change some other things:

to parts of the form

    {
      "name": [
        "Wärmemenge",
        {
          "-lang": "en",
          "#text": "Heat amount"
        }
      ],
      "unit": " Wh",
      "offset": "28",
      "bitSize": "32",
      "factor": "1"
    },

otherwise the entries (only the ones of the first form, though) will not be processed correctly, and the results of these readings are not shown.

Does this help?

nmaas87 commented 7 years ago

I changed expected to 1 as well, but that did not help. Setting debug to false gave me following:

PARSED:
    ZIEL.......: 0x0015
    QUELLE.....: 0x427b
    PROTOKOLL..: PV1
    BEFEHL.....: 0x0100
    ANZ_FRAMES.: 10
    CHECKSUM...: 0x12
    NB1........: 0x01 - 0x01
    NB2........: 0x08 - 0x08
    NB3........: 0x00 - 0x00
    NB4........: 0x00 - 0x00
    SEPTETT1...: 0x00
    CHECKSUM1..: 0x76
    NB5........: 0x00 - 0x00
    NB6........: 0x00 - 0x00
    NB7........: 0x7f - 0xff
    NB8........: 0x7f - 0xff
    SEPTETT2...: 0x0c
    CHECKSUM2..: 0x75
    NB9........: 0x02 - 0x02
    NB10.......: 0x0a - 0x0a
    NB11.......: 0x00 - 0x00
    NB12.......: 0x00 - 0x00
    SEPTETT3...: 0x00
    CHECKSUM3..: 0x73
    NB13.......: 0x6a - 0xea
    NB14.......: 0x01 - 0x01
    NB15.......: 0x32 - 0xb2
    NB16.......: 0x01 - 0x01
    SEPTETT4...: 0x05
    CHECKSUM4..: 0x5c
    NB17.......: 0x00 - 0x00
    NB18.......: 0x00 - 0x00
    NB19.......: 0x00 - 0x00
    NB20.......: 0x00 - 0x00
    SEPTETT5...: 0x00
    CHECKSUM5..: 0x7f
    NB21.......: 0x01 - 0x01
    NB22.......: 0x0b - 0x0b
    NB23.......: 0x00 - 0x00
    NB24.......: 0x00 - 0x00
    SEPTETT6...: 0x00
    CHECKSUM6..: 0x73
    NB25.......: 0x00 - 0x00
    NB26.......: 0x00 - 0x00
    NB27.......: 0x00 - 0x00
    NB28.......: 0x00 - 0x00
    SEPTETT7...: 0x00
    CHECKSUM7..: 0x7f
    NB29.......: 0x02 - 0x02
    NB30.......: 0x01 - 0x01
    NB31.......: 0x00 - 0x00
    NB32.......: 0x0b - 0x0b
    SEPTETT8...: 0x00
    CHECKSUM8..: 0x71
    NB33.......: 0x6a - 0xea
    NB34.......: 0x01 - 0x01
    NB35.......: 0x32 - 0xb2
    NB36.......: 0x01 - 0x01
    SEPTETT9...: 0x05
    CHECKSUM9..: 0x5c
    NB37.......: 0x1b - 0x1b
    NB38.......: 0x02 - 0x02
    NB39.......: 0x16 - 0x16
    NB40.......: 0x02 - 0x02
    SEPTETT10..: 0x00
    CHECKSUM10.: 0x4a
    PAYLOAD....: 0x01 0x08 0x00 0x00 0x00 0x00 0xff 0xff 0x02 0x0a 0x00 0x00 0xea 0x01 0xb2 0x01 0x00 0x00 0x00 0x00 0x01 0x0b 0x00 0x00 0x00 0x00 0x00 0x00 0x02 0x01 0x00 0x0b 0xea 0x01 0xb2 0x01 0x1b 0x02 0x16 0x02

PARSED:
    ZIEL1......: 0x00
    ZIEL2......: 0x00
    QUELLE1....: 0x7b
    QUELLE2....: 0x42
    PROTOKOLL..: 0x20
    BEFEHL1....: 0x00
    BEFEHL2....: 0x05
    ID1........: 0x00
    ID2........: 0x00
    WERT1......: 0x00
    WERT2......: 0x00
    WERT3......: 0x00
    WERT4......: 0x00
    SEPTETT....: 0x00
    CHECKSUM...: 0x1d

PARSED:
    ZIEL.......: 0x0010
    QUELLE.....: 0x427b
    PROTOKOLL..: PV1
    BEFEHL.....: 0x0100
    ANZ_FRAMES.: 9
    CHECKSUM...: 0x18
    NB1........: 0x6a - 0xea
    NB2........: 0x01 - 0x01
    NB3........: 0x32 - 0xb2
    NB4........: 0x01 - 0x01
    SEPTETT1...: 0x05
    CHECKSUM1..: 0x5c
    NB5........: 0x1b - 0x1b
    NB6........: 0x02 - 0x02
    NB7........: 0x16 - 0x16
    NB8........: 0x02 - 0x02
    SEPTETT2...: 0x00
    CHECKSUM2..: 0x4a
    NB9........: 0x00 - 0x00
    NB10.......: 0x7f - 0xff
    NB11.......: 0x1e - 0x9e
    NB12.......: 0x11 - 0x11
    SEPTETT3...: 0x06
    CHECKSUM3..: 0x4b
    NB13.......: 0x00 - 0x00
    NB14.......: 0x7f - 0xff
    NB15.......: 0x23 - 0x23
    NB16.......: 0x0b - 0x0b
    SEPTETT4...: 0x02
    CHECKSUM4..: 0x50
    NB17.......: 0x0b - 0x0b
    NB18.......: 0x05 - 0x05
    NB19.......: 0x7f - 0xff
    NB20.......: 0x7f - 0xff
    SEPTETT5...: 0x0c
    CHECKSUM5..: 0x65
    NB21.......: 0x00 - 0x00
    NB22.......: 0x00 - 0x00
    NB23.......: 0x6c - 0xec
    NB24.......: 0x03 - 0x03
    SEPTETT6...: 0x04
    CHECKSUM6..: 0x0c
    NB25.......: 0x00 - 0x00
    NB26.......: 0x00 - 0x00
    NB27.......: 0x00 - 0x00
    NB28.......: 0x00 - 0x00
    SEPTETT7...: 0x00
    CHECKSUM7..: 0x7f
    NB29.......: 0x00 - 0x00
    NB30.......: 0x00 - 0x00
    NB31.......: 0x00 - 0x00
    NB32.......: 0x00 - 0x00
    SEPTETT8...: 0x00
    CHECKSUM8..: 0x7f
    NB33.......: 0x68 - 0x68
    NB34.......: 0x00 - 0x00
    NB35.......: 0x00 - 0x00
    NB36.......: 0x00 - 0x00
    SEPTETT9...: 0x00
    CHECKSUM9..: 0x17
    PAYLOAD....: 0xea 0x01 0xb2 0x01 0x1b 0x02 0x16 0x02 0x00 0xff 0x9e 0x11 0x00 0xff 0x23 0x0b 0x0b 0x05 0xff 0xff 0x00 0x00 0xec 0x03 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x68 0x00 0x00 0x00

However, I never get an JSON output. (Thanks a lot for your help :))

adbuerger commented 7 years ago

In your specification at

{
  "vbusSpecification": {
    "device": [
      {
        "address": "0x427B",
        "name": "DeltaSol BS 2009",
        "isMaster": "true"
      }    
    ],
    "packet": [
    {
      "destination": "0x0010",  <--
      ...

how many of those blocks beginning with destination follow packet. I set expected_packages to the corresponding number, then it worked for me.

nmaas87 commented 7 years ago

Only 1 and i set it in the config to 1, here is my specification:

{
  "vbusSpecification": {
    "device": [
      {
        "address": "0x427B",
        "name": "DeltaSol BS 2009",
          "mask": "0xFFFF",
        "isMaster": "true"
      }    
    ],
    "packet": [
    {
      "destination": "0x0010",
      "source": "0x427B",
      "command": "0x0100",
      "field": [
        {
          "offset": "0",
          "name": [
            "Temperatur Sensor 1",
            {
              "-lang": "en",
              "#text": "Temperature sensor 1"
            }
          ],
          "bitSize": "15",
          "factor": "0.1",
          "unit": " °C"
        },
        {
          "offset": "2",
          "name": [
            "Temperatur Sensor 2",
            {
              "-lang": "en",
              "#text": "Temperature sensor 2"
            }
          ],
          "bitSize": "15",
          "factor": "0.1",
          "unit": " °C"
        },
        {
          "offset": "4",
          "name": [
            "Temperatur Sensor 3",
            {
              "-lang": "en",
              "#text": "Temperature sensor 3"
            }
          ],
          "bitSize": "15",
          "factor": "0.1",
          "unit": " °C"
        },
        {
          "offset": "6",
          "name": [
            "Temperatur Sensor 4",
            {
              "-lang": "en",
              "#text": "Temperature sensor 4"
            }
          ],
          "bitSize": "15",
          "factor": "0.1",
          "unit": " °C"
        },
        {
          "offset": "8",
          "name": [
            "Drehzahl Relais 1",
            {
              "-lang": "en",
              "#text": "Pump speed 1"
            }
          ],
          "bitSize": "8",
          "unit": " %"
        },
        {
          "offset": "12",
          "name": [
            "Drehzahl Relais 2",
            {
              "-lang": "en",
              "#text": "Pump speed 2"
            }
          ],
          "bitSize": "8",
          "unit": " %"
        },
        {
          "offset": "10",
          "name": [
            "Betriebsstunden Relais 1",
            {
              "-lang": "en",
              "#text": "Operating hours relais 1"
            }
          ],
          "bitSize": "16",
          "factor": "1",
          "unit": " h"
        },
        {
          "offset": "14",
          "name": [
            "Betriebsstunden Relais 2",
            {
              "-lang": "en",
              "#text": "Operating hours relais 2"
            }
          ],
          "bitSize": "16",
          "factor": "1",
          "unit": " h"
        },
        {
          "offset": "16",
          "name": "UnitType",
          "factor": "1",
          "bitSize": "8"
        },
        {
          "offset": "17",
          "name": "System",
          "bitSize": "8"
        },
        {
          "offset": "20",
          "name": "ErrorMask",
          "bitSize": "16"
        },
        {
          "offset": "22",
          "name": "Systemzeit",
          "bitSize": "15",
          "format": "t",
          "timeRef": "1"
        },
        {
          "offset": "20",
          "name": "Sensor 1 defekt",
          "bitSize": "1",
          "bitPos": "0"
        },
        {
          "offset": "20",
          "name": "Sensor 2 defekt",
          "bitSize": "1",
          "bitPos": "1"
        },
        {
          "offset": "20",
          "name": "Sensor 3 defekt",
          "bitSize": "1",
          "bitPos": "2"
        },
        {
          "offset": "20",
          "name": "Sensor 4 defekt",
          "bitSize": "1",
          "bitPos": "3"
        },
        {
          "offset": "24",
          "name": "Statusmask",
          "bitSize": "32"
        },
        {
          "name": [
            "Wärmemenge",
            {
              "-lang": "en",
              "#text": "Heat amount"
            }
          ],
          "unit": " Wh",
          "offset": "28",
          "bitSize": "32",
          "factor": "1"
        },
        {
          "offset": "32",
          "name": "SV Version",
          "bitSize": "16",
          "factor": "0.01"
        },
        {
          "offset": "34",
          "name": "Variante",
          "bitSize": "16"
        }
      ]
    }
    ]
  }
}
adbuerger commented 7 years ago

Ok maybe a stupid question, but: did you restart your Python interpreter so that the new value is actually used? Because what you describe is what happens at my installation when I set the value of expected_packages e. g. to 2.

Also, for all values to show up, you will have to adjust your specs as described above - though this does not explain why no values show up at all.

nmaas87 commented 7 years ago

Not a stupid question at all, things like that happen 👍. But I did that, even did delete pyc files by hand in case there was some problem in that direction :/.

Complete start in debug looks like this:

{u'isMaster': u'true', u'mask': u'0xFFFF', u'name': u'DeltaSol BS 2009', u'address': u'0x427B'}
{u'source': u'0x427B', u'destination': u'0x0010', u'command': u'0x0100', u'field': [{u'bitSize': u'15', u'factor': u'0.1', u'name': [u'Temperatur Sensor 1', {u'-lang': u'en', u'#text': u'Temperature sensor 1'}], u'unit': u' \xb0C', u'offset': u'0'}, {u'bitSize': u'15', u'factor': u'0.1', u'name': [u'Temperatur Sensor 2', {u'-lang': u'en', u'#text': u'Temperature sensor 2'}], u'unit': u' \xb0C', u'offset': u'2'}, {u'bitSize': u'15', u'factor': u'0.1', u'name': [u'Temperatur Sensor 3', {u'-lang': u'en', u'#text': u'Temperature sensor 3'}], u'unit': u' \xb0C', u'offset': u'4'}, {u'bitSize': u'15', u'factor': u'0.1', u'name': [u'Temperatur Sensor 4', {u'-lang': u'en', u'#text': u'Temperature sensor 4'}], u'unit': u' \xb0C', u'offset': u'6'}, {u'bitSize': u'8', u'name': [u'Drehzahl Relais 1', {u'-lang': u'en', u'#text': u'Pump speed 1'}], u'unit': u' %', u'offset': u'8'}, {u'bitSize': u'8', u'name': [u'Drehzahl Relais 2', {u'-lang': u'en', u'#text': u'Pump speed 2'}], u'unit': u' %', u'offset': u'12'}, {u'bitSize': u'16', u'factor': u'1', u'name': [u'Betriebsstunden Relais 1', {u'-lang': u'en', u'#text': u'Operating hours relais 1'}], u'unit': u' h', u'offset': u'10'}, {u'bitSize': u'16', u'factor': u'1', u'name': [u'Betriebsstunden Relais 2', {u'-lang': u'en', u'#text': u'Operating hours relais 2'}], u'unit': u' h', u'offset': u'14'}, {u'bitSize': u'8', u'factor': u'1', u'name': u'UnitType', u'offset': u'16'}, {u'bitSize': u'8', u'name': u'System', u'offset': u'17'}, {u'bitSize': u'16', u'name': u'ErrorMask', u'offset': u'20'}, {u'bitSize': u'15', u'format': u't', u'timeRef': u'1', u'name': u'Systemzeit', u'offset': u'22'}, {u'bitSize': u'1', u'bitPos': u'0', u'name': u'Sensor 1 defekt', u'offset': u'20'}, {u'bitSize': u'1', u'bitPos': u'1', u'name': u'Sensor 2 defekt', u'offset': u'20'}, {u'bitSize': u'1', u'bitPos': u'2', u'name': u'Sensor 3 defekt', u'offset': u'20'}, {u'bitSize': u'1', u'bitPos': u'3', u'name': u'Sensor 4 defekt', u'offset': u'20'}, {u'bitSize': u'32', u'name': u'Statusmask', u'offset': u'24'}, {u'bitSize': u'32', u'factor': u'1', u'name': [u'W\xe4rmemenge', {u'-lang': u'en', u'#text': u'Heat amount'}], u'unit': u' Wh', u'offset': u'28'}, {u'bitSize': u'16', u'factor': u'0.01', u'name': u'SV Version', u'offset': u'32'}, {u'bitSize': u'16', u'name': u'Variante', u'offset': u'34'}]}
  {u'bitSize': u'15', u'factor': u'0.1', u'name': [u'Temperatur Sensor 1', {u'-lang': u'en', u'#text': u'Temperature sensor 1'}], u'unit': u' \xb0C', u'offset': u'0'}
  {u'bitSize': u'15', u'factor': u'0.1', u'name': [u'Temperatur Sensor 2', {u'-lang': u'en', u'#text': u'Temperature sensor 2'}], u'unit': u' \xb0C', u'offset': u'2'}
  {u'bitSize': u'15', u'factor': u'0.1', u'name': [u'Temperatur Sensor 3', {u'-lang': u'en', u'#text': u'Temperature sensor 3'}], u'unit': u' \xb0C', u'offset': u'4'}
  {u'bitSize': u'15', u'factor': u'0.1', u'name': [u'Temperatur Sensor 4', {u'-lang': u'en', u'#text': u'Temperature sensor 4'}], u'unit': u' \xb0C', u'offset': u'6'}
  {u'bitSize': u'8', u'name': [u'Drehzahl Relais 1', {u'-lang': u'en', u'#text': u'Pump speed 1'}], u'unit': u' %', u'offset': u'8'}
  {u'bitSize': u'8', u'name': [u'Drehzahl Relais 2', {u'-lang': u'en', u'#text': u'Pump speed 2'}], u'unit': u' %', u'offset': u'12'}
  {u'bitSize': u'16', u'factor': u'1', u'name': [u'Betriebsstunden Relais 1', {u'-lang': u'en', u'#text': u'Operating hours relais 1'}], u'unit': u' h', u'offset': u'10'}
  {u'bitSize': u'16', u'factor': u'1', u'name': [u'Betriebsstunden Relais 2', {u'-lang': u'en', u'#text': u'Operating hours relais 2'}], u'unit': u' h', u'offset': u'14'}
  {u'bitSize': u'8', u'factor': u'1', u'name': u'UnitType', u'offset': u'16'}
  {u'bitSize': u'8', u'name': u'System', u'offset': u'17'}
  {u'bitSize': u'16', u'name': u'ErrorMask', u'offset': u'20'}
  {u'bitSize': u'15', u'format': u't', u'timeRef': u'1', u'name': u'Systemzeit', u'offset': u'22'}
  {u'bitSize': u'1', u'bitPos': u'0', u'name': u'Sensor 1 defekt', u'offset': u'20'}
  {u'bitSize': u'1', u'bitPos': u'1', u'name': u'Sensor 2 defekt', u'offset': u'20'}
  {u'bitSize': u'1', u'bitPos': u'2', u'name': u'Sensor 3 defekt', u'offset': u'20'}
  {u'bitSize': u'1', u'bitPos': u'3', u'name': u'Sensor 4 defekt', u'offset': u'20'}
  {u'bitSize': u'32', u'name': u'Statusmask', u'offset': u'24'}
  {u'bitSize': u'32', u'factor': u'1', u'name': [u'W\xe4rmemenge', {u'-lang': u'en', u'#text': u'Heat amount'}], u'unit': u' Wh', u'offset': u'28'}
  {u'bitSize': u'16', u'factor': u'0.01', u'name': u'SV Version', u'offset': u'32'}
  {u'bitSize': u'16', u'name': u'Variante', u'offset': u'34'}
PARSED:
    ZIEL.......: 0x0015
    QUELLE.....: 0x427b
    PROTOKOLL..: PV1
    BEFEHL.....: 0x0100
    ANZ_FRAMES.: 10
    CHECKSUM...: 0x12
    NB1........: 0x01 - 0x01
    NB2........: 0x08 - 0x08
    NB3........: 0x00 - 0x00
    NB4........: 0x00 - 0x00
    SEPTETT1...: 0x00
    CHECKSUM1..: 0x76
    NB5........: 0x1e - 0x1e
    NB6........: 0x00 - 0x00
    NB7........: 0x7f - 0xff
    NB8........: 0x7f - 0xff
    SEPTETT2...: 0x0c
    CHECKSUM2..: 0x57
    NB9........: 0x02 - 0x02
    NB10.......: 0x0a - 0x0a
    NB11.......: 0x00 - 0x00
    NB12.......: 0x00 - 0x00
    SEPTETT3...: 0x00
    CHECKSUM3..: 0x73
    NB13.......: 0x7c - 0xfc
    NB14.......: 0x01 - 0x01
    NB15.......: 0x26 - 0xa6
    NB16.......: 0x01 - 0x01
    SEPTETT4...: 0x05
    CHECKSUM4..: 0x56
    NB17.......: 0x00 - 0x00
    NB18.......: 0x00 - 0x00
    NB19.......: 0x00 - 0x00
    NB20.......: 0x00 - 0x00
    SEPTETT5...: 0x00
    CHECKSUM5..: 0x7f
    NB21.......: 0x01 - 0x01
    NB22.......: 0x0b - 0x0b
    NB23.......: 0x00 - 0x00
    NB24.......: 0x00 - 0x00
    SEPTETT6...: 0x00
    CHECKSUM6..: 0x73
    NB25.......: 0x00 - 0x00
    NB26.......: 0x00 - 0x00
    NB27.......: 0x00 - 0x00
    NB28.......: 0x00 - 0x00
    SEPTETT7...: 0x00
    CHECKSUM7..: 0x7f
    NB29.......: 0x02 - 0x02
    NB30.......: 0x01 - 0x01
    NB31.......: 0x00 - 0x00
    NB32.......: 0x0b - 0x0b
    SEPTETT8...: 0x00
    CHECKSUM8..: 0x71
    NB33.......: 0x7c - 0xfc
    NB34.......: 0x01 - 0x01
    NB35.......: 0x26 - 0xa6
    NB36.......: 0x01 - 0x01
    SEPTETT9...: 0x05
    CHECKSUM9..: 0x56
    NB37.......: 0x06 - 0x06
    NB38.......: 0x02 - 0x02
    NB39.......: 0x15 - 0x15
    NB40.......: 0x02 - 0x02
    SEPTETT10..: 0x00
    CHECKSUM10.: 0x60
    PAYLOAD....: 0x01 0x08 0x00 0x00 0x1e 0x00 0xff 0xff 0x02 0x0a 0x00 0x00 0xfc 0x01 0xa6 0x01 0x00 0x00 0x00 0x00 0x01 0x0b 0x00 0x00 0x00 0x00 0x00 0x00 0x02 0x01 0x00 0x0b 0xfc 0x01 0xa6 0x01 0x06 0x02 0x15 0x02

PARSED:
    ZIEL1......: 0x00
    ZIEL2......: 0x00
    QUELLE1....: 0x7b
    QUELLE2....: 0x42
    PROTOKOLL..: 0x20
    BEFEHL1....: 0x00
    BEFEHL2....: 0x05
    ID1........: 0x00
    ID2........: 0x00
    WERT1......: 0x00
    WERT2......: 0x00
    WERT3......: 0x00
    WERT4......: 0x00
    SEPTETT....: 0x00
    CHECKSUM...: 0x1d

PARSED:
    ZIEL.......: 0x0010
    QUELLE.....: 0x427b
    PROTOKOLL..: PV1
    BEFEHL.....: 0x0100
    ANZ_FRAMES.: 9
    CHECKSUM...: 0x18
    NB1........: 0x7c - 0xfc
    NB2........: 0x01 - 0x01
    NB3........: 0x26 - 0xa6
    NB4........: 0x01 - 0x01
    SEPTETT1...: 0x05
    CHECKSUM1..: 0x56
    NB5........: 0x06 - 0x06
    NB6........: 0x02 - 0x02
    NB7........: 0x15 - 0x15
    NB8........: 0x02 - 0x02
    SEPTETT2...: 0x00
    CHECKSUM2..: 0x60
    NB9........: 0x1e - 0x1e
    NB10.......: 0x7f - 0xff
    NB11.......: 0x1f - 0x9f
    NB12.......: 0x11 - 0x11
    SEPTETT3...: 0x06
    CHECKSUM3..: 0x2c
    NB13.......: 0x00 - 0x00
    NB14.......: 0x7f - 0xff
    NB15.......: 0x23 - 0x23
    NB16.......: 0x0b - 0x0b
    SEPTETT4...: 0x02
    CHECKSUM4..: 0x50
    NB17.......: 0x0b - 0x0b
    NB18.......: 0x05 - 0x05
    NB19.......: 0x7f - 0xff
    NB20.......: 0x7f - 0xff
    SEPTETT5...: 0x0c
    CHECKSUM5..: 0x65
    NB21.......: 0x00 - 0x00
    NB22.......: 0x00 - 0x00
    NB23.......: 0x0d - 0x0d
    NB24.......: 0x04 - 0x04
    SEPTETT6...: 0x00
    CHECKSUM6..: 0x6e
    NB25.......: 0x00 - 0x00
    NB26.......: 0x00 - 0x00
    NB27.......: 0x00 - 0x00
    NB28.......: 0x00 - 0x00
    SEPTETT7...: 0x00
    CHECKSUM7..: 0x7f
    NB29.......: 0x00 - 0x00
    NB30.......: 0x00 - 0x00
    NB31.......: 0x00 - 0x00
    NB32.......: 0x00 - 0x00
    SEPTETT8...: 0x00
    CHECKSUM8..: 0x7f
    NB33.......: 0x68 - 0x68
    NB34.......: 0x00 - 0x00
    NB35.......: 0x00 - 0x00
    NB36.......: 0x00 - 0x00
    SEPTETT9...: 0x00
    CHECKSUM9..: 0x17
    PAYLOAD....: 0xfc 0x01 0xa6 0x01 0x06 0x02 0x15 0x02 0x1e 0xff 0x9f 0x11 0x00 0xff 0x23 0x0b 0x0b 0x05 0xff 0xff 0x00 0x00 0x0d 0x04 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x68 0x00 0x00 0x00

Then it starts again

adbuerger commented 7 years ago

Oh, wait a minute :-) Have a look at load_data() in https://github.com/rellit/resol-vbus-python/blob/master/resol.py at around line 52:

while len(result) < config.expected_packets:
    buf = readstream()
    msgs = splitmsg(buf)
    for msg in msgs:
        if "PV1" == get_protocolversion(msg):
            if config.debug:
                print format_message_pv1(msg)
            parse_payload(msg)
        elif "PV2" == get_protocolversion(msg):
            if config.debug:
                print format_message_pv2(msg)

it seems to me that if "PV2" == get_protocolversion(msg) we can never call the function parse_payload(msg). Maybe that's the problem. Do you get "PV2? If so, then you can maybe change the code accordingly (which will only work if parse_payload() would still be valid for that case, of course).

nmaas87 commented 7 years ago

I got it 👍 Ok, funny thing - PV2 - which I also thought about did not do anything useful - you cannot parse it - so thats ok :)

BUT: changed parse_payload to:

def parse_payload(msg):
    payload = get_payload(msg)
    for packet in spec.spec['packet']:
        print(packet['source'] + ":" + get_source(msg))
        print(packet['destination'] + ":" + get_destination(msg))
        print(packet['command'] + ":" + get_command(msg))
        if packet['source'] == get_source(msg) and packet['destination'] == get_destination(msg) and packet['command'] == get_command(msg):
            #print packet

And got following output:

PV1
0x427B:0x427b
0x0010:0x0015
0x0100:0x0100
PV2
PV1
0x427B:0x427b
0x0010:0x0010
0x0100:0x0100

... because of the fact that the hex value of the address was written with a capital B in the config/spec and the network gave it back with a small b... Well... Basically that was it.

After I changed that, in the expected packets to 1 again, I got this:

{
    "DeltaSol BS 2009": {
        "E": "",
        "S": "",
        "Betriebsstunden Relais 2": "2851.0 h",
        "Betriebsstunden Relais 1": "4511.0 h",
        "W\u00e4rmemenge": "0.0 Wh",
        "U": "",
        "V": "",
        "Drehzahl Relais 1": "0 %",
        "Temperatur Sensor 4": "53.3 \u00b0C",
        "Drehzahl Relais 2": "0 %",
        "Temperatur Sensor 2": "41.9 \u00b0C",
        "Temperatur Sensor 3": "51.1 \u00b0C",
        "Temperatur Sensor 1": "46.3 \u00b0C"
    }
}

perfect! I changed the function to all .lower() and opened up an PR to this repo, so in the future other guys should not be shot in the foot by this problem ;).

Thanks a zillion for your help 👍

adbuerger commented 7 years ago

You're welcome! I'm glad I could help and that we solved the problem! Have fun!