BAC0 icon indicating copy to clipboard operation
BAC0 copied to clipboard

Initiate device with object_list

Open majuss opened this issue 9 months ago • 6 comments

I try to initiate a controller with a object_list. I found inconsistencies, sometimes its called objects_list.

I do the following, but the property is still empty. This even occurs when I use the object list from the example: https://bac0.readthedocs.io/en/latest/controller.html#object-list

import asyncio
import BAC0
from bacpypes3.object import AnalogInputObject


bacnet = None


analog_input = [AnalogInputObject(
    objectName='Temperature Sensor',
    presentValue=23.5,
    units='degreesCelsius'
)]

async def main():
    # Create task for running coroutines concurrently
    # Replace with your actual BACnet device address and  details

    async with BAC0.start(ip="192.168.1.216/24") as bacnet:
        my_device = await BAC0.device(object_list = analog_input, network=bacnet, device_id=1725101, address ='17251:1' )
        print(my_device.properties)

if __name__ == "__main__":
    asyncio.run(main())

majuss avatar Mar 28 '25 13:03 majuss

object list is to create the local "image" of a remote controller. Not to create a local object in the running instance of BAC0. From the definition of your list, I suspect you mixed both concepts.

ChristianTremblay avatar Apr 12 '25 17:04 ChristianTremblay

Ah okay, could you please provide a complete minimal runnable example how I can initiate the controller with the object_lsit?

Because when I use you example object_list it also is empty:

import asyncio
import BAC0
from bacpypes3.object import AnalogInputObject


bacnet = None


my_obj_list = [('file', 1),
             ('analogInput', 2),
             ('analogInput', 3),
             ('analogInput', 5),
             ('analogInput', 4),
             ('analogInput', 0),
             ('analogInput', 1)]


async def main():
    # Create task for running coroutines concurrently
    # Replace with your actual BACnet device address and  details

    async with BAC0.start(ip="192.168.1.133/24") as bacnet:
        my_device = await BAC0.device(object_list = my_obj_list, network=bacnet, device_id=1725101, address ='17251:1' )
        print(my_device.properties)

if __name__ == "__main__":
    asyncio.run(main())

Or is it correct that the property objects_list is empty because these are the ones the controller actually finds on the network?

majuss avatar Apr 14 '25 07:04 majuss

@ChristianTremblay Hi Christian, I also looked at bacpypes3 directly, but the documentation is really sparse and I don't really understand the concept behind the library. I would be very happy about a minimal example.

EDIT: We want to create a simulated controller standalone with datapoints, we don't want to mirror an existing one or connect to a physical controller.

majuss avatar May 06 '25 12:05 majuss

In order to simulate a BACnet device, you don't need to use the device class, which is meant to connect with other devices on the network. You can create a BAC0 object and then create points into it. This page is the right example https://bac0.readthedocs.io/en/latest/local_objects.html

leanfm avatar May 07 '25 17:05 leanfm

Thank you @leanfm ! But unfortunately the doc example is missing the code: https://bac0.readthedocs.io/en/latest/local_objects.html#models "# code here".

Furthermore most of the "samples" are outdated and won't run with the bacpypes3 version of the lib, for example: https://github.com/ChristianTremblay/BAC0/blob/main/samples/excel_from_discovered_devices.py

So I want to create a local device with objects and a way to react to who_is requests from the network. Is there a way to do this?

majuss avatar May 12 '25 10:05 majuss

Try this : https://github.com/ChristianTremblay/BAC0/blob/main/tests/manual_test_create_device.py

ChristianTremblay avatar May 14 '25 18:05 ChristianTremblay

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 Jul 14 '25 02:07 github-actions[bot]