No description
  • Go 73%
  • Makefile 18%
  • Dockerfile 9%
Find a file
Jonas Heinrich 0a72845fb2
Some checks failed
CI / build (push) Has been cancelled
return complete history
2026-06-29 16:23:25 +02:00
.github Build(deps): Bump actions/checkout from 6 to 7 2026-06-19 16:21:19 +02:00
docs ⚗️ Refactor protocol interaction 2026-05-11 17:20:54 +02:00
pkg return complete history 2026-06-29 16:23:25 +02:00
.gitignore Update .gitignore 2025-01-19 12:32:15 +01:00
.golangci.yaml ⬆️ Use Go 1.26 2026-04-03 17:58:55 +02:00
.openapi-config.yaml ⚗️ Refactor protocol interaction 2026-05-11 17:20:54 +02:00
.pre-commit-config.yaml 👷 Update pre-commit 2025-08-11 01:23:24 +02:00
config.schema.v1.json 📝 Minor documentation update 2026-05-15 22:34:11 +02:00
config.yaml fixes 2026-06-29 16:07:49 +02:00
Dockerfile ⬆️ Use Go 1.26 2026-04-03 17:58:55 +02:00
generator.patch.yaml ⚗️ Refactor protocol interaction 2026-05-11 17:20:54 +02:00
go.mod fixes 2026-06-29 16:07:49 +02:00
go.sum fixes 2026-06-29 16:07:49 +02:00
LICENSE.txt Add license 2022-10-06 07:33:58 +00:00
Makefile updated 2026-06-29 15:03:11 +02:00
README.md updated 2026-06-29 15:03:11 +02:00
VERSION updated 2026-06-29 15:03:11 +02:00

Netzservice SWKA exporter for prometheus

Prometheus exporter for Netzservice-SWKA customer accounts.

Setup

config:
  username: myuser
  password: mypassword

Note: there is JSON schema for configuration here

Run locally

./exporter
ts=2024-02-25T08:18:50.577Z caller=main.go:83 level=info msg="Starting tuya_smartplug_exporter" version="(version=v1.0.0, branch=main, revision=9d0b7b3)" config=config.yaml
ts=2024-02-25T08:18:50.582Z caller=main.go:98 level=info msg="Configured 1 devices"
ts=2024-02-25T08:18:50.583Z caller=tls_config.go:313 level=info msg="Listening on" address=[::]:9999
ts=2024-02-25T08:18:50.583Z caller=tls_config.go:316 level=info msg="TLS is disabled." http2=false address=[::]:9999

Run using docker

docker run -ti -v $(pwd)/config.yaml:/config.yaml:ro ghcr.io/rkosegi/tuya-smartplug-exporter:v1.1.0

Example output

curl --silent localhost:9999/metrics | grep ^tuya
tuya_smartplug_exporter_build_info{branch="main",goarch="amd64",goos="linux",goversion="go1.26.2",revision="96c611a",tags="unknown",version="v1.1.0"} 1
tuya_smartplug_last_scrape_error 0
tuya_smartplug_current{device="livingroom-1"} 0.093
tuya_smartplug_power{device="livingroom-1"} 8.6
tuya_smartplug_scrape_duration_sum{device="livingroom-1"} 73
tuya_smartplug_scrape_duration_count{device="livingroom-1"} 1
tuya_smartplug_total_scrapes_sum 0.62671565
tuya_smartplug_total_scrapes_count 3
tuya_smartplug_voltage{device="livingroom-1"} 242.9
tuya_smartplug_read_packets_total{device="livingroom-1"} 6
tuya_smartplug_sent_packets_total{device="livingroom-1"} 9

Description of metrics

Name Type Description Scope
tuya_smartplug_last_scrape_error Counter Indication of overall error during scrape Global
tuya_smartplug_scrapes_total Summary Overall duration and count of scrapes Global
tuya_smartplug_exporter_build_info Gauge Build info Global
tuya_smartplug_current Gauge Electrical current drawn, in Amperes Device
tuya_smartplug_power Gauge Total power used, in Watts Device
tuya_smartplug_scrape_duration Summary Summary of scrape operation Device
tuya_smartplug_switch_on Gauge Whether the plug is switched on (1 for on, 0 for off) Device
tuya_smartplug_voltage Gauge Electrical voltage, in Volts Device
tuya_smartplug_read_errors_total Counter Total number of read errors Device
tuya_smartplug_read_packets_total Counter Total number of read packets Device
tuya_smartplug_sent_errors_total Counter Total number of sent errors Device
tuya_smartplug_sent_packets_total Counter Total number of sent packets Device

Install using Helm chart to k8s cluster

First, make sure your values are present in file my-values.yaml, then run

helm repo add rkosegi https://rkosegi.github.io/helm-charts/ --force-update
helm upgrade --install rkosegi/generic-exporter --values my-values.yaml

Sample Grafana dashboard

dashboard

Acknowledgment

Portion of client code is inspired by @rkosegi implementation in tuya-smartplug-exporter