Python API for TP-Link Kasa and Tapo devices
Actively maintained. Last release 2 days ago, commits in 11 of the last 26 weeks. A safe choice.
pip install python-kasapython-kasa
python-kasa is a Python library to control TPLink's smart home devices (plugs, wall switches, power strips, and bulbs).
This is a voluntary, community-driven effort and is not affiliated, sponsored, or endorsed by TPLink.
Contributions in any form (adding missing features, reporting issues, fixing or triaging existing ones, improving the documentation, or device donations) are more than welcome!
Getting started
You can install the most recent release using pip:
pip install python-kasa
Alternatively, you can clone this repository and use uv to install the development version:
git clone https://github.com/python-kasa/python-kasa.git
cd python-kasa/
uv sync --all-extras
uv run kasa
If you have not yet provisioned your device, you can do so using the cli tool.
Discovering devices
Running kasa discover will send discovery packets to the default broadcast address (255.255.255.255) to discover supported devices.
If your device requires authentication to control it,
you need to pass the credentials using --username and --password options or define KASA_USERNAME and KASA_PASSWORD environment variables.
[!NOTE] If your system has multiple network interfaces, you can specify the broadcast address using the
--targetoption.
The discover command will automatically execute the state command on all the discovered devices: