BAC0 - Library depending on BACpypes (Python 3) to build automation script for BACnet applications
_date = Date(
year=_d.year - 1900, month=_d.month, day=_d.day, day_of_week=_d.isoweekday()
).value
_time = Time(
hour=_t.hour,
minute=_t.minute,
second=_t.second,
hundredth=int(_t.microsecond / 10000),
).value
What do you want to do ? Create 1 BACnet device that will present 100 motors with 2 points ?
It’s possible to create that using a simple name convention
Motor001_speed
Motor001_torque
[…]
Motor100_speed
Motor100_torque
In your code, the presentValue of each point is updated based on the value for from your radio gateway.
import BAC0
from BAC0.core.devices.local.models import (
analog_input,
datetime_value,
character_string,
)
new_device = = BAC0.connect(ip='192.168.10.184/16', port=47808, deviceId=124)
_new_objects = analog_value(
instance=0,
name="DA-T",
description="Discharge Air Temp in degC",
presentValue=10,
properties={"units": "degreesCelsius"},
)
_new_objects = analog_value(
instance=1,
name="ZN-T",
description="ZoneTemperature in degC",
presentValue=20,
properties={"units": "degreesCelsius"},
)
_new_objects.add_objects_to_application(new_device)
2021-12-28 13:13:09,846 - INFO | Starting BAC0 version 21.02.25 (Lite)
2021-12-28 13:13:09,850 - INFO | Use BAC0.log_level to adjust verbosity of the app.
2021-12-28 13:13:09,852 - INFO | Ex. BAC0.log_level('silence') or BAC0.log_level('error')
2021-12-28 13:13:09,854 - INFO | Starting TaskManager
2021-12-28 13:13:09,909 - INFO | Using ip : 192.168.0.103
2021-12-28 13:13:09,912 - INFO | Starting app...
2021-12-28 13:13:09,914 - INFO | BAC0 started
2021-12-28 13:13:09,916 - INFO | Registered as Simple BACnet/IP App
2021-12-28 13:13:09,947 - INFO | Update Local COV Task started
BAC0.log_level('silence')
?
Hey Christian I noticed your post on SO, I was playing around with trying to make a driver for Node Red for BACnet.
https://stackoverflow.com/questions/70511960/python-shell-node-keep-a-python-script-running/70520584?noredirect=1#:~:text=interesting%20work%20guys%20henry%2C%20%40sandeep.kgp
I have sort of given up on it for the time being its too time consuming trying to learn Node & JavaScript. Just don't have the time! Its very do-able if there were some Node.js guru's out there...., I personally think Node Red could do anything Tridium can do and its free. who needs to spend $5k on a JACE????!
Hello christian, I'm going through a scenario of multiple connections to bacnet, maybe you can help me
I have an API (python+flask) that receives the device address (bbmAddress) is passed via parameter..
the problem is when this API is called by more than one consumer at the same time, to read the points of a device,
and only the first call works, and the others respond (IP Address provided (xx.x.xx.xx) already used by BAC0.
Check if another software is using port 47808 on this network interface...)
When I try to manage the connections, calling a disconnect, it ends up that one connection influences the other, and it turns out that only 1 of the N requests will return (usually the last one)
I don't know if my scenario seems very specific, or I'm not understanding very well how bacnet behaves, in these scenarios,
and if there is a way to do that, either in the end the solution will be to control who makes the requests to this API (1 at a time) or I don't know how to use the library for this scenario.
any suggestion or idea?
Thanks.
Hello
I am connected to the bacnet from another system. I connect to the bacnet using the following script:
bacnet=bac0.connect(ip="10.95.32.212/25")
Then I read and write data to devices in my code. When I am running my code I am getting plenty of warnings. Following I have included some of them. Can you please let me know what is the reason?