Skip to main content

Python library for communication with Tapo Cameras

Project description

PyTapo

Python library for communication with Tapo Cameras.

Used inside Home Assistant Integration HomeAssistant-Tapo-Control.

Pre-Requirements

  • Python3.13
  • PIP modules installed

Install:

python3 -m pip install pytapo

Usage examples:

Initiate library:

from pytapo import Tapo

user = "" # user you set in Advanced Settings -> Camera Account
password = "" # password you set in Advanced Settings -> Camera Account
host = "" # ip of the camera, example: 192.168.1.52

tapo = Tapo(host, user, password)

print(tapo.getBasicInfo())

Authentication

Depending on your camera model and firmware version, the authentication method varies.

Normally you should be able to authenticate using the "camera account" created via the Tapo App (Settings > Advanced settings > Camera account).

In case of a similar stack trace:

Traceback (most recent call last):
  File "/home/user/Projects/pytapo/pytapo/__init__.py", line 41, in __init__
    self.basicInfo = self.getBasicInfo()
  File "/home/user/Projects/pytapo/pytapo/__init__.py", line 232, in getBasicInfo
    return self.performRequest(
  File "/home/user/Projects/pytapo/pytapo/__init__.py", line 95, in performRequest
    self.ensureAuthenticated()
  File "/home/user/Projects/pytapo/pytapo/__init__.py", line 61, in ensureAuthenticated
    return self.refreshStok()
  File "/home/user/Projects/pytapo/pytapo/__init__.py", line 80, in refreshStok
    raise Exception("Invalid authentication data")
Exception: Invalid authentication data

Attempt to authenticate using admin as user and your TP-Link cloud account password as password.

Downloading Recordings

Integration supports downloading recordings saved on camera's SD card.

See example script. You need to call it with following ENV values:

  • HOST: IP Address of your camera
  • PASSWORD_CLOUD: Tapo cloud account password, it is required to access the recordings, everything is still local
  • OUTPUT: Directory where you wish to save all the recordings
  • DATE: Date for which to download recordings in format of YYYYMMDD, for example 20230221.

You also need to have ffmpeg installed as that is used for converting the streams to watchable file.

Contributions:

Contributions to pytapo are welcomed.

By creating a PR you acknowledge and agree that you are not breaking any TOS, law and/or have a permission to provide and share the code changes.

Owner of this repository is not legally responsible for any PRs or code changes to this project created by 3rd parties.

When you make a new change to the code base, make sure to have 100% unit test coverage, see below for more information about tests.

Test instructions

Set the following environment variables:

PYTAPO_USER - user you set in Advanced Settings -> Camera Account

PYTAPO_PASSWORD - password you set in Advanced Settings -> Camera Account

PYTAPO_IP - ip of the camera, example: 192.168.1.52

Install pre-commit and tox from pip.

Run pre-commit install and pre-commit install -t pre-push.

Then run tox to run all the tests.

Linters are ran on every commit.

Tests are ran on push.

Your camera may do all the actions supported by this library, including, but not limited to, move, change privacy mode and reboot while tests are running. Camera does not format SD card during tests.

After the tests are done, your camera should be in the initial state.

Thank you

FAQ

See https://github.com/JurajNyiri/HomeAssistant-Tapo-Control?tab=readme-ov-file#troubleshooting--faq

Disclaimer

Pytapo is an unofficial module for achieving interoperability with Tapo cameras.

Author is in no way affiliated with Tp-Link or Tapo.

All the api requests used within the library are available and published on the internet (examples linked above) and this module is purely just a wrapper around those https requests.

Author does not guarantee functionality of this library and is not responsible for any damage.

All product names, trademarks and registered trademarks in this repository, are property of their respective owners.

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

pytapo-3.4.15.tar.gz (59.3 kB view details)

Uploaded Source

Built Distribution

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

pytapo-3.4.15-py3-none-any.whl (64.2 kB view details)

Uploaded Python 3

File details

Details for the file pytapo-3.4.15.tar.gz.

File metadata

  • Download URL: pytapo-3.4.15.tar.gz
  • Upload date:
  • Size: 59.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.10.15

File hashes

Hashes for pytapo-3.4.15.tar.gz
Algorithm Hash digest
SHA256 da10bf31c7156abed771ee532f6eaac1532b150f9bc678220a2b4dc74f12cf71
MD5 53cb6c57e7e51f4fba75d23dc2d849bd
BLAKE2b-256 2f1bd5a50539b98ac7a8d137e483bc5739953a53d30eed32c31743e54dbbdbde

See more details on using hashes here.

File details

Details for the file pytapo-3.4.15-py3-none-any.whl.

File metadata

  • Download URL: pytapo-3.4.15-py3-none-any.whl
  • Upload date:
  • Size: 64.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.10.15

File hashes

Hashes for pytapo-3.4.15-py3-none-any.whl
Algorithm Hash digest
SHA256 1d911c904fa39b06f5f5c4488cbed0e0c5951462139a255a2d5f85a33d27e8b7
MD5 c3a98269d024a9d6b5f7c4e90afc8356
BLAKE2b-256 3ae8635aa7b2600b84d1c91f8bd521a5db7bf64c685561830a8be6829e04ca97

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