Files
felhom.eu/scripts/bench/README.md
T
admin b4dcf4b373
gates / gates (push) Successful in 6m35s
Power-off spike (Part A) on the N100: plugswitch, wall-power figures, the hub's view
plugswitch.py refuses 'off' unless 20 s of readings show the N100 is already off (standby + 1 W,
no ping); 7 tests, each check red-proofed. By hand: guest shutdown 12 s, host off, 0.0 W; the hub
stayed silent and 'ONLINE' for 18 min; plug off/on did not start the N100, its power button did
(dashboard in 42 s). Wall figures into SIZING.md 4 and sizing.json power (8.5 / 20.7 / 0.0 W).
2026-10-13 19:15:08 +02:00

3.0 KiB
Raw Blame History

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. Its felhom-bench user 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.