BAC0 - Library depending on BACpypes (Python 3) to build automation script for BACnet applications
Not so many points. And I did made the sequence a few years ago so I knew what to look for…. And what I forgot to expose [sigh]…
On influxdb, I used tags to store point names, descriptions, etc this should help they have a nice search engine… records name are based on device IDs and object instances (to eliminate duplicates risks)
from ddcmath.psychrometric import Psychrometric
In [5]: e = Psychrometric(temperature=25, humidity=50, SI=True)
25.00 degree_Celsius 50.00 percent
25.00 degree_Celsius 50.00 percent
In [6]: e
Out[6]: T: 25.00 degree_Celsius | H: 50.00 percent | DP: 13.86 degree_Celsius | WET: 18.00 degree_Celsius -> Enthalpy: 68.14 kilojoule / kilogram
e = Psychrometric(temperature=25, wetbulb=18, SI=True)
25.00 degree_Celsius 50.05 percent
25.00 degree_Celsius 50.05 percent
In [8]: e
Out[8]: T: 25.00 degree_Celsius | H: 50.05 percent | DP: 13.87 degree_Celsius | WET: 18.00 degree_Celsius -> Enthalpy: 68.17 kilojoule / kilogram
e = Psychrometric(temperature=25, dewpoint=13.9, SI=True)
13.90 degree_Celsius 25.00 degree_Celsius
13.90 degree_Celsius 25.00 degree_Celsius
In [10]: e
Out[10]: T: 25.00 degree_Celsius | H: 50.11 percent | DP: 13.90 degree_Celsius | WET: 18.01 degree_Celsius -> Enthalpy: 68.20 kilojoule / kilogram
dev['point'].subscribe_cov()
dev['point'].cancel_cov()
How do you ovrride an BO with BAC0? When I read the BO is comes thru as active
If I run:
import BAC0, time, random
bacnet = BAC0.lite()
address = '12345:2'
object_type = 'binaryOutput'
object_instance = '1'
value = 'False'
read_vals = f'{address} {object_type} {object_instance} presentValue'
check = bacnet.read(read_vals)
print("check ",check)
write_vals = f'{address} {object_type} {object_instance} presentValue {value}'
print("Excecuting write_vals statement:", write_vals)
write_result = bacnet.write(write_vals)
read_vals = f'{address} {object_type} {object_instance} presentValue'
check = bacnet.read(read_vals)
print("check ",check)
bacnet.disconnect()
print('BACnet disconnected')
I cant get to the end of the code it doesnt like what I am trying to write.
check active
Excecuting write_vals statement: 12345:2 binaryOutput 1 presentValue False
Traceback (most recent call last):
File "/root/bacnet/./test_cov.py", line 49, in <module>
main()
File "/root/bacnet/./test_cov.py", line 41, in main
initialize_objects(bacnet_device)
File "/root/bacnet/./test_cov.py", line 25, in initialize_objects
_new_objects.add_objects_to_application(bacdev)
File "/usr/local/lib/python3.10/site-packages/BAC0/core/devices/local/object.py", line 186, in add_objects_to_application
raise TypeError("Provide BAC0Application object or BAC0 Base instance")
TypeError: Provide BAC0Application object or BAC0 Base instance
#!/usr/bin/env python
import BAC0
from BAC0.core.devices.local.models import analog_value
import logging
import random
import sys
import time
logging.basicConfig(
stream=sys.stderr,
level=logging.DEBUG,
format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s'
)
log = logging.getLogger(__name__)
def initialize_objects(bacdev):
_new_objects = analog_value(
name='a_test_point',
presentValue=0
)
_new_objects.add_objects_to_application(bacdev)
def update_values(bacdev):
i = random.randint(1, 65535)
log.debug('setting new value of a_test_point to {}'.format(i))
bacdev['a_test_point'].presentValue = i
def main():
#BAC0.log_level('silence')
#bacnet_device = BAC0.lite(deviceId=4169000, localObjName='cov_test')
bacnet_device = BAC0.connect(ip='10.15.4.253/24', bbmdAddress='10.15.88.48:47808', bbmdTTL=900)
#for i in dir(bacnet_device):
# print(i)
#print(type(bacnet_device))
initialize_objects(bacnet_device)
#while True:
#pass
#update_values(bacnet_device)
#time.sleep(32)
if __name__ == "__main__":
main()
connect()
and uncomment everything else, it works fine, but again only if the controller doing the subscribing is on the same subnet (10.15.4.0/24) as the BAC0 device.