add stall detection + auto-start OCR if snipped
This commit is contained in:
parent
9dc07adaea
commit
18d5a23bac
1 changed files with 30 additions and 9 deletions
37
install.ps1
37
install.ps1
|
|
@ -197,11 +197,16 @@ def run_ocr(cp):
|
||||||
alert_pct = cp.getfloat("watcher", "alert_pct", fallback=95.0)
|
alert_pct = cp.getfloat("watcher", "alert_pct", fallback=95.0)
|
||||||
reset_pct = cp.getfloat("watcher", "reset_pct", fallback=50.0)
|
reset_pct = cp.getfloat("watcher", "reset_pct", fallback=50.0)
|
||||||
cooldown = cp.getint("watcher", "cooldown_secs", fallback=120)
|
cooldown = cp.getint("watcher", "cooldown_secs", fallback=120)
|
||||||
|
# stall = hold not growing -> lasers/drones stopped (depleted rock, idle drones)
|
||||||
|
stall_secs = cp.getint("watcher", "stall_secs", fallback=150)
|
||||||
|
|
||||||
print(f"[ocr] watching region={region} every {poll}s; "
|
print(f"[ocr] watching region={region} every {poll}s; "
|
||||||
f"alert>={alert_pct}% reset<{reset_pct}%")
|
f"alert>={alert_pct}% reset<{reset_pct}% stall>{stall_secs}s")
|
||||||
armed = True
|
armed = True
|
||||||
last_alert = 0.0
|
last_alert = 0.0
|
||||||
|
last_cur = -1
|
||||||
|
last_grow = time.time()
|
||||||
|
last_stall_alert = 0.0
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
img = grab_region(region)
|
img = grab_region(region)
|
||||||
|
|
@ -213,11 +218,23 @@ def run_ocr(cp):
|
||||||
print(f"[ocr] {cur}/{cap} m3 ({pct:.1f}%) armed={armed}")
|
print(f"[ocr] {cur}/{cap} m3 ({pct:.1f}%) armed={armed}")
|
||||||
if pct < reset_pct:
|
if pct < reset_pct:
|
||||||
armed = True
|
armed = True
|
||||||
|
# --- still mining? (hold should be growing) ---
|
||||||
|
if cur > last_cur:
|
||||||
|
last_grow = time.time()
|
||||||
|
last_cur = cur
|
||||||
|
if pct < alert_pct - 1 and time.time() - last_grow > stall_secs \
|
||||||
|
and time.time() - last_stall_alert > cooldown:
|
||||||
|
notify(cp, "Mining stopped?",
|
||||||
|
f"Hold hasn't grown in {stall_secs}s at {pct:.0f}% — rock "
|
||||||
|
f"depleted, drones idle, or lasers offlined? Check.",
|
||||||
|
priority="high", tags="warning")
|
||||||
|
last_stall_alert = time.time()
|
||||||
|
# --- hold full ---
|
||||||
if armed and pct >= alert_pct and \
|
if armed and pct >= alert_pct and \
|
||||||
time.time() - last_alert > cooldown:
|
time.time() - last_alert > cooldown:
|
||||||
notify(cp, "Retriever ore hold full",
|
notify(cp, "Hold full — compress",
|
||||||
f"Ore hold at {pct:.0f}% ({cur:,}/{cap:,} m3). "
|
f"Hold at {pct:.0f}% ({cur:,}/{cap:,} m3). "
|
||||||
f"Stop mining / unload.")
|
f"Compress / unload / swap.")
|
||||||
armed = False
|
armed = False
|
||||||
last_alert = time.time()
|
last_alert = time.time()
|
||||||
else:
|
else:
|
||||||
|
|
@ -579,9 +596,10 @@ if (-not (Test-Path (Join-Path $dir "config.ini"))) {
|
||||||
[watcher]
|
[watcher]
|
||||||
mode = ocr
|
mode = ocr
|
||||||
poll_secs = 10
|
poll_secs = 10
|
||||||
alert_pct = 95
|
alert_pct = 90
|
||||||
reset_pct = 50
|
reset_pct = 50
|
||||||
cooldown_secs = 120
|
cooldown_secs = 120
|
||||||
|
stall_secs = 150
|
||||||
|
|
||||||
[ntfy]
|
[ntfy]
|
||||||
server = https://ntfy.sh
|
server = https://ntfy.sh
|
||||||
|
|
@ -615,9 +633,12 @@ ore_hold_m3 = 50000
|
||||||
yield_m3_per_min = 0
|
yield_m3_per_min = 0
|
||||||
|
|
||||||
"@ | Set-Content -Path (Join-Path $dir "config.ini") -Encoding UTF8
|
"@ | Set-Content -Path (Join-Path $dir "config.ini") -Encoding UTF8
|
||||||
Write-Host "config.ini created. ntfy topic: $topic" } else { Write-Host "config.ini kept." }
|
Write-Host "config.ini created. ntfy topic: $topic" } else { Write-Host "config.ini kept (existing)." }
|
||||||
if (-not (Get-Command python -ErrorAction SilentlyContinue)) { winget install --id Python.Python.3.12 -e --silent --accept-package-agreements --accept-source-agreements; $env:Path=[Environment]::GetEnvironmentVariable("Path","Machine")+";"+[Environment]::GetEnvironmentVariable("Path","User") }
|
if (-not (Get-Command python -ErrorAction SilentlyContinue)) { winget install --id Python.Python.3.12 -e --silent --accept-package-agreements --accept-source-agreements; $env:Path=[Environment]::GetEnvironmentVariable("Path","Machine")+";"+[Environment]::GetEnvironmentVariable("Path","User") }
|
||||||
python -m pip install --quiet windows-toasts 2>$null
|
python -m pip install --quiet windows-toasts mss pillow pytesseract 2>$null
|
||||||
Get-Process pythonw -ErrorAction SilentlyContinue | Stop-Process -ErrorAction SilentlyContinue
|
Get-Process pythonw -ErrorAction SilentlyContinue | Stop-Process -ErrorAction SilentlyContinue
|
||||||
foreach ($w in "eve_combat_watcher.py","eve_chat_watcher.py") { Start-Process pythonw -ArgumentList "`"$dir\$w`"" -WorkingDirectory $dir -WindowStyle Hidden; Write-Host "started $w" }
|
$ws = @("eve_combat_watcher.py","eve_chat_watcher.py")
|
||||||
|
if ((Get-Content (Join-Path $dir "config.ini")) -match "^region\s*=\s*\S") { $ws += "eve_orehold_watcher.py" }
|
||||||
|
foreach ($w in $ws) { Start-Process pythonw -ArgumentList "`"$dir\$w`"" -WorkingDirectory $dir -WindowStyle Hidden; Write-Host "started $w" }
|
||||||
Write-Host ""; Write-Host "Done. Watchers running -> phone + Discord. ntfy topic: $topic"
|
Write-Host ""; Write-Host "Done. Watchers running -> phone + Discord. ntfy topic: $topic"
|
||||||
|
Write-Host "For live compress + stall alerts, run once: python eve_orehold_watcher.py --snip (box your hold m3), then re-run this."
|
||||||
Loading…
Add table
Add a link
Reference in a new issue