### Install Go and Dependencies
Source: https://github.com/wimaha/teslablehttpproxy/blob/main/docs/manually_gen_key.md
Installs Go, Git, and build essentials, then downloads and configures Go for use. Ensure you are in your home directory before running.
```bash
sudo apt update && sudo apt install -y wget git build-essential
wget https://dl.google.com/go/go1.22.1.linux-arm64.tar.gz
tar -xvf go1.22.1.linux-arm64.tar.gz
mkdir -p ~/.local/share && mv go ~/.local/share
export GOPATH=$HOME/.local/share/go
export PATH=$HOME/.local/share/go/bin:$PATH
echo 'export GOPATH=$HOME/.local/share/go' >> ~/.bashrc
echo 'export PATH=$HOME/.local/share/go/bin:$PATH' >> ~/.bashrc
```
--------------------------------
### Install Docker
Source: https://github.com/wimaha/teslablehttpproxy/blob/main/docs/installation.md
Install Docker on your Raspberry Pi using the official convenience script.
```bash
curl -sSL https://get.docker.com | sh
```
--------------------------------
### Start Docker Container
Source: https://github.com/wimaha/teslablehttpproxy/blob/main/docs/installation.md
Start the TeslaBleHttpProxy Docker container in detached mode.
```bash
docker compose up -d
```
--------------------------------
### Initial Load and Setup
Source: https://github.com/wimaha/teslablehttpproxy/blob/main/html/logs.html
Performs the initial loading of logs and statistics when the page loads. Also sets up the initial display for the refresh interval.
```javascript
// Initial load (auto-refresh is off by default)
loadLogs();
loadStats();
updateIntervalDisplay();
```
--------------------------------
### Install Tesla Vehicle Command Tool
Source: https://github.com/wimaha/teslablehttpproxy/blob/main/docs/manually_gen_key.md
Clones the vehicle-command repository, builds the tool, and sets necessary permissions for network operations.
```bash
git clone https://github.com/teslamotors/vehicle-command.git
cd vehicle-command
go get ./...
go build ./...
go install ./...
sudo setcap 'cap_net_admin=eip' "$(which tesla-control)"
```
--------------------------------
### API: Start Charging
Source: https://github.com/wimaha/teslablehttpproxy/blob/main/README.md
Initiates the charging process for the specified vehicle. The request automatically wakes the vehicle if it is asleep.
```http
http://localhost:8080/api/1/vehicles/{VIN}/command/charge_start
```
--------------------------------
### Set Environment Variables on Command Line
Source: https://github.com/wimaha/teslablehttpproxy/blob/main/docs/environment_variables.md
You can set environment variables directly on the command line when starting the program. This is useful for quick tests or single-instance deployments.
```bash
logLevel=debug scanTimeout=5 cacheMaxAge=10 vehicleDataCacheTime=60 httpListenAddress=:5687 ./TeslaBleHttpProxy
```
--------------------------------
### API: Start Charging and Wait for Completion
Source: https://github.com/wimaha/teslablehttpproxy/blob/main/README.md
Initiates charging and waits for the command to complete before returning. Automatically wakes the vehicle if it is asleep.
```http
http://localhost:8080/api/1/vehicles/{VIN}/command/charge_start?wait=true
```
--------------------------------
### Docker Compose Deployment Configuration
Source: https://context7.com/wimaha/teslablehttpproxy/llms.txt
Example docker-compose.yml for deploying TeslaBleHttpProxy. Configure environment variables for logging, timeouts, caching, and network settings.
```yaml
# docker-compose.yml
services:
tesla-ble-http-proxy:
image: wimaha/tesla-ble-http-proxy
container_name: tesla-ble-http-proxy
volumes:
- ~/TeslaBleHttpProxy/key:/key # persistent key storage
- /var/run/dbus:/var/run/dbus # required for BLE on Linux
restart: always
privileged: true
network_mode: host # exposes :8080 directly on host
cap_add:
- NET_ADMIN
- SYS_ADMIN
environment:
- logLevel=info # debug | info (default: info)
- scanTimeout=5 # seconds to scan for BLE device (default: 5)
- cacheMaxAge=5 # HTTP Cache-Control max-age for body_controller_state (default: 5)
- vehicleDataCacheTime=30 # seconds to cache vehicle_data endpoints in memory (default: 30)
- httpListenAddress=:8080 # listen address (default: :8080)
```
--------------------------------
### Get Proxy Version
Source: https://context7.com/wimaha/teslablehttpproxy/llms.txt
Retrieve the currently running version of TeslaBleHttpProxy. This version is set at build time.
```bash
curl -s http://localhost:8080/api/proxy/1/version | jq .
```
--------------------------------
### Get Proxy Version
Source: https://github.com/wimaha/teslablehttpproxy/blob/main/README.md
Retrieves the version information of the TeslaBleHttpProxy.
```APIDOC
## GET /api/proxy/1/version
### Description
Retrieves the version of the proxy.
### Method
GET
### Endpoint
`/api/proxy/1/version`
### Response
#### Success Response (200)
- **version** (string) - The version of the proxy.
```
--------------------------------
### Retrieve Log Statistics
Source: https://context7.com/wimaha/teslablehttpproxy/llms.txt
Get statistics about the stored log entries, including counts for different log levels.
```bash
BASE="http://localhost:8080"
curl -s "$BASE/api/logs/stats" | jq .
```
--------------------------------
### Update Raspberry Pi OS Packages
Source: https://github.com/wimaha/teslablehttpproxy/blob/main/docs/installation.md
Update the package list and upgrade installed packages on your Raspberry Pi.
```bash
sudo apt-get update && sudo apt-get upgrade
```
--------------------------------
### Auto-Refresh and Live Mode Control
Source: https://github.com/wimaha/teslablehttpproxy/blob/main/html/logs.html
Manages the automatic refreshing of logs and enables a 'Live Mode' for continuous updates. Includes functions to start, stop, and update the display of the refresh interval.
```javascript
function startAutoRefresh() {
// Clear any existing interval
if (autoRefreshInterval) {
clearInterval(autoRefreshInterval);
autoRefreshInterval = null;
}
// Get interval from selector or live mode
let intervalMs;
if (isLiveMode) {
intervalMs = 1000; // Live mode: 1 second
} else {
const intervalValue = parseInt(document.getElementById('intervalSelect').value);
if (intervalValue === 0) { // Auto-refresh is off
return;
}
intervalMs = intervalValue * 1000;
}
currentInterval = intervalMs;
// Start the interval
autoRefreshInterval = setInterval(() => {
loadLogs();
loadStats();
}, intervalMs);
updateIntervalDisplay();
}
function stopAutoRefresh() {
if (autoRefreshInterval) {
clearInterval(autoRefreshInterval);
autoRefreshInterval = null;
}
updateIntervalDisplay();
}
function updateIntervalDisplay() {
const intervalSelect = document.getElementById('intervalSelect');
const liveModeCheckbox = document.getElementById('liveModeCheckbox');
if (isLiveMode) {
interval
```
--------------------------------
### GET /api/1/vehicles/{vin}/vehicle_data — Fetch Vehicle Data
Source: https://context7.com/wimaha/teslablehttpproxy/llms.txt
Retrieves live vehicle data over BLE and returns it in the same JSON format as the Tesla Fleet API. Results are cached per-endpoint per-VIN (default 30 s). By default both `charge_state` and `climate_state` are returned; use the `endpoints` query parameter to request a specific subset. Pass `?wakeup=true` to wake the vehicle before fetching.
```APIDOC
## GET /api/1/vehicles/{vin}/vehicle_data
### Description
Retrieves live vehicle data over BLE and returns it in the same JSON format as the Tesla Fleet API. Results are cached per-endpoint per-VIN (default 30 s). By default both `charge_state` and `climate_state` are returned; use the `endpoints` query parameter to request a specific subset. Pass `?wakeup=true` to wake the vehicle before fetching.
### Method
GET
### Endpoint
/api/1/vehicles/{vin}/vehicle_data
### Parameters
#### Path Parameters
- **vin** (string) - Required - The Vehicle Identification Number.
#### Query Parameters
- **endpoints** (string) - Optional - A comma or semicolon-separated list of specific data endpoints to retrieve (e.g., `charge_state`, `climate_state`). Defaults to `charge_state;climate_state`.
- **wakeup** (boolean) - Optional - If true, the vehicle will be woken up before fetching data.
### Request Example
```bash
VIN="5YJ3E1EA1JF123456"
BASE="http://localhost:8080"
# Fetch all default endpoints (charge_state + climate_state)
curl -s "$BASE/api/1/vehicles/$VIN/vehicle_data" | jq .
# Fetch only charge_state (faster, fewer BLE calls)
curl -s "$BASE/api/1/vehicles/$VIN/vehicle_data?endpoints=charge_state"
# Fetch climate_state only with automatic wakeup
curl -s "$BASE/api/1/vehicles/$VIN/vehicle_data?endpoints=climate_state&wakeup=true"
```
### Response
#### Success Response (200)
- **response** (object) - Contains the result, reason, and the requested vehicle data.
- **result** (boolean) - True if the request was successfully processed.
- **reason** (string) - A message indicating the outcome of the request.
- **response** (object) - An object containing the requested vehicle data, such as `charge_state` and `climate_state`.
- **charge_state** (object) - Contains information about the vehicle's charging status.
- **climate_state** (object) - Contains information about the vehicle's climate control status.
#### Response Example
```json
{
"response": {
"result": true,
"reason": "The request was successfully processed.",
"response": {
"charge_state": {
"battery_level": 72,
"charging_state": "Disconnected",
"charge_limit_soc": 80,
"charger_actual_current": 0,
"charger_power": 0,
"minutes_to_full_charge": 0,
"battery_range": 213.5
},
"climate_state": {
"inside_temp": 21.5,
"outside_temp": 18.0,
"is_climate_on": false,
"driver_temp_setting": 20.5
}
}
}
}
```
```
--------------------------------
### API: Get Vehicle Data with Automatic Wakeup
Source: https://github.com/wimaha/teslablehttpproxy/blob/main/README.md
Retrieves vehicle data and automatically wakes the vehicle if it is asleep. Useful when the vehicle might be offline. Data is cached.
```http
http://localhost:8080/api/1/vehicles/{VIN}/vehicle_data?wakeup=true
```
--------------------------------
### API: Get Vehicle Data
Source: https://github.com/wimaha/teslablehttpproxy/blob/main/README.md
Retrieves comprehensive data about the vehicle. By default, it does not wake the vehicle. Data is cached in memory for 30 seconds per endpoint.
```http
http://localhost:8080/api/1/vehicles/{VIN}/vehicle_data
```
--------------------------------
### API: Get Specific Vehicle Data with Wakeup
Source: https://github.com/wimaha/teslablehttpproxy/blob/main/README.md
Retrieves a specific data endpoint and automatically wakes the vehicle if it is asleep. Recommended for frequent data requests to minimize latency.
```http
http://localhost:8080/api/1/vehicles/{VIN}/vehicle_data?endpoints=charge_state&wakeup=true
```
--------------------------------
### Get Body Controller State
Source: https://github.com/wimaha/teslablehttpproxy/blob/main/README.md
Retrieves the current state of the vehicle's body controller. This endpoint requires the Vehicle Identification Number (VIN) as a path parameter.
```APIDOC
## GET /api/1/vehicles/{VIN}/body_controller_state
### Description
Retrieves the current state of the vehicle's body controller.
### Method
GET
### Endpoint
`/api/1/vehicles/{VIN}/body_controller_state`
### Parameters
#### Path Parameters
- **VIN** (string) - Required - The Vehicle Identification Number.
```
--------------------------------
### API: Get Specific Vehicle Data Endpoint
Source: https://github.com/wimaha/teslablehttpproxy/blob/main/README.md
Retrieves only the specified data endpoint (e.g., charge_state) for the vehicle. This reduces response time and data transfer. Caching is applied per endpoint.
```http
http://localhost:8080/api/1/vehicles/{VIN}/vehicle_data?endpoints=charge_state
```
--------------------------------
### Build and Run TeslaBleHttpProxy Locally
Source: https://github.com/wimaha/teslablehttpproxy/blob/main/README.md
Compile the Go program locally and run it from the command line. Ensure a 'key' folder is created for storing generated keys.
```bash
go build .
./TeslaBleHttpProxy
```
--------------------------------
### Manual Build with Environment Variables
Source: https://context7.com/wimaha/teslablehttpproxy/llms.txt
Build and run TeslaBleHttpProxy manually using environment variables to configure its behavior.
```bash
logLevel=debug \
scanTimeout=10 \
cacheMaxAge=0 \
vehicleDataCacheTime=60 \
httpListenAddress=:8080 \
./TeslaBleHttpProxy
```
--------------------------------
### Create TeslaBleHttpProxy Docker Directory
Source: https://github.com/wimaha/teslablehttpproxy/blob/main/docs/installation.md
Create a directory for Docker files and navigate into it. Also create a 'key' subdirectory.
```bash
mkdir TeslaBleHttpProxy
cd TeslaBleHttpProxy
mkdir key
```
--------------------------------
### Navigate to Home Directory
Source: https://github.com/wimaha/teslablehttpproxy/blob/main/docs/installation.md
Change the current directory to your home directory on the Raspberry Pi.
```bash
cd ~
```
--------------------------------
### Show Docker Container Logs
Source: https://github.com/wimaha/teslablehttpproxy/blob/main/docs/installation.md
Display the logs for the tesla-ble-http-proxy container from the last 12 hours.
```bash
docker logs --since 12h tesla-ble-http-proxy
```
--------------------------------
### Manage Keys via Web UI Endpoints
Source: https://context7.com/wimaha/teslablehttpproxy/llms.txt
Scriptable web UI endpoints for key management, including generation, sending to vehicle, activation, and removal. Requires NFC confirmation for sending keys.
```bash
BASE="http://localhost:8080"
# Generate a Charging Manager key (recommended)
curl -s -L "$BASE/gen_keys?role=charging_manager"
# Generate an Owner key (full access)
curl -s -L "$BASE/gen_keys?role=owner"
# Send a generated key to the vehicle (requires NFC card confirmation on center console)
curl -s -X POST "$BASE/send_key" \
-d "VIN=5YJ3E1EA1JF123456&role=charging_manager"
# Activate a different key role (switches the active BLE identity)
curl -s -X POST "$BASE/activate_key" \
-d "role=owner"
# Remove keys for a role
curl -s -L "$BASE/remove_keys?role=owner"
```
--------------------------------
### Fetch Vehicle Data via HTTP to BLE
Source: https://context7.com/wimaha/teslablehttpproxy/llms.txt
Retrieve live vehicle data over BLE. Results are cached per-endpoint per-VIN (default 30s). Use `?wakeup=true` to wake the vehicle before fetching. Specify `endpoints` to request specific data subsets.
```bash
VIN="5YJ3E1EA1JF123456"
BASE="http://localhost:8080"
# Fetch all default endpoints (charge_state + climate_state)
curl -s "$BASE/api/1/vehicles/$VIN/vehicle_data" | jq .
# {
# "response": {
# "result": true,
# "reason": "The request was successfully processed.",
# "response": {
# "charge_state": {
# "battery_level": 72,
# "charging_state": "Disconnected",
# "charge_limit_soc": 80,
# "charger_actual_current": 0,
# "charger_power": 0,
# "minutes_to_full_charge": 0,
# "battery_range": 213.5,
# ...
# },
# "climate_state": {
# "inside_temp": 21.5,
# "outside_temp": 18.0,
# "is_climate_on": false,
# "driver_temp_setting": 20.5,
# ...
# }
# }
# }
# }
# Fetch only charge_state (faster, fewer BLE calls)
curl -s "$BASE/api/1/vehicles/$VIN/vehicle_data?endpoints=charge_state"
# Fetch climate_state only with automatic wakeup
curl -s "$BASE/api/1/vehicles/$VIN/vehicle_data?endpoints=climate_state&wakeup=true"
# Multiple endpoints separated by semicolon
curl -s "$BASE/api/1/vehicles/$VIN/vehicle_data?endpoints=charge_state;climate_state"
```
--------------------------------
### Retrieve Log Entries with Filtering
Source: https://context7.com/wimaha/teslablehttpproxy/llms.txt
Fetch log entries from the proxy. Supports filtering by log level, time range, and limiting the number of entries returned.
```bash
BASE="http://localhost:8080"
# Latest 50 log entries
curl -s "$BASE/api/logs?limit=50" | jq .
# Only error-level entries
curl -s "$BASE/api/logs?level=error&limit=100"
# Entries since a specific timestamp (RFC3339)
curl -s "$BASE/api/logs?since=2024-08-01T10:00:00Z"
```
--------------------------------
### SSH into Raspberry Pi
Source: https://github.com/wimaha/teslablehttpproxy/blob/main/docs/installation.md
Connect to your Raspberry Pi using SSH. Replace 'user' with your username and 'IP' with your Pi's IP address.
```bash
ssh user@IP
```
--------------------------------
### Generate Private and Public Keys
Source: https://github.com/wimaha/teslablehttpproxy/blob/main/docs/manually_gen_key.md
Creates a private key using OpenSSL's Elliptic Curve (EC) algorithm and derives the corresponding public key.
```bash
openssl ecparam -genkey -name prime256v1 -noout > private.pem
openssl ec -in private.pem -pubout > public.pem
```
--------------------------------
### Log Rendering and Formatting Functions
Source: https://github.com/wimaha/teslablehttpproxy/blob/main/html/logs.html
Contains functions for formatting timestamps, determining log level colors, formatting custom fields, and rendering log entries into HTML. It also includes a utility for escaping HTML.
```javascript
let autoRefreshInterval = null;
let currentInterval = 5000; // Default: 5 seconds
let isLiveMode = false;
function formatTimestamp(timestamp) {
const date = new Date(timestamp);
return date.toLocaleString();
}
function getLevelColor(level) {
const colors = {
'debug': '#888888',
'info': '#4CAF50',
'warn': '#FF9800',
'error': '#F44336',
'fatal': '#E91E63'
};
return colors[level.toLowerCase()] || '#d4d4d4';
}
function formatFields(fields) {
if (!fields || Object.keys(fields).length === 0) {
return '';
}
return ' ' + Object.entries(fields).map(([k, v]) => `${k}=${JSON.stringify(v)}`).join(' ');
}
function renderLogs(entries) {
const container = document.getElementById('logContainer');
// Handle null, undefined, or non-array responses
if (!entries || !Array.isArray(entries)) {
container.innerHTML = '
No logs found.
';
return;
}
if (entries.length === 0) {
container.innerHTML = 'No logs found.
';
return;
}
const html = entries.map(entry => {
const levelColor = getLevelColor(entry.level);
const timestamp = formatTimestamp(entry.timestamp);
const fields = formatFields(entry.fields);
return ` [${timestamp}] [${entry.level.toUpperCase()}]
${escapeHtml(entry.message)}${escapeHtml(fields)}
`;
}).join('');
container.innerHTML = html;
// Auto-scroll to bottom
container.scrollTop = container.scrollHeight;
}
function escapeHtml(text) {
const div = document.createElement('div');
div.textContent = text;
return div.innerHTML;
}
```
--------------------------------
### Event Listeners for Log Viewer Controls
Source: https://github.com/wimaha/teslablehttpproxy/blob/main/html/logs.html
Sets up event listeners for user interactions with the log viewer controls, including refresh, clear, live mode toggle, interval selection, and filters.
```javascript
// Event listeners
document.getElementById('refreshBtn').addEventListener('click', () => {
loadLogs();
loadStats();
});
document.getElementById('clearBtn').addEventListener('click', () => {
document.getElementById('logContainer').innerHTML = 'Logs cleared.
';
});
document.getElementById('liveModeCheckbox').addEventListener('change', toggleLiveMode);
document.getElementById('intervalSelect').addEventListener('change', function() {
if (!isLiveMode) {
const intervalValue = parseInt(this.value);
if (intervalValue === 0) {
stopAutoRefresh();
} else {
startAutoRefresh();
}
}
});
document.getElementById('levelFilter').addEventListener('change', loadLogs);
document.getElementById('limitFilter').addEventListener('change', loadLogs);
```
--------------------------------
### Docker Compose Configuration
Source: https://github.com/wimaha/teslablehttpproxy/blob/main/docs/installation.md
Configuration for the TeslaBleHttpProxy Docker container using docker-compose.yml. Mounts local directories for keys and D-Bus access.
```yaml
services:
tesla-ble-http-proxy:
image: wimaha/tesla-ble-http-proxy
container_name: tesla-ble-http-proxy
volumes:
- ~/TeslaBleHttpProxy/key:/key
- /var/run/dbus:/var/run/dbus
restart: always
privileged: true
network_mode: host
cap_add:
- NET_ADMIN
- SYS_ADMIN
```
--------------------------------
### POST /api/1/vehicles/{vin}/command/{command} — Send a Vehicle Command
Source: https://context7.com/wimaha/teslablehttpproxy/llms.txt
Sends a command to the Tesla vehicle over BLE. Commands are queued and processed sequentially. The vehicle is automatically woken up before any command (except `wake_up` itself). By default the endpoint returns immediately after queuing; pass `?wait=true` to block until the command completes.
```APIDOC
## POST /api/1/vehicles/{vin}/command/{command}
### Description
Sends a command to the Tesla vehicle over BLE. Commands are queued and processed sequentially. The vehicle is automatically woken up before any command (except `wake_up` itself). By default the endpoint returns immediately after queuing; pass `?wait=true` to block until the command completes.
Supported commands: `wake_up`, `charge_start`, `charge_stop`, `set_charging_amps`, `set_charge_limit`, `auto_conditioning_start`, `auto_conditioning_stop`, `charge_port_door_open`, `charge_port_door_close`, `flash_lights`, `honk_horn`, `door_lock`, `door_unlock`, `set_sentry_mode`.
### Method
POST
### Endpoint
/api/1/vehicles/{vin}/command/{command}
### Parameters
#### Path Parameters
- **vin** (string) - Required - The Vehicle Identification Number.
- **command** (string) - Required - The command to send to the vehicle. See supported commands in the description.
#### Query Parameters
- **wait** (boolean) - Optional - If true, the endpoint will block until the command completes.
#### Request Body
- **charging_amps** (string) - Required for `set_charging_amps` command - The desired charging amperage.
- **percent** (string) - Required for `set_charge_limit` command - The desired charge limit percentage.
- **on** (boolean) - Required for `set_sentry_mode` command - Whether to turn Sentry Mode on or off.
### Request Example
```bash
VIN="5YJ3E1EA1JF123456"
BASE="http://localhost:8080"
# Start charging (fire-and-forget)
curl -s -X POST "$BASE/api/1/vehicles/$VIN/command/charge_start"
# Set charging current to 8 A
curl -s -X POST "$BASE/api/1/vehicles/$VIN/command/set_charging_amps" \
-H "Content-Type: application/json" \
-d '{"charging_amps": "8"}'
# Enable sentry mode
curl -s -X POST "$BASE/api/1/vehicles/$VIN/command/set_sentry_mode" \
-H "Content-Type: application/json" \
-d '{"on": true}'
```
### Response
#### Success Response (200)
- **response** (object) - Contains the result and reason for the command execution.
- **result** (boolean) - True if the command was successfully received or processed.
- **reason** (string) - A message indicating the outcome of the command.
#### Response Example
```json
{
"response": {
"result": true,
"reason": "The command was successfully received and will be processed shortly."
}
}
```
#### Error Response Example
```json
{
"response": {
"result": false,
"reason": "The command \"unknown_cmd\" is not supported."
}
}
```
```
--------------------------------
### Key Management - Web UI Endpoints
Source: https://context7.com/wimaha/teslablehttpproxy/llms.txt
Endpoints for managing vehicle keys via the web UI, including key generation, sending keys to the vehicle, activating key roles, and removing keys.
```APIDOC
## Web UI Key Management Endpoints
### Description
These endpoints are part of the built-in web dashboard and handle key generation, vehicle pairing, and key role switching. While primarily for the web UI, they can be scripted.
### Method
GET / POST
### Endpoints
- **/gen_keys?role={role}** (GET): Generates a new key for the specified role.
- **/send_key** (POST): Sends a generated key to the vehicle. Requires VIN and role in the request body.
- **/activate_key** (POST): Activates a different key role, switching the active BLE identity. Requires the role in the request body.
- **/remove_keys?role={role}** (GET): Removes keys associated with the specified role.
### Parameters
#### Query Parameters (for GET requests)
- **role** (string) - Required - The role for which to generate or remove keys (e.g., 'charging_manager', 'owner').
#### Request Body (for POST requests)
- **VIN** (string) - Required (for send_key) - The Vehicle Identification Number.
- **role** (string) - Required (for send_key, activate_key) - The role of the key to send or activate.
### Request Example (Generate Charging Manager key)
```bash
curl -s -L "http://localhost:8080/gen_keys?role=charging_manager"
```
### Request Example (Send key to vehicle)
```bash
curl -s -X POST "http://localhost:8080/send_key" \
-d "VIN=5YJ3E1EA1JF123456&role=charging_manager"
```
### Request Example (Activate key role)
```bash
curl -s -X POST "http://localhost:8080/activate_key" \
-d "role=owner"
```
### Request Example (Remove keys)
```bash
curl -s -L "http://localhost:8080/remove_keys?role=owner"
```
```
--------------------------------
### Configure evcc with TeslaBleHttpProxy (BLE Proxy)
Source: https://context7.com/wimaha/teslablehttpproxy/llms.txt
Use this configuration in evcc when TeslaBleHttpProxy is running on a local machine and acts as the sole vehicle interface via BLE.
```yaml
vehicles:
- name: tesla
type: template
template: tesla-ble
title: My Tesla
capacity: 75 # battery capacity in kWh
vin: 5YJ3E1EA1JF123456
url: 192.168.1.100 # IP of the machine running TeslaBleHttpProxy
port: 8080
```
--------------------------------
### Toggle Live Mode
Source: https://github.com/wimaha/teslablehttpproxy/blob/main/html/logs.html
Manages the behavior of the log viewer based on the live mode setting. Enables auto-refresh and sets a fixed interval when live mode is active.
```javascript
function toggleLiveMode() {
isLiveMode = document.getElementById('liveModeCheckbox').checked;
if (isLiveMode) {
// Live mode: always use 1s interval and enable auto-refresh
startAutoRefresh();
} else {
// Live mode off: use selected interval
const intervalValue = parseInt(document.getElementById('intervalSelect').value);
if (intervalValue === 0) {
stopAutoRefresh();
} else {
startAutoRefresh();
}
}
}
```
--------------------------------
### Proxy Version
Source: https://context7.com/wimaha/teslablehttpproxy/llms.txt
Retrieves the currently running version of the TeslaBleHttpProxy. This information is set at build time.
```APIDOC
## GET /api/proxy/1/version — Proxy Version
### Description
Returns the currently running version of TeslaBleHttpProxy (set at build time via Go linker flags).
### Method
GET
### Endpoint
/api/proxy/1/version
### Response
#### Success Response (200)
- **response** (object) - Contains the version information.
- **version** (string) - The version string of the proxy.
### Response Example
```json
{
"response": {
"result": true,
"reason": "The request was successfully processed.",
"response": {
"version": "1.4.2"
}
}
}
```
```
--------------------------------
### Send Vehicle Command via HTTP to BLE
Source: https://context7.com/wimaha/teslablehttpproxy/llms.txt
Use this endpoint to send commands to your Tesla vehicle over BLE. Commands are processed sequentially. The vehicle is woken up automatically for most commands. Use `?wait=true` to block until the command completes.
```bash
VIN="5YJ3E1EA1JF123456"
BASE="http://localhost:8080"
# Start charging (fire-and-forget)
curl -s -X POST "$BASE/api/1/vehicles/$VIN/command/charge_start"
# {"response":{"result":true,"reason":"The command was successfully received and will be processed shortly."}}
# Start charging and wait for completion
curl -s -X POST "$BASE/api/1/vehicles/$VIN/command/charge_start?wait=true"
# {"response":{"result":true,"reason":"The command was successfully processed."}}
# Stop charging
curl -s -X POST "$BASE/api/1/vehicles/$VIN/command/charge_stop"
# Set charging current to 8 A
curl -s -X POST "$BASE/api/1/vehicles/$VIN/command/set_charging_amps" \
-H "Content-Type: application/json" \
-d '{"charging_amps": "8"}'
# Set charge limit to 80 %
curl -s -X POST "$BASE/api/1/vehicles/$VIN/command/set_charge_limit" \
-H "Content-Type: application/json" \
-d '{"percent": "80"}'
# Enable sentry mode
curl -s -X POST "$BASE/api/1/vehicles/$VIN/command/set_sentry_mode" \
-H "Content-Type: application/json" \
-d '{"on": true}'
# Lock / unlock doors
curl -s -X POST "$BASE/api/1/vehicles/$VIN/command/door_lock"
curl -s -X POST "$BASE/api/1/vehicles/$VIN/command/door_unlock"
# Explicit wake-up
curl -s -X POST "$BASE/api/1/vehicles/$VIN/command/wake_up"
# Error response (unsupported command)
curl -s -X POST "$BASE/api/1/vehicles/$VIN/command/unknown_cmd"
# {"response":{"result":false,"reason":"The command \"unknown_cmd\" is not supported."}}
```
--------------------------------
### Add User to Docker Group
Source: https://github.com/wimaha/teslablehttpproxy/blob/main/docs/installation.md
Add the current user to the 'docker' group to allow Docker commands without sudo. Log out and log back in for changes to take effect.
```bash
sudo usermod -aG docker $USER
```
--------------------------------
### evcc Configuration for Commands Only
Source: https://github.com/wimaha/teslablehttpproxy/blob/main/README.md
Configure evcc to use the proxy solely for commands, fetching vehicle data via the Tesla API. Requires IP, access token, refresh token, and VIN.
```yaml
- name: model3
type: template
template: tesla
title: Tesla
icon: car
commandProxy: http://YOUR_IP:8080
accessToken: YOUR_ACCESS_TOKEN
refreshToken: YOUR_REFRSH_TOKEN
capacity: 60
vin: YOUR_VIN
```
--------------------------------
### Configure evcc with TeslaBleHttpProxy (Hybrid Mode)
Source: https://context7.com/wimaha/teslablehttpproxy/llms.txt
This configuration is for evcc's hybrid mode, where TeslaBleHttpProxy is used only for commands, and the Tesla Fleet API provides vehicle data. Ensure the proxy is accessible via the specified URL.
```yaml
- name: tesla-hybrid
type: template
template: tesla
title: Tesla (hybrid)
commandProxy: http://192.168.1.100:8080
accessToken: YOUR_ACCESS_TOKEN
refreshToken: YOUR_REFRESH_TOKEN
capacity: 75
vin: 5YJ3E1EA1JF123456
```
--------------------------------
### Update Docker Container
Source: https://github.com/wimaha/teslablehttpproxy/blob/main/docs/installation.md
Update the TeslaBleHttpProxy Docker image and restart the container.
```bash
docker pull wimaha/tesla-ble-http-proxy
docker compose up -d
```
--------------------------------
### Log Fetching and Statistics Functions
Source: https://github.com/wimaha/teslablehttpproxy/blob/main/html/logs.html
Handles fetching logs based on selected filters (level, limit) and retrieving statistics about the logs. Includes error handling for API requests.
```javascript
async function loadLogs() {
const level = document.getElementById('levelFilter').value;
const limit = document.getElementById('limitFilter').value;
const params = new URLSearchParams();
if (level) params.append('level', level);
if (limit) params.append('limit', limit);
try {
const response = await fetch(`/api/logs?${params.toString()}`);
if (!response.ok) {
throw new Error('Failed to load logs');
}
const entries = await response.json();
// Ensure entries is always an array
const entriesArray = Array.isArray(entries) ? entries : [];
renderLogs(entriesArray);
} catch (error) {
document.getElementById('logContainer').innerHTML = `Error loading logs: ${error.message}
`;
}
}
async function loadStats() {
try {
const response = await fetch('/api/logs/stats');
if (!response.ok) {
throw new Error('Failed to load stats');
}
const stats = await response.json();
const statsHtml = ` Total Entries: ${stats.total_entries} / ${stats.max_entries} | Retention: ${stats.retention_hours} hours | Levels: ${Object.entries(stats.level_counts || {}).map(([k, v]) => `${k}: ${v}`).join(', ')} | ${stats.oldest_entry ? `Oldest: ${formatTimestamp(stats.oldest_entry)} |` : ''} ${stats.newest_entry ? `Newest: ${formatTimestamp(stats.newest_entry)}` : ''} `;
document.getElementById('stats').innerHTML = statsHtml;
} catch (error) {
document.getElementById('stats').innerHTML = `Error loading stats: ${error.message}`;
}
}
```
--------------------------------
### Retrieve Log Entries
Source: https://context7.com/wimaha/teslablehttpproxy/llms.txt
Fetches stored log entries. Supports filtering by log level, time range, and a limit on the number of entries returned. Also provides access to log statistics.
```APIDOC
## GET /api/logs — Retrieve Log Entries
### Description
Returns stored log entries as a JSON array. Supports filtering by log level, time range, and count limit.
### Method
GET
### Endpoint
/api/logs
### Parameters
#### Query Parameters
- **level** (string) - Optional - Filters logs by the specified level (e.g., 'error').
- **since** (string) - Optional - Filters logs that occurred since the specified timestamp (RFC3339 format).
- **limit** (integer) - Optional - Limits the number of log entries returned.
### Response
#### Success Response (200)
- (array) - An array of log entry objects, each containing details like 'level', 'message', and 'time'.
### Response Example
```json
[
{"level":"INFO","message":"Received HTTP request","time":"2024-08-01T12:00:00Z",...},
{"level":"DEBUG","message":"VehicleData endpoint cache hit","time":"..."}
]
```
## GET /api/logs/stats — Log Statistics
### Description
Retrieves statistics about the stored log entries.
### Method
GET
### Endpoint
/api/logs/stats
### Response
#### Success Response (200)
- (object) - An object containing counts for different log levels.
- **total** (integer) - Total number of log entries.
- **debug** (integer) - Number of debug level logs.
- **info** (integer) - Number of info level logs.
- **warn** (integer) - Number of warning level logs.
- **error** (integer) - Number of error level logs.
### Response Example
```json
{"total": 1240, "debug": 800, "info": 380, "warn": 40, "error": 20}
```
```
--------------------------------
### API: Set Charging Amps
Source: https://github.com/wimaha/teslablehttpproxy/blob/main/README.md
Sets the charging amps for the vehicle. Requires a JSON body specifying the desired amperage. Automatically wakes the vehicle if it is asleep.
```http
http://localhost:8080/api/1/vehicles/{VIN}/command/set_charging_amps
```
--------------------------------
### Vehicle Data
Source: https://github.com/wimaha/teslablehttpproxy/blob/main/README.md
Retrieve vehicle data, which is fetched from the vehicle and returned in a format similar to the Tesla Fleet API. Responses are cached in memory. The `wakeup` parameter can be used to wake the car if it's asleep.
```APIDOC
## Vehicle Data API
### Description
This API endpoint allows you to retrieve various data points from your Tesla vehicle. The data is fetched via BLE and returned in a format consistent with the Tesla Fleet API. Responses are cached to improve performance. By default, the vehicle is not woken up automatically, but you can enable this with the `wakeup` parameter.
### Method
GET
### Endpoint
`/api/1/vehicles/{VIN}/vehicle_data`
### Parameters
#### Path Parameters
- **VIN** (string) - Required - The Vehicle Identification Number.
#### Query Parameters
- **wakeup** (boolean) - Optional - If `true`, the vehicle will be woken up if it is asleep before fetching data. The proxy intelligently skips this check if the vehicle was recently confirmed awake.
- **endpoints** (string) - Optional - A comma-separated list of specific data endpoints to retrieve (e.g., `charge_state,climate_state`). If not provided, a default set of data is returned.
### Examples
**Get all vehicle data:**
`GET http://localhost:8080/api/1/vehicles/{VIN}/vehicle_data`
**Get vehicle data with automatic wakeup:**
`GET http://localhost:8080/api/1/vehicles/{VIN}/vehicle_data?wakeup=true`
**Get specific data (charge state only):**
`GET http://localhost:8080/api/1/vehicles/{VIN}/vehicle_data?endpoints=charge_state`
**Get specific data with automatic wakeup:**
`GET http://localhost:8080/api/1/vehicles/{VIN}/vehicle_data?endpoints=charge_state&wakeup=true`
### Response
#### Success Response (200)
Returns a JSON object containing the requested vehicle data. Default data includes `charge_state` and `climate_state`. Specific data can be requested via the `endpoints` parameter.
Example (partial):
```json
{
"charge_state": {
"charging_status": "Charging",
"charge_miles_added": 1.5,
"charge_energy_added": 0.5,
"battery_level": 75,
"battery_range": 200
},
"climate_state": {
"inside_temp": 22,
"outside_temp": 18,
"is_climate_on": true
}
}
```
```
--------------------------------
### API: Explicitly Wake Up Vehicle
Source: https://github.com/wimaha/teslablehttpproxy/blob/main/README.md
Manually wakes up the vehicle. This command is automatically handled by other commands if the vehicle is asleep, but can be called explicitly.
```http
http://localhost:8080/api/1/vehicles/{VIN}/command/wake_up
```
--------------------------------
### Vehicle Commands
Source: https://github.com/wimaha/teslablehttpproxy/blob/main/README.md
Send commands to the Tesla vehicle. Commands automatically wake up the vehicle if it is asleep. The `wait` parameter can be set to `true` to wait for the command to complete.
```APIDOC
## Vehicle Commands API
### Description
This API allows you to send various commands to your Tesla vehicle. The proxy handles waking up the vehicle automatically if it is asleep. You can optionally wait for the command to complete by setting the `wait` query parameter to `true`.
### Supported Commands
- wake_up
- charge_start
- charge_stop
- set_charging_amps
- set_charge_limit
- auto_conditioning_start
- auto_conditioning_stop
- charge_port_door_open
- charge_port_door_close
- flash_lights
- honk_horn
- door_lock
- door_unlock
- set_sentry_mode
### Method
POST
### Endpoint
`/api/1/vehicles/{VIN}/command/{command_name}`
### Parameters
#### Path Parameters
- **VIN** (string) - Required - The Vehicle Identification Number.
- **command_name** (string) - Required - The name of the command to execute (e.g., `charge_start`).
#### Query Parameters
- **wait** (boolean) - Optional - If `true`, the request will wait for the command to complete before returning.
### Request Body
For commands like `set_charging_amps`, a JSON body is required:
```json
{
"charging_amps": ""
}
```
### Examples
**Start charging:**
`POST http://localhost:8080/api/1/vehicles/{VIN}/command/charge_start`
**Start charging and wait for completion:**
`POST http://localhost:8080/api/1/vehicles/{VIN}/command/charge_start?wait=true`
**Stop charging:**
`POST http://localhost:8080/api/1/vehicles/{VIN}/command/charge_stop`
**Set charging amps to 5A:**
`POST http://localhost:8080/api/1/vehicles/{VIN}/command/set_charging_amps`
Request Body:
```json
{
"charging_amps": "5"
}
```
**Explicitly wake up the vehicle:**
`POST http://localhost:8080/api/1/vehicles/{VIN}/command/wake_up`
```
--------------------------------
### Send Public Key to Tesla via BLE
Source: https://github.com/wimaha/teslablehttpproxy/blob/main/docs/manually_gen_key.md
Transmits the generated public key to the Tesla vehicle using the tesla-control tool over Bluetooth Low Energy. Replace YOUR_VIN with the actual vehicle VIN.
```bash
tesla-control -vin YOUR_VIN -ble add-key-request public.pem owner cloud_key
```
--------------------------------
### evcc Configuration for Full Vehicle Data
Source: https://github.com/wimaha/teslablehttpproxy/blob/main/README.md
Use this configuration in evcc for the Tesla BLE HTTP Proxy to access both vehicle data and commands. Ensure VIN and URL are correctly set.
```yaml
vehicles:
- name: tesla
type: template
template: tesla-ble
title: Your Tesla (optional)
capacity: 60 # Akkukapazität in kWh (optional)
vin: VIN # Erforderlich für BLE-Verbindung
url: IP # URL des Tesla BLE HTTP Proxy
port: 8080 # Port des Tesla BLE HTTP Proxy (optional)
```
--------------------------------
### API: Set Charging Amps Body
Source: https://github.com/wimaha/teslablehttpproxy/blob/main/README.md
The JSON body required for the `set_charging_amps` API endpoint. Specifies the desired charging amperage.
```json
{"charging_amps": "5"}
```
--------------------------------
### Set Environment Variables in Docker Compose
Source: https://github.com/wimaha/teslablehttpproxy/blob/main/docs/environment_variables.md
Use the 'environment' section in your docker-compose.yml to define environment variables for the application. This is a common method for configuring containerized applications.
```yaml
environment:
- logLevel=debug
- scanTimeout=5
- cacheMaxAge=10
- vehicleDataCacheTime=60
- httpListenAddress=:5687
```
--------------------------------
### JavaScript Confirmation for Key Removal
Source: https://github.com/wimaha/teslablehttpproxy/blob/main/html/dashboard.html
This JavaScript function is used to display a confirmation dialog before removing a Tesla API key. It warns the user about the irreversible nature of the action and potential consequences.
```javascript
function confirmRemoveKey(displayName) {
var message = '⚠️ WARNING: This action cannot be undone!\n\n';
message += 'You are about to remove the key for "' + displayName + '".\n\n';
message += 'After removal:\n';
message += '• The key will be permanently deleted\n';
message += '• You may need to set up a new key if this was your only key\n';
message += '• If this is the active key, the proxy will stop working until you activate another key\n\n';
message += 'Are you absolutely sure you want to proceed?';
return confirm(message);
}
```
--------------------------------
### Poll Vehicle Body Controller State
Source: https://context7.com/wimaha/teslablehttpproxy/llms.txt
Use this endpoint to poll the vehicle's body controller state without waking the vehicle. Responses include Cache-Control headers.
```bash
VIN="5YJ3E1EA1JF123456"
BASE="http://localhost:8080"
curl -s "$BASE/api/1/vehicles/$VIN/body_controller_state" | jq .
```
--------------------------------
### Update Interval Display
Source: https://github.com/wimaha/teslablehttpproxy/blob/main/html/logs.html
Updates the visual display of the selected refresh interval. Ensures the UI reflects the current setting.
```javascript
function updateIntervalDisplay() {
const intervalSelect = document.getElementById('intervalSelect');
const selectedInterval = parseInt(intervalSelect.value);
if (selectedInterval === 0) {
intervalSelect.disabled = true;
intervalSelect.style.opacity = '0.6';
intervalSelect.style.cursor = 'not-allowed';
} else {
intervalSelect.disabled = false;
intervalSelect.style.opacity = '1';
intervalSelect.style.cursor = 'pointer';
}
}
```
--------------------------------
### Body Controller State
Source: https://github.com/wimaha/teslablehttpproxy/blob/main/README.md
Retrieve the state of the vehicle's body controller. This request does not wake up the vehicle. It provides information on vehicle lock status, sleep status, and user presence.
```APIDOC
## Body Controller State API
### Description
This API endpoint retrieves the current state of the vehicle's body controller. This request does not initiate a vehicle wake-up. The response includes details about the vehicle's lock status, sleep status, and user presence.
### Method
GET
### Endpoint
`/api/1/vehicles/{VIN}/body_controller_state`
### Parameters
#### Path Parameters
- **VIN** (string) - Required - The Vehicle Identification Number.
### Response
#### Success Response (200)
Returns a JSON object with the body controller state.
Example:
```json
{
"vehicleLockState": "VEHICLELOCKSTATE_LOCKED",
"vehicleSleepStatus": "VEHICLE_SLEEP_STATUS_ASLEEP",
"userPresence": "VEHICLE_USER_PRESENCE_NOT_PRESENT"
}
```
#### Possible Values
- **vehicleLockState**:
- `VEHICLELOCKSTATE_UNLOCKED`
- `VEHICLELOCKSTATE_LOCKED`
- `VEHICLELOCKSTATE_INTERNAL_LOCKED`
- `VEHICLELOCKSTATE_SELECTIVE_UNLOCKED`
- **vehicleSleepStatus**:
- `VEHICLE_SLEEP_STATUS_UNKNOWN`
- `VEHICLE_SLEEP_STATUS_AWAKE`
- `VEHICLE_SLEEP_STATUS_ASLEEP`
- **userPresence**:
- `VEHICLE_USER_PRESENCE_UNKNOWN`
- `VEHICLE_USER_PRESENCE_NOT_PRESENT`
- `VEHICLE_USER_PRESENCE_PRESENT`
```
--------------------------------
### API: Stop Charging
Source: https://github.com/wimaha/teslablehttpproxy/blob/main/README.md
Stops the charging process for the specified vehicle. The request automatically wakes the vehicle if it is asleep.
```http
http://localhost:8080/api/1/vehicles/{VIN}/command/charge_stop
```