feat(monitor): combined fuel+TPMS monitoring with SQLite history - #6
Merged
Conversation
- Add src/vehicle-db.ts — SQLite DB (3 tables: checks, tpms_readings, alerts) via better-sqlite3; WAL mode; foreign keys enforced - Add src/monitor-helpers.ts — pure helpers: fetchOutdoorTempF (Open-Meteo, no key), newlyLitWheels, tpmsSeverity - Add monitor.ts — combined polling script: one vehicle.status() call drives both fuel-level checks and TPMS lamp checks; temperature logged for correlation; fill-ups trigger vehicle.odometer(); SQLite writes every run - Extend alert-backends.ts — FuelAlertMessage | TpmsAlertMessage union type; both Console and ntfy backends handle both kinds - TPMS dedup tracks per-wheel + allLamps flag independently; allLamps re-arms after per-wheel alerts are already sent (critical escalation) - deployment/crontab and entrypoint.sh updated to use monitor.ts - Dockerfile: add python3 make g++ for better-sqlite3 native build - .env.example: HOME_LAT/HOME_LON, FUEL_FILLUP_THRESHOLD, VEHICLE_DB_PATH - 26 new tests (vehicle-db ×8, monitor-logic ×14, fetch-temp ×4) - 57 tests total; 53 pass; 4 pre-existing CanadianVehicle failures Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This was referenced Apr 15, 2026
Closed
Closed
…lyLitWheels
TypeScript inferred `result` as `Array<'frontLeft'|'frontRight'|'rearLeft'|'rearRight'>`
from the wheels.filter call, then rejected `result.push('allLamps')` since `'allLamps'`
is not in that union. The function return type is already `string[]`, so an explicit
annotation aligns the inferred type with the intent.
Closes #7
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
allflag, deduplicates alerts, and re-arms when lamps clear.vehicle.status()call drives both checks; temperature fetched from Open-Meteo (free, no API key) and logged alongside every reading.checks,tpms_readings,alerts) viabetter-sqlite3instate/vehicle-monitor.db.New files
src/vehicle-db.tssrc/monitor-helpers.tsmonitor.tsmonitor-fuel.tsfor new runs)Key design decisions
43.2419, -70.9164458) defaults to Dover NH; override withHOME_LAT/HOME_LONallLampsflag independently — critical escalation fires even if per-wheel alerts were already sentmonitor-fuel.tsleft intact for backward compatibility; crontab and entrypoint.sh updated to usemonitor.tsTest plan
main, unrelated to this PR)TEST_ALERT=tpms npm run monitorfor manual TPMS alert verificationTEST_ALERT=low npm run monitorfor manual fuel alert verificationCloses #4
Closes #5
🤖 Generated with Claude Code