Reading from/ writing to T3-LB using BAC0 (via Python)

Hello everyone,

I am able to connect my Jetson Nano to a BACnet network and run bacnet.whois() and bacnet.devices and see the Temco T3-LB controller; I use this information to then create a BACnet object representing the controller. This is the code I use:

import BAC0

# Connect to the BACnet network
bacnet = BAC0.connect(ip='192.168.99.105/24')

# Discover the BACnet controller and obtain its IP address and Device Instance ID
controller_info = bacnet.whois()[0]
controller_ip, device_instance_id = controller_info

# Create a BACnet object representing the controller
controller = BAC0.device(address=controller_ip, device_id=device_instance_id, network=bacnet)

The following is the output for running bacnet.whois() and bacnet.devices in a Python console:

>>> bacnet.whois()
[('192.168.99.2', 205244)]
>>> bacnet.devices
        Manufacturer       Address   Device ID
Name
T3-LB  TemcoControls  192.168.99.2      205244

However, I have not been able to find documentation on how exactly to read from OR write to (overwrite) a value of an AnalogOutput; I also cannot get the points for the controller. I have been trying without success for the past few days. This is what I get when I try to get the points:

>>> controller.points
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/username/archiconda3/lib/python3.7/site-packages/BAC0/core/devices/Points.py", line 725, in __repr__
    val = float(self.lastValue)
TypeError: float() argument must be a string or a number, not 'NoneType'

The closest thing I could get to read values without immediately getting errors was running the following:

>>> objects = bacnet.read('192.168.99.2 device 205244 objectList')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/username/archiconda3/lib/python3.7/site-packages/BAC0/core/io/Read.py", line 217, in read
    "APDU Abort Reason : {}".format(reason)
BAC0.core.io.IOExceptions.NoResponseFromController: APDU Abort Reason : noResponse

but as you can see, I got a noResponse.

I want to know how to use the labels used for the analog outputs (OUT7) and what should the values be for obj_type_str and prop_id_str in build_rp_request, I already know which addr and obj_inst_str to use.

TL;DR version: I need to know how to programmatically (by using Python, via BAC0) read from and overwrite to the different Analog Outputs. It would be much appreciated!

Here is a section of python using BAC0 library, I hope this can help you
import BAC0
myIPAddr = ‘192.168.1.1/24’
bacnet = BAC0.lite(ip=myIPAddr, )

bacnet.whois()

print(bacnet.whois())

data = bacnet.read(‘20:0x010000000000 analogValue 2 presentValue’)
print(data)

BAC0 Library

Hi Fan Du,

Thank you for your response. However, I did not really understand how I can use your sample code and modify it to be used for my use case.
As I mentioned previously, I want to know how to use the labels used for the analog outputs (OUT7) and what should the values be for obj_type_str and prop_id_str in build_rp_request. How can I know what to put in bacnet.read('192.168.99.2 <obj_type_str> 205244 <prop_id_str>')? Where would I use OUT7?
Also, I am not able to get the points from the controller; it keeps returning None as mentioned in my initial post. Why is that? How can I solve this?

I need to learn how to read more bacnet information in python. If I have some progress I will share the success with you.Thanks

2 Likes

I was able to read the value of OUT7 using the following Python snippet:

# bacnet.read('<addr> <type> <inst> <prop>')
readRequest = bacnet.read('192.168.99.2 analogOutput 7 presentValue')
print(readRequest)  # This outputs '100.0' (meaning it's on)

However, when I try to overwrite the value at OUT7 using:

# bacnet.write('<addr> <type> <inst> <prop> <value> - <priority>')
writeResult = bacnet.write('192.168.99.2 analogOutput 7 presentValue 0.00 - 16')

writeResult returns None instead of either True or False even though the AnalogOutputObject class documentation shows that presentValue is a writable property [https://github.com/JoelBender/bacpypes/blob/a5be2ad5ac69821c12299716b167dd52041b5342/py34/bacpypes/object.py#L1024]. I tried to play with the priority and change it from 16 (which is typically used for manual operator commands or low-priority automated commands) but that didn’t help.

I can change the value manually through the T3000 Windows app but for some reason not through BAC0. This is how the T3000 output window shows regarding my device at OUT7:

Great news, Python is not used here but we’ll help where we can.

Be aware of the function of the Auto/Manual setting, when the output is in manual mode the programs running on the controller itself and also external masters like your Python machine on the network will not be able to flip the output. Be sure to set the output to Auto when you want to manage the output under program control.

Thank you for pointing this out; it was exactly what was missing! I am now able to read from AND write to the analog output.
Thank you all for your help!

1 Like

Hi Maurice,

I can write to the output of the analog device when it is on AUTO (i.e. the value changes on the T3000 software); however, the device does not turn on like it’s supposed to. I suppose that this is not the intended behavior, so what am I doing wrong? Is there something I might have missed?

If there is no program running then your commands will have priority. Please search the forum for ‘priority level’ and you can see which action and command has higher priority. To debug further you will need to get down to the packet level, wireshark is used for that. Also the bacnet tool will be useful, T3000 > tools > bacnet tool. You can search the forum on how to use the Bacnet tool.

1 Like

I quite literally tried to set the value to “100” at every priority level (except for levels 6 and 10, which raised exceptions when I tried to do a BACnet write with these levels) and the light bulb remained off.

The light bulb can only be turned on either:

  • if the HOA Switch of AO1 is manually set to ON
  • or if “Auto/Man” of AO1 is set to Manual and I change the value from 0.00 to 100.00%
1 Like

Please update the latest firmware rev64.5, in which different priority arrays are supported to modify the output value.

1 Like

Hi Chelsea,

Thanks for the new firmware update! I can now control the output devices as intended.

1 Like