tesla-fleet-api 0.3.0 → 0.4.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.
Files changed (192) hide show
  1. package/dist/_virtual/_rolldown/runtime.cjs +22 -0
  2. package/dist/_virtual/_rolldown/runtime.mjs +12 -0
  3. package/dist/charging.cjs +53 -0
  4. package/dist/charging.d.cts +31 -0
  5. package/dist/charging.d.mts +30 -0
  6. package/dist/charging.mjs +53 -0
  7. package/dist/commands.cjs +802 -0
  8. package/dist/commands.d.cts +350 -0
  9. package/dist/commands.d.mts +349 -0
  10. package/dist/commands.mjs +800 -0
  11. package/dist/const.cjs +300 -0
  12. package/dist/const.d.cts +287 -0
  13. package/dist/const.d.mts +287 -0
  14. package/dist/const.mjs +263 -0
  15. package/dist/energy.cjs +137 -0
  16. package/dist/energy.d.cts +95 -0
  17. package/{src/energy.ts → dist/energy.d.mts} +17 -140
  18. package/dist/energy.mjs +137 -0
  19. package/dist/energyspecific.cjs +99 -0
  20. package/dist/energyspecific.d.cts +78 -0
  21. package/dist/energyspecific.d.mts +77 -0
  22. package/dist/energyspecific.mjs +99 -0
  23. package/dist/exceptions.cjs +1487 -0
  24. package/dist/exceptions.d.cts +1142 -0
  25. package/dist/exceptions.d.mts +1142 -0
  26. package/dist/exceptions.mjs +1324 -0
  27. package/dist/index.cjs +226 -0
  28. package/dist/index.d.cts +14 -0
  29. package/dist/index.d.mts +14 -0
  30. package/dist/index.mjs +14 -0
  31. package/dist/partner.cjs +32 -0
  32. package/dist/partner.d.cts +24 -0
  33. package/dist/partner.d.mts +23 -0
  34. package/dist/partner.mjs +32 -0
  35. package/dist/router.cjs +0 -0
  36. package/dist/router.d.cts +1 -0
  37. package/dist/router.d.mts +1 -0
  38. package/dist/router.mjs +1 -0
  39. package/dist/signing/crypto.cjs +31 -0
  40. package/dist/signing/crypto.mjs +27 -0
  41. package/dist/signing/session.cjs +112 -0
  42. package/dist/signing/session.d.cts +69 -0
  43. package/dist/signing/session.d.mts +69 -0
  44. package/dist/signing/session.mjs +110 -0
  45. package/dist/tariff.cjs +292 -0
  46. package/dist/{tariff.d.ts → tariff.d.cts} +17 -17
  47. package/dist/tariff.d.mts +29 -0
  48. package/dist/tariff.mjs +291 -0
  49. package/dist/teslafleetapi.cjs +125 -0
  50. package/dist/teslafleetapi.d.cts +64 -0
  51. package/dist/teslafleetapi.d.mts +64 -0
  52. package/dist/teslafleetapi.mjs +125 -0
  53. package/dist/teslemetry.cjs +36 -0
  54. package/dist/teslemetry.d.cts +23 -0
  55. package/dist/teslemetry.d.mts +23 -0
  56. package/dist/teslemetry.mjs +36 -0
  57. package/dist/tessie.cjs +34 -0
  58. package/dist/tessie.d.cts +23 -0
  59. package/dist/tessie.d.mts +23 -0
  60. package/dist/tessie.mjs +34 -0
  61. package/dist/types/commands.d.cts +28 -0
  62. package/dist/types/commands.d.mts +28 -0
  63. package/dist/types/live_status.d.cts +30 -0
  64. package/dist/types/live_status.d.mts +30 -0
  65. package/dist/types/products.d.cts +58 -0
  66. package/dist/types/products.d.mts +58 -0
  67. package/dist/types/responses.d.cts +9 -0
  68. package/dist/types/responses.d.mts +9 -0
  69. package/dist/types/site_info.d.cts +154 -0
  70. package/dist/types/site_info.d.mts +154 -0
  71. package/dist/types/vehicle.d.cts +27 -0
  72. package/dist/types/vehicle.d.mts +27 -0
  73. package/dist/types/vehicle_data.d.cts +278 -0
  74. package/dist/types/vehicle_data.d.mts +278 -0
  75. package/dist/types.cjs +0 -0
  76. package/dist/types.d.cts +9 -0
  77. package/dist/types.d.mts +9 -0
  78. package/dist/types.mjs +1 -0
  79. package/dist/user.cjs +28 -0
  80. package/dist/user.d.cts +17 -0
  81. package/dist/user.d.mts +16 -0
  82. package/dist/user.mjs +28 -0
  83. package/dist/vehicle.cjs +804 -0
  84. package/dist/vehicle.d.cts +550 -0
  85. package/dist/vehicle.d.mts +549 -0
  86. package/dist/vehicle.mjs +804 -0
  87. package/dist/vehiclesigned.cjs +20 -0
  88. package/dist/vehiclesigned.d.cts +14 -0
  89. package/dist/{vehiclesigned.d.ts → vehiclesigned.d.mts} +3 -3
  90. package/dist/vehiclesigned.mjs +20 -0
  91. package/dist/vehiclespecific.cjs +604 -0
  92. package/dist/vehiclespecific.d.cts +433 -0
  93. package/dist/vehiclespecific.d.mts +432 -0
  94. package/dist/vehiclespecific.mjs +604 -0
  95. package/package.json +108 -35
  96. package/dist/charging.d.ts +0 -30
  97. package/dist/charging.js +0 -51
  98. package/dist/charging.js.map +0 -1
  99. package/dist/commands.d.ts +0 -352
  100. package/dist/commands.js +0 -875
  101. package/dist/commands.js.map +0 -1
  102. package/dist/energy.d.ts +0 -94
  103. package/dist/energy.js +0 -125
  104. package/dist/energy.js.map +0 -1
  105. package/dist/energyspecific.d.ts +0 -77
  106. package/dist/energyspecific.js +0 -97
  107. package/dist/energyspecific.js.map +0 -1
  108. package/dist/helpers.d.ts +0 -2
  109. package/dist/helpers.js +0 -10
  110. package/dist/helpers.js.map +0 -1
  111. package/dist/index.d.ts +0 -15
  112. package/dist/index.js +0 -15
  113. package/dist/index.js.map +0 -1
  114. package/dist/partner.d.ts +0 -23
  115. package/dist/partner.js +0 -31
  116. package/dist/partner.js.map +0 -1
  117. package/dist/signing/crypto.d.ts +0 -10
  118. package/dist/signing/crypto.js +0 -26
  119. package/dist/signing/crypto.js.map +0 -1
  120. package/dist/signing/errors.d.ts +0 -29
  121. package/dist/signing/errors.js +0 -40
  122. package/dist/signing/errors.js.map +0 -1
  123. package/dist/signing/session.d.ts +0 -69
  124. package/dist/signing/session.js +0 -102
  125. package/dist/signing/session.js.map +0 -1
  126. package/dist/tariff.js +0 -302
  127. package/dist/tariff.js.map +0 -1
  128. package/dist/teslafleetapi.d.ts +0 -58
  129. package/dist/teslafleetapi.js +0 -120
  130. package/dist/teslafleetapi.js.map +0 -1
  131. package/dist/teslemetry.d.ts +0 -29
  132. package/dist/teslemetry.js +0 -39
  133. package/dist/teslemetry.js.map +0 -1
  134. package/dist/tessie.d.ts +0 -23
  135. package/dist/tessie.js +0 -28
  136. package/dist/tessie.js.map +0 -1
  137. package/dist/types/commands.d.ts +0 -44
  138. package/dist/types/commands.js +0 -11
  139. package/dist/types/commands.js.map +0 -1
  140. package/dist/types/live_status.d.ts +0 -26
  141. package/dist/types/live_status.js +0 -2
  142. package/dist/types/live_status.js.map +0 -1
  143. package/dist/types/products.d.ts +0 -54
  144. package/dist/types/products.js +0 -2
  145. package/dist/types/products.js.map +0 -1
  146. package/dist/types/responses.d.ts +0 -5
  147. package/dist/types/responses.js +0 -2
  148. package/dist/types/responses.js.map +0 -1
  149. package/dist/types/site_info.d.ts +0 -150
  150. package/dist/types/site_info.js +0 -2
  151. package/dist/types/site_info.js.map +0 -1
  152. package/dist/types/vehicle.d.ts +0 -23
  153. package/dist/types/vehicle.js +0 -10
  154. package/dist/types/vehicle.js.map +0 -1
  155. package/dist/types/vehicle_data.d.ts +0 -274
  156. package/dist/types/vehicle_data.js +0 -2
  157. package/dist/types/vehicle_data.js.map +0 -1
  158. package/dist/user.d.ts +0 -16
  159. package/dist/user.js +0 -26
  160. package/dist/user.js.map +0 -1
  161. package/dist/vehicle.d.ts +0 -548
  162. package/dist/vehicle.js +0 -774
  163. package/dist/vehicle.js.map +0 -1
  164. package/dist/vehiclesigned.js +0 -19
  165. package/dist/vehiclesigned.js.map +0 -1
  166. package/dist/vehiclespecific.d.ts +0 -432
  167. package/dist/vehiclespecific.js +0 -601
  168. package/dist/vehiclespecific.js.map +0 -1
  169. package/src/charging.ts +0 -66
  170. package/src/commands.ts +0 -1134
  171. package/src/energyspecific.ts +0 -116
  172. package/src/helpers.ts +0 -11
  173. package/src/index.ts +0 -21
  174. package/src/partner.ts +0 -37
  175. package/src/signing/crypto.ts +0 -29
  176. package/src/signing/errors.ts +0 -50
  177. package/src/signing/session.ts +0 -132
  178. package/src/tariff.ts +0 -375
  179. package/src/teslafleetapi.ts +0 -182
  180. package/src/teslemetry.ts +0 -54
  181. package/src/tessie.ts +0 -42
  182. package/src/types/commands.ts +0 -62
  183. package/src/types/live_status.ts +0 -27
  184. package/src/types/products.ts +0 -61
  185. package/src/types/responses.ts +0 -1
  186. package/src/types/site_info.ts +0 -159
  187. package/src/types/vehicle.ts +0 -33
  188. package/src/types/vehicle_data.ts +0 -286
  189. package/src/user.ts +0 -35
  190. package/src/vehicle.ts +0 -886
  191. package/src/vehiclesigned.ts +0 -20
  192. package/src/vehiclespecific.ts +0 -818
