FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [View Raw Code]   [Original HTTPS Page]

python-kasa/docs/source/codeinfo.md at patch · Partha-dev01/python-kasa · GitHub

Repository navigation

Latest commit

 

History

History
26 lines (22 loc) · 872 Bytes
  1. python-kasa
  2. docs
  3. source

codeinfo.md

File metadata and controls

26 lines (22 loc) · 872 Bytes

:::{note} The library is fully async and methods that perform IO need to be run inside an async coroutine. Code examples assume you are following them inside asyncio REPL:

    $ python -m asyncio

Or the code is running inside an async function:

import asyncio
from kasa import Discover

async def main():
    dev = await Discover.discover_single("127.0.0.1",username="un@example.com",password="pw")
    await dev.turn_on()
    await dev.update()

if __name__ == "__main__":
    asyncio.run(main())

All of your code needs to run inside the same event loop so only call asyncio.run once.

The main entry point for the API is {meth}~kasa.Discover.discover and {meth}~kasa.Discover.discover_single which return Device objects. Most newer devices require your TP-Link cloud username and password, but this can be omitted for older devices. :::


Back | FazBrowse Home | New Git URL