Skip to main content

A Python library for Tapo sockets.

Project description

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

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

taposockets-1.2.0.tar.gz (5.1 kB view hashes)

Uploaded Source

Built Distribution

taposockets-1.2.0-py3-none-any.whl (5.8 kB view hashes)

Uploaded Python 3

Supported by

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