@@ -0,0 +1,125 @@
1
+ import Charging from "./charging.mjs";
2
+ import Energy from "./energy.mjs";
3
+ import Partner from "./partner.mjs";
4
+ import User from "./user.mjs";
5
+ import Vehicle from "./vehicle.mjs";
6
+ import { SERVERS, is_valid_region } from "./const.mjs";
7
+ import { ResponseError, TeslaFleetConnectionError, TeslaFleetError, raise_for_status } from "./exceptions.mjs";
8
+ // src/teslafleetapi.ts
9
+ var TeslaFleetApi = class {
10
+ server = null;
11
+ accessToken;
12
+ charging;
13
+ energy;
14
+ partner;
15
+ user;
16
+ vehicle;
17
+ debug = false;
18
+ /** Abort a request (including reading its body) after this many milliseconds; `null` waits indefinitely. */
19
+ timeout;
20
+ constructor(options) {
21
+ this.debug = !!options.debug;
22
+ this.timeout = options.timeout ?? null;
23
+ this.accessToken = options.accessToken ?? null;
24
+ if (options.server) this.server = options.server;
25
+ else if (options.region && is_valid_region(options.region)) this.server = SERVERS[options.region];
26
+ else throw new Error("Either server or region must be provided.");
27
+ this.debug && console.debug(`Using server ${this.server}`);
28
+ if (options.chargingScope !== false) this.charging = new Charging(this);
29
+ if (options.energyScope !== false) this.energy = new Energy(this);
30
+ if (options.userScope !== false) this.user = new User(this);
31
+ if (options.partnerScope !== false) this.partner = new Partner(this);
32
+ if (options.vehicleScope !== false) this.vehicle = new Vehicle(this);
33
+ }
34
+ /**
35
+ * Turn a response into its decoded JSON body, throwing the matching
36
+ * `TeslaFleetError` for an error status and `ResponseError` for a
37
+ * successful response whose body is not JSON.
38
+ */
39
+ async _response(resp) {
40
+ await raise_for_status(resp);
41
+ const text = await resp.text();
42
+ try {
43
+ return JSON.parse(text);
44
+ } catch {
45
+ throw new ResponseError(text, resp.status);
46
+ }
47
+ }
48
+ /**
49
+ * Make a request to the Tesla Fleet API.
50
+ * @param method
51
+ * @param path
52
+ * @param params
53
+ * @param json
54
+ * @returns The decoded JSON body.
55
+ * @throws A `TeslaFleetError` subclass for an error status, or
56
+ * `TeslaFleetConnectionError` (with the original error as `cause`) when the
57
+ * request could not complete or timed out.
58
+ */
59
+ async _request(method, path, params = null, json = null) {
60
+ if (!this.server) throw new Error("Server was not set at init. Call findServer() first.");
61
+ if (method === "GET" && json !== null) throw new Error("GET requests cannot have a body.");
62
+ this.debug && console.debug(`Sending request to ${path}`);
63
+ if (params) {
64
+ params = Object.fromEntries(Object.entries(params).filter(([_, v]) => v != null));
65
+ this.debug && console.debug(`Parameters: ${JSON.stringify(params)}`);
66
+ }
67
+ if (json) {
68
+ json = Object.fromEntries(Object.entries(json).filter(([_, v]) => v != null));
69
+ this.debug && console.debug(`Body: ${JSON.stringify(json)}`);
70
+ }
71
+ const headers = {
72
+ Authorization: `Bearer ${this.accessToken}`,
73
+ "Content-Type": "application/json",
74
+ "X-Library": `node tesla_fleet_api`
75
+ };
76
+ const query = params ? "?" + new URLSearchParams(params).toString() : "";
77
+ try {
78
+ const resp = await fetch(`${this.server}/${path}${query}`, {
79
+ method,
80
+ headers,
81
+ body: json ? JSON.stringify(json) : null,
82
+ signal: this.timeout != null ? AbortSignal.timeout(this.timeout) : null
83
+ });
84
+ return await this._response(resp);
85
+ } catch (error) {
86
+ if (error instanceof TeslaFleetError) throw error;
87
+ throw new TeslaFleetConnectionError(null, null, { cause: error });
88
+ }
89
+ }
90
+ /**
91
+ * Returns products mapped to user.
92
+ * @returns An array of products including both vehicles and energy sites.
93
+ */
94
+ async products() {
95
+ return this._request("GET", "api/1/products").then(({ response }) => response);
96
+ }
97
+ /**
98
+ * Return Tesla products separated into vehicles and energy_sites
99
+ * @returns A dictionary of vehicles and energy sites, each with an array of those products
100
+ */
101
+ async products_by_type() {
102
+ return this.products().then((products) => ({
103
+ vehicles: products.filter((product) => "vin" in product),
104
+ energy_sites: products.filter((product) => "energy_site_id" in product)
105
+ }));
106
+ }
107
+ async loadPrivateKey(path) {
108
+ return (await import("fs")).promises.readFile(path, "utf8").then((key) => {
109
+ this.accessToken = key;
110
+ }).catch(async () => {
111
+ const { privateKey: _privateKey } = (await import("crypto")).generateKeyPairSync("ec", {
112
+ namedCurve: "secp256r1",
113
+ publicKeyEncoding: {
114
+ type: "spki",
115
+ format: "pem"
116
+ },
117
+ privateKeyEncoding: {
118
+ type: "pkcs8",
119
+ format: "pem"
120
+ }
121
+ });
122
+ });
123
+ }
124
+ };
125
+ export { TeslaFleetApi as default };
@@ -0,0 +1,36 @@
1
+ const require_teslafleetapi = require("./teslafleetapi.cjs");
2
+ // src/teslemetry.ts
3
+ var Teslemetry = class extends require_teslafleetapi.default {
4
+ constructor(accessToken, region = "api") {
5
+ super({
6
+ accessToken,
7
+ server: `https://${region}.teslemetry.com`,
8
+ partnerScope: false,
9
+ userScope: false
10
+ });
11
+ }
12
+ async _response(resp) {
13
+ if (resp.headers.has("x-region")) {
14
+ const region = resp.headers.get("x-region")?.toLowerCase();
15
+ if (region) this.server = `https://${region}.teslemetry.com`;
16
+ }
17
+ return super._response(resp);
18
+ }
19
+ /**
20
+ * Test the connection to Teslemetry
21
+ */
22
+ async test() {
23
+ return this._request("GET", "api/test").then(({ response }) => response);
24
+ }
25
+ /**
26
+ * Get details about your Teslemetry account
27
+ * @param update_region Update the server URL based on the region in the metadata
28
+ */
29
+ async metadata(update_region = true) {
30
+ return this._request("GET", "api/metadata").then((metadata) => {
31
+ if (update_region) this.server = `https://${metadata.region.toLowerCase()}.teslemetry.com`;
32
+ return metadata;
33
+ });
34
+ }
35
+ };
36
+ exports.default = Teslemetry;
@@ -0,0 +1,23 @@
1
+ import TeslaFleetApi from "./teslafleetapi.cjs";
2
+ import { Scope } from "./const.cjs";
3
+ type Region = "na" | "eu" | "api";
4
+ type Metadata = {
5
+ uid: string;
6
+ region: "NA" | "EU";
7
+ scopes: Scope[];
8
+ vins: string[];
9
+ };
10
+ declare class Teslemetry extends TeslaFleetApi {
11
+ constructor(accessToken: string, region?: Region);
12
+ _response(resp: Response): Promise<any>;
13
+ /**
14
+ * Test the connection to Teslemetry
15
+ */
16
+ test(): Promise<boolean>;
17
+ /**
18
+ * Get details about your Teslemetry account
19
+ * @param update_region Update the server URL based on the region in the metadata
20
+ */
21
+ metadata(update_region?: boolean): Promise<Metadata>;
22
+ }
23
+ export = Teslemetry;
@@ -0,0 +1,23 @@
1
+ import TeslaFleetApi from "./teslafleetapi.mjs";
2
+ import { Scope } from "./const.mjs";
3
+ type Region = "na" | "eu" | "api";
4
+ type Metadata = {
5
+ uid: string;
6
+ region: "NA" | "EU";
7
+ scopes: Scope[];
8
+ vins: string[];
9
+ };
10
+ export default class Teslemetry extends TeslaFleetApi {
11
+ constructor(accessToken: string, region?: Region);
12
+ _response(resp: Response): Promise<any>;
13
+ /**
14
+ * Test the connection to Teslemetry
15
+ */
16
+ test(): Promise<boolean>;
17
+ /**
18
+ * Get details about your Teslemetry account
19
+ * @param update_region Update the server URL based on the region in the metadata
20
+ */
21
+ metadata(update_region?: boolean): Promise<Metadata>;
22
+ }
23
+ export {};
@@ -0,0 +1,36 @@
1
+ import TeslaFleetApi from "./teslafleetapi.mjs";
2
+ // src/teslemetry.ts
3
+ var Teslemetry = class extends TeslaFleetApi {
4
+ constructor(accessToken, region = "api") {
5
+ super({
6
+ accessToken,
7
+ server: `https://${region}.teslemetry.com`,
8
+ partnerScope: false,
9
+ userScope: false
10
+ });
11
+ }
12
+ async _response(resp) {
13
+ if (resp.headers.has("x-region")) {
14
+ const region = resp.headers.get("x-region")?.toLowerCase();
15
+ if (region) this.server = `https://${region}.teslemetry.com`;
16
+ }
17
+ return super._response(resp);
18
+ }
19
+ /**
20
+ * Test the connection to Teslemetry
21
+ */
22
+ async test() {
23
+ return this._request("GET", "api/test").then(({ response }) => response);
24
+ }
25
+ /**
26
+ * Get details about your Teslemetry account
27
+ * @param update_region Update the server URL based on the region in the metadata
28
+ */
29
+ async metadata(update_region = true) {
30
+ return this._request("GET", "api/metadata").then((metadata) => {
31
+ if (update_region) this.server = `https://${metadata.region.toLowerCase()}.teslemetry.com`;
32
+ return metadata;
33
+ });
34
+ }
35
+ };
36
+ export { Teslemetry as default };
@@ -0,0 +1,34 @@
1
+ const require_teslafleetapi = require("./teslafleetapi.cjs");
2
+ // src/tessie.ts
3
+ var Tessie = class extends require_teslafleetapi.default {
4
+ constructor(accessToken) {
5
+ super({
6
+ accessToken,
7
+ server: `https://api.tessie.com`,
8
+ partnerScope: false,
9
+ userScope: false
10
+ });
11
+ }
12
+ /**
13
+ * Get your approved Tesla scopes
14
+ */
15
+ async tesla_scopes() {
16
+ return this._request("GET", "auth/tesla_scopes").then(({ scopes }) => scopes);
17
+ }
18
+ async metadata() {
19
+ return this._request("GET", "auth/tesla_scopes");
20
+ }
21
+ async status(vin) {
22
+ return this._request("GET", `${vin}/status`).then(({ status }) => status);
23
+ }
24
+ async state(vin, use_cache = true) {
25
+ return this._request("GET", `${vin}/state`, { use_cache });
26
+ }
27
+ async vehicles(only_active = false) {
28
+ return this._request("GET", "vehicles", { only_active }).then(({ results }) => results);
29
+ }
30
+ async wake(vin) {
31
+ return this._request("POST", `${vin}/wake`).then(({ result }) => result);
32
+ }
33
+ };
34
+ exports.default = Tessie;
@@ -0,0 +1,23 @@
1
+ import TeslaFleetApi from "./teslafleetapi.cjs";
2
+ import { Scope } from "./const.cjs";
3
+ import { VehicleDataResponse } from "./types/vehicle_data.cjs";
4
+ type TessieVehicleResponse = {
5
+ vin: string;
6
+ is_active: boolean;
7
+ last_state: VehicleDataResponse;
8
+ };
9
+ declare class Tessie extends TeslaFleetApi {
10
+ constructor(accessToken: string);
11
+ /**
12
+ * Get your approved Tesla scopes
13
+ */
14
+ tesla_scopes(): Promise<Scope[]>;
15
+ metadata(): Promise<{
16
+ scopes: Scope[];
17
+ }>;
18
+ status(vin: string): Promise<"asleep" | "waiting_for_sleep" | "awake">;
19
+ state(vin: string, use_cache?: boolean): Promise<VehicleDataResponse>;
20
+ vehicles(only_active?: boolean): Promise<TessieVehicleResponse[]>;
21
+ wake(vin: string): Promise<boolean>;
22
+ }
23
+ export = Tessie;
@@ -0,0 +1,23 @@
1
+ import TeslaFleetApi from "./teslafleetapi.mjs";
2
+ import { Scope } from "./const.mjs";
3
+ import { VehicleDataResponse } from "./types/vehicle_data.mjs";
4
+ type TessieVehicleResponse = {
5
+ vin: string;
6
+ is_active: boolean;
7
+ last_state: VehicleDataResponse;
8
+ };
9
+ export default class Tessie extends TeslaFleetApi {
10
+ constructor(accessToken: string);
11
+ /**
12
+ * Get your approved Tesla scopes
13
+ */
14
+ tesla_scopes(): Promise<Scope[]>;
15
+ metadata(): Promise<{
16
+ scopes: Scope[];
17
+ }>;
18
+ status(vin: string): Promise<"asleep" | "waiting_for_sleep" | "awake">;
19
+ state(vin: string, use_cache?: boolean): Promise<VehicleDataResponse>;
20
+ vehicles(only_active?: boolean): Promise<TessieVehicleResponse[]>;
21
+ wake(vin: string): Promise<boolean>;
22
+ }
23
+ export {};
@@ -0,0 +1,34 @@
1
+ import TeslaFleetApi from "./teslafleetapi.mjs";
2
+ // src/tessie.ts
3
+ var Tessie = class extends TeslaFleetApi {
4
+ constructor(accessToken) {
5
+ super({
6
+ accessToken,
7
+ server: `https://api.tessie.com`,
8
+ partnerScope: false,
9
+ userScope: false
10
+ });
11
+ }
12
+ /**
13
+ * Get your approved Tesla scopes
14
+ */
15
+ async tesla_scopes() {
16
+ return this._request("GET", "auth/tesla_scopes").then(({ scopes }) => scopes);
17
+ }
18
+ async metadata() {
19
+ return this._request("GET", "auth/tesla_scopes");
20
+ }
21
+ async status(vin) {
22
+ return this._request("GET", `${vin}/status`).then(({ status }) => status);
23
+ }
24
+ async state(vin, use_cache = true) {
25
+ return this._request("GET", `${vin}/state`, { use_cache });
26
+ }
27
+ async vehicles(only_active = false) {
28
+ return this._request("GET", "vehicles", { only_active }).then(({ results }) => results);
29
+ }
30
+ async wake(vin) {
31
+ return this._request("POST", `${vin}/wake`).then(({ result }) => result);
32
+ }
33
+ };
34
+ export { Tessie as default };
@@ -0,0 +1,28 @@
1
+ import { ClimateMode, ClimateModes, Level, Scope, Seat, Seats, Trunk, VehicleDataEndpoint } from "../const.cjs";
2
+ declare namespace commands_d_exports {
3
+ export { AlertTypes, ClimateMode, ClimateModes, CommandResponse, FleetTelemetryConfig, Level, Scope, Seat, Seats, Trunk, VehicleDataEndpoint };
4
+ }
5
+ export interface CommandResponse {
6
+ response: {
7
+ result: boolean;
8
+ reason: string;
9
+ };
10
+ error?: string;
11
+ }
12
+ export type AlertTypes = "customer" | "service";
13
+ export interface FleetTelemetryConfig {
14
+ vins: string[];
15
+ config: {
16
+ hostname: string;
17
+ ca: string;
18
+ fields: {
19
+ [key: string]: {
20
+ interval_seconds: number;
21
+ };
22
+ };
23
+ alert_types: AlertTypes[];
24
+ exp: number;
25
+ port: number;
26
+ };
27
+ }
28
+ export { type ClimateMode, ClimateModes, type Level, type Scope, type Seat, Seats, type Trunk, type VehicleDataEndpoint, commands_d_exports };
@@ -0,0 +1,28 @@
1
+ import { ClimateMode, ClimateModes, Level, Scope, Seat, Seats, Trunk, VehicleDataEndpoint } from "../const.mjs";
2
+ declare namespace commands_d_exports {
3
+ export { AlertTypes, ClimateMode, ClimateModes, CommandResponse, FleetTelemetryConfig, Level, Scope, Seat, Seats, Trunk, VehicleDataEndpoint };
4
+ }
5
+ export interface CommandResponse {
6
+ response: {
7
+ result: boolean;
8
+ reason: string;
9
+ };
10
+ error?: string;
11
+ }
12
+ export type AlertTypes = "customer" | "service";
13
+ export interface FleetTelemetryConfig {
14
+ vins: string[];
15
+ config: {
16
+ hostname: string;
17
+ ca: string;
18
+ fields: {
19
+ [key: string]: {
20
+ interval_seconds: number;
21
+ };
22
+ };
23
+ alert_types: AlertTypes[];
24
+ exp: number;
25
+ port: number;
26
+ };
27
+ }
28
+ export { type ClimateMode, ClimateModes, type Level, type Scope, type Seat, Seats, type Trunk, type VehicleDataEndpoint, commands_d_exports };
@@ -0,0 +1,30 @@
1
+ declare namespace live_status_d_exports {
2
+ export { LiveStatusResponse, WallConnector };
3
+ }
4
+ export type LiveStatusResponse = {
5
+ solar_power?: number;
6
+ energy_left?: number;
7
+ total_pack_energy?: number;
8
+ percentage_charged?: number;
9
+ backup_capable?: boolean;
10
+ battery_power?: number;
11
+ load_power?: number;
12
+ grid_status?: string;
13
+ grid_services_active?: boolean;
14
+ grid_power?: number;
15
+ grid_services_power?: number;
16
+ generator_power?: number;
17
+ island_status?: string;
18
+ storm_mode_active?: boolean;
19
+ timestamp: Date;
20
+ wall_connectors?: WallConnector[];
21
+ };
22
+ export type WallConnector = {
23
+ din: string;
24
+ vin?: string;
25
+ wall_connector_state: number;
26
+ wall_connector_fault_state: number;
27
+ wall_connector_power: number;
28
+ ocpp_status: number;
29
+ };
30
+ export { live_status_d_exports };
@@ -0,0 +1,30 @@
1
+ declare namespace live_status_d_exports {
2
+ export { LiveStatusResponse, WallConnector };
3
+ }
4
+ export type LiveStatusResponse = {
5
+ solar_power?: number;
6
+ energy_left?: number;
7
+ total_pack_energy?: number;
8
+ percentage_charged?: number;
9
+ backup_capable?: boolean;
10
+ battery_power?: number;
11
+ load_power?: number;
12
+ grid_status?: string;
13
+ grid_services_active?: boolean;
14
+ grid_power?: number;
15
+ grid_services_power?: number;
16
+ generator_power?: number;
17
+ island_status?: string;
18
+ storm_mode_active?: boolean;
19
+ timestamp: Date;
20
+ wall_connectors?: WallConnector[];
21
+ };
22
+ export type WallConnector = {
23
+ din: string;
24
+ vin?: string;
25
+ wall_connector_state: number;
26
+ wall_connector_fault_state: number;
27
+ wall_connector_power: number;
28
+ ocpp_status: number;
29
+ };
30
+ export { live_status_d_exports };
@@ -0,0 +1,58 @@
1
+ import { VehicleResponse } from "./vehicle.cjs";
2
+ import { VehicleConfig } from "./vehicle_data.cjs";
3
+ declare namespace products_d_exports {
4
+ export { Components, EnergyProduct, Features, ProductsData, ProductsResponse, VehicleProduct, WallConnector };
5
+ }
6
+ export type ProductsData = {
7
+ response: ProductsResponse;
8
+ count: number;
9
+ };
10
+ export type ProductsResponse = (VehicleProduct | EnergyProduct)[];
11
+ export type VehicleProduct = VehicleResponse & {
12
+ vehicle_config: VehicleConfig;
13
+ command_signing: string;
14
+ release_notes_supported: boolean;
15
+ };
16
+ export type EnergyProduct = {
17
+ energy_site_id: number;
18
+ resource_type: string;
19
+ site_name: string;
20
+ id: string;
21
+ gateway_id: string;
22
+ asset_site_id: string;
23
+ warp_site_number: string;
24
+ energy_left: number;
25
+ total_pack_energy: number;
26
+ percentage_charged: number;
27
+ battery_type: string;
28
+ backup_capable: boolean;
29
+ battery_power: number;
30
+ go_off_grid_test_banner_enabled: null | boolean;
31
+ storm_mode_enabled: boolean;
32
+ powerwall_onboarding_settings_set: boolean;
33
+ powerwall_tesla_electric_interested_in: null | boolean;
34
+ vpp_tour_enabled: null | boolean;
35
+ sync_grid_alert_enabled: boolean;
36
+ breaker_alert_enabled: boolean;
37
+ components: Components;
38
+ features: Features;
39
+ };
40
+ export type Components = {
41
+ battery: boolean;
42
+ battery_type: string;
43
+ solar: boolean;
44
+ solar_type: string;
45
+ grid: boolean;
46
+ load_meter: boolean;
47
+ market_type: string;
48
+ wall_connectors: WallConnector[];
49
+ };
50
+ export type WallConnector = {
51
+ device_id: string;
52
+ din: string;
53
+ is_active: boolean;
54
+ };
55
+ export type Features = {
56
+ rate_plan_manager_no_pricing_constraint: boolean;
57
+ };
58
+ export { products_d_exports };
@@ -0,0 +1,58 @@
1
+ import { VehicleResponse } from "./vehicle.mjs";
2
+ import { VehicleConfig } from "./vehicle_data.mjs";
3
+ declare namespace products_d_exports {
4
+ export { Components, EnergyProduct, Features, ProductsData, ProductsResponse, VehicleProduct, WallConnector };
5
+ }
6
+ export type ProductsData = {
7
+ response: ProductsResponse;
8
+ count: number;
9
+ };
10
+ export type ProductsResponse = (VehicleProduct | EnergyProduct)[];
11
+ export type VehicleProduct = VehicleResponse & {
12
+ vehicle_config: VehicleConfig;
13
+ command_signing: string;
14
+ release_notes_supported: boolean;
15
+ };
16
+ export type EnergyProduct = {
17
+ energy_site_id: number;
18
+ resource_type: string;
19
+ site_name: string;
20
+ id: string;
21
+ gateway_id: string;
22
+ asset_site_id: string;
23
+ warp_site_number: string;
24
+ energy_left: number;
25
+ total_pack_energy: number;
26
+ percentage_charged: number;
27
+ battery_type: string;
28
+ backup_capable: boolean;
29
+ battery_power: number;
30
+ go_off_grid_test_banner_enabled: null | boolean;
31
+ storm_mode_enabled: boolean;
32
+ powerwall_onboarding_settings_set: boolean;
33
+ powerwall_tesla_electric_interested_in: null | boolean;
34
+ vpp_tour_enabled: null | boolean;
35
+ sync_grid_alert_enabled: boolean;
36
+ breaker_alert_enabled: boolean;
37
+ components: Components;
38
+ features: Features;
39
+ };
40
+ export type Components = {
41
+ battery: boolean;
42
+ battery_type: string;
43
+ solar: boolean;
44
+ solar_type: string;
45
+ grid: boolean;
46
+ load_meter: boolean;
47
+ market_type: string;
48
+ wall_connectors: WallConnector[];
49
+ };
50
+ export type WallConnector = {
51
+ device_id: string;
52
+ din: string;
53
+ is_active: boolean;
54
+ };
55
+ export type Features = {
56
+ rate_plan_manager_no_pricing_constraint: boolean;
57
+ };
58
+ export { products_d_exports };
@@ -0,0 +1,9 @@
1
+ declare namespace responses_d_exports {
2
+ export { OptionsResponse };
3
+ }
4
+ export type OptionsResponse = {
5
+ code: string;
6
+ displayName: string;
7
+ isActive: boolean;
8
+ }[];
9
+ export { responses_d_exports };
@@ -0,0 +1,9 @@
1
+ declare namespace responses_d_exports {
2
+ export { OptionsResponse };
3
+ }
4
+ export type OptionsResponse = {
5
+ code: string;
6
+ displayName: string;
7
+ isActive: boolean;
8
+ }[];
9
+ export { responses_d_exports };