BAC0 icon indicating copy to clipboard operation
BAC0 copied to clipboard

Read Multiple request_dict Returns One

Open chrisreichert53 opened this issue 1 year ago • 1 comments

I believe there is a bug in the readMultiple method when providing request_dict. It looks like in each iteration of the response, it resets the request_dict[object_identifier] to an empty list. This works fine for single properties but only returns the last property when multiple are provided.

https://github.com/ChristianTremblay/BAC0/blob/ef972e31577ebbcb3df6983ad69bbfbcd52b4a9c/BAC0/core/io/Read.py#L297-L317

Suggestion in place of:

https://github.com/ChristianTremblay/BAC0/blob/ef972e31577ebbcb3df6983ad69bbfbcd52b4a9c/BAC0/core/io/Read.py#L317

to

if str(object_identifier) not in dict_values:
    dict_values[str(object_identifier)] = []

chrisreichert53 avatar Sep 27 '24 03:09 chrisreichert53

If you can test develop branch, your proposal is added

Thanks

ChristianTremblay avatar Oct 12 '24 02:10 ChristianTremblay

@bill-clapham please add details as I thought it was fixed

ChristianTremblay avatar Nov 21 '24 02:11 ChristianTremblay

Hi Christian, thanks for looking in to this. In the main branch of BAC0 2024.9.20 the bug highlighted by @chrisreichert53 on line 317 of Read.py is what was causing my error. for document continuity I will add my code extracts.

Sample code

    bacnet = BAC0.start(BACNET_ADAPTER)
    _rpm = {'address': '192.168.2.100:47808',
              'objects': {'analogValue:14': ['objectName', 'presentValue', 'statusFlags', 'units'],
                          'analogValue:15': ['presentValue', 'objectName']}}

    readRes = await bacnet.readMultiple('192.168.2.100:47808', request_dict=_rpm)
    pprint(readRes)

Above code produced:

{'analog-value,14': [(<PropertyIdentifier: units>, <EngineeringUnits: degrees-celsius>)],
 'analog-value,15': [(<PropertyIdentifier: object-name>, "JesPl'CHEP_FCU_106'RHvacCoo'TCtlC'SpCPrt")]}

After making the suggested change to Read.py the same code produces:

{'analog-value,14': [(<PropertyIdentifier: object-name>, "JesPl'CHEP_FCU_106'RHvacCoo'TCtlC'SpCCmf"),
                     (<PropertyIdentifier: present-value>, 24.0),
                     (<PropertyIdentifier: status-flags>, <StatusFlags: >),
                     (<PropertyIdentifier: units>, <EngineeringUnits: degrees-celsius>)],
 'analog-value,15': [(<PropertyIdentifier: present-value>, 40.0),
                     (<PropertyIdentifier: object-name>, "JesPl'CHEP_FCU_106'RHvacCoo'TCtlC'SpCPrt")]}

The correct data is now shown but in a different structure as documented in https://bac0.readthedocs.io/en/latest/read.html

Using: Python, Version 3.13 BAC0, Version: 2024.9.20 bacpypes3, Version: 0.0.98

Again, big thanks for your work Christian 👍👍

bill-clapham avatar Nov 22 '24 19:11 bill-clapham

Have you tried the develop branch to see if the issue is fixed ?

ChristianTremblay avatar Dec 05 '24 13:12 ChristianTremblay

Hi @ChristianTremblay Apologies for the delay, been offline recently. I tried the latest code from the developer branch (copied on 29 Jan) but have the same issue where the keys in the returned dict are strings instead of tuples and the values for each key is a list of tuples but the tuple items are bacpypes3 classes.

I'm an amateur programmer at best so please excuse any wording inaccuracies. Regards Bill

bill-clapham avatar Jan 28 '25 19:01 bill-clapham

This issue had no activity for a long period of time. If this issue is still required, please update the status or else, it will be closed. Please note that an issue can be reopened if required.

github-actions[bot] avatar Mar 30 '25 02:03 github-actions[bot]