Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BAC0: "RuntimeError: no running event loop" when connecting to a foreign device #513

Open
PramodKumarGH opened this issue Jan 9, 2025 · 0 comments

Comments

@PramodKumarGH
Copy link

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:\Users\dmaske\Desktop\New folder\test_bacnet.py", line 7, in
bacnet = BAC0.connect(bbmdAddress=bbmdIP, bbmdTTL=bbmdTTL) # Connect
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\dmaske\AppData\Roaming\Python\Python311\site-packages\BAC0\scripts\Lite.py", line 141, in init
self._ping_task.start()
File "C:\Users\dmaske\AppData\Roaming\Python\Python311\site-packages\BAC0\tasks\TaskManager.py", line 143, in start
self.aio_task = asyncio.create_task(self.execute(), name=f"aio{self.name}")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\Python311\Lib\asyncio\tasks.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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant