tesla-fleet-api
Version:
A library for the [Tesla Fleet API](https://developer.tesla.com/docs/fleet-api), and the third parties services [Teslemetry](https://teslemetry.com/docs/getting-started/api) and [Tessie](https://developer.tessie.com/docs/tesla-api-comparison), which provi
445 lines (444 loc) • 17.9 kB
TypeScript
import { AlertTypes, ClimateMode, CommandResponse, Level, Seat, Trunk, VehicleDataEndpoint } from "./types/commands.js";
import { OptionsResponse } from "./types/responses.js";
import { VehicleResponse } from "./types/vehicle.js";
import { VehicleDataResponse } from "./types/vehicle_data.js";
import Vehicle from "./vehicle.js";
interface FleetTelemetryConfig {
hostname: string;
ca: string;
fields: {
[key: string]: {
interval_seconds: number;
};
};
alert_types: AlertTypes[];
exp: number;
port: number;
}
export default class VehicleSpecific {
parent: Vehicle;
vin: string;
model: string;
pre2021: boolean;
constructor(parent: Vehicle, vin: string);
/**
* Controls the front (which_trunk: "front") or rear (which_trunk: "rear") trunk.
* @param which_trunk "front" or "rear"
*/
actuate_truck(which_trunk: Trunk): Promise<CommandResponse>;
/**
* Adjusts vehicle media playback volume.
* @param volume A floating point number from 0.0 to 11.0.
*/
adjust_volume(volume: number): Promise<CommandResponse>;
/**
* Starts climate preconditioning.
*/
auto_conditioning_start(): Promise<CommandResponse>;
/**
* Stops climate preconditioning.
*/
auto_conditioning_stop(): Promise<CommandResponse>;
/**
* Cancels the countdown to install the vehicle software update.
*/
cancel_software_update(): Promise<CommandResponse>;
/**
* Charges in max range mode -- we recommend limiting the use of this mode to long trips.
*/
charge_max_range(): Promise<CommandResponse>;
/**
* Closes the charge port door.
*/
charge_port_door_close(): Promise<CommandResponse>;
/**
* Opens the charge port door.
*/
charge_port_door_open(): Promise<CommandResponse>;
/**
* Charges in Standard mode.
*/
charge_standard(): Promise<CommandResponse>;
/**
* Starts charging the vehicle.
*/
charge_start(): Promise<CommandResponse>;
/**
* Stops charging the vehicle.
*/
charge_stop(): Promise<CommandResponse>;
/**
* Deactivates PIN to Drive and resets the associated PIN for vehicles running firmware versions 2023.44+. This command is only accessible to fleet managers or owners.
*/
clear_pin_to_drive_admin(): Promise<CommandResponse>;
/**
* Locks the vehicle.
*/
door_lock(): Promise<CommandResponse>;
/**
* Unlocks the vehicle.
*/
door_unlock(): Promise<CommandResponse>;
/**
* Erases user's data from the user interface. Requires the vehicle to be in park.
*/
erase_user_data(): Promise<CommandResponse>;
/**
* Briefly flashes the vehicle headlights. Requires the vehicle to be in park.
*/
flash_lights(): Promise<CommandResponse>;
/**
* Restricts certain vehicle UI functionality from guest users
* @param enable `true` or `false`
*/
guest_mode(enable: boolean): Promise<CommandResponse>;
/**
* Honks the vehicle horn. Requires the vehicle to be in park.
*/
honk_horn(): Promise<CommandResponse>;
/**
* Advances media player to next favorite track.
*/
media_next_fav(): Promise<CommandResponse>;
/**
* Advances media player to next track.
*/
media_next_track(): Promise<CommandResponse>;
/**
* Advances media player to previous favorite track.
*/
media_prev_fav(): Promise<CommandResponse>;
/**
* Advances media player to previous track.
*/
media_prev_track(): Promise<CommandResponse>;
/**
* Toggles current play/pause state.
*/
media_toggle_playback(): Promise<CommandResponse>;
/**
* Turns the volume down by one.
*/
media_volume_down(): Promise<CommandResponse>;
/**
* Start navigation to given coordinates. Order can be used to specify order of multiple stops.
* @param lat Latitude
* @param lon Longitude
* @param order Order of multiple stops
*/
navigation_gps_request(lat: number, lon: number, order?: number): Promise<CommandResponse>;
/**
* Sends a location to the in-vehicle navigation system.
* @param type "share_ext_content_raw"
* @param locale ISO locale such as "en-US"
* @param timestamp_ms
*/
navigation_request(value: string, locale: string, type?: string): Promise<CommandResponse>;
/**
* Start navigation to a supercharger.
* @param id Supercharger ID
* @param order Order of multiple stops
* @returns
*/
navigation_sc_request(id: number, order?: number): Promise<CommandResponse>;
/**
* Sets automatic seat heating and cooling.
* @param auto_seat_position Seat position
* @param auto_climate_on `true` or `false`
*/
remote_auto_seat_climate_request(auto_seat_position: Seat | number, auto_climate_on: boolean): Promise<CommandResponse>;
/**
* Sets automatic steering wheel heating on/off.
* @param on `true` or `false`
*/
remote_auto_steering_wheel_heat_climate_request(on: boolean): Promise<CommandResponse>;
/**
* Plays a sound through the vehicle external speaker.
* @param sound Fart is `0`, Locate ping is `2000`
*/
remote_boombox(sound?: number): Promise<CommandResponse>;
/**
* Sets seat cooling.
* @param seat_position Seat position
* @param seat_cooler_level Cooling level
*/
remote_seat_cooler_request(seat_position: Seat | number, seat_cooler_level: Level): Promise<CommandResponse>;
/**
* Sets seat heating.
* @param seat_position Seat position
* @param seat_heater_level Heating level
*/
remote_seat_heater_request(seat_position: Seat | number, seat_heater_level: Level): Promise<CommandResponse>;
/**
* Starts the vehicle remotely. Requires keyless driving to be enabled.
*/
remote_start_drive(): Promise<CommandResponse>;
/**
* Sets steering wheel heat level.
* @param level Heating level
*/
remote_steering_wheel_heat_level_request(level: Level): Promise<CommandResponse>;
/**
* Sets steering wheel heating on/off. For vehicles that do not support auto steering wheel heat.
* @param on `true` or `false`
*/
remote_steering_wheel_heater_request(on: boolean): Promise<CommandResponse>;
/**
* Removes PIN to Drive. Requires the car to be in Pin to Drive mode and not in Valet mode. Note that this only works if PIN to Drive is not active. This command also requires the Tesla Vehicle Command Protocol - for more information, please see refer to the documentation here.
*/
reset_pin_to_drive_pin(): Promise<CommandResponse>;
/**
* Removes PIN for Valet Mode.
*/
reset_valet_pin(): Promise<CommandResponse>;
/**
* Schedules a vehicle software update (over the air "OTA") to be installed in the future.
* @param offset_sec Offset in seconds
*/
schedule_software_update(offset_sec: number): Promise<CommandResponse>;
/**
* Turns Bioweapon Defense Mode on and off.
* @param on `true` or `false`
* @param manual_override `true` or `false`
*/
set_bioweapon_mode(on: boolean, manual_override: boolean): Promise<CommandResponse>;
/**
* Sets the vehicle overheat protection.
* @param on `true` or `false`
* @param fan_only `true` or `false`
*/
set_cabin_overheat_protection(on: boolean, fan_only: boolean): Promise<CommandResponse>;
/**
* Sets the vehicle's charge limit to a custom percentage.
* @param percent Charge limit percentage typically between 50-100
*/
set_charge_limit(percent: number): Promise<CommandResponse>;
/**
* Sets the charge limit to the standard setting.
* @param percent Current limit in Amps typically between 5-32
*/
set_charging_amps(charging_amps: number): Promise<CommandResponse>;
/**
* Enables climate keeper mode.
* @param climate_keeper_mode `0` is Off, `1` is Keep, `2` is Dog, `3` is Camp
*/
set_climate_keeper_mode(climate_keeper_mode: number | ClimateMode): Promise<CommandResponse>;
/**
* Adjusts the Cabin Overheat Protection temperature (COP).
* @param cop_temp Integer representing Low (0/30C/90F), Medium (1/35C/95F), or High (2/40C/100F)
*/
set_cop_temp(cop_temp: 0 | 1 | 2 | 30 | 35 | 40 | 90 | 95 | 100): Promise<CommandResponse>;
/**
* Sets a four-digit passcode for PIN to Drive. This PIN must then be entered before the vehicle can be driven.
* @param on `true` or `false`
* @param password Four-digit passcode
*/
set_pin_to_drive(on: boolean, password: string | number): Promise<CommandResponse>;
/**
* Sets an override for preconditioning — it should default to empty if no override is used.
* Also known as "Defrost Mode"
* @param on `true` or `false`
* @param manual_override `true` or `false`
*/
set_preconditioning_max(on: boolean, manual_override: boolean): Promise<CommandResponse>;
/**
* Sets a time at which charging should be completed. The time parameter is minutes after midnight (e.g: time=120 schedules charging for 2:00am vehicle local time).
* @param enable `true` or `false`
* @param time Minutes after midnight
*/
set_scheduled_charging(enable: boolean, time: number): Promise<CommandResponse>;
/**
* Sets a time at which departure should be completed. The time parameter is minutes after midnight (e.g: time=120 schedules departure for 2:00am vehicle local time).
* @param enable `true` or `false`
* @param preconditioning_enabled `true` or `false`
* @param preconditioning_weekdays_only `true` or `false`
* @param departure_time Minutes after midnight
* @param off_peak_charging_enabled `true` or `false`
* @param off_peak_charging_weekdays_only `true` or `false`
* @param end_off_peak_time Minutes after midnight
*/
set_scheduled_departure(enable?: boolean, preconditioning_enabled?: boolean, preconditioning_weekdays_only?: boolean, departure_time?: number, off_peak_charging_enabled?: boolean, off_peak_charging_weekdays_only?: boolean, end_off_peak_time?: number): Promise<CommandResponse>;
/**
* Enables and disables Sentry Mode. Sentry Mode allows customers to watch the vehicle cameras live from the mobile app, as well as record sentry events.
* @param on `true` or `false`
*/
set_sentry_mode(on: boolean): Promise<CommandResponse>;
/**
* Sets the driver and/or passenger-side cabin temperature (and other zones if sync is enabled).
* @param driver_temp Driver temperature
* @param passenger_temp Passenger temperature
*/
set_temps(driver_temp: number, passenger_temp: number): Promise<CommandResponse>;
/**
* Turns on Valet Mode and sets a four-digit passcode that must then be entered to disable Valet Mode.
* @param on `true` or `false`
* @param password Four-digit passcode
*/
set_valet_mode(on: boolean, password: string | number): Promise<CommandResponse>;
/**
* Changes the name of a vehicle. This command also requires the Tesla Vehicle Command Protocol - for more information, please see refer to the documentation here.
* @param vehicle_name New name
*/
set_vehicle_name(vehicle_name: string): Promise<CommandResponse>;
/**
* Activates Speed Limit Mode with a four-digit PIN.
* @param pin Four-digit PIN
*/
speed_limit_activate(pin: string | number): Promise<CommandResponse>;
/**
* Deactivates Speed Limit Mode and resets the associated PIN.
* @param pin Four-digit PIN
*/
speed_limit_clear_pin(pin: string | number): Promise<CommandResponse>;
/**
* Deactivates Speed Limit Mode and resets the associated PIN for vehicles running firmware versions 2023.38+. This command is only accessible to fleet managers or owners.
*/
speed_limit_clear_pin_admin(): Promise<CommandResponse>;
/**
* Deactivates Speed Limit Mode.
* @param pin Four-digit PIN
*/
speed_limit_deactivate(pin: string | number): Promise<CommandResponse>;
/**
* Sets the maximum speed allowed when Speed Limit Mode is active.
* @param limit_mph Maximum speed in MPH
*/
speed_limit_set_limit(limit_mph: number): Promise<CommandResponse>;
/**
* Controls the panoramic sunroof on the Model S.
* @param state "stop", "close" or "vent"
*/
sun_roof_control(state: "stop" | "close" | "vent"): Promise<CommandResponse>;
/**
* Records a drive note. The note parameter is truncated to 80 characters in length.
* @param note Drive note
*/
take_drivenote(note: string): Promise<CommandResponse>;
/**
* Turns on HomeLink (used to open and close garage doors).
* @param token
* @param lat Latitude
* @param lon Longitude
*/
trigger_homelink(lat: number, lon: number, token?: string): Promise<CommandResponse>;
/**
* Upcoming calendar entries stored on the vehicle.
* @param calendar_data Calendar data
*/
upcoming_calendar_entries(calendar_data: string): Promise<CommandResponse>;
/**
* Control the windows of a parked vehicle. Supported commands: vent and close. When closing, specify lat and lon of user to ensure they are within range of vehicle (unless this is an M3 platform vehicle).
* @param command "vent" or "close"
* @param lat Latitude
* @param lon Longitude
*/
window_control(command: "vent" | "close", lat: number, lon: number): Promise<CommandResponse>;
/**
* Returns all allowed drivers for a vehicle. This endpoint is only available for the vehicle owner.
*/
drivers(): Promise<Record<string, any>>;
/**
* Removes driver access from a vehicle. Share users can only remove their own access. Owners can remove share access or their own.
* @param share_user_id
*/
drivers_remove(share_user_id?: number): Promise<Record<string, any>>;
/**
* Returns eligible vehicle subscriptions.
* @param vin Vehicle Identification Number
*/
eligible_subscriptions(): Promise<Record<string, any>>;
/**
* Returns eligibile vehicle upgrades.
* @param vin Vehicle Identification Number
*/
eligible_upgrades(): Promise<Record<string, any>>;
/**
* Checks whether vehicles can accept Tesla commands protocol for the partner's public key
* @param vins list of Vehicle Identification Number
* @returns
*/
fleet_status(): Promise<Record<string, any>>;
/**
* Configures vehicles to connect to self-hosted fleet-telemetry server. This endpoint has concurrency 1 (status 429 will be returned if many calls are made at the same time). Multiple vehicles can be configured with a single call.
* @param config A dictionary description the fleet telemetry configuration
* @returns
*/
fleet_telemetry_config(config: FleetTelemetryConfig): Promise<Record<string, any>>;
/**
* Disconnects vehicles to stream telemetry data to self hosted fleet-telemetry server.
* @returns
*/
fleet_telemetry_config_delete(): Promise<Record<string, any>>;
/**
* Fetches a vehicle's fleet telemetry config. synced set to true means the vehicle has adopted the target config. synced set to false means the vehicle will attempt to adopt the target config when it next establishes a backend connection.
* @returns
*/
fleet_telemetry_config_get(): Promise<Record<string, any>>;
/**
* Returns whether or not mobile access is enabled for the vehicle.
*/
mobile_enabled(): Promise<Record<string, any>>;
/**
* Returns the charging sites near the current location of the vehicle.
* @param count
* @param radius
* @param detail
*/
nearby_charging_sites(count?: number, radius?: number, detail?: boolean): Promise<Record<string, any>>;
/**
* Returns vehicle option details.
* @param vin Vehicle Identification Number
*/
options(vin: string): Promise<OptionsResponse>;
/**
* List of recent alerts
*/
recent_alerts(): Promise<Record<string, any>>;
/**
* Returns firmware release notes.
* @param staged
* @param language
*/
release_notes(staged?: boolean, language?: string): Promise<Record<string, any>>;
/**
* Returns service data.
*/
service_data(): Promise<Record<string, any>>;
/**
* Returns the share invites for a vehicle.
*/
share_invites(): Promise<Record<string, any>>;
/**
* Creates a share invite for a vehicle.
*/
share_invites_create(): Promise<Record<string, any>>;
/**
* Revokes a share invite.
* @param id
*/
share_invites_revoke(id: string): Promise<Record<string, any>>;
/**
* Signed Commands is a generic endpoint replacing legacy commands.
* @param routable_message
*/
signed_command(routable_message: string): Promise<Record<string, any>>;
/**
* Returns information about a vehicle.
*/
vehicle(): Promise<VehicleResponse>;
/**
* Makes a live call to the vehicle. This may return cached data if the vehicle is offline. For vehicles running firmware versions 2023.38+, location_data is required to fetch vehicle location. This will result in a location sharing icon to show on the vehicle UI.
* @param endpoints
*/
vehicle_data(endpoints?: VehicleDataEndpoint[] | string): Promise<VehicleDataResponse>;
/**
* Wakes the vehicle from sleep, which is a state to minimize idle energy consumption.
*/
wake_up(): Promise<Record<string, any>>;
/**
* Returns warranty details.
* @param vin
*/
warranty_details(): Promise<Record<string, any>>;
}
export {};