On HAOS, I have pyscript installed, and I am trying to test making an api call to Wolfram Alpha in python. The code works fine in a normal environment:
import wolframalpha
@service
def WolframAlphaTest():
wolframalpha_client = wolframalpha.Client('API-KEY')
response = wolframalpha_client.query("What is the melting point of iron?")
log.info(next (response.results).text)
However, in HA, it gives me an error:
Exception in <file.wolframalpha_test.WolframAlphaTest> line 6: response = await wolframalpha_client.query(“What is the melting point of iron?”) ^ RuntimeError: asyncio.run() cannot be called from a running event loop
I’ve tried using async and await with asyncio, but haven’t had any luck there either, assuming I’m using those correctly.
import asyncio
import wolframalpha
@service
async def WolframAlphaTest():
wolframalpha_client = wolframalpha.Client('API_KEY')
response = await wolframalpha_client.query("What is the melting point of iron?")
answer = next(response.results).text
log.info(answer)
Any help would be appreciated!