Wrapper for python-kasa to connect with cloud devices.
Project description
PyKasaCloud
This is a library wrapper that allows you to connect to some TPLink/Kasa/Tapo devices via the cloud utilizing the excellent python-kasa library. Essentially this adds a transport and protocol class to facilitate this. This has not been tested extensively as I only have access to "iot" protocol devices and I'm not sure if other devices utilize passthrough mechanism via the cloud api.
This library was written to support the TPLink Cloud Integration.
Usage
Rather than use discovery like python-kasa you must get connect to the cloud (providing credentials) to obtain a token.
cloud: KasaCloud = await KasaCloud.kasacloud(username="username", password="password")
You can then get a dictionary of devices. The deviceId in the cloud will be the keys and the values will be kasa.Devices.
devices: dict[str, Device] = cloud.getDevices()
You can then interact with these devices like python-kasa devices.
Caching tokens
To cache tokens to a json file, provide a path.
cloud: KasaCloud = await KasaCloud.kasacloud(username="username", password="password", token_storage_file=".kasacloud.json")
Subsequent authenication can be accomplished just using the token_storage_file parameter.
cloud: KasaCloud = await KasaCloud.kasacloud( token_storage_file=".kasacloud.json")
Refesh Token and Callbacks
If you are storing the token externally, say in a HomeAssistant Config Entry simply pass a Token object (inside async_setup_entry in __init__.py of a given integration)
async def update_token(token: Token) -> None:
data = entry.data | {TOKEN: token}
result = hass.config_entries.async_update_entry(
entry=entry, data=data, unique_id=entry.unique_id
)
if not result:
raise TokenUpdateError("Unable to update token in config entry")
try:
cloud: KasaCloud = await KasaCloud.kasacloud(
token=entry.data.get(TOKEN), token_update_callback=update_token
)
except AuthenticationError as err:
raise ConfigEntryAuthFailed(err) from err
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pykasacloud-2025.9.1.tar.gz.
File metadata
- Download URL: pykasacloud-2025.9.1.tar.gz
- Upload date:
- Size: 7.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.28.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
27bed1b8e028c0eeaa2f16ed284e6cf63d0851f5b3737bb450e981ce5e09cee9
|
|
| MD5 |
2955fc3c72413767e9fba69b9f79fc22
|
|
| BLAKE2b-256 |
b6654b04630022cadee2c709c52e480256f35998e145bb8db05050354b0c3a60
|
File details
Details for the file pykasacloud-2025.9.1-py3-none-any.whl.
File metadata
- Download URL: pykasacloud-2025.9.1-py3-none-any.whl
- Upload date:
- Size: 10.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.28.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ac297489ac59f0322cd8eb8b60c868c0e34f5d5e8c21f44d0f173ea92015331c
|
|
| MD5 |
c728d62714c81d026b746385fafc3c96
|
|
| BLAKE2b-256 |
eefbcf22f25ef8f136768d28dcb4cd09a937d0e84a60cc73868bd118d0cd87aa
|