feat(vehicle): allow widening the Sentry Mode polling interval via POLLING_SENTRY_INTERVAL - #5594
feat(vehicle): allow widening the Sentry Mode polling interval via POLLING_SENTRY_INTERVAL#5594onevcat wants to merge 2 commits into
Conversation
…LLING_SENTRY_INTERVAL
✅ Deploy Preview for teslamate ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
I rechecked the state-machine path and found an important caveat in the current documentation. In polling-only mode, increasing The implementation still preserves the existing minimum cadence—30 seconds for polling-only and 60 seconds with streaming—even when the variable is unset, zero, or below those thresholds. Before this PR is ready, we should document the broader tradeoff and add regression coverage for both minimum intervals, while restoring any pre-existing environment-variable value during test cleanup. onevtail - an assistant to @onevcat |
Problem
While Sentry Mode keeps the vehicle awake,
try_to_suspendschedules the nextvehicle_datafetch at a hard-coded30 * i— 30 s in polling-only mode, 60 s with streaming enabled. NoPOLLING_*schedule variable controls this branch.On the billed Fleet API this makes Sentry parking the single most expensive routine state. At Tesla's ~$0.002/request, a Sentry-parked hour costs ~$0.12 in
vehicle_datacalls; roughly three Sentry-parked hours per day exceeds the entire $10 monthly free tier on their own — more than driving itself under typical polling configs, where streaming carries the drive data.Measured on a real car (v4.0.1, Fleet Telemetry streaming enabled): the developer billing counter advanced ~1 request/minute while parked with Sentry on, and stopped within minutes of turning Sentry off. Streaming records do not trigger fetches in
:online, so this polling cadence is the entire Sentry-parked cost.POLLING_MINIMUM_INTERVALcan floor this cadence, but it floors every scheduled fetch — the post-wake first fetch, gear/charge-detection fetches and retry paths included — so using it to tame Sentry has global side effects.Change
A new
POLLING_SENTRY_INTERVALenvironment variable (seconds, default0). The Sentry branch now schedulesmax(30 * i, sentry_interval()):0: behavior is exactly as before.30 * iare ignored, so it can never tighten polling.The trade-off is documented: a wider interval delays noticing that Sentry Mode was turned off (and therefore the start of the suspend flow) by up to the chosen value.
Includes a test mirroring the existing "does not suspend if sentry mode is active" case with the variable set, and a docs table entry.