current commit
210510.2 · bin: tweak voltage thresholds
#!/usr/bin/env python

import csv
import json
import time

LOG_CSV_FILE = '/m/data/home/sense/realtime.csv'
TIME_WINDOW_SECONDS = 90 * 60

VOLTAGE_DIFF_THRESHOLD = 5.0
VOLTAGE_MAX_THRESHOLD = 252.9

if __name__ == '__main__':
    now = time.time()
    with open(LOG_CSV_FILE) as f:
        for row in csv.DictReader(f):
            if now - float(row['ts']) > TIME_WINDOW_SECONDS:
                continue
            total = float(row['volt'])
            v1 = float(row['volt1'])
            v2 = float(row['volt2'])
            diff = abs(v1 - v2)
            if diff >= VOLTAGE_DIFF_THRESHOLD:
                print(f'voltage difference {diff} is high')
            if total >= VOLTAGE_MAX_THRESHOLD:
                print(f'combined voltage {total} is high')