Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
- feat: link the software update icon to the notateslaapp release notes (#5490 - @NirKli)
- feat: add fullscreen mode to vehicle summary map (#5495 - @hakong)
- feat(web): expose VIN in car summary ( #5556 - @Helvio88, @magrathean-uk)
- feat(vehicle): allow widening the Sentry Mode polling interval via POLLING_SENTRY_INTERVAL (#5594 - @onevcat)

### Improvements and bug fixes

Expand Down
3 changes: 2 additions & 1 deletion lib/teslamate/vehicles/vehicle.ex
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ defmodule TeslaMate.Vehicles.Vehicle do
def online_interval, do: interval("POLLING_ONLINE_INTERVAL", 60)
def charging_interval, do: interval("POLLING_CHARGING_INTERVAL", 5)
def minimum_interval, do: interval("POLLING_MINIMUM_INTERVAL", 0)
def sentry_interval, do: interval("POLLING_SENTRY_INTERVAL", 0)

def identify(%Vehicle{display_name: name, vin: vin, vehicle_config: config}) do
case config do
Expand Down Expand Up @@ -1751,7 +1752,7 @@ defmodule TeslaMate.Vehicles.Vehicle do
case can_fall_asleep(vehicle, data) do
{:error, :sentry_mode} ->
{:keep_state, %Data{data | last_used: DateTime.utc_now()},
[broadcast_summary(), schedule_fetch(30 * i, data)]}
[broadcast_summary(), schedule_fetch(max(30 * i, sentry_interval()), data)]}

{:error, :preconditioning} ->
if suspend?, do: Logger.warning("Preconditioning ...", car_id: car.id)
Expand Down
39 changes: 39 additions & 0 deletions test/teslamate/vehicles/vehicle/suspend_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,45 @@ defmodule TeslaMate.Vehicles.Vehicle.SuspendTest do
refute_receive _
end

test "widens the sentry mode fetch interval via POLLING_SENTRY_INTERVAL", %{test: name} do
:ok = System.put_env("POLLING_SENTRY_INTERVAL", "3600")
on_exit(fn -> System.delete_env("POLLING_SENTRY_INTERVAL") end)

now_ts = DateTime.utc_now() |> DateTime.to_unix(:millisecond)

not_suspendable =
online_event(now_ts,
drive_state: %{timestamp: now_ts, latitude: 0.0, longitude: 0.0},
vehicle_state: %{sentry_mode: true, car_version: ""}
)

events = [
{:ok, online_event(now_ts - 1)},
{:ok, not_suspendable}
]

suspend_after_idle_ms = 10
suspend_ms = 100

:ok =
start_vehicle(name, events,
settings: %{
use_streaming_api: false,
suspend_after_idle_min: round(suspend_after_idle_ms / 60),
suspend_min: suspend_ms
}
)

assert_receive {:start_state, car, :online, date: _}
assert_receive {:insert_position, ^car, %{}}

assert_receive {:pubsub, {:broadcast, _, _, %Summary{state: :online, sentry_mode: true}}}

refute_receive _, round(suspend_ms * 0.5)

refute_receive _
end

@tag :capture_log
test "does not suspend if any of the doors are open", %{test: name} do
now_ts = DateTime.utc_now() |> DateTime.to_unix(:millisecond)
Expand Down
1 change: 1 addition & 0 deletions website/docs/configuration/environment_variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ TeslaMate accepts the following environment variables for runtime configuration:
| **POLLING_ONLINE_INTERVAL** | Interval between API fetch when the vehicle is online (in seconds). **Important: Do not alter this setting unless you are certain of the implications.** | 60 |
| **POLLING_DEFAULT_INTERVAL** | Default interval between API fetch (in seconds). **Important: Do not alter this setting unless you are certain of the implications.** | 15 |
| **POLLING_MINIMUM_INTERVAL** | Minimum interval between API fetch. No minimum by default. **Important: Do not alter this setting unless you are certain of the implications.** | 0 |
| **POLLING_SENTRY_INTERVAL** | Interval between API fetch while Sentry Mode keeps the vehicle awake (in seconds). Values below the built-in cadence (30 s, or 60 s with streaming) are ignored. Widening this reduces billed Fleet API requests during long Sentry-parked periods, at the cost of slower detection of Sentry Mode being disabled. | 0 |
| **HTTP_POOL_SIZE** | The default size of the HTTP connection pool for domains other than `TESLA_API_HOST`, `nominatim.openstreetmap.org`, and `api.github.com`. This setting determines the maximum number of simultaneous connections allowed for these domains. | 5 |
| **HTTP_POOL_TIMEOUT** | The maximum time (in microseconds) to wait for a connection from the HTTP pool before timing out. This setting helps prevent indefinite waits when the pool is exhausted. | 10000 |
| **ULIMIT_MAX_NOFILE** | Sets the maximum number of open file descriptors for the TeslaMate process. This can prevent memory bloat in environments with very high default `ulimit` values. Set to `0` to disable this feature. | 65536 |
Expand Down