It would be cool to have a complet example code.
E.g. i tried this so far:
from moonraker_api import MoonrakerClient, MoonrakerListener
class APIConnector(MoonrakerListener):
def __init__(self):
self.running = False
self.client = MoonrakerClient(
self,
"yourURL.local",
"7125",
"",
)
async def start(self) -> None:
"""Start the websocket connection."""
self.running = True
return await self.client.connect()
async def stop(self) -> None:
"""Stop the websocket connection."""
self.running = False
await self.client.disconnect()
async def get_printer_info():
api_connector = APIConnector()
await api_connector.start()
response = await api_connector.client.request("printer.info")
return response
printer_info = asyncio.run(get_printer_info())
print(printer_info)
but I always get the error:
response = await api_connector.client.request("printer.info")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: object AwaitableTaskContext can't be used in 'await' expression
Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x0000024C10544290>```
It would be cool to have a complet example code.
E.g. i tried this so far:
but I always get the error: