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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user