Skip to main content

Wrapper for python-kasa to connect with cloud devices.

Project description

PyKasaCloud

GitHub Release

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.

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pykasacloud-2025.7.12.tar.gz (7.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pykasacloud-2025.7.12-py3-none-any.whl (10.0 kB view details)

Uploaded Python 3

File details

Details for the file pykasacloud-2025.7.12.tar.gz.

File metadata

  • Download URL: pykasacloud-2025.7.12.tar.gz
  • Upload date:
  • Size: 7.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.28.1

File hashes

Hashes for pykasacloud-2025.7.12.tar.gz
Algorithm Hash digest
SHA256 630f7e1190053961fe4ddb7be5403630a7fd949b5ae58f3fee1895e54f88a173
MD5 c1192816aacdef00e7c15060f6a69b1f
BLAKE2b-256 07c63fb9ada94203fb39edc4abb73bc8f634b01d4e1534e496ed661d2794763d

See more details on using hashes here.

File details

Details for the file pykasacloud-2025.7.12-py3-none-any.whl.

File metadata

File hashes

Hashes for pykasacloud-2025.7.12-py3-none-any.whl
Algorithm Hash digest
SHA256 7dcff7ad65eedee4d0ef5c811ffd5c4bb826deeb11d2ae2b61f329630973d7be
MD5 3d959a04ff30f0053c004b7292b06478
BLAKE2b-256 f559d242a3c38afe763e25a070c1c6f8f84232be71ed2c5638b1bbf7856f9b94

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page