Bench: --plug hp — the HP t740 (demo-hp) is on a metered plug too
gates / gates (push) Successful in 6m51s
gates / gates (push) Successful in 6m51s
plugmeter.py and plugswitch.py take --plug n100|hp (plug.json / plug-hp.json, outside the repo). The HP plug read 23-33 W while the box started its three guests.
This commit is contained in:
@@ -46,3 +46,10 @@ update `plug.json`. Its output prints the key — send it to a file, never to a
|
||||
|
||||
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).
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
~/.venvs/plugmeter/bin/python scripts/bench/plugmeter.py --once
|
||||
~/.venvs/plugmeter/bin/python scripts/bench/plugmeter.py --duration 600 > run.csv
|
||||
~/.venvs/plugmeter/bin/python scripts/bench/plugmeter.py --source ha --once
|
||||
~/.venvs/plugmeter/bin/python scripts/bench/plugmeter.py --plug hp --once # the HP t740 (demo-hp)
|
||||
|
||||
CSV columns: utc_time, watts, milliamps, volts, kwh_total.
|
||||
|
||||
@@ -28,6 +29,8 @@ never printed. Secrets live only in ~/.config/felhom-bench/ (700/600), never in
|
||||
import argparse, datetime, http.client, json, os, socket, ssl, sys, time
|
||||
|
||||
CONF = os.path.expanduser('~/.config/felhom-bench')
|
||||
# --plug: which machine's plug (2026-10-13: the N100 on plug.json, the HP t740 on plug-hp.json).
|
||||
PLUG_FILES = {'n100': 'plug.json', 'hp': 'plug-hp.json'}
|
||||
|
||||
|
||||
def log(msg):
|
||||
@@ -39,9 +42,9 @@ def now():
|
||||
|
||||
|
||||
class TuyaSource:
|
||||
def __init__(self):
|
||||
def __init__(self, plug='n100'):
|
||||
import tinytuya
|
||||
c = json.load(open(os.path.join(CONF, 'plug.json')))
|
||||
c = json.load(open(os.path.join(CONF, PLUG_FILES[plug])))
|
||||
self.dps = c['dps']
|
||||
self.dev = tinytuya.OutletDevice(c['id'], c['ip'], c['key'], version=float(c['version']))
|
||||
self.dev.set_socketTimeout(5)
|
||||
@@ -119,9 +122,10 @@ def main():
|
||||
ap.add_argument('--interval', type=float, default=2.0, help='seconds between reads (default 2)')
|
||||
ap.add_argument('--duration', type=float, default=0, help='seconds to run; 0 = until stopped')
|
||||
ap.add_argument('--once', action='store_true', help='one read, then exit (rc 1 if it failed)')
|
||||
ap.add_argument('--plug', choices=sorted(PLUG_FILES), default='n100', help='which machine (tuya source only)')
|
||||
a = ap.parse_args()
|
||||
|
||||
src = TuyaSource() if a.source == 'tuya' else HASource()
|
||||
src = TuyaSource(a.plug) if a.source == 'tuya' else HASource()
|
||||
print('utc_time,watts,milliamps,volts,kwh_total', flush=True)
|
||||
start = time.monotonic()
|
||||
fails = 0
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
~/.venvs/plugmeter/bin/python scripts/bench/plugswitch.py status
|
||||
~/.venvs/plugmeter/bin/python scripts/bench/plugswitch.py off
|
||||
~/.venvs/plugmeter/bin/python scripts/bench/plugswitch.py on
|
||||
~/.venvs/plugmeter/bin/python scripts/bench/plugswitch.py status --plug hp # the HP t740's plug
|
||||
|
||||
Reads ~/.config/felhom-bench/plug.json (the same file plugmeter.py reads). `off` also needs, in that file:
|
||||
"standby_w": the plug's measured reading with the machine powered off (the A2 figure);
|
||||
@@ -18,14 +19,14 @@ The key and the device id are never printed. Pinned by scripts/bench/test_plugsw
|
||||
"""
|
||||
import json, os, subprocess, sys, time
|
||||
|
||||
CONF = os.path.expanduser('~/.config/felhom-bench/plug.json')
|
||||
PLUG_FILES = {'n100': 'plug.json', 'hp': 'plug-hp.json'} # --plug, as plugmeter.py
|
||||
WINDOW_S = 20
|
||||
STEP_S = 2
|
||||
MARGIN_W = 1.0
|
||||
|
||||
|
||||
def load():
|
||||
return json.load(open(CONF))
|
||||
def load(plug='n100'):
|
||||
return json.load(open(os.path.expanduser('~/.config/felhom-bench/' + PLUG_FILES[plug])))
|
||||
|
||||
|
||||
def device(c):
|
||||
@@ -71,11 +72,14 @@ def off_allowed(samples, standby_w, window_s=WINDOW_S):
|
||||
|
||||
|
||||
def main(argv):
|
||||
plug = 'n100'
|
||||
if len(argv) == 4 and argv[2] == '--plug' and argv[3] in PLUG_FILES:
|
||||
plug, argv = argv[3], argv[:2]
|
||||
if len(argv) != 2 or argv[1] not in ('on', 'off', 'status'):
|
||||
print('usage: plugswitch.py on|off|status', file=sys.stderr)
|
||||
print('usage: plugswitch.py on|off|status [--plug n100|hp]', file=sys.stderr)
|
||||
return 64
|
||||
cmd = argv[1]
|
||||
c = load()
|
||||
c = load(plug)
|
||||
dev = device(c)
|
||||
if cmd == 'status':
|
||||
w, on = read_watts(dev, c)
|
||||
|
||||
Reference in New Issue
Block a user