From 963148e2fa98eaff81b4f0f87eb6e34f78daf178 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sven=20H=C3=B6xter?= Date: Mon, 14 Apr 2025 15:06:39 +0200 Subject: [PATCH] Introduce panelPrint for printing Panel/System Data Along the way we make sure that a status query does not alert the state. --- home/portalmonitor.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/home/portalmonitor.py b/home/portalmonitor.py index 20d327c..ccaa2fb 100755 --- a/home/portalmonitor.py +++ b/home/portalmonitor.py @@ -100,6 +100,11 @@ def stateCheck(newState, stateFile): return change +def panelPrint(currentPower): + print(f"Total Power: {currentPower[0]}") + for panel in currentPower[1]: + print(f"{panel['SNALIAS']}: {panel['POWER']} - {panel['SITETIME']}") + # read configuration file conf = configparser.ConfigParser() @@ -113,14 +118,16 @@ if isDaylight(conf['config'].getfloat('lat'), conf['config'].getfloat('lon'), conf['config']['stationId']) if args.printStatus: - print(f"Total Power: {currentPower[0]}") - for panel in currentPower[1]: - print(f"{panel['SNALIAS']}: {panel['POWER']} - {panel['SITETIME']}") + panelPrint(currentPower) + sys.exit(0) - if currentPower == 0: + if currentPower[0] == 0: if stateCheck('FAILED', conf['config']['stateFile']): print('Error: Power dropped to 0 but we should have daylight!') + panelPrint(currentPower) sys.exit(1) else: if stateCheck('OK', conf['config']['stateFile']): - print(f"Resolved: Inverter reports {currentPower}W") + print('Resolved') + panelPrint(currentPower) + sys.exit(0) \ No newline at end of file -- 2.39.5