Registry / communication / python-kasa

python-kasa

JSON →
library0.10.2pypypi✓ verified 86d ago

Python API for TP-Link Kasa and Tapo smart home devices. Version 0.10.2 supports bulbs, plugs, switches, hubs, cameras, robot vacuums, and more. Active development with frequent releases.

pip install python-kasa
INSTALL
IMPORT
SIG · PYTHON-KASA
P
python-kasa
communicationpythonv0.10.2
Install
6.2s avg
Import
1174ms
Disk
51MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.7.7 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 1.202s · 55.4MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 6.2s · import 1.146s · 57MB
51MB installed
● package 51MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Discover
from kasa import Discover
from kasa.discover import Discover
Discover is exposed at the top-level kasa module since v0.4.0
Device
from kasa import Device
from kasa.device import Device
Device is exposed at the top-level kasa module
SmartDevice
from kasa import SmartDevice
from kasa.smart import SmartDevice
SmartDevice is exported from kasa directly

Discover all Kasa/Tapo devices on the network using credentials.

import asyncio from kasa import Discover, Credentials async def main(): creds = Credentials(username='email@example.com', password='password123') devices = await Discover.discover(credentials=creds) for ip, dev in devices.items(): print(f'{ip}: {dev.alias} ({dev.model})') asyncio.run(main())
kasa --version
Debug
Known issues
breakingPython 3.11 is now required (requires_python >=3.11). Python 3.9 and 3.10 no longer supported.
fix
Upgrade Python to 3.11 or later.
affects: >=0.10.0
breakingTapo cloud credentials are required for newer Tapo devices (Tapo protocol). Old Kasa devices may also need credentials depending on firmware. `Discover.discover()` with no credentials will find fewer devices.
fix
Pass a `Credentials` object with email and password to `Discover.discover()`.
affects: >=0.7.0
gotchaAsynchronous API: all methods are async. You must use `asyncio.run()` or await inside an async context.
fix
Wrap code in `async def main(): ... asyncio.run(main())`.
affects: all
deprecatedDirect import from `kasa.smart` or `kasa.iot` submodules is discouraged. Use top-level `kasa.SmartDevice` or `kasa.IotDevice` instead.
fix
Import from `kasa` directly: `from kasa import SmartDevice`.
affects: >=0.8.0
gotchaDevice update may fail if a child device (e.g., plug on a hub) reports unsupported data. Ensure you run the latest version.
fix
Upgrade to >=0.8.1.
affects: <0.8.1
Errors
Common errors & fixes
AttributeError: module 'kasa' has no attribute 'Discover'
Importing from a wrong location or using too old version (<0.4.0).
fix
Use `from kasa import Discover` and upgrade python-kasa: `pip install --upgrade python-kasa`.
RuntimeError: asyncio.run() cannot be called from a running event loop
Trying to run async code inside an already running loop (e.g., Jupyter or script already async).
fix
Use `await` directly if already in async context, or use `nest_asyncio.apply()` for Jupyter.
kasa.exceptions.SmartDeviceException: Authentication failed
Invalid credentials or Tapo account has two-factor authentication enabled.
fix
Ensure credentials are correct and use an app password if 2FA is on. For some devices, use the local IP-based discovery without credentials.
kasa.exceptions.TimeoutError: Timed out
Device not reachable on the network or firewall blocking.
fix
Verify device IP and network connectivity. Ensure you are on the same subnet.
Upgrade
Version history
0.10.2latest on PyPI · released Feb 12, 2025
Audit
Dependencies
aiohttprequiredAsynchronous HTTP client for Tapo protocol
cryptographyrequiredEncryption used for Tapo device communication
Agent activity
26 hits · last 30 days
node
24
OpenAI (training)
1
Resources
python-kasa — pip install python-kasa · libregistry