Error reading point values from bacnet device

1.1k Views Asked by At
import BAC0

bacnet = BAC0.connect()

my_obj_list = [('file', 1),
             ('analogInput', 1002),
             ('analogInput', 1),
             ('analogInput', 1006),
             ('analogInput', 1011),
             ('analogInput', 1010),
             ('analogInput', 1001)]


# # Provide it as an argument
fx = BAC0.device('16102:19', 1610219, bacnet, object_list = my_obj_list)
p=fx.points
for point in p:
    print(point)

The code is returning the point values as expected, but throwing an exception. Can not figure out what I'm doing wrong.

error

2018-11-26 17:45:51,864 - INFO | Starting BAC0 version 0.99.944 (Lite) 2018-11-26 17:45:51,908 - INFO | Using ip : 192.168.0.16 2018-11-26 17:45:51,909 - INFO | Starting app... 2018-11-26 17:45:51,910 - INFO | BAC0 started 2018-11-26 17:45:51,910 - INFO | Registered as Simple BACnet/IP App 2018-11-26 17:45:54,529 - INFO | Changing device state to DeviceDisconnected'> 2018-11-26 17:45:54,726 - INFO | Changing device state to RPDeviceConnected'> 2018-11-26 17:45:54,928 - INFO | Device 1610219:[device1610219] found... building points list 2018-11-26 17:45:57,674 - INFO | Ready! 2018-11-26 17:45:57,676 - INFO | Polling started, values read every 10 seconds Exception in thread rpm_poll: Traceback (most recent call last): File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_64\lib\threading.py", line 916, in _bootstrap_inner self.run() File "C:_website\BacTest\venv\lib\site-packages\BAC0\tasks\TaskManager.py", line 45, in run self.process() File "C:_website\BacTest\venv\lib\site-packages\BAC0\tasks\TaskManager.py", line 52, in process self.task() File "C:_website\BacTest\venv\lib\site-packages\BAC0\tasks\Poll.py", line 77, in task self.device.read_multiple(list(self.device.points_name), points_per_request=25) File "C:_website\BacTest\venv\lib\site-packages\BAC0\core\devices\mixins\read_mixin.py", line 452, in read_multiple self.read_single(each,points_per_request=1, discover_request=discover_request) File "C:_website\BacTest\venv\lib\site-packages\BAC0\core\devices\mixins\read_mixin.py", line 459, in read_single return self.properties.network.read(request) File "C:_website\BacTest\venv\lib\site-packages\BAC0\core\io\Read.py", line 87, in read args_split, arr_index=arr_index, vendor_id=vendor_id, bacoid=bacoid)) File "C:_website\BacTest\venv\lib\site-packages\BAC0\core\io\Read.py", line 310, in build_rp_request addr, obj_type, obj_inst, prop_id = args[:4] ValueError: not enough values to unpack (expected 4, got 2)

device1610219/ai_2 : 2.30 noUnits device1610219/zone_temp : 45.00 degreesFahrenheit device1610219/ai_6 : 75.00 degreesFahrenheit device1610219/ai_11 : 1.00 65535 device1610219/ai_10 : -53.30 degreesFahrenheit device1610219/ai_1 : 0.00 noUnits

Process finished with exit code 0

1

There are 1 best solutions below

0
On

I've made some tests trying to replicate your bug and I think you may be fighting with a weird device.

Using the exact same script I succeed reading all points.

If I may suggest though, declaring your device using default "poll" parameters will assure reading of all points every 10 seconds.

Using points will force a reading of points (one by one) when called which will slow the process. For that, I would use point.lastValue

When the device polls its point list, internally, it'll use a ReadPropertyMultiple that will read a bunch of points and properties at the same time. It is more efficient.

Something like (playing with format...) :

import BAC0

bacnet = BAC0.lite()

# # Provide it as an argument
fx = BAC0.device('2:5', 5, bacnet)

for name in fx.points_name:
    if fx[name].units:
        val = '{:>10.2f}'.format(fx[name].lastValue)
        units = fx[name].units
    else:
        units = '({})'.format(fx[name].properties.units_state)
        val = '{:>10}'.format(fx[name].lastValue)
    print('{:<20} : {} {:<10}'.format(fx[name].properties.name, val, units))

(Extract of result)

2018-12-06 20:43:17,167 - INFO    | Starting BAC0 version 0.99.944 (Lite)
2018-12-06 20:43:17,283 - INFO    | Using ip : 192.168.210.11
2018-12-06 20:43:17,285 - INFO    | Starting app...
2018-12-06 20:43:17,292 - INFO    | BAC0 started
2018-12-06 20:43:17,292 - INFO    | Registered as Simple BACnet/IP App
2018-12-06 20:43:19,295 - INFO    | Changing device state to DeviceDisconnected'>
2018-12-06 20:43:20,156 - INFO    | Changing device state to RPMDeviceConnected'>
2018-12-06 20:43:20,716 - INFO    | Device 5:[FX14 0005] found... building points 
2018-12-06 20:43:32,691 - INFO    | Ready!
2018-12-06 20:43:32,696 - INFO    | Polling started, values read every 10 seconds
nvoAI3               :      -1.17 degreesCelsius
nvoAI4               :      42.33 percent
nvoAI6               :     354.00 kilopascals
nvoAI5               :       1.85 percent
nvoAI1               :      22.05 degreesCelsius
nvoAI2               :      20.84 degreesCelsius
[...]
nciOvrdDO5.State     :          1 (['AUTO', 'ON', 'OFF'])
nvoAlarmPompe        :          1 (['OFF', 'ON'])
nvoAlrmGravePompe    :          1 (['OFF', 'ON'])
nvoTempOccup         :          1 (['OFF', 'ON'])
nciModeOperation     :          2 (['ARRET', 'AUTO', 'CHAUFF', 'REFROID', 'ELECTR'])
nciOvrdDO2.State     :          1 (['AUTO', 'ON', 'OFF'])
nciOvrdDO3.State     :          1 (['AUTO', 'ON', 'OFF'])
nciOvrdDO4.State     :          1 (['AUTO', 'ON', 'OFF'])
nciOvrdDO1.State     :          1 (['AUTO', 'ON', 'OFF'])
nciModeDeshum        :          1 (['Aucune', 'Ventilation', 'Rechauff'])
nciOvrdAO1.State     :          2 (['AUTO', 'MAN', '100', '0'])
nciOvrdAO2.State     :          1 (['AUTO', 'MAN', '100', '0'])
nvoDI7               :   inactive (('Off', 'On'))
nvoDI8               :   inactive (('Off', 'On'))
nvoDI10              :   inactive (('Off', 'On'))
nvoDI9               :   inactive (('Off', 'On'))
nvoDI6               :   inactive (('Off', 'On'))
nvoDI4               :   inactive (('Off', 'On'))

If you keep getting issues, please post one here : https://github.com/ChristianTremblay/BAC0/issues