Skip to content

Example code "V2 API Usage" won't run - "no running event loop" #3

@Jaxom99

Description

@Jaxom99

After installing the right versions and inserting my credentials from the EnergyID platform, I try to run the proposed snippet of code (put in the .py file) using :
python3.13 energyid-webhooks.py

And then I could call this script regularly using NodeRED.

But the python command returns an error :

# python3.13 energyid-webhooks.py 
Traceback (most recent call last):
  File "/usr/src/energyid-python/energyid-webhooks.py", line 5, in <module>
    client = WebhookClient(
        provisioning_key="**obfuscated_for_github**",
    ...<4 lines>...
        #reauth_interval=24  # Hours between token refresh
    )
  File "/usr/local/lib/python3.13/site-packages/energyid_webhooks/client_v2.py", line 105, in __init__
    self.session = session or ClientSession()
                              ~~~~~~~~~~~~~^^
  File "/usr/local/lib/python3.13/site-packages/aiohttp/client.py", line 316, in __init__
    loop = loop or asyncio.get_running_loop()
                   ~~~~~~~~~~~~~~~~~~~~~~~~^^
RuntimeError: no running event loop

Am I doing something wrong ? Is this code supposed to be called inside something else ?

Thanks for your insights !

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions