Local energy monitoring • Tuya • Python • FastAPI

Energy monitoring without the cloud

A fully local real-time energy monitoring system for Tuya smart relays: power, voltage, current, power factor, energy and billing — live via WebSocket, all data on your own machine.

measured in real time

What it tracks

Six parameters with historical graphs (today, yesterday, month, year, custom range) and live updates via WebSocket push.

Power
0–3600 W
Real-time active power with peak detection over a configurable sliding window
🔌
Voltage
230 V
Mains voltage monitoring with warning and alert thresholds
📊
Current
0–16 A
Instantaneous current with peak value over the last N samples
📉
Power Factor
0–1
Ratio of active to apparent power — read directly from device firmware
Energy
kWh
Accumulated energy for any period: today, month, year or custom range
💰
Bill
₴ € $
Automatic cost calculation with single-zone or two-zone (day/night) tariff

interface

What it looks like

A real-time monitoring dashboard — dark theme, responsive design, works on any screen.

Power Trace real-time energy monitoring dashboard
What the dashboard can do →

under the hood

How it works

All components run locally — no cloud services required.

🔌
Tuya Relay
Atorch GR2PWS
🐍
Collector
collector.py
💾
SQLite
WAL mode
FastAPI
api.py
🌐
Browser
WebSocket
📡 Push, not polling — the device physically ticks every ~60 s. This is a hardware MCU firmware limit, not our delay. The collector listens for spontaneous packets via a persistent socket.
WebSocket live — the browser receives real-time updates via WS push from the server. HTTP fallback polling (every 5 s) starts automatically if the WebSocket fails to connect or drops.
💾 SQLite + WAL — local database, no external services. All data stays on your PC or Raspberry Pi.
🌐 Remote access via Tailscale — built into Settings, no backend changes required since the API already binds to 0.0.0.0.
🧭 Watchdog — a supervisor process keeps the collector and API alive, restarting either one if it crashes, and shuts both down cleanly on exit.
🔍 On-demand analysis — a built-in engine turns raw telemetry into a structured report with plain-language insights, generated on request.

on demand

Built-in analysis engine

One click turns raw telemetry into a structured report with plain-language insights.

Health Key Insights Grid Quality Input Capacity Load Analysis Power Factor Energy Consumption System State Events Detective Engine Data Coverage
“Source impedance measured at 0.42 Ohm — the voltage dips you are seeing start in your own wiring, not out on the grid.”
How the analysis engine works →

quick start

Getting started

Three steps to full energy monitoring.

1
⬇ Download
Download the installer for Windows or Linux from the Releases page. No Python, no dependencies, nothing to build.
Download →
2
⚙ Configure Tuya
Register on Tuya IoT Platform, create a project and get your Access ID, Secret and device Local Key.
How to do it →
3
▶ Run
Launch Power Trace — it starts the collector and API for you. Open localhost:8000 in your browser and configure in Settings.
Settings →

documentation

Guides

Step-by-step guides for every part of the setup.