j4v3l/tapo-exporter

By j4v3l

Updated 10 months ago

Grafana, Prometheus and InfluxDB exporter for Tp-Link Tapo smart devices

Buildkit cache
Image
Networking
Monitoring & observability
Web analytics
0

6.5K

j4v3l/tapo-exporter repository overview

Tapo Exporter

CI/CD Pipeline Docker Build Docker Pulls Docker Stars License: MIT

A Grafana, Prometheus and InfluxDB exporter for Tapo smart devices. This container automatically collects metrics from your Tapo smart plugs and makes them available for monitoring and visualization.

Quick Start

Docker Run
# Create a .env file
cat > .env << EOL
# Number of devices to monitor
TAPO_DEVICE_COUNT=1

# Device 1 configuration (P110)
TAPO_DEVICE_1_NAME="Living Room"
TAPO_DEVICE_1_TYPE="p110"
TAPO_DEVICE_1_IP="192.168.1.100"
TAPO_DEVICE_1_EMAIL="[email protected]"
TAPO_DEVICE_1_PASSWORD="your_password"

# InfluxDB Configuration (optional)
INFLUXDB_URL=http://influxdb:8086
INFLUXDB_TOKEN=your_influxdb_token
INFLUXDB_ORG=tapo
INFLUXDB_BUCKET=tapo

# Logging Configuration
LOG_LEVEL=INFO
LOG_DIR=/var/log/tapo
EOL

# Run the container
docker run -d \
  --name tapo-exporter \
  -p 8000:8000 \
  -v $(pwd)/.env:/app/.env \
  -v /var/log/tapo:/var/log/tapo \
  j4v3l/tapo-exporter:latest
Docker Compose

Create a docker-compose.yml file:

version: '3.8'

services:
  tapo-exporter:
    image: j4v3l/tapo-exporter:latest
    container_name: tapo-exporter
    ports:
      - "8000:8000"
    volumes:
      - ./.env:/app/.env
      - /var/log/tapo:/var/log/tapo
    restart: unless-stopped

  prometheus:
    image: prom/prometheus:latest
    container_name: prometheus
    ports:
      - "9090:9090"
    volumes:
      - ./prometheus.yml:/etc/prometheus/prometheus.yml
    restart: unless-stopped

  grafana:
    image: grafana/grafana:latest
    container_name: grafana
    ports:
      - "3000:3000"
    volumes:
      - grafana-data:/var/lib/grafana
    restart: unless-stopped

  influxdb:
    image: influxdb:2.0
    container_name: influxdb
    ports:
      - "8086:8086"
    volumes:
      - influxdb-data:/var/lib/influxdb2
    environment:
      - DOCKER_INFLUXDB_INIT_MODE=setup
      - DOCKER_INFLUXDB_INIT_USERNAME=admin
      - DOCKER_INFLUXDB_INIT_PASSWORD=your_password
      - DOCKER_INFLUXDB_INIT_ORG=tapo
      - DOCKER_INFLUXDB_INIT_BUCKET=tapo
    restart: unless-stopped

volumes:
  grafana-data:
  influxdb-data:

Create a prometheus.yml file:

global:
  scrape_interval: 15s

scrape_configs:
  - job_name: 'tapo'
    static_configs:
      - targets: ['tapo-exporter:8000']

Start the stack:

docker-compose up -d

Configuration

Environment Variables
VariableDescriptionRequiredDefault
TAPO_DEVICE_COUNTNumber of devices to monitorYes-
TAPO_DEVICE_X_NAMEName of device XYes-
TAPO_DEVICE_X_TYPEType of device X (p110/p115)Yes-
TAPO_DEVICE_X_IPIP address of device XYes-
TAPO_DEVICE_X_EMAILEmail for device XYes-
TAPO_DEVICE_X_PASSWORDPassword for device XYes-
INFLUXDB_URLInfluxDB URLNo-
INFLUXDB_TOKENInfluxDB tokenNo-
INFLUXDB_ORGInfluxDB organizationNotapo
INFLUXDB_BUCKETInfluxDB bucketNotapo
LOG_LEVELLogging levelNoINFO
LOG_DIRLog directoryNo/var/log/tapo
Supported Devices
  • P110 Smart Plug
  • P115 Smart Plug

Accessing the Services

Metrics

The exporter collects the following metrics:

  • Power consumption (watts)
  • Voltage (volts)
  • Current (amps)
  • Energy usage (watt-hours)
  • Runtime statistics
  • Device protection status
  • WiFi signal strength

Support

For issues and feature requests, please visit our GitHub repository.

License

MIT License

Tag summary

Content type

Buildkit_cache

Digest

sha256:ecd6ebadb

Size

568.5 MB

Last updated

10 months ago

docker pull j4v3l/tapo-exporter:buildcache