publish eve_local_watcher.py

This commit is contained in:
brockdarnold 2026-06-15 00:24:43 +00:00
parent 65f9a69f01
commit 7c2b2b8c3b

View file

@ -101,8 +101,12 @@ def main():
if tcmd: if tcmd:
pytesseract.pytesseract.tesseract_cmd = tcmd pytesseract.pytesseract.tesseract_cmd = tcmd
poll = cp.getint("local", "poll_secs", fallback=8) if cp.has_section("local") else 8 sec = cp.has_section("local")
cooldown = cp.getint("local", "cooldown_secs", fallback=30) if cp.has_section("local") else 30 poll = cp.getint("local", "poll_secs", fallback=8) if sec else 8
cooldown = cp.getint("local", "cooldown_secs", fallback=180) if sec else 180
# only meaningful in QUIET systems (Solitude etc.); above this it's just noise
max_pop = cp.getint("local", "max_pop", fallback=12) if sec else 12
confirm = cp.getint("local", "confirm_reads", fallback=3) if sec else 3
if "--test" in sys.argv: if "--test" in sys.argv:
region = get_region(cp) region = get_region(cp)
@ -136,15 +140,17 @@ def main():
if prev is None: if prev is None:
prev = count prev = count
print(f"[local] baseline {count} pilots") print(f"[local] baseline {count} pilots")
elif count > max_pop:
prev = count # busy system — track, never alert
pending, pend_n = None, 0
elif count > prev: elif count > prev:
# confirm over 2 reads to shrug off OCR jitter # require the higher count to persist across `confirm` reads (OCR jitter)
pend_n = pend_n + 1 if pending == count else 1 pend_n = pend_n + 1 if pending == count else 1
pending = count pending = count
if pend_n >= 2 and now - last_alert > cooldown: if pend_n >= confirm and now - last_alert > cooldown:
w.notify(cp, "Someone entered Local", w.notify(cp, "Someone entered Local",
f"+{count - prev} in Local — {count} pilots now (was {prev}). " f"+{count - prev} in Local — {count} pilots now (was {prev}). "
"Check d-scan / watch for a visitor on your field.", "Check d-scan.", priority="high", tags="eyes")
priority="high", tags="eyes,warning")
last_alert = now last_alert = now
prev = count prev = count
pending, pend_n = None, 0 pending, pend_n = None, 0