4.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.
plugswitch.py — switch the N100's plug (on, off, status)
~/.venvs/plugmeter/bin/python scripts/bench/plugswitch.py status
~/.venvs/plugmeter/bin/python scripts/bench/plugswitch.py off # only when the N100 is already off
~/.venvs/plugmeter/bin/python scripts/bench/plugswitch.py on
off is not a power-cut button. It refuses (exit 2, with the reason) unless the plug's readings over at least
20 s are all below standby_w + 1 W and the N100 answers no ping. standby_w (0.0, measured 2026-10-13) and
host_ping live in plug.json. Pinned by test_plugswitch.py. Never use it on any other plug.
The N100 does not start when the plug comes back on after a deliberate power-off (2026-10-13,
documentation/audits/poweroff-2026-10-13/): press its power button.
The HP t740 (demo-hp) is on a metered plug too (2026-10-13)
Same tools, --plug hp (config ~/.config/felhom-bench/plug-hp.json, the plug at LAN 192.168.0.107, protocol 3.4,
the HP at 192.168.0.104). plugswitch.py off --plug hp refuses until the HP's switched-off figure (standby_w) is
measured. The wizard reads both plugs from one Tuya account; the credentials are TUYA_DEVICE_ID_N100 and
TUYA_DEVICE_ID_HP (renamed from TUYA_DEVICE_ID by the operator).
plugcut.py — a real power cut, on purpose (2026-10-13 night)
plugswitch.py off stays „not a power-cut button". plugcut.py is the separate tool that cuts a running machine:
~/.venvs/plugmeter/bin/python scripts/bench/plugcut.py --plug hp --off-seconds 10 --i-mean-a-power-cut --log DIR
- Only the plug
hp(the N100's only with--allow-n100); only with--i-mean-a-power-cut; 1–60 s, up to 3600 s only with--long. - Three ways back on: the plug's own countdown (data point 9, sent in the same command as the off, then read back —
not shown running → on at once); a detached watchdog process started before the off (on after off-seconds + 15 s,
survives the tool being killed);
finally:in the tool. - One line per action to stdout and
DIR/plugcut.log. Pinned bytest_plugcut.py(12 tests, each guard red-proofed).