tesla-fleet-api 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +284 -1
- package/dist/_virtual/_rolldown/runtime.cjs +10 -0
- package/dist/bluetooth/adapters/shared.cjs +38 -0
- package/dist/bluetooth/adapters/shared.mjs +36 -0
- package/dist/bluetooth/async.cjs +121 -0
- package/dist/bluetooth/async.d.cts +10 -0
- package/dist/bluetooth/async.d.mts +10 -0
- package/dist/bluetooth/async.mjs +116 -0
- package/dist/bluetooth/broadcast.cjs +153 -0
- package/dist/bluetooth/broadcast.d.cts +59 -0
- package/dist/bluetooth/broadcast.d.mts +59 -0
- package/dist/bluetooth/broadcast.mjs +151 -0
- package/dist/bluetooth/constants.cjs +99 -0
- package/dist/bluetooth/constants.d.cts +70 -0
- package/dist/bluetooth/constants.d.mts +70 -0
- package/dist/bluetooth/constants.mjs +72 -0
- package/dist/bluetooth/esphome.cjs +292 -0
- package/dist/bluetooth/esphome.d.cts +83 -0
- package/dist/bluetooth/esphome.d.mts +83 -0
- package/dist/bluetooth/esphome.mjs +291 -0
- package/dist/bluetooth/framing.cjs +125 -0
- package/dist/bluetooth/framing.d.cts +45 -0
- package/dist/bluetooth/framing.d.mts +45 -0
- package/dist/bluetooth/framing.mjs +122 -0
- package/dist/bluetooth/homey.cjs +155 -0
- package/dist/bluetooth/homey.d.cts +75 -0
- package/dist/bluetooth/homey.d.mts +75 -0
- package/dist/bluetooth/homey.mjs +150 -0
- package/dist/bluetooth/names.cjs +24 -0
- package/dist/bluetooth/names.d.cts +10 -0
- package/dist/bluetooth/names.d.mts +10 -0
- package/dist/bluetooth/names.mjs +20 -0
- package/dist/bluetooth/noble.cjs +178 -0
- package/dist/bluetooth/noble.d.cts +58 -0
- package/dist/bluetooth/noble.d.mts +58 -0
- package/dist/bluetooth/noble.mjs +177 -0
- package/dist/bluetooth/streamglue.cjs +157 -0
- package/dist/bluetooth/streamglue.d.cts +37 -0
- package/dist/bluetooth/streamglue.d.mts +37 -0
- package/dist/bluetooth/streamglue.mjs +154 -0
- package/dist/bluetooth/teslabluetooth.cjs +67 -0
- package/dist/bluetooth/teslabluetooth.d.cts +41 -0
- package/dist/bluetooth/teslabluetooth.d.mts +41 -0
- package/dist/bluetooth/teslabluetooth.mjs +66 -0
- package/dist/bluetooth/transport.cjs +10 -0
- package/dist/bluetooth/transport.d.cts +95 -0
- package/dist/bluetooth/transport.d.mts +95 -0
- package/dist/bluetooth/transport.mjs +10 -0
- package/dist/bluetooth/vehiclebluetooth.cjs +1272 -0
- package/dist/bluetooth/vehiclebluetooth.d.cts +495 -0
- package/dist/bluetooth/vehiclebluetooth.d.mts +495 -0
- package/dist/bluetooth/vehiclebluetooth.mjs +1270 -0
- package/dist/bluetooth/verify.cjs +93 -0
- package/dist/bluetooth/verify.d.cts +35 -0
- package/dist/bluetooth/verify.d.mts +35 -0
- package/dist/bluetooth/verify.mjs +91 -0
- package/dist/bluetooth.cjs +53 -0
- package/dist/bluetooth.d.cts +10 -0
- package/dist/bluetooth.d.mts +10 -0
- package/dist/bluetooth.mjs +9 -0
- package/dist/commands.cjs +1080 -85
- package/dist/commands.d.cts +585 -54
- package/dist/commands.d.mts +583 -51
- package/dist/commands.mjs +1084 -93
- package/dist/const.cjs +22 -0
- package/dist/const.d.cts +21 -0
- package/dist/const.d.mts +21 -0
- package/dist/const.mjs +20 -1
- package/dist/energy.cjs +24 -19
- package/dist/energy.d.cts +21 -15
- package/dist/energy.d.mts +21 -15
- package/dist/energy.mjs +24 -19
- package/dist/energyisland.cjs +38 -0
- package/dist/energyisland.mjs +37 -0
- package/dist/energyparsers.cjs +118 -0
- package/dist/energyparsers.d.cts +39 -0
- package/dist/energyparsers.d.mts +39 -0
- package/dist/energyparsers.mjs +116 -0
- package/dist/energyspecific.cjs +375 -17
- package/dist/energyspecific.d.cts +199 -19
- package/dist/energyspecific.d.mts +197 -16
- package/dist/energyspecific.mjs +370 -18
- package/dist/exceptions.cjs +3 -2
- package/dist/exceptions.d.cts +3 -2
- package/dist/exceptions.d.mts +3 -2
- package/dist/exceptions.mjs +3 -2
- package/dist/funnel.cjs +297 -0
- package/dist/funnel.d.cts +118 -0
- package/dist/funnel.d.mts +118 -0
- package/dist/funnel.mjs +292 -0
- package/dist/index.cjs +61 -0
- package/dist/index.d.cts +22 -8
- package/dist/index.d.mts +22 -8
- package/dist/index.mjs +19 -6
- package/dist/log.cjs +75 -0
- package/dist/log.d.cts +4 -0
- package/dist/log.d.mts +4 -0
- package/dist/log.mjs +71 -0
- package/dist/oauth.cjs +143 -0
- package/dist/oauth.d.cts +69 -0
- package/dist/oauth.d.mts +69 -0
- package/dist/oauth.mjs +143 -0
- package/dist/powerwall/client.cjs +818 -0
- package/dist/powerwall/client.d.cts +297 -0
- package/dist/powerwall/client.d.mts +297 -0
- package/dist/powerwall/client.mjs +807 -0
- package/dist/powerwall/components.cjs +188 -0
- package/dist/powerwall/components.d.cts +45 -0
- package/dist/powerwall/components.d.mts +45 -0
- package/dist/powerwall/components.mjs +182 -0
- package/dist/powerwall/energysite.cjs +216 -0
- package/dist/powerwall/energysite.d.cts +104 -0
- package/dist/powerwall/energysite.d.mts +104 -0
- package/dist/powerwall/energysite.mjs +214 -0
- package/dist/powerwall/exceptions.cjs +59 -0
- package/dist/powerwall/exceptions.d.cts +38 -0
- package/dist/powerwall/exceptions.d.mts +38 -0
- package/dist/powerwall/exceptions.mjs +51 -0
- package/dist/powerwall/gateway.cjs +102 -0
- package/dist/powerwall/gateway.d.cts +57 -0
- package/dist/powerwall/gateway.d.mts +57 -0
- package/dist/powerwall/gateway.mjs +101 -0
- package/dist/powerwall/merge.cjs +163 -0
- package/dist/powerwall/merge.d.cts +63 -0
- package/dist/powerwall/merge.d.mts +63 -0
- package/dist/powerwall/merge.mjs +159 -0
- package/dist/powerwall/models.d.cts +95 -0
- package/dist/powerwall/models.d.mts +95 -0
- package/dist/powerwall/queries.cjs +17 -0
- package/dist/powerwall/queries.mjs +10 -0
- package/dist/powerwall/transport.cjs +232 -0
- package/dist/powerwall/transport.mjs +227 -0
- package/dist/powerwall.cjs +47 -0
- package/dist/powerwall.d.cts +9 -0
- package/dist/powerwall.d.mts +9 -0
- package/dist/powerwall.mjs +8 -0
- package/dist/router/base.cjs +203 -0
- package/dist/router/base.d.cts +112 -0
- package/dist/router/base.d.mts +112 -0
- package/dist/router/base.mjs +200 -0
- package/dist/router/energysite.cjs +65 -0
- package/dist/router/energysite.d.cts +47 -0
- package/dist/router/energysite.d.mts +47 -0
- package/dist/router/energysite.mjs +60 -0
- package/dist/router.cjs +13 -0
- package/dist/router.d.cts +3 -1
- package/dist/router.d.mts +3 -1
- package/dist/router.mjs +3 -1
- package/dist/signing/crypto.cjs +28 -0
- package/dist/signing/crypto.mjs +26 -1
- package/dist/signing/energy.cjs +123 -0
- package/dist/signing/energy.d.cts +45 -0
- package/dist/signing/energy.d.mts +45 -0
- package/dist/signing/energy.mjs +120 -0
- package/dist/signing/jws.cjs +229 -0
- package/dist/signing/jws.d.cts +45 -0
- package/dist/signing/jws.d.mts +45 -0
- package/dist/signing/jws.mjs +211 -0
- package/dist/signing/keys.cjs +191 -0
- package/dist/signing/keys.d.cts +21 -0
- package/dist/signing/keys.d.mts +21 -0
- package/dist/signing/keys.mjs +182 -0
- package/dist/signing/session.cjs +104 -30
- package/dist/signing/session.d.cts +60 -23
- package/dist/signing/session.d.mts +60 -23
- package/dist/signing/session.mjs +105 -31
- package/dist/tariff.cjs +27 -0
- package/dist/tariff.d.cts +11 -0
- package/dist/tariff.d.mts +11 -0
- package/dist/tariff.mjs +27 -1
- package/dist/teslafleetapi.cjs +256 -55
- package/dist/teslafleetapi.d.cts +110 -14
- package/dist/teslafleetapi.d.mts +110 -14
- package/dist/teslafleetapi.mjs +258 -57
- package/dist/teslemetry.cjs +152 -5
- package/dist/teslemetry.d.cts +95 -5
- package/dist/teslemetry.d.mts +93 -3
- package/dist/teslemetry.mjs +151 -6
- package/dist/teslemetryenergy.cjs +287 -0
- package/dist/teslemetryenergy.d.cts +154 -0
- package/dist/teslemetryenergy.d.mts +154 -0
- package/dist/teslemetryenergy.mjs +282 -0
- package/dist/teslemetryvehicle.cjs +407 -0
- package/dist/teslemetryvehicle.d.cts +238 -0
- package/dist/teslemetryvehicle.d.mts +238 -0
- package/dist/teslemetryvehicle.mjs +405 -0
- package/dist/tessie.cjs +42 -5
- package/dist/tessie.d.cts +51 -5
- package/dist/tessie.d.mts +49 -3
- package/dist/tessie.mjs +42 -5
- package/dist/tessievehicle.cjs +514 -0
- package/dist/tessievehicle.d.cts +333 -0
- package/dist/tessievehicle.d.mts +333 -0
- package/dist/tessievehicle.mjs +513 -0
- package/dist/types/live_status.d.cts +16 -16
- package/dist/types/live_status.d.mts +16 -16
- package/dist/types/responses.d.cts +5 -1
- package/dist/types/responses.d.mts +5 -1
- package/dist/types/vehicle.d.cts +7 -1
- package/dist/types/vehicle.d.mts +7 -1
- package/dist/types.d.cts +3 -3
- package/dist/types.d.mts +3 -3
- package/dist/util.cjs +41 -0
- package/dist/util.d.cts +18 -0
- package/dist/util.d.mts +18 -0
- package/dist/util.mjs +40 -0
- package/dist/vehicle.cjs +79 -36
- package/dist/vehicle.d.cts +42 -26
- package/dist/vehicle.d.mts +42 -26
- package/dist/vehicle.mjs +80 -37
- package/dist/vehiclesigned.cjs +20 -5
- package/dist/vehiclesigned.d.cts +14 -5
- package/dist/vehiclesigned.d.mts +14 -5
- package/dist/vehiclesigned.mjs +20 -5
- package/dist/vehiclespecific.cjs +126 -15
- package/dist/vehiclespecific.d.cts +82 -18
- package/dist/vehiclespecific.d.mts +82 -18
- package/dist/vehiclespecific.mjs +126 -15
- package/package.json +70 -3
|
@@ -0,0 +1,405 @@
|
|
|
1
|
+
import { ClosureState } from "./const.mjs";
|
|
2
|
+
import { InvalidResponse } from "./exceptions.mjs";
|
|
3
|
+
import Vehicle from "./vehicle.mjs";
|
|
4
|
+
import VehicleSpecific from "./vehiclespecific.mjs";
|
|
5
|
+
// src/teslemetryvehicle.ts
|
|
6
|
+
/** A Teslemetry vehicle: the Fleet REST commands plus Teslemetry's `custom_command` routes. */
|
|
7
|
+
var TeslemetryVehicle = class extends VehicleSpecific {
|
|
8
|
+
_request(method, path, params, json) {
|
|
9
|
+
return this.parent.parent._request(method, path, params, json);
|
|
10
|
+
}
|
|
11
|
+
_custom_command(name, json) {
|
|
12
|
+
return this._request("POST", `api/1/vehicles/${this.vin}/custom_command/${name}`, null, json);
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Get or set Auto mode.
|
|
16
|
+
* @deprecated Python marks this for removal in a future release.
|
|
17
|
+
* @param value `true` enables it, `false` disables it, omit to read it.
|
|
18
|
+
*/
|
|
19
|
+
async server_side_polling(value) {
|
|
20
|
+
this.parent.parent._log("This method is deprecated and will be removed in a future release.");
|
|
21
|
+
return this.parent.parent.server_side_polling(this.vin, value);
|
|
22
|
+
}
|
|
23
|
+
/** Force a refresh of the vehicle data. */
|
|
24
|
+
async data_refresh() {
|
|
25
|
+
return this.parent.parent.vehicle_data_refresh(this.vin);
|
|
26
|
+
}
|
|
27
|
+
/** Performs a no-op on the vehicle. */
|
|
28
|
+
async ping() {
|
|
29
|
+
return this._custom_command("ping");
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Open, close, move and stop the vehicle's doors, frunk, trunk, charge port and tonneau.
|
|
33
|
+
* @example await vehicle.closure({ front_trunk: ClosureState.OPEN });
|
|
34
|
+
*/
|
|
35
|
+
async closure(options = {}) {
|
|
36
|
+
const keys = [
|
|
37
|
+
["frontDriverDoor", options.front_driver_door],
|
|
38
|
+
["frontPassengerDoor", options.front_passenger_door],
|
|
39
|
+
["rearDriverDoor", options.rear_driver_door],
|
|
40
|
+
["rearPassengerDoor", options.rear_passenger_door],
|
|
41
|
+
["rearTrunk", options.rear_trunk],
|
|
42
|
+
["frontTrunk", options.front_trunk],
|
|
43
|
+
["chargePort", options.charge_port],
|
|
44
|
+
["tonneau", options.tonneau]
|
|
45
|
+
];
|
|
46
|
+
return this._custom_command("closure", Object.fromEntries(keys.filter(([, state]) => state !== ClosureState.NONE)));
|
|
47
|
+
}
|
|
48
|
+
/** Opens the rear trunk; unlike `actuate_trunk`, never closes it. */
|
|
49
|
+
async open_rear_trunk() {
|
|
50
|
+
return this.closure({ rear_trunk: ClosureState.OPEN });
|
|
51
|
+
}
|
|
52
|
+
/** Closes the rear trunk; unlike `actuate_trunk`, never opens it. */
|
|
53
|
+
async close_rear_trunk() {
|
|
54
|
+
return this.closure({ rear_trunk: ClosureState.CLOSE });
|
|
55
|
+
}
|
|
56
|
+
/** Opens the tonneau cover. */
|
|
57
|
+
async open_tonneau() {
|
|
58
|
+
return this.closure({ tonneau: ClosureState.OPEN });
|
|
59
|
+
}
|
|
60
|
+
/** Closes the tonneau cover. */
|
|
61
|
+
async close_tonneau() {
|
|
62
|
+
return this.closure({ tonneau: ClosureState.CLOSE });
|
|
63
|
+
}
|
|
64
|
+
/** Stops the tonneau cover. */
|
|
65
|
+
async stop_tonneau() {
|
|
66
|
+
return this.closure({ tonneau: ClosureState.STOP });
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Sets multiple seat heaters at once.
|
|
70
|
+
* @example await vehicle.seat_heater({ front_left: SeatHeaterLevel.HIGH });
|
|
71
|
+
*/
|
|
72
|
+
async seat_heater(options = {}) {
|
|
73
|
+
return this._custom_command("seat_heater", {
|
|
74
|
+
frontLeft: options.front_left,
|
|
75
|
+
frontRight: options.front_right,
|
|
76
|
+
rearLeft: options.rear_left,
|
|
77
|
+
rearRight: options.rear_right,
|
|
78
|
+
rearLeftBack: options.rear_left_back,
|
|
79
|
+
rearCenter: options.rear_center,
|
|
80
|
+
rearRightBack: options.rear_right_back,
|
|
81
|
+
thirdRowLeft: options.third_row_left,
|
|
82
|
+
thirdRowRight: options.third_row_right
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Enable or disable charging on solar, and set its charge limits.
|
|
87
|
+
* @param enabled
|
|
88
|
+
* @param lower_charge_limit 0 to `upper_charge_limit`
|
|
89
|
+
* @param upper_charge_limit `lower_charge_limit` to 100
|
|
90
|
+
*/
|
|
91
|
+
async charge_on_solar(enabled, lower_charge_limit, upper_charge_limit) {
|
|
92
|
+
return this._custom_command("charge_on_solar", {
|
|
93
|
+
enabled,
|
|
94
|
+
lowerChargeLimit: lower_charge_limit,
|
|
95
|
+
upperChargeLimit: upper_charge_limit
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
/** Gets the current charge-on-solar settings. */
|
|
99
|
+
async get_charge_on_solar() {
|
|
100
|
+
return this._request("GET", `api/1/vehicles/${this.vin}/custom_command/charge_on_solar`);
|
|
101
|
+
}
|
|
102
|
+
/** Save the last 10 minutes of dashcam footage. */
|
|
103
|
+
async dashcam_save() {
|
|
104
|
+
return this._custom_command("dashcam_save");
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Play a supported video URL in the vehicle.
|
|
108
|
+
* @param url Video URL, e.g. a YouTube URL.
|
|
109
|
+
*/
|
|
110
|
+
async play_video(url) {
|
|
111
|
+
return this._custom_command("play_video", { url });
|
|
112
|
+
}
|
|
113
|
+
/** Stop the currently playing light show. */
|
|
114
|
+
async stop_light_show() {
|
|
115
|
+
return this._custom_command("stop_light_show");
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Start a light show on the vehicle.
|
|
119
|
+
* @param show_index Index of the light show to play.
|
|
120
|
+
* @param start_time Start time in milliseconds since epoch.
|
|
121
|
+
* @param volume Volume level for the light show.
|
|
122
|
+
* @param dance_moves Enable dance moves during the light show.
|
|
123
|
+
*/
|
|
124
|
+
async start_light_show(show_index, start_time, volume, dance_moves) {
|
|
125
|
+
return this._custom_command("start_light_show", {
|
|
126
|
+
show_index,
|
|
127
|
+
start_time,
|
|
128
|
+
volume,
|
|
129
|
+
dance_moves
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Deactivates PIN to Drive.
|
|
134
|
+
* @param pin 4-digit PIN to clear.
|
|
135
|
+
*/
|
|
136
|
+
async clear_pin_to_drive(pin) {
|
|
137
|
+
return this._custom_command("clear_pin_to_drive", { pin });
|
|
138
|
+
}
|
|
139
|
+
/** Remove all impermanent keys from the vehicle. */
|
|
140
|
+
async remove_key() {
|
|
141
|
+
return this._custom_command("remove_key");
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Sets the front zone light level. Named to match the signed sibling for router failover.
|
|
145
|
+
* @param level 0 off, 1 low, 2 medium, 3 high.
|
|
146
|
+
*/
|
|
147
|
+
async set_front_zone_lights(level) {
|
|
148
|
+
return this._custom_command("front_zone_light", { level });
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Sets the rear zone light level. Named to match the signed sibling for router failover.
|
|
152
|
+
* @param level 0 off, 1 low, 2 medium, 3 high.
|
|
153
|
+
*/
|
|
154
|
+
async set_rear_zone_lights(level) {
|
|
155
|
+
return this._custom_command("rear_zone_light", { level });
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Sets outlets on or off.
|
|
159
|
+
* @param request 0 off, 1 cabin and bed, 2 cabin.
|
|
160
|
+
*/
|
|
161
|
+
async set_outlets(request) {
|
|
162
|
+
return this._custom_command("set_outlets", { request });
|
|
163
|
+
}
|
|
164
|
+
/** Sets the outlet SOC limit percentage. */
|
|
165
|
+
async set_outlet_soc_limit(percent) {
|
|
166
|
+
return this._custom_command("set_outlet_soc_limit", { percent });
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Sets power feed on or off.
|
|
170
|
+
* @param request 0 off, 1 feed 1, 2 feed 2, 3 both.
|
|
171
|
+
*/
|
|
172
|
+
async set_power_feed(request) {
|
|
173
|
+
return this._custom_command("set_power_feed", { request });
|
|
174
|
+
}
|
|
175
|
+
/** Sets the power feed SOC limit percentage. */
|
|
176
|
+
async set_power_feed_soc_limit(percent) {
|
|
177
|
+
return this._custom_command("set_power_feed_soc_limit", { percent });
|
|
178
|
+
}
|
|
179
|
+
/** Sets the lightbar brightness. */
|
|
180
|
+
async set_lightbar_brightness(brightness) {
|
|
181
|
+
return this._custom_command("set_lightbar_brightness", { brightness });
|
|
182
|
+
}
|
|
183
|
+
/** Enables or disables the lightbar middle light. */
|
|
184
|
+
async set_lightbar_middle(on) {
|
|
185
|
+
return this._custom_command("set_lightbar_middle", { on });
|
|
186
|
+
}
|
|
187
|
+
/** Enables or disables the ditch lights. */
|
|
188
|
+
async set_lightbar_ditch(on) {
|
|
189
|
+
return this._custom_command("set_lightbar_ditch", { on });
|
|
190
|
+
}
|
|
191
|
+
/** Starts or stops the trailer light test. */
|
|
192
|
+
async set_trailer_light_test(on) {
|
|
193
|
+
return this._custom_command("set_trailer_light_test", { on });
|
|
194
|
+
}
|
|
195
|
+
/** Sets the truck bed light auto state. */
|
|
196
|
+
async set_truck_bed_light_auto(on) {
|
|
197
|
+
return this._custom_command("set_truck_bed_light_auto", { on });
|
|
198
|
+
}
|
|
199
|
+
/** Sets the truck bed light brightness. */
|
|
200
|
+
async set_truck_bed_light_brightness(brightness) {
|
|
201
|
+
return this._custom_command("set_truck_bed_light_brightness", { brightness });
|
|
202
|
+
}
|
|
203
|
+
/** Enables or disables the Powershare feature. */
|
|
204
|
+
async set_powershare_feature(on) {
|
|
205
|
+
return this._custom_command("set_powershare_feature", { on });
|
|
206
|
+
}
|
|
207
|
+
/** Enables or disables an active Powershare session. */
|
|
208
|
+
async set_powershare_request(on) {
|
|
209
|
+
return this._custom_command("set_powershare_request", { on });
|
|
210
|
+
}
|
|
211
|
+
/** Sets the Powershare discharge limit percentage. */
|
|
212
|
+
async set_powershare_discharge_limit(percent) {
|
|
213
|
+
return this._custom_command("set_powershare_discharge_limit", { percent });
|
|
214
|
+
}
|
|
215
|
+
/** Sets HVAC recirculation on or off. Named to match the signed sibling for router failover. */
|
|
216
|
+
async set_recirculation(on) {
|
|
217
|
+
return this._custom_command("hvac_recirculation", { on });
|
|
218
|
+
}
|
|
219
|
+
/** Enables or disables tent mode. */
|
|
220
|
+
async set_tent_mode(on) {
|
|
221
|
+
return this._custom_command("set_tent_mode", { on });
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Sets the suspension level.
|
|
225
|
+
* @param level 1 entry, 2 low, 3 medium, 4 high, 5 very high, 6 extract.
|
|
226
|
+
*/
|
|
227
|
+
async set_suspension_level(level) {
|
|
228
|
+
return this._custom_command("set_suspension_level", { level });
|
|
229
|
+
}
|
|
230
|
+
/** Turns Low Power mode on or off, reducing standby consumption while parked. */
|
|
231
|
+
async set_low_power_mode(on) {
|
|
232
|
+
return this._custom_command("set_low_power_mode", { on });
|
|
233
|
+
}
|
|
234
|
+
/** Turns Keep Accessory Power mode on or off, keeping 12V accessory power available while parked. */
|
|
235
|
+
async set_keep_accessory_power_mode(on) {
|
|
236
|
+
return this._custom_command("set_keep_accessory_power_mode", { on });
|
|
237
|
+
}
|
|
238
|
+
/** Sets the displayed temperature unit. */
|
|
239
|
+
async set_temperature_unit(unit) {
|
|
240
|
+
return this._custom_command("set_temperature_unit", { unit });
|
|
241
|
+
}
|
|
242
|
+
/** Sets the displayed distance unit. */
|
|
243
|
+
async set_distance_unit(unit) {
|
|
244
|
+
return this._custom_command("set_distance_unit", { unit });
|
|
245
|
+
}
|
|
246
|
+
/** Sets the displayed clock format (12h or 24h). */
|
|
247
|
+
async set_time_display_format(format) {
|
|
248
|
+
return this._custom_command("set_time_display_format", { format });
|
|
249
|
+
}
|
|
250
|
+
/** Sets the displayed tire pressure unit. */
|
|
251
|
+
async set_tire_pressure_unit(unit) {
|
|
252
|
+
return this._custom_command("set_tire_pressure_unit", { unit });
|
|
253
|
+
}
|
|
254
|
+
/** Sets the displayed energy unit (percentage or distance). */
|
|
255
|
+
async set_energy_display_format(format) {
|
|
256
|
+
return this._custom_command("set_energy_display_format", { format });
|
|
257
|
+
}
|
|
258
|
+
/** Activates or deactivates parental controls with a PIN. */
|
|
259
|
+
async parental_controls(activate, pin) {
|
|
260
|
+
return this._custom_command("parental_controls", {
|
|
261
|
+
activate,
|
|
262
|
+
pin
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
/** Clears the parental controls PIN. */
|
|
266
|
+
async parental_controls_clear_pin(pin) {
|
|
267
|
+
return this._custom_command("parental_controls_clear_pin", { pin });
|
|
268
|
+
}
|
|
269
|
+
/** Clears the parental controls PIN as admin (fleet manager or owner). */
|
|
270
|
+
async parental_controls_clear_pin_admin() {
|
|
271
|
+
return this._custom_command("parental_controls_clear_pin_admin");
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Enables or disables a parental controls setting.
|
|
275
|
+
* @param setting 1 speed limit, 2 acceleration, 3 safety features, 4 curfew.
|
|
276
|
+
* @param enable
|
|
277
|
+
*/
|
|
278
|
+
async parental_controls_enable_setting(setting, enable) {
|
|
279
|
+
return this._custom_command("parental_controls_enable_setting", {
|
|
280
|
+
setting,
|
|
281
|
+
enable
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
/** Sets the parental controls speed limit. */
|
|
285
|
+
async parental_controls_set_speed_limit(limit_mph) {
|
|
286
|
+
return this._custom_command("parental_controls_set_speed_limit", { limit_mph });
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* Navigates to coordinates with a named destination. Named to match the signed sibling for router failover.
|
|
290
|
+
* @param lat
|
|
291
|
+
* @param lon
|
|
292
|
+
* @param destination
|
|
293
|
+
* @param order Sent as given: on tesla-protocol 6, `RemoteNavTripOrder_E` is 0 replace, 1 prepend, 2 append.
|
|
294
|
+
*/
|
|
295
|
+
async navigation_gps_destination_request(lat, lon, destination, order) {
|
|
296
|
+
return this._custom_command("navigation_gps_destination", {
|
|
297
|
+
lat,
|
|
298
|
+
lon,
|
|
299
|
+
destination,
|
|
300
|
+
order
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
/** Auto-secures the vehicle: locks it, closes windows, and so on. */
|
|
304
|
+
async auto_secure_vehicle() {
|
|
305
|
+
return this._custom_command("auto_secure_vehicle");
|
|
306
|
+
}
|
|
307
|
+
/** Cancels a State of Health test. */
|
|
308
|
+
async cancel_soh_test() {
|
|
309
|
+
return this._custom_command("cancel_soh_test");
|
|
310
|
+
}
|
|
311
|
+
/** Returns the charging sites near the vehicle's current location. */
|
|
312
|
+
async get_nearby_charging_sites(count, radius, detail) {
|
|
313
|
+
return this._custom_command("get_nearby_charging_sites", {
|
|
314
|
+
count,
|
|
315
|
+
radius,
|
|
316
|
+
detail
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
/** Gets the current time-of-use rate tariff schedule. */
|
|
320
|
+
async get_rate_tariff() {
|
|
321
|
+
return this._custom_command("get_rate_tariff");
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* Triggers a time-of-use rate tariff update, with no schedule payload.
|
|
325
|
+
* Deliberately not named `set_rate_tariff`: the signed sibling takes a
|
|
326
|
+
* required schedule, which a router failing over here would silently drop.
|
|
327
|
+
*/
|
|
328
|
+
async trigger_rate_tariff_update() {
|
|
329
|
+
return this._custom_command("set_rate_tariff");
|
|
330
|
+
}
|
|
331
|
+
/**
|
|
332
|
+
* Gets a snapshot of cached vehicle telemetry.
|
|
333
|
+
* @param topics Topics to include.
|
|
334
|
+
* @param cursor Return only what changed since this cursor.
|
|
335
|
+
*/
|
|
336
|
+
async telemetry(topics, cursor) {
|
|
337
|
+
return this._request("GET", `api/1/vehicles/${this.vin}/telemetry`, {
|
|
338
|
+
topics: joinTopics(topics),
|
|
339
|
+
cursor
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
/** Creates a cursor-aware reader of this vehicle's cached telemetry. */
|
|
343
|
+
create_telemetry_tracker(topics) {
|
|
344
|
+
return new TeslemetryVehicleTelemetry(this, topics);
|
|
345
|
+
}
|
|
346
|
+
};
|
|
347
|
+
function joinTopics(topics) {
|
|
348
|
+
return Array.isArray(topics) ? topics.join(";") : topics;
|
|
349
|
+
}
|
|
350
|
+
/** Python truthiness, which an update's fields are tested by: an empty object or list counts as absent. */
|
|
351
|
+
function hasContent(value) {
|
|
352
|
+
return value !== null && typeof value === "object" ? Object.keys(value).length > 0 : !!value;
|
|
353
|
+
}
|
|
354
|
+
/** A cursor-aware vehicle telemetry reader, keeping a snapshot merged from each update. */
|
|
355
|
+
var TeslemetryVehicleTelemetry = class {
|
|
356
|
+
/** The cursor the next `update()` sends. */
|
|
357
|
+
cursor = 0;
|
|
358
|
+
/** Everything received so far. `data` merges field by field; other topics are replaced whole. */
|
|
359
|
+
snapshot = {};
|
|
360
|
+
_parent;
|
|
361
|
+
_topics;
|
|
362
|
+
constructor(parent, topics) {
|
|
363
|
+
this._parent = parent;
|
|
364
|
+
this._topics = joinTopics(topics);
|
|
365
|
+
}
|
|
366
|
+
/**
|
|
367
|
+
* Get the changes since the last update, and merge them into `snapshot`.
|
|
368
|
+
* @returns The update's `response`.
|
|
369
|
+
* @throws InvalidResponse when the update has an empty `response`, or no `cursor`.
|
|
370
|
+
*/
|
|
371
|
+
async update() {
|
|
372
|
+
const response = (await this._parent.telemetry(this._topics, this.cursor))?.response;
|
|
373
|
+
if (!hasContent(response)) throw new InvalidResponse("No response from telemetry");
|
|
374
|
+
if (typeof response !== "object" || !("cursor" in response)) throw new InvalidResponse("Telemetry response did not contain a cursor");
|
|
375
|
+
this.cursor = response.cursor;
|
|
376
|
+
if (hasContent(response.state)) this.snapshot.state = response.state;
|
|
377
|
+
if (hasContent(response.data)) this.snapshot.data = {
|
|
378
|
+
...this.snapshot.data,
|
|
379
|
+
...response.data
|
|
380
|
+
};
|
|
381
|
+
for (const topic of [
|
|
382
|
+
"connectivity",
|
|
383
|
+
"alerts",
|
|
384
|
+
"errors",
|
|
385
|
+
"vehicle_data"
|
|
386
|
+
]) if (hasContent(response[topic])) this.snapshot[topic] = response[topic];
|
|
387
|
+
return response;
|
|
388
|
+
}
|
|
389
|
+
};
|
|
390
|
+
/** Creates `TeslemetryVehicle`s. Teslemetry cannot use the Fleet API directly, so `create` is the only factory. */
|
|
391
|
+
var TeslemetryVehicles = class extends Vehicle {
|
|
392
|
+
/** Class `create` instantiates; a subclass overrides it to supply its own vehicle type. */
|
|
393
|
+
static Vehicle = TeslemetryVehicle;
|
|
394
|
+
createFleet = void 0;
|
|
395
|
+
createSigned = void 0;
|
|
396
|
+
specific = void 0;
|
|
397
|
+
specificSigned = void 0;
|
|
398
|
+
/** Creates a vehicle, and records it by VIN. */
|
|
399
|
+
create(vin) {
|
|
400
|
+
const vehicle = new this.constructor.Vehicle(this, vin);
|
|
401
|
+
this.byVin.set(vin, vehicle);
|
|
402
|
+
return vehicle;
|
|
403
|
+
}
|
|
404
|
+
};
|
|
405
|
+
export { TeslemetryVehicle, TeslemetryVehicleTelemetry, TeslemetryVehicles };
|
package/dist/tessie.cjs
CHANGED
|
@@ -1,13 +1,26 @@
|
|
|
1
|
+
const require_exceptions = require("./exceptions.cjs");
|
|
1
2
|
const require_teslafleetapi = require("./teslafleetapi.cjs");
|
|
3
|
+
const require_tessievehicle = require("./tessievehicle.cjs");
|
|
2
4
|
// src/tessie.ts
|
|
3
5
|
var Tessie = class extends require_teslafleetapi.default {
|
|
4
|
-
|
|
6
|
+
static Vehicles = require_tessievehicle.TessieVehicles;
|
|
7
|
+
_transport_name = "tessie";
|
|
8
|
+
wait_for_completion;
|
|
9
|
+
max_attempts;
|
|
10
|
+
constructor(accessToken, options = {}) {
|
|
11
|
+
const { wait_for_completion = true, max_attempts = 3, ...rest } = options;
|
|
5
12
|
super({
|
|
13
|
+
...rest,
|
|
6
14
|
accessToken,
|
|
7
15
|
server: `https://api.tessie.com`,
|
|
8
|
-
partnerScope: false
|
|
9
|
-
userScope: false
|
|
16
|
+
partnerScope: false
|
|
10
17
|
});
|
|
18
|
+
this.wait_for_completion = wait_for_completion;
|
|
19
|
+
this.max_attempts = max_attempts;
|
|
20
|
+
}
|
|
21
|
+
/** Tessie has one server; there is nothing to find. */
|
|
22
|
+
async find_server() {
|
|
23
|
+
throw new require_exceptions.LibraryError("Do not use this function for Tessie.");
|
|
11
24
|
}
|
|
12
25
|
/**
|
|
13
26
|
* Get your approved Tesla scopes
|
|
@@ -15,20 +28,44 @@ var Tessie = class extends require_teslafleetapi.default {
|
|
|
15
28
|
async tesla_scopes() {
|
|
16
29
|
return this._request("GET", "auth/tesla_scopes").then(({ scopes }) => scopes);
|
|
17
30
|
}
|
|
31
|
+
/** Get the user's scopes. */
|
|
32
|
+
async scopes() {
|
|
33
|
+
return this._request("GET", "auth/tesla_scopes").then(({ scopes }) => scopes);
|
|
34
|
+
}
|
|
18
35
|
async metadata() {
|
|
19
36
|
return this._request("GET", "auth/tesla_scopes");
|
|
20
37
|
}
|
|
21
38
|
async status(vin) {
|
|
39
|
+
if (vin === void 0) return super.status();
|
|
22
40
|
return this._request("GET", `${vin}/status`).then(({ status }) => status);
|
|
23
41
|
}
|
|
24
42
|
async state(vin, use_cache = true) {
|
|
25
43
|
return this._request("GET", `${vin}/state`, { use_cache });
|
|
26
44
|
}
|
|
27
|
-
async
|
|
28
|
-
return this._request("GET", "vehicles", { only_active })
|
|
45
|
+
async list_vehicles(only_active = false) {
|
|
46
|
+
return this._request("GET", "vehicles", { only_active });
|
|
29
47
|
}
|
|
30
48
|
async wake(vin) {
|
|
31
49
|
return this._request("POST", `${vin}/wake`).then(({ result }) => result);
|
|
32
50
|
}
|
|
51
|
+
/** Get battery health data for every vehicle. */
|
|
52
|
+
async all_battery_health(options = {}) {
|
|
53
|
+
const { start, end, distance_format, only_active = false } = options;
|
|
54
|
+
return this._request("GET", "battery_health", {
|
|
55
|
+
from: start,
|
|
56
|
+
to: end,
|
|
57
|
+
distance_format,
|
|
58
|
+
only_active
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
/** Get charging costs for every vehicle. */
|
|
62
|
+
async charging_invoices(options = {}) {
|
|
63
|
+
const { start, end, ...params } = options;
|
|
64
|
+
return this._request("GET", "charging_invoices", {
|
|
65
|
+
from: start,
|
|
66
|
+
to: end,
|
|
67
|
+
...params
|
|
68
|
+
});
|
|
69
|
+
}
|
|
33
70
|
};
|
|
34
71
|
exports.default = Tessie;
|
package/dist/tessie.d.cts
CHANGED
|
@@ -1,23 +1,69 @@
|
|
|
1
|
-
import TeslaFleetApi from "./teslafleetapi.cjs";
|
|
1
|
+
import TeslaFleetApi, { AccessToken } from "./teslafleetapi.cjs";
|
|
2
|
+
import { TessieVehicles } from "./tessievehicle.cjs";
|
|
3
|
+
import { Logger } from "./log.cjs";
|
|
2
4
|
import { Scope } from "./const.cjs";
|
|
3
5
|
import { VehicleDataResponse } from "./types/vehicle_data.cjs";
|
|
6
|
+
import Vehicle from "./vehicle.cjs";
|
|
4
7
|
type TessieVehicleResponse = {
|
|
5
8
|
vin: string;
|
|
6
9
|
is_active: boolean;
|
|
7
10
|
last_state: VehicleDataResponse;
|
|
8
11
|
};
|
|
9
|
-
|
|
10
|
-
|
|
12
|
+
export type TessieOptions = {
|
|
13
|
+
debug?: boolean;
|
|
14
|
+
logger?: Logger;
|
|
15
|
+
fetch?: typeof fetch;
|
|
16
|
+
timeout?: number;
|
|
17
|
+
/** Default for each command's `wait_for_completion`. */
|
|
18
|
+
wait_for_completion?: boolean;
|
|
19
|
+
/** Default for each command's `max_attempts`. */
|
|
20
|
+
max_attempts?: number;
|
|
21
|
+
};
|
|
22
|
+
/** Options of `all_battery_health`. `start` and `end` are sent as `from` and `to`. */
|
|
23
|
+
export type TessieAllBatteryHealthOptions = {
|
|
24
|
+
start?: number | null;
|
|
25
|
+
end?: number | null;
|
|
26
|
+
distance_format?: string;
|
|
27
|
+
only_active?: boolean;
|
|
28
|
+
};
|
|
29
|
+
/** Options of `charging_invoices`. `start` and `end` are sent as `from` and `to`. */
|
|
30
|
+
export type TessieChargingInvoicesOptions = {
|
|
31
|
+
start?: number | null;
|
|
32
|
+
end?: number | null;
|
|
33
|
+
timezone?: string;
|
|
34
|
+
vin?: string;
|
|
35
|
+
format?: string;
|
|
36
|
+
only_active?: boolean;
|
|
37
|
+
};
|
|
38
|
+
export default class Tessie extends TeslaFleetApi {
|
|
39
|
+
static Vehicles: new (parent: TeslaFleetApi) => Vehicle;
|
|
40
|
+
vehicles: TessieVehicles;
|
|
41
|
+
readonly _transport_name: string;
|
|
42
|
+
wait_for_completion: boolean;
|
|
43
|
+
max_attempts: number;
|
|
44
|
+
constructor(accessToken: AccessToken, options?: TessieOptions);
|
|
45
|
+
/** Tessie has one server; there is nothing to find. */
|
|
46
|
+
find_server(): Promise<string>;
|
|
11
47
|
/**
|
|
12
48
|
* Get your approved Tesla scopes
|
|
13
49
|
*/
|
|
14
50
|
tesla_scopes(): Promise<Scope[]>;
|
|
51
|
+
/** Get the user's scopes. */
|
|
52
|
+
scopes(): Promise<Scope[]>;
|
|
15
53
|
metadata(): Promise<{
|
|
16
54
|
scopes: Scope[];
|
|
17
55
|
}>;
|
|
56
|
+
/** With no VIN, the API status (`"ok"`); with a VIN, that vehicle's sleep status. */
|
|
57
|
+
status(): Promise<string>;
|
|
18
58
|
status(vin: string): Promise<"asleep" | "waiting_for_sleep" | "awake">;
|
|
19
59
|
state(vin: string, use_cache?: boolean): Promise<VehicleDataResponse>;
|
|
20
|
-
|
|
60
|
+
list_vehicles(only_active?: boolean): Promise<{
|
|
61
|
+
results: TessieVehicleResponse[];
|
|
62
|
+
}>;
|
|
21
63
|
wake(vin: string): Promise<boolean>;
|
|
64
|
+
/** Get battery health data for every vehicle. */
|
|
65
|
+
all_battery_health(options?: TessieAllBatteryHealthOptions): Promise<any>;
|
|
66
|
+
/** Get charging costs for every vehicle. */
|
|
67
|
+
charging_invoices(options?: TessieChargingInvoicesOptions): Promise<any>;
|
|
22
68
|
}
|
|
23
|
-
export
|
|
69
|
+
export {};
|
package/dist/tessie.d.mts
CHANGED
|
@@ -1,23 +1,69 @@
|
|
|
1
|
-
import TeslaFleetApi from "./teslafleetapi.mjs";
|
|
1
|
+
import TeslaFleetApi, { AccessToken } from "./teslafleetapi.mjs";
|
|
2
|
+
import { TessieVehicles } from "./tessievehicle.mjs";
|
|
3
|
+
import { Logger } from "./log.mjs";
|
|
2
4
|
import { Scope } from "./const.mjs";
|
|
3
5
|
import { VehicleDataResponse } from "./types/vehicle_data.mjs";
|
|
6
|
+
import Vehicle from "./vehicle.mjs";
|
|
4
7
|
type TessieVehicleResponse = {
|
|
5
8
|
vin: string;
|
|
6
9
|
is_active: boolean;
|
|
7
10
|
last_state: VehicleDataResponse;
|
|
8
11
|
};
|
|
12
|
+
export type TessieOptions = {
|
|
13
|
+
debug?: boolean;
|
|
14
|
+
logger?: Logger;
|
|
15
|
+
fetch?: typeof fetch;
|
|
16
|
+
timeout?: number;
|
|
17
|
+
/** Default for each command's `wait_for_completion`. */
|
|
18
|
+
wait_for_completion?: boolean;
|
|
19
|
+
/** Default for each command's `max_attempts`. */
|
|
20
|
+
max_attempts?: number;
|
|
21
|
+
};
|
|
22
|
+
/** Options of `all_battery_health`. `start` and `end` are sent as `from` and `to`. */
|
|
23
|
+
export type TessieAllBatteryHealthOptions = {
|
|
24
|
+
start?: number | null;
|
|
25
|
+
end?: number | null;
|
|
26
|
+
distance_format?: string;
|
|
27
|
+
only_active?: boolean;
|
|
28
|
+
};
|
|
29
|
+
/** Options of `charging_invoices`. `start` and `end` are sent as `from` and `to`. */
|
|
30
|
+
export type TessieChargingInvoicesOptions = {
|
|
31
|
+
start?: number | null;
|
|
32
|
+
end?: number | null;
|
|
33
|
+
timezone?: string;
|
|
34
|
+
vin?: string;
|
|
35
|
+
format?: string;
|
|
36
|
+
only_active?: boolean;
|
|
37
|
+
};
|
|
9
38
|
export default class Tessie extends TeslaFleetApi {
|
|
10
|
-
|
|
39
|
+
static Vehicles: new (parent: TeslaFleetApi) => Vehicle;
|
|
40
|
+
vehicles: TessieVehicles;
|
|
41
|
+
readonly _transport_name: string;
|
|
42
|
+
wait_for_completion: boolean;
|
|
43
|
+
max_attempts: number;
|
|
44
|
+
constructor(accessToken: AccessToken, options?: TessieOptions);
|
|
45
|
+
/** Tessie has one server; there is nothing to find. */
|
|
46
|
+
find_server(): Promise<string>;
|
|
11
47
|
/**
|
|
12
48
|
* Get your approved Tesla scopes
|
|
13
49
|
*/
|
|
14
50
|
tesla_scopes(): Promise<Scope[]>;
|
|
51
|
+
/** Get the user's scopes. */
|
|
52
|
+
scopes(): Promise<Scope[]>;
|
|
15
53
|
metadata(): Promise<{
|
|
16
54
|
scopes: Scope[];
|
|
17
55
|
}>;
|
|
56
|
+
/** With no VIN, the API status (`"ok"`); with a VIN, that vehicle's sleep status. */
|
|
57
|
+
status(): Promise<string>;
|
|
18
58
|
status(vin: string): Promise<"asleep" | "waiting_for_sleep" | "awake">;
|
|
19
59
|
state(vin: string, use_cache?: boolean): Promise<VehicleDataResponse>;
|
|
20
|
-
|
|
60
|
+
list_vehicles(only_active?: boolean): Promise<{
|
|
61
|
+
results: TessieVehicleResponse[];
|
|
62
|
+
}>;
|
|
21
63
|
wake(vin: string): Promise<boolean>;
|
|
64
|
+
/** Get battery health data for every vehicle. */
|
|
65
|
+
all_battery_health(options?: TessieAllBatteryHealthOptions): Promise<any>;
|
|
66
|
+
/** Get charging costs for every vehicle. */
|
|
67
|
+
charging_invoices(options?: TessieChargingInvoicesOptions): Promise<any>;
|
|
22
68
|
}
|
|
23
69
|
export {};
|