Skip to content

Configuration

TeslaSync is configured with environment variables. Docker Compose injects them from .env; Helm derives them from chart values. The names below are the variables the Go processes actually read.

Required Tesla settings

VariablePurpose
TESLA_CLIENT_IDTesla Developer application client ID
TESLA_CLIENT_SECRETTesla Developer application secret
TESLA_REDIRECT_URIOAuth callback URL (https://your-domain/api/v1/auth/callback in prod)
TESLA_API_BASE_URLTesla Fleet API region endpoint (NA / EU / CN — see Tesla Fleet API)

The OAuth scopes TeslaSync requests are fixed in code (internal/tesla/client_auth.go): openid offline_access vehicle_device_data vehicle_location vehicle_cmds vehicle_charging_cmds. Your Tesla Developer application must have all five enabled or post-OAuth calls fail with invalid_scope.

Authentication & identity

TeslaSync delegates user identity to a reverse-proxy auth provider (Authentik, Authelia, oauth2-proxy, Keycloak proxy, Cloudflare Access, Tailscale Funnel, etc.). It does not ship a built-in login form.

VariableDefaultPurpose
FORWARD_AUTH_HEADERempty (open mode)Name of the request header the proxy injects (e.g. X-Forwarded-User, X-Authentik-Username, Remote-User, X-Auth-Request-User)
AUTH_PROVIDER_HINTemptyDisplay label surfaced in /api/v1/system/auth-mode so the UI can describe the provider
AUTHENTIK_URLemptyAuthentik JWKS URL for direct SSE JWT validation (production-only)
AUTHENTIK_HMAC_KEYemptyHMAC key used when the Authentik bypass IngressRoute mints signed SSE cookies

Behaviour matrix

FORWARD_AUTH_HEADERWhat happens on a request
Empty / unsetOpen mode. Anonymous requests pass through. Identity-required endpoints (settings export, audit log, RBAC, API keys, impersonation, TOTP, scheduled exports) return 501 with code AUTH_MODE_OPEN.
Set to a header nameForward-auth mode. Every /api/v1/* request must carry that header. Missing → 401 with code MISSING_IDENTITY. Present → subject debounce-recorded into auth_subjects (60s window).

Open mode is intended for local trials on localhost. Never expose an open-mode install to the public internet — there is no enforcement on read paths and any caller can browse vehicle state.

Reference: internal/api/forward_auth_middleware.go, internal/auth/subject.go, internal/auth/subject_recorder.go.

Token encryption

Tesla OAuth tokens (access + refresh) are stored in the users table. ENCRYPTION_KEY controls whether they are encrypted with AES-GCM at rest.

VariableDefaultBehaviour
ENCRYPTION_KEYemptybase64-encoded key used to derive the AES-GCM wrapping key. Generate with openssl rand -base64 32.
APP_ENVemptyWhen production (or prod), an empty ENCRYPTION_KEY causes the API to log.Fatal at startup. Source: internal/crypto/crypto.go.
GO_ENVemptyAlias for APP_ENV. Same production-startup guard applies.
EnvironmentENCRYPTION_KEY unsetENCRYPTION_KEY set
Development (APP_ENV/GO_ENV unset or not production)API logs a warning; tokens stored in plaintext in PostgresAES-GCM encryption applied
Production (APP_ENV=production or GO_ENV=production)API refuses to start (ENCRYPTION_KEY is required)AES-GCM encryption applied

Rotating ENCRYPTION_KEY makes existing encrypted tokens unreadable — every Tesla account on the install needs to re-run Connect Tesla after a rotation.

Core service settings

VariableDefaultPurpose
TESLASYNC_PORT4000 bare / 8080 composeAPI listen port
TESLASYNC_LOG_LEVELinfozerolog level (debug, info, warn, error)
CORS_ORIGINSemptyAllowed browser origins; empty = runtime default
WORKER_POLL_INTERVAL15s bare / 30s composePolling interval when telemetry is not streaming
WORKER_SLEEP_POLL_MULT4Sleep-state polling backoff multiplier
DATABASE_HOSTpostgresPostgreSQL / TimescaleDB host
DATABASE_PORT5432Database port
DATABASE_USERteslasyncDatabase user
DATABASE_PASSteslasyncDatabase password
DATABASE_NAMEteslasyncDatabase name
DATABASE_SSLMODEdisablePostgreSQL SSL mode
DATABASE_MAX_CONNS25Maximum pgx pool connections
DATABASE_MIN_CONNS5Minimum pgx pool connections
DATABASE_STATEMENT_TIMEOUT30000Query timeout in milliseconds
DATABASE_HEALTH_CHECK_PERIOD5spgx pool health-check interval
MQTT_ENABLEDtrueEnable MQTT integration
MQTT_HOSTmosquittoMQTT broker host
MQTT_PORT1883MQTT broker port
MQTT_CLIENT_IDteslasyncMQTT client ID
MQTT_PREFIXteslasyncMQTT topic prefix
REDIS_ENABLEDfalse bare / true composeEnable Redis-backed runtime cache
REDIS_HOSTredisRedis host
REDIS_PORT6379Redis port
REDIS_DB0Redis logical database
LIVE_SIGNAL_STORE_MODEhybridhybrid (L1+L2 Redis) or local (L1-only)

Fleet Telemetry settings

VariableDefaultPurpose
FLEET_TELEMETRY_ENABLEDfalseEnable Fleet Telemetry ingestion
FLEET_TELEMETRY_HOSTemptyPublic telemetry hostname (must have valid TLS)
FLEET_TELEMETRY_PORT4443Telemetry server port
FLEET_TELEMETRY_TOPIC_BASEtelemetryMQTT topic prefix
FLEET_TELEMETRY_BATCH_MS100Signal batching window
FLEET_TELEMETRY_STALE_TIMEOUT15mStaleness threshold before polling fallback
FLEET_TELEMETRY_FALLBACK_POLL_INTERVAL5mPolling fallback interval when stream is stale
FLEET_TELEMETRY_SNAPSHOT_WRITE_INTERVAL10s bare / 1s composeSnapshot write throttle
FLEET_TELEMETRY_CLEANUP_INTERVAL2mStale session cleanup interval
FLEET_TELEMETRY_STALE_SESSION_TIMEOUT5mClose idle drive/charge sessions after this

Vehicle Command Proxy

VariableDefaultPurpose
TESLA_COMMAND_PROXY_URLemptyURL of the Tesla Vehicle Command proxy. Required for vehicles that need signed commands (Model 3/Y from 2021+, Model S/X refresh, Cybertruck). wake_up always goes direct.

In Compose, the proxy is in the commands profile as vehicle-command-proxy. In Helm use commandProxy.enabled or commandProxy.external.url. See Remote Commands for routing details and the full 65-endpoint reference.

Helix AI settings

Helix AI ships off by default per feature (registry contract in internal/ai/features/registry.go). These variables only enable the infrastructure — each feature is still independently toggled in Settings → Helix in the UI.

VariableDefaultPurpose
AI_PROVIDERollamaActive provider: ollama, openai, azure, anthropic
AI_MODELprovider-defaultOverride the chat model
AI_DAILY_BUDGET_USD0 (unlimited)Hard daily spend cap; rejects calls when exceeded
AI_RATE_LIMIT_PER_MIN60Per-user rate limit on AI routes
AI_REDACTION_ENABLEDtrueStrip PII (VINs, locations, emails) before sending to LLM
OLLAMA_HOSThttp://ollama:11434Ollama base URL
OLLAMA_MODELllama3.1:8bOllama chat model
OLLAMA_HEALTH_INTERVAL30sHealth-prober interval (suspends provider on failure)
OPENAI_API_KEYemptyOpenAI API key
OPENAI_MODELgpt-4o-miniOpenAI chat model
OPENAI_BASE_URLhttps://api.openai.com/v1Override for compatible endpoints
AZURE_OPENAI_ENDPOINTemptyAzure OpenAI / Foundry endpoint
AZURE_OPENAI_API_KEYemptyAzure API key
AZURE_OPENAI_DEPLOYMENTemptyAzure deployment name
AZURE_OPENAI_API_VERSION2024-08-01-previewAzure API version
ANTHROPIC_API_KEYemptyAnthropic API key
ANTHROPIC_MODELclaude-3-5-haiku-latestAnthropic chat model
RAG_EMBED_MODELtext-embedding-3-smallEmbedding model for the docs/help RAG corpus (pgvector)

See Helix AI for the full feature list, decorator chain, and provider matrix.

Optional raw telemetry capture

VariableDefaultPurpose
MONGODB_ENABLEDfalseEnable optional MongoDB raw signal capture
MONGODB_URImongodb://localhost:27017MongoDB connection URI
MONGODB_DATABASEteslasyncMongoDB database name
MONGODB_TTL_DAYS7Raw telemetry retention TTL

Observability

VariableDefaultPurpose
OTEL_ENABLEDfalseEnable OpenTelemetry tracing
OTEL_ENDPOINTlocalhost:4317 / jaeger:4317OTLP gRPC collector endpoint
OTEL_SERVICE_NAMEteslasyncService name for traces
OTEL_INSECUREtrueUse insecure OTLP transport

Maps and cost analysis

VariableDefaultPurpose
GOOGLE_MAPS_API_KEYemptyOptional Google Maps geocoding/tiles
AZURE_MAPS_API_KEYemptyOptional Azure Maps geocoding/tiles
GAS_PRICE_ENABLEDfalseEnable gas price polling for cost comparisons
GAS_PRICE_POLL_INTERVAL7dGas price polling interval
GAS_PRICE_API_KEYemptyEIA API key for gas price data

Helm web/API routing values

For the default same-origin deployment, browsers call /api/v1/... on the web host. Nginx inside the web pod proxies that path to the internal API service.

yaml
config:
  apiEndpoint: "http://teslasync-dev-api.teslasync-dev.svc.cluster.local:8080"
  browserApiBase: ""
  webEndpoint: "https://teslasync.example.com"
  forwardAuthHeader: "X-Authentik-Username"
ValueMeaning
config.apiEndpointInternal URL used by web/Nginx proxy_pass; safe to use svc.cluster.local.
config.browserApiBasePublic browser API base. Leave empty for relative /api/v1 paths. Never set to a K8s DNS name.
config.webEndpointPublic web origin for CORS / auth redirects.
config.forwardAuthHeaderHeader set by Authentik, Authelia, oauth2-proxy, or another ForwardAuth provider.

Frontend runtime preferences

User-level preferences — theme, display mode, units (km/mi, °C/°F, kWh, bar/psi), date/time format, timezone, locale, currency, decimal precision, gas-comparison settings, and dashboard layout — are managed in the in-app Settings page and persisted through /api/v1/settings. Do not hardcode units in pages; the frontend converts SI source units to user preferences via useUnits() / useFormatting() at the React render boundary only.

Released under the MIT License.
Visitors