I am trying to connect to a BACnet foreign device using the BAC0 Python library. Below is my script:
import BAC0 print(BAC0.version) bbmdIP = '10.x.y.z:47808' # Replace with actual IP bbmdTTL = 900 bacnet = BAC0.lite(bbmdAddress=bbmdIP, bbmdTTL=bbmdTTL) # Connect print(bacnet.vendorName.strValue) print(bacnet.modelName.strValue) whois_results = bacnet.whois() print("WhoIs results:", whois_results) print(bacnet.devices) bacnet.discover(networks='known')
However, I keep getting the following error:
2025-01-09 14:35:05,917 - INFO | Starting Asynchronous BAC0 version 2024.09.10 (Lite) 2025-01-09 14:35:05,920 - INFO | Using bacpypes3 version 0.0.98 2025-01-09 14:35:05,921 - INFO | Use BAC0.log_level to adjust verbosity of the app. 2025-01-09 14:35:05,921 - INFO | Ex. BAC0.log_level('silence') or BAC0.log_level('error') Traceback (most recent call last): File "C:UsersdmaskeDesktopNew foldertest_bacnet.py", line 7, in <module> bacnet = BAC0.connect(bbmdAddress=bbmdIP, bbmdTTL=bbmdTTL) # Connect ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:UsersdmaskeAppDataRoamingPythonPython311site-packagesBAC0scriptsLite.py", line 141, in __init__ self._ping_task.start() File "C:UsersdmaskeAppDataRoamingPythonPython311site-packagesBAC0tasksTaskManager.py", line 143, in start self.aio_task = asyncio.create_task(self.execute(), name=f"aio{self.name}") ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:Program FilesPython311Libasynciotasks.py", line 371, in create_task loop = events.get_running_loop() ^^^^^^^^^^^^^^^^^^^^^^^^^ RuntimeError: no running event loop sys:1: RuntimeWarning: coroutine 'Task.execute' was never awaited
What I Have Tried Running the script with different variations of BAC0.lite() and BAC0.connect(), but the error persists. Verified that my BACnet devices are accessible using Yabe software, where I can register and discover all devices successfully. Experimented with adding an event loop manually, but it didn’t work. Why is asyncio.create_task() failing with RuntimeError: no running event loop? How can I properly connect to a foreign BACnet device using BAC0? Are there any workarounds or configurations I need to change?
submitted by /u/werner__heisenberger
[link] [comments]
r/learnpython I am trying to connect to a BACnet foreign device using the BAC0 Python library. Below is my script: import BAC0 print(BAC0.version) bbmdIP = ’10.x.y.z:47808′ # Replace with actual IP bbmdTTL = 900 bacnet = BAC0.lite(bbmdAddress=bbmdIP, bbmdTTL=bbmdTTL) # Connect print(bacnet.vendorName.strValue) print(bacnet.modelName.strValue) whois_results = bacnet.whois() print(“WhoIs results:”, whois_results) print(bacnet.devices) bacnet.discover(networks=’known’) However, I keep getting the following error: 2025-01-09 14:35:05,917 – INFO | Starting Asynchronous BAC0 version 2024.09.10 (Lite) 2025-01-09 14:35:05,920 – INFO | Using bacpypes3 version 0.0.98 2025-01-09 14:35:05,921 – INFO | Use BAC0.log_level to adjust verbosity of the app. 2025-01-09 14:35:05,921 – INFO | Ex. BAC0.log_level(‘silence’) or BAC0.log_level(‘error’) Traceback (most recent call last): File “C:UsersdmaskeDesktopNew foldertest_bacnet.py”, line 7, in <module> bacnet = BAC0.connect(bbmdAddress=bbmdIP, bbmdTTL=bbmdTTL) # Connect ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File “C:UsersdmaskeAppDataRoamingPythonPython311site-packagesBAC0scriptsLite.py”, line 141, in __init__ self._ping_task.start() File “C:UsersdmaskeAppDataRoamingPythonPython311site-packagesBAC0tasksTaskManager.py”, line 143, in start self.aio_task = asyncio.create_task(self.execute(), name=f”aio{self.name}”) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File “C:Program FilesPython311Libasynciotasks.py”, line 371, in create_task loop = events.get_running_loop() ^^^^^^^^^^^^^^^^^^^^^^^^^ RuntimeError: no running event loop sys:1: RuntimeWarning: coroutine ‘Task.execute’ was never awaited What I Have Tried Running the script with different variations of BAC0.lite() and BAC0.connect(), but the error persists. Verified that my BACnet devices are accessible using Yabe software, where I can register and discover all devices successfully. Experimented with adding an event loop manually, but it didn’t work. Why is asyncio.create_task() failing with RuntimeError: no running event loop? How can I properly connect to a foreign BACnet device using BAC0? Are there any workarounds or configurations I need to change? submitted by /u/werner__heisenberger [link] [comments]
I am trying to connect to a BACnet foreign device using the BAC0 Python library. Below is my script:
import BAC0 print(BAC0.version) bbmdIP = '10.x.y.z:47808' # Replace with actual IP bbmdTTL = 900 bacnet = BAC0.lite(bbmdAddress=bbmdIP, bbmdTTL=bbmdTTL) # Connect print(bacnet.vendorName.strValue) print(bacnet.modelName.strValue) whois_results = bacnet.whois() print("WhoIs results:", whois_results) print(bacnet.devices) bacnet.discover(networks='known')
However, I keep getting the following error:
2025-01-09 14:35:05,917 - INFO | Starting Asynchronous BAC0 version 2024.09.10 (Lite) 2025-01-09 14:35:05,920 - INFO | Using bacpypes3 version 0.0.98 2025-01-09 14:35:05,921 - INFO | Use BAC0.log_level to adjust verbosity of the app. 2025-01-09 14:35:05,921 - INFO | Ex. BAC0.log_level('silence') or BAC0.log_level('error') Traceback (most recent call last): File "C:UsersdmaskeDesktopNew foldertest_bacnet.py", line 7, in <module> bacnet = BAC0.connect(bbmdAddress=bbmdIP, bbmdTTL=bbmdTTL) # Connect ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:UsersdmaskeAppDataRoamingPythonPython311site-packagesBAC0scriptsLite.py", line 141, in __init__ self._ping_task.start() File "C:UsersdmaskeAppDataRoamingPythonPython311site-packagesBAC0tasksTaskManager.py", line 143, in start self.aio_task = asyncio.create_task(self.execute(), name=f"aio{self.name}") ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:Program FilesPython311Libasynciotasks.py", line 371, in create_task loop = events.get_running_loop() ^^^^^^^^^^^^^^^^^^^^^^^^^ RuntimeError: no running event loop sys:1: RuntimeWarning: coroutine 'Task.execute' was never awaited
What I Have Tried Running the script with different variations of BAC0.lite() and BAC0.connect(), but the error persists. Verified that my BACnet devices are accessible using Yabe software, where I can register and discover all devices successfully. Experimented with adding an event loop manually, but it didn’t work. Why is asyncio.create_task() failing with RuntimeError: no running event loop? How can I properly connect to a foreign BACnet device using BAC0? Are there any workarounds or configurations I need to change?
submitted by /u/werner__heisenberger
[link] [comments]