You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have installed all the required libraries, it's maybe because i don't know how the async and await works.. so first thing
import asyncio
from kasa import SmartPlug
from pprint import pformat as pf
plug = SmartPlug("ip of the device")
asyncio.run(plug.update())
await plug.turn_on()
if i do this it says await outside async
if i do this
import asyncio
from kasa import SmartPlug
from pprint import pformat as pf
async def main():
plug = SmartPlug("ip of the device")
asyncio.run(plug.update())
await plug.turn_on()
asyncio.run(main())
it says this
Traceback (most recent call last):
File "d:/Documents/8sem/Project Phase II/new/let's do this/demo.py", line 11, in <module>
asyncio.run(main())
File "C:\Users\ReNew\AppData\Local\Programs\Python\Python38-32\lib\asyncio\runners.py", line 43, in run
return loop.run_until_complete(main)
File "C:\Users\ReNew\AppData\Local\Programs\Python\Python38-32\lib\asyncio\base_events.py", line 612, in run_until_complete
return future.result()
File "d:/Documents/8sem/Project Phase II/new/let's do this/demo.py", line 8, in main
asyncio.run(plug.update())
File "C:\Users\ReNew\AppData\Local\Programs\Python\Python38-32\lib\asyncio\runners.py", line 33, in run
raise RuntimeError(
RuntimeError: asyncio.run() cannot be called from a running event loop
sys:1: RuntimeWarning: coroutine 'SmartDevice.update' was never awaited
I have installed all the required libraries, it's maybe because i don't know how the async and await works.. so first thing
if i do this it says await outside async
if i do this
it says this
can someone help me on how to move forward