scripts/bench/plugmeter.py prints watts/mA/V/kWh as CSV from the Tuya plug on the LAN (default) or from Home Assistant on demo-hp's guest. 10-minute side by side and a 3-minute control in documentation/audits/plugmeter-2026-10-13/: Home Assistant alone did not move for 3 minutes, so the LAN reader is the measurement source. No key, device id or token in the repo; secrets scan 0 hits with a positive control.
2.3 KiB
scripts/bench — bench tools that run on DooPlex
plugmeter.py — the N100's power meter
The N100 demo box (demo-felhom) is on a Tuya Wi-Fi plug with a power meter. plugmeter.py reads it and
prints CSV (utc_time, watts, milliamps, volts, kwh_total) every --interval seconds (default 2).
~/.venvs/plugmeter/bin/python scripts/bench/plugmeter.py --once # one reading
~/.venvs/plugmeter/bin/python scripts/bench/plugmeter.py --duration 600 > a.csv # 10 minutes
~/.venvs/plugmeter/bin/python scripts/bench/plugmeter.py --source ha --once # through Home Assistant
--source tuya(default) — use this for measurements. It talks to the plug on the home LAN and makes it re-measure on every read; a new value every 2 s. Each value is the plug's previous measurement (it answers a refresh with what it holds), so a row lags by about one interval. About one read in four takes up to 8 s instead of 2 s; the row is late, not lost.--source ha— the backup. Home Assistant on demo-hp's guest (https://ha.enkisfelhom.hu, installed from the Felhom catalog) reads the plug through Tuya's cloud. On its own it did not change for 3 minutes (2026-10-13); it moves only when something makes the plug report — the tuya reader does. It keeps history and graphs. Itsfelhom-benchuser is local-access-only, so the tool connects to the guest's LAN address and still checks the certificate by name.
Setup (done 2026-10-13, documentation/audits/plugmeter-2026-10-13/): a user venv
(python3 -m venv ~/.venvs/plugmeter && ~/.venvs/plugmeter/bin/pip install tinytuya), and the files under
~/.config/felhom-bench/ (700; every file 600): plug.json (device id, local key, address, data points),
ha.json, ha.token, and the tinytuya wizard's output. None of them ever goes into a repo.
kwh_total is the plug's add_ele counter — energy since the plug last reported to the cloud, not a
lifetime total. Use watts × time for energy.
When the plug moves address or is paired again: re-run the tinytuya wizard in ~/.config/felhom-bench/
(credentials TUYA_ID, TUYA_SECRET, TUYA_DEVICE_ID from ~/.config/credentials, region eu) and
update plug.json. Its output prints the key — send it to a file, never to a terminal or a log.