Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

LB100 unable to turn on or off the lights #68

Copy link
Copy link
@shnkreddy98

Description

@shnkreddy98
Issue body actions

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

can someone help me on how to move forward

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.