Skip to main content

Taposockets

A python library for accessing Tapo smart sockets

Install required libraries

pip install taposocket

Required plugin for pre-commit hook

pre-commit install --hook-type pre-commit --hook-type pre-push

Test the code

pytest -s -v test.py

Other required tools

docker and docker-compose

Usage

import os
from dotenv import load_dotenv

from taposockets import P100, P115


if __name__ == "__main__":
    load_dotenv()
    p100 = P100(os.environ.get("address"), os.environ.get("user"), os.environ.get("password"))
    p115 = P115(os.environ.get("address"), os.environ.get("user"), os.environ.get("password"))

    p100.turn_on()
    p100.turn_off()
    p100.toggle_state()

    p100.turn_on_with_delay(10)
    p100.turn_off_with_delay(10)

    print(p100.get_device_info())
    print(p100.get_device_name())
    print(p115.get_energy_usage())

Start metrics services (Prometheus + Grafana + custom metrics server)

cd metrics && docker-compose up

Example of IP and Port for used services

http://192.168.2.169:3010 # Grafana
http://192.168.2.169:9090 # Prometheus
http://192.168.2.169:8989 # Custom Prometheus Metrics
Set datasource as promethues
Fig.1 - Set prometheus as datasource


Import dashboard from json
Fig.2 - Import dashboard json


Check promethues for metrics
Fig.3 - Check promethues for metrics


Example metrics
Fig.4 - Example prometheus custom metrics


Final Dashboard
Fig.5 - Dashboard

Metadata

Release files for taposockets 1.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for taposockets 1.2.0
File Size Uploaded
taposockets-1.2.0.tar.gz 5.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for taposockets 1.2.0
File Interpreter ABI Platform
taposockets-1.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 10.8 kB

Release files / taposockets-1.2.0.tar.gz

Download URL taposockets-1.2.0.tar.gz
Size 5.1 kB
Tags Source
SHA-256 checksum
How to use checksums
370805a53d326ff33c6b97454279dc3ab51255397700a0650914a1653eb59f9b
BLAKE2b-256 checksum
How to use checksums
7169d17a7ca2d3f62a81baec22a962eedb34b13a6f07c7e7b0be0611469c1b29
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.7

Release files / taposockets-1.2.0-py3-none-any.whl

Download URL taposockets-1.2.0-py3-none-any.whl
Size 5.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
01ef190cff22194c4180fc9627cfb1ee0d791c4d070a018bb84baaf63b89fdb5
BLAKE2b-256 checksum
How to use checksums
4546f5d9d9d11e55a178134794a0355110ea52b54df646fe7f9d218f467991e5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.7

Release history Release notifications | RSS feed

This release

1.2.0 This release

2 release files

1.1.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page