python-kasa
Python API for TP-Link Kasa and Tapo devices
What it is and what it does
python-kasa is a community-maintained Python library and CLI tool for discovering and controlling TP-Link Kasa and Tapo smart home devices. It provides both a high-level async API for programmatic control and a command-line interface for direct device management. The library handles device discovery via broadcast, authentication, and feature-based control (turning devices on/off, adjusting brightness, color temperature, and other device-specific settings).
The package is built on async I/O (aiohttp, asyncclick) and supports modern Python versions (3.11+). It works with a wide range of TP-Link hardware including plugs, power strips, wall switches, bulbs, light strips, hubs, and hub-connected devices. The library is not affiliated with TP-Link and relies on community contributions for device support and testing.
Use it for:
- Automate smart plugs and switches in a home network via Python scripts or scheduled tasks.
- Build a dashboard or mobile app that discovers and controls multiple TP-Link devices.
- Integrate TP-Link devices into a broader home automation system (e.g., Home Assistant).
- Query device state (power, brightness, color) and log telemetry for monitoring.
- Provision and configure TP-Link devices programmatically before deployment.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Control TP-Link Kasa and Tapo smart home devices (plugs, switches, bulbs, strips, hubs) over the network via Python or command-line interface.
Yes, if you own TP-Link Kasa or Tapo devices and need to control them from Python or the command line. The library is actively maintained, has low install friction, and covers a broad range of device types. The GPL-3.0-or-later license is permissive for personal and open-source use but requires attention if you plan to distribute proprietary software. No known security vulnerabilities.
Install
python-kasa on PyPI
pip
pip install python-kasauv
uv add python-kasapoetry
poetry add python-kasaInstalling python-kasa
Before you install
Low friction: pure Python wheel with 5 runtime dependencies (aiohttp, asyncclick, cryptography, mashumaro, tzdata). Active maintenance with recent commits; last release 548 days ago but repository shows ongoing development.
License in practice
GPL-3.0-or-later (copyleft): you must share modifications under the same license if you distribute derived work. Acceptable for internal use and open-source projects; check your distribution model before embedding.
Quickstart
pip install python-kasa
import asyncio
from kasa import Discover
async def main():
dev = await Discover.discover_single("192.0.2.123")
await dev.turn_on()
await dev.update()
asyncio.run(main())
Requires Python 3.11 or later; devices must be on the same network or reachable by IP address.
Verify before relying
- Whether authentication (username/password) is required for all device types or only some models.
- Performance and latency characteristics when controlling many devices simultaneously.
- Support status for devices not explicitly listed in the documentation.
Package facts
| License | GPL-3.0-or-later (copyleft) |
| Python support | supports the current Python release (<4.0,>=3.11) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 5 — aiohttp, asyncclick, cryptography, mashumaro, tzdata |
| Maintenance | actively maintained — 548 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 194,598/month — #9,829 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: python_kasa-0.10.2-py3-none-any.whl
Tags
More Networking packages
h11 is a pure-Python HTTP/1.1 protocol…
permissive · top 100 on PyPI
psutilpsutil retrieves real-time information about…
permissive · top 1,000 on PyPI
pyOpenSSLpyOpenSSL wraps OpenSSL's SSL/TLS functionality…
permissive · top 1,000 on PyPI
uvloopuvloop is a drop-in replacement for Python's…
permissive · top 1,000 on PyPI
execnetexecnet lets you spawn and communicate with…
permissive · top 1,000 on PyPI
pyzmqPyZMQ provides Python bindings for ZeroMQ…
permissive · top 1,000 on PyPI
plugp100A Python library for controlling and…
copyleft · top 15,000 on PyPI
tplink-omada-clientA Python client library for interacting with…
permissive · top 15,000 on PyPI
broadlinkA Python module and CLI for discovering,…
permissive · top 15,000 on PyPI
pytapoPyTapo is a Python library that communicates…
permissive · top 15,000 on PyPI
govee-api-laggatControls Govee LED strips and bulbs via the…
permissive · top 15,000 on PyPI
pywizlightA Python library and CLI tool for discovering…
permissive · top 15,000 on PyPI
meross-iotA Python library for controlling Meross IoT…
permissive · top 15,000 on PyPI
dlipowerManages Digital Loggers web-based network power…
permissive · top 15,000 on PyPI
flux-ledControls Magic Home and Surp Life WiFi LED…
copyleft · top 15,000 on PyPI
roombapyroombapy is a Python library for controlling…
permissive · top 15,000 on PyPI