tesla-fleet-api 0.4.0 → 0.6.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 +269 -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 +96 -0
- package/dist/bluetooth/constants.d.cts +68 -0
- package/dist/bluetooth/constants.d.mts +68 -0
- package/dist/bluetooth/constants.mjs +70 -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 +165 -0
- package/dist/bluetooth/homey.d.cts +84 -0
- package/dist/bluetooth/homey.d.mts +84 -0
- package/dist/bluetooth/homey.mjs +159 -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 +97 -0
- package/dist/bluetooth/transport.d.mts +97 -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 +52 -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 +56 -3
package/dist/const.cjs
CHANGED
|
@@ -14,6 +14,8 @@ const TOKEN_URLS = Object.freeze({
|
|
|
14
14
|
function is_valid_region(value) {
|
|
15
15
|
return Object.hasOwn(SERVERS, value);
|
|
16
16
|
}
|
|
17
|
+
/** `navigation_request`'s locale when none is given: this process's, as in Python. */
|
|
18
|
+
const DEFAULT_LOCALE = new Intl.DateTimeFormat().resolvedOptions().locale || "en-US";
|
|
17
19
|
/** Model name keyed by the fourth character of the VIN. */
|
|
18
20
|
const Models = Object.freeze({
|
|
19
21
|
S: "Model S",
|
|
@@ -261,6 +263,23 @@ const BluetoothVehicleData = Object.freeze({
|
|
|
261
263
|
SUSPENSION_STATE: "GetSuspensionState",
|
|
262
264
|
CHILD_PRESENCE_DETECTION_STATE: "GetChildPresenceDetectionState"
|
|
263
265
|
});
|
|
266
|
+
/** Telemetry topics in Teslemetry snapshots. */
|
|
267
|
+
const SnapshotTopic = Object.freeze({
|
|
268
|
+
STATE: "state",
|
|
269
|
+
DATA: "data",
|
|
270
|
+
CONNECTIVITY: "connectivity",
|
|
271
|
+
ALERTS: "alerts",
|
|
272
|
+
ERRORS: "errors",
|
|
273
|
+
VEHICLE_DATA: "vehicle_data"
|
|
274
|
+
});
|
|
275
|
+
/** Teslemetry telemetry topics that can be awaited. */
|
|
276
|
+
const WaitTopic = Object.freeze({
|
|
277
|
+
STATE: "state",
|
|
278
|
+
DATA: "data",
|
|
279
|
+
CONNECTIVITY: "connectivity",
|
|
280
|
+
ALERTS: "alerts",
|
|
281
|
+
ERRORS: "errors"
|
|
282
|
+
});
|
|
264
283
|
exports.AuthorizationRole = AuthorizationRole;
|
|
265
284
|
exports.AuthorizedClientKeyType = AuthorizedClientKeyType;
|
|
266
285
|
exports.AuthorizedClientState = AuthorizedClientState;
|
|
@@ -272,6 +291,7 @@ exports.CabinOverheatProtectionTemp = CabinOverheatProtectionTemp;
|
|
|
272
291
|
exports.ClimateKeeperMode = ClimateKeeperMode;
|
|
273
292
|
exports.ClimateModes = ClimateModes;
|
|
274
293
|
exports.ClosureState = ClosureState;
|
|
294
|
+
exports.DEFAULT_LOCALE = DEFAULT_LOCALE;
|
|
275
295
|
exports.DeviceType = DeviceType;
|
|
276
296
|
exports.DistanceUnit = DistanceUnit;
|
|
277
297
|
exports.EnergyDeviceIdentifierType = EnergyDeviceIdentifierType;
|
|
@@ -287,6 +307,7 @@ exports.SERVERS = SERVERS;
|
|
|
287
307
|
exports.Scope = Scope;
|
|
288
308
|
exports.SeatHeaterLevel = SeatHeaterLevel;
|
|
289
309
|
exports.Seats = Seats;
|
|
310
|
+
exports.SnapshotTopic = SnapshotTopic;
|
|
290
311
|
exports.SunRoofCommand = SunRoofCommand;
|
|
291
312
|
exports.TOKEN_URLS = TOKEN_URLS;
|
|
292
313
|
exports.TemperatureUnit = TemperatureUnit;
|
|
@@ -296,5 +317,6 @@ exports.TirePressureUnit = TirePressureUnit;
|
|
|
296
317
|
exports.Trunk = Trunk;
|
|
297
318
|
exports.VehicleDataEndpoint = VehicleDataEndpoint;
|
|
298
319
|
exports.VehicleImageType = VehicleImageType;
|
|
320
|
+
exports.WaitTopic = WaitTopic;
|
|
299
321
|
exports.WindowCommand = WindowCommand;
|
|
300
322
|
exports.is_valid_region = is_valid_region;
|
package/dist/const.d.cts
CHANGED
|
@@ -11,6 +11,8 @@ export declare const SERVERS: Readonly<Record<Region, string>>;
|
|
|
11
11
|
export declare const TOKEN_URLS: Readonly<Record<Region, string>>;
|
|
12
12
|
/** Check if a string is a valid region and narrow its type. */
|
|
13
13
|
export declare function is_valid_region(value: string): value is Region;
|
|
14
|
+
/** `navigation_request`'s locale when none is given: this process's, as in Python. */
|
|
15
|
+
export declare const DEFAULT_LOCALE: string;
|
|
14
16
|
/** Model name keyed by the fourth character of the VIN. */
|
|
15
17
|
export declare const Models: Readonly<Record<string, string>>;
|
|
16
18
|
type ValueOf<T> = T[keyof T];
|
|
@@ -284,4 +286,23 @@ export declare const BluetoothVehicleData: Readonly<{
|
|
|
284
286
|
readonly CHILD_PRESENCE_DETECTION_STATE: "GetChildPresenceDetectionState";
|
|
285
287
|
}>;
|
|
286
288
|
export type BluetoothVehicleData = ValueOf<typeof BluetoothVehicleData>;
|
|
289
|
+
/** Telemetry topics in Teslemetry snapshots. */
|
|
290
|
+
export declare const SnapshotTopic: Readonly<{
|
|
291
|
+
readonly STATE: "state";
|
|
292
|
+
readonly DATA: "data";
|
|
293
|
+
readonly CONNECTIVITY: "connectivity";
|
|
294
|
+
readonly ALERTS: "alerts";
|
|
295
|
+
readonly ERRORS: "errors";
|
|
296
|
+
readonly VEHICLE_DATA: "vehicle_data";
|
|
297
|
+
}>;
|
|
298
|
+
export type SnapshotTopic = ValueOf<typeof SnapshotTopic>;
|
|
299
|
+
/** Teslemetry telemetry topics that can be awaited. */
|
|
300
|
+
export declare const WaitTopic: Readonly<{
|
|
301
|
+
readonly STATE: "state";
|
|
302
|
+
readonly DATA: "data";
|
|
303
|
+
readonly CONNECTIVITY: "connectivity";
|
|
304
|
+
readonly ALERTS: "alerts";
|
|
305
|
+
readonly ERRORS: "errors";
|
|
306
|
+
}>;
|
|
307
|
+
export type WaitTopic = ValueOf<typeof WaitTopic>;
|
|
287
308
|
export {};
|
package/dist/const.d.mts
CHANGED
|
@@ -11,6 +11,8 @@ export declare const SERVERS: Readonly<Record<Region, string>>;
|
|
|
11
11
|
export declare const TOKEN_URLS: Readonly<Record<Region, string>>;
|
|
12
12
|
/** Check if a string is a valid region and narrow its type. */
|
|
13
13
|
export declare function is_valid_region(value: string): value is Region;
|
|
14
|
+
/** `navigation_request`'s locale when none is given: this process's, as in Python. */
|
|
15
|
+
export declare const DEFAULT_LOCALE: string;
|
|
14
16
|
/** Model name keyed by the fourth character of the VIN. */
|
|
15
17
|
export declare const Models: Readonly<Record<string, string>>;
|
|
16
18
|
type ValueOf<T> = T[keyof T];
|
|
@@ -284,4 +286,23 @@ export declare const BluetoothVehicleData: Readonly<{
|
|
|
284
286
|
readonly CHILD_PRESENCE_DETECTION_STATE: "GetChildPresenceDetectionState";
|
|
285
287
|
}>;
|
|
286
288
|
export type BluetoothVehicleData = ValueOf<typeof BluetoothVehicleData>;
|
|
289
|
+
/** Telemetry topics in Teslemetry snapshots. */
|
|
290
|
+
export declare const SnapshotTopic: Readonly<{
|
|
291
|
+
readonly STATE: "state";
|
|
292
|
+
readonly DATA: "data";
|
|
293
|
+
readonly CONNECTIVITY: "connectivity";
|
|
294
|
+
readonly ALERTS: "alerts";
|
|
295
|
+
readonly ERRORS: "errors";
|
|
296
|
+
readonly VEHICLE_DATA: "vehicle_data";
|
|
297
|
+
}>;
|
|
298
|
+
export type SnapshotTopic = ValueOf<typeof SnapshotTopic>;
|
|
299
|
+
/** Teslemetry telemetry topics that can be awaited. */
|
|
300
|
+
export declare const WaitTopic: Readonly<{
|
|
301
|
+
readonly STATE: "state";
|
|
302
|
+
readonly DATA: "data";
|
|
303
|
+
readonly CONNECTIVITY: "connectivity";
|
|
304
|
+
readonly ALERTS: "alerts";
|
|
305
|
+
readonly ERRORS: "errors";
|
|
306
|
+
}>;
|
|
307
|
+
export type WaitTopic = ValueOf<typeof WaitTopic>;
|
|
287
308
|
export {};
|
package/dist/const.mjs
CHANGED
|
@@ -13,6 +13,8 @@ const TOKEN_URLS = Object.freeze({
|
|
|
13
13
|
function is_valid_region(value) {
|
|
14
14
|
return Object.hasOwn(SERVERS, value);
|
|
15
15
|
}
|
|
16
|
+
/** `navigation_request`'s locale when none is given: this process's, as in Python. */
|
|
17
|
+
const DEFAULT_LOCALE = new Intl.DateTimeFormat().resolvedOptions().locale || "en-US";
|
|
16
18
|
/** Model name keyed by the fourth character of the VIN. */
|
|
17
19
|
const Models = Object.freeze({
|
|
18
20
|
S: "Model S",
|
|
@@ -260,4 +262,21 @@ const BluetoothVehicleData = Object.freeze({
|
|
|
260
262
|
SUSPENSION_STATE: "GetSuspensionState",
|
|
261
263
|
CHILD_PRESENCE_DETECTION_STATE: "GetChildPresenceDetectionState"
|
|
262
264
|
});
|
|
263
|
-
|
|
265
|
+
/** Telemetry topics in Teslemetry snapshots. */
|
|
266
|
+
const SnapshotTopic = Object.freeze({
|
|
267
|
+
STATE: "state",
|
|
268
|
+
DATA: "data",
|
|
269
|
+
CONNECTIVITY: "connectivity",
|
|
270
|
+
ALERTS: "alerts",
|
|
271
|
+
ERRORS: "errors",
|
|
272
|
+
VEHICLE_DATA: "vehicle_data"
|
|
273
|
+
});
|
|
274
|
+
/** Teslemetry telemetry topics that can be awaited. */
|
|
275
|
+
const WaitTopic = Object.freeze({
|
|
276
|
+
STATE: "state",
|
|
277
|
+
DATA: "data",
|
|
278
|
+
CONNECTIVITY: "connectivity",
|
|
279
|
+
ALERTS: "alerts",
|
|
280
|
+
ERRORS: "errors"
|
|
281
|
+
});
|
|
282
|
+
export { AuthorizationRole, AuthorizedClientKeyType, AuthorizedClientState, AuthorizedClientType, AuthorizedVerificationType, AutoSeat, BluetoothVehicleData, CabinOverheatProtectionTemp, ClimateKeeperMode, ClimateModes, ClosureState, DEFAULT_LOCALE, DeviceType, DistanceUnit, EnergyDeviceIdentifierType, EnergyDisplayFormat, EnergyExportMode, EnergyIslandMode, EnergyOperationMode, Level, Method, Models, PhoneFontSize, SERVERS, Scope, SeatHeaterLevel, Seats, SnapshotTopic, SunRoofCommand, TOKEN_URLS, TemperatureUnit, TeslaEnergyPeriod, TimeDisplayFormat, TirePressureUnit, Trunk, VehicleDataEndpoint, VehicleImageType, WaitTopic, WindowCommand, is_valid_region };
|
package/dist/energy.cjs
CHANGED
|
@@ -1,17 +1,25 @@
|
|
|
1
1
|
const require_energyspecific = require("./energyspecific.cjs");
|
|
2
2
|
// src/energy.ts
|
|
3
3
|
var Energy = class {
|
|
4
|
+
/** Class `create` instantiates; a subclass overrides it to supply its own site type. */
|
|
5
|
+
static Site = require_energyspecific.default;
|
|
4
6
|
parent;
|
|
7
|
+
/** Every site created by this factory, keyed by `energy_site_id`; the latest `create` call wins. */
|
|
8
|
+
byId = /* @__PURE__ */ new Map();
|
|
5
9
|
constructor(parent) {
|
|
6
10
|
this.parent = parent;
|
|
7
11
|
}
|
|
8
12
|
/**
|
|
9
13
|
* Create an Energy class for a specific site.
|
|
10
14
|
* @param energy_site_id ID field of an energy site from /api/1/products endpoint.
|
|
15
|
+
* @param private_key RSA key `VERIFIED` on this gateway, for client-signed device commands. Requires `din`. Without one the site is unsigned: unlike vehicles, there is no fallback to the parent's key.
|
|
16
|
+
* @param din Gateway DIN (the energy site's `gateway_id` in `products`).
|
|
11
17
|
* @returns `EnergySpecific` class
|
|
12
18
|
*/
|
|
13
|
-
|
|
14
|
-
|
|
19
|
+
create(energy_site_id, private_key, din) {
|
|
20
|
+
const site = new this.constructor.Site(this, energy_site_id, private_key, din);
|
|
21
|
+
this.byId.set(energy_site_id, site);
|
|
22
|
+
return site;
|
|
15
23
|
}
|
|
16
24
|
/**
|
|
17
25
|
* Adjust the site's backup reserve.
|
|
@@ -25,16 +33,15 @@ var Energy = class {
|
|
|
25
33
|
/**
|
|
26
34
|
* Returns the backup (off-grid) event history of the site in duration of seconds.
|
|
27
35
|
* @param energy_site_id ID field of an energy site from /api/1/products endpoint.
|
|
28
|
-
* @param
|
|
36
|
+
* @param period Period of the window to retrieve backup events. This can be day, week, month, year, lifetime and should align with the window requested.
|
|
29
37
|
* @param start_date Start date of the window to retrieve backup events in RFC3339 format. i.e. 2023-01-01T00:00:00-08:00
|
|
30
38
|
* @param end_date End date of the window to retrieve backup events in RFC3339 format. i.e. 2023-01-01T00:00:00-08:00
|
|
31
|
-
* @param period Period of the window to retrieve backup events. This can be day, week, month, year, lifetime and should align with the window requested.
|
|
32
39
|
* @param time_zone Timezone of the requested window in IANA name format. i.e. 'America/Los_Angeles'
|
|
33
40
|
* @returns
|
|
34
41
|
*/
|
|
35
|
-
async backup_history(energy_site_id,
|
|
42
|
+
async backup_history(energy_site_id, period, start_date, end_date, time_zone) {
|
|
36
43
|
return this.parent._request("GET", `api/1/energy_sites/${energy_site_id}/calendar_history`, {
|
|
37
|
-
kind,
|
|
44
|
+
kind: "backup",
|
|
38
45
|
start_date,
|
|
39
46
|
end_date,
|
|
40
47
|
period,
|
|
@@ -44,15 +51,14 @@ var Energy = class {
|
|
|
44
51
|
/**
|
|
45
52
|
* Returns the charging history of a wall connector.
|
|
46
53
|
* @param energy_site_id ID field of an energy site from /api/1/products endpoint.
|
|
47
|
-
* @param
|
|
48
|
-
* @param
|
|
49
|
-
* @param end_date End date of the window to retrieve backup events in RFC3339 format. i.e. 2023-01-01T00:00:00-08:00
|
|
54
|
+
* @param start_date Start date of the window to retrieve charging events in RFC3339 format. i.e. 2023-01-01T00:00:00-08:00
|
|
55
|
+
* @param end_date End date of the window to retrieve charging events in RFC3339 format. i.e. 2023-01-01T00:00:00-08:00
|
|
50
56
|
* @param time_zone Timezone of the requested window in IANA name format. i.e. 'America/Los_Angeles'
|
|
51
57
|
* @returns
|
|
52
58
|
*/
|
|
53
|
-
async charge_history(energy_site_id,
|
|
59
|
+
async charge_history(energy_site_id, start_date, end_date, time_zone) {
|
|
54
60
|
return this.parent._request("GET", `api/1/energy_sites/${energy_site_id}/telemetry_history`, {
|
|
55
|
-
kind,
|
|
61
|
+
kind: "charge",
|
|
56
62
|
start_date,
|
|
57
63
|
end_date,
|
|
58
64
|
time_zone
|
|
@@ -61,16 +67,15 @@ var Energy = class {
|
|
|
61
67
|
/**
|
|
62
68
|
* Returns the energy measurements of the site, aggregated to the requested period.
|
|
63
69
|
* @param energy_site_id ID field of an energy site from /api/1/products endpoint.
|
|
64
|
-
* @param
|
|
65
|
-
* @param
|
|
66
|
-
* @param end_date End date of the window to retrieve
|
|
67
|
-
* @param period Period of the window to retrieve backup events. This can be day, week, month, year, lifetime and should align with the window requested.
|
|
70
|
+
* @param period Period of the window to retrieve energy measurements. This can be day, week, month, year, lifetime and should align with the window requested.
|
|
71
|
+
* @param start_date Start date of the window to retrieve energy measurements in RFC3339 format. i.e. 2023-01-01T00:00:00-08:00
|
|
72
|
+
* @param end_date End date of the window to retrieve energy measurements in RFC3339 format. i.e. 2023-01-01T00:00:00-08:00
|
|
68
73
|
* @param time_zone Timezone of the requested window in IANA name format. i.e. 'America/Los_Angeles'
|
|
69
74
|
* @returns
|
|
70
75
|
*/
|
|
71
|
-
async energy_history(energy_site_id,
|
|
76
|
+
async energy_history(energy_site_id, period, start_date, end_date, time_zone) {
|
|
72
77
|
return this.parent._request("GET", `api/1/energy_sites/${energy_site_id}/calendar_history`, {
|
|
73
|
-
kind,
|
|
78
|
+
kind: "energy",
|
|
74
79
|
start_date,
|
|
75
80
|
end_date,
|
|
76
81
|
period,
|
|
@@ -96,7 +101,7 @@ var Energy = class {
|
|
|
96
101
|
* @returns
|
|
97
102
|
*/
|
|
98
103
|
async live_status(energy_site_id) {
|
|
99
|
-
return this.parent._request("GET", `api/1/energy_sites/${energy_site_id}/live_status`)
|
|
104
|
+
return this.parent._request("GET", `api/1/energy_sites/${energy_site_id}/live_status`);
|
|
100
105
|
}
|
|
101
106
|
/**
|
|
102
107
|
* Adjust the site's off-grid vehicle charging backup reserve.
|
|
@@ -122,7 +127,7 @@ var Energy = class {
|
|
|
122
127
|
* @returns
|
|
123
128
|
*/
|
|
124
129
|
async site_info(energy_site_id) {
|
|
125
|
-
return this.parent._request("GET", `api/1/energy_sites/${energy_site_id}/site_info`)
|
|
130
|
+
return this.parent._request("GET", `api/1/energy_sites/${energy_site_id}/site_info`);
|
|
126
131
|
}
|
|
127
132
|
/**
|
|
128
133
|
* Update storm watch participation.
|
package/dist/energy.d.cts
CHANGED
|
@@ -1,16 +1,25 @@
|
|
|
1
|
+
import { TeslaEnergyPeriod } from "./const.cjs";
|
|
1
2
|
import EnergySpecific from "./energyspecific.cjs";
|
|
2
3
|
import TeslaFleetApi from "./teslafleetapi.cjs";
|
|
3
4
|
import { LiveStatusResponse } from "./types/live_status.cjs";
|
|
5
|
+
import { ResponseEnvelope } from "./types/responses.cjs";
|
|
4
6
|
import { SiteInfoResponse } from "./types/site_info.cjs";
|
|
7
|
+
import { KeyObject } from "crypto";
|
|
5
8
|
declare class Energy {
|
|
9
|
+
/** Class `create` instantiates; a subclass overrides it to supply its own site type. */
|
|
10
|
+
static Site: new (parent: Energy, energy_site_id: number, private_key?: KeyObject, din?: string) => EnergySpecific;
|
|
6
11
|
parent: TeslaFleetApi;
|
|
12
|
+
/** Every site created by this factory, keyed by `energy_site_id`; the latest `create` call wins. */
|
|
13
|
+
byId: Map<number, EnergySpecific>;
|
|
7
14
|
constructor(parent: TeslaFleetApi);
|
|
8
15
|
/**
|
|
9
16
|
* Create an Energy class for a specific site.
|
|
10
17
|
* @param energy_site_id ID field of an energy site from /api/1/products endpoint.
|
|
18
|
+
* @param private_key RSA key `VERIFIED` on this gateway, for client-signed device commands. Requires `din`. Without one the site is unsigned: unlike vehicles, there is no fallback to the parent's key.
|
|
19
|
+
* @param din Gateway DIN (the energy site's `gateway_id` in `products`).
|
|
11
20
|
* @returns `EnergySpecific` class
|
|
12
21
|
*/
|
|
13
|
-
|
|
22
|
+
create(energy_site_id: number, private_key?: KeyObject, din?: string): EnergySpecific;
|
|
14
23
|
/**
|
|
15
24
|
* Adjust the site's backup reserve.
|
|
16
25
|
* @param energy_site_id ID field of an energy site from /api/1/products endpoint.ID field of an energy site from /api/1/products endpoint.
|
|
@@ -21,35 +30,32 @@ declare class Energy {
|
|
|
21
30
|
/**
|
|
22
31
|
* Returns the backup (off-grid) event history of the site in duration of seconds.
|
|
23
32
|
* @param energy_site_id ID field of an energy site from /api/1/products endpoint.
|
|
24
|
-
* @param
|
|
33
|
+
* @param period Period of the window to retrieve backup events. This can be day, week, month, year, lifetime and should align with the window requested.
|
|
25
34
|
* @param start_date Start date of the window to retrieve backup events in RFC3339 format. i.e. 2023-01-01T00:00:00-08:00
|
|
26
35
|
* @param end_date End date of the window to retrieve backup events in RFC3339 format. i.e. 2023-01-01T00:00:00-08:00
|
|
27
|
-
* @param period Period of the window to retrieve backup events. This can be day, week, month, year, lifetime and should align with the window requested.
|
|
28
36
|
* @param time_zone Timezone of the requested window in IANA name format. i.e. 'America/Los_Angeles'
|
|
29
37
|
* @returns
|
|
30
38
|
*/
|
|
31
|
-
backup_history(energy_site_id: number,
|
|
39
|
+
backup_history(energy_site_id: number, period: TeslaEnergyPeriod | string | null, start_date?: string | null, end_date?: string | null, time_zone?: string | null): Promise<Record<string, any>>;
|
|
32
40
|
/**
|
|
33
41
|
* Returns the charging history of a wall connector.
|
|
34
42
|
* @param energy_site_id ID field of an energy site from /api/1/products endpoint.
|
|
35
|
-
* @param
|
|
36
|
-
* @param
|
|
37
|
-
* @param end_date End date of the window to retrieve backup events in RFC3339 format. i.e. 2023-01-01T00:00:00-08:00
|
|
43
|
+
* @param start_date Start date of the window to retrieve charging events in RFC3339 format. i.e. 2023-01-01T00:00:00-08:00
|
|
44
|
+
* @param end_date End date of the window to retrieve charging events in RFC3339 format. i.e. 2023-01-01T00:00:00-08:00
|
|
38
45
|
* @param time_zone Timezone of the requested window in IANA name format. i.e. 'America/Los_Angeles'
|
|
39
46
|
* @returns
|
|
40
47
|
*/
|
|
41
|
-
charge_history(energy_site_id: number,
|
|
48
|
+
charge_history(energy_site_id: number, start_date: string, end_date: string, time_zone?: string | null): Promise<Record<string, any>>;
|
|
42
49
|
/**
|
|
43
50
|
* Returns the energy measurements of the site, aggregated to the requested period.
|
|
44
51
|
* @param energy_site_id ID field of an energy site from /api/1/products endpoint.
|
|
45
|
-
* @param
|
|
46
|
-
* @param
|
|
47
|
-
* @param end_date End date of the window to retrieve
|
|
48
|
-
* @param period Period of the window to retrieve backup events. This can be day, week, month, year, lifetime and should align with the window requested.
|
|
52
|
+
* @param period Period of the window to retrieve energy measurements. This can be day, week, month, year, lifetime and should align with the window requested.
|
|
53
|
+
* @param start_date Start date of the window to retrieve energy measurements in RFC3339 format. i.e. 2023-01-01T00:00:00-08:00
|
|
54
|
+
* @param end_date End date of the window to retrieve energy measurements in RFC3339 format. i.e. 2023-01-01T00:00:00-08:00
|
|
49
55
|
* @param time_zone Timezone of the requested window in IANA name format. i.e. 'America/Los_Angeles'
|
|
50
56
|
* @returns
|
|
51
57
|
*/
|
|
52
|
-
energy_history(energy_site_id: number,
|
|
58
|
+
energy_history(energy_site_id: number, period: TeslaEnergyPeriod | string | null, start_date?: string | null, end_date?: string | null, time_zone?: string | null): Promise<Record<string, any>>;
|
|
53
59
|
/**
|
|
54
60
|
* Allow/disallow charging from the grid and exporting energy to the grid.
|
|
55
61
|
* @param energy_site_id
|
|
@@ -63,7 +69,7 @@ declare class Energy {
|
|
|
63
69
|
* @param energy_site_id
|
|
64
70
|
* @returns
|
|
65
71
|
*/
|
|
66
|
-
live_status(energy_site_id: number): Promise<LiveStatusResponse
|
|
72
|
+
live_status(energy_site_id: number): Promise<ResponseEnvelope<LiveStatusResponse>>;
|
|
67
73
|
/**
|
|
68
74
|
* Adjust the site's off-grid vehicle charging backup reserve.
|
|
69
75
|
* @param energy_site_id ID field of an energy site from /api/1/products endpoint.
|
|
@@ -83,7 +89,7 @@ declare class Energy {
|
|
|
83
89
|
* @param energy_site_id ID field of an energy site from /api/1/products endpoint.
|
|
84
90
|
* @returns
|
|
85
91
|
*/
|
|
86
|
-
site_info(energy_site_id: number): Promise<SiteInfoResponse
|
|
92
|
+
site_info(energy_site_id: number): Promise<ResponseEnvelope<SiteInfoResponse>>;
|
|
87
93
|
/**
|
|
88
94
|
* Update storm watch participation.
|
|
89
95
|
* @param energy_site_id ID field of an energy site from /api/1/products endpoint.
|
package/dist/energy.d.mts
CHANGED
|
@@ -1,16 +1,25 @@
|
|
|
1
|
+
import { TeslaEnergyPeriod } from "./const.mjs";
|
|
1
2
|
import EnergySpecific from "./energyspecific.mjs";
|
|
2
3
|
import TeslaFleetApi from "./teslafleetapi.mjs";
|
|
3
4
|
import { LiveStatusResponse } from "./types/live_status.mjs";
|
|
5
|
+
import { ResponseEnvelope } from "./types/responses.mjs";
|
|
4
6
|
import { SiteInfoResponse } from "./types/site_info.mjs";
|
|
7
|
+
import { KeyObject } from "crypto";
|
|
5
8
|
export default class Energy {
|
|
9
|
+
/** Class `create` instantiates; a subclass overrides it to supply its own site type. */
|
|
10
|
+
static Site: new (parent: Energy, energy_site_id: number, private_key?: KeyObject, din?: string) => EnergySpecific;
|
|
6
11
|
parent: TeslaFleetApi;
|
|
12
|
+
/** Every site created by this factory, keyed by `energy_site_id`; the latest `create` call wins. */
|
|
13
|
+
byId: Map<number, EnergySpecific>;
|
|
7
14
|
constructor(parent: TeslaFleetApi);
|
|
8
15
|
/**
|
|
9
16
|
* Create an Energy class for a specific site.
|
|
10
17
|
* @param energy_site_id ID field of an energy site from /api/1/products endpoint.
|
|
18
|
+
* @param private_key RSA key `VERIFIED` on this gateway, for client-signed device commands. Requires `din`. Without one the site is unsigned: unlike vehicles, there is no fallback to the parent's key.
|
|
19
|
+
* @param din Gateway DIN (the energy site's `gateway_id` in `products`).
|
|
11
20
|
* @returns `EnergySpecific` class
|
|
12
21
|
*/
|
|
13
|
-
|
|
22
|
+
create(energy_site_id: number, private_key?: KeyObject, din?: string): EnergySpecific;
|
|
14
23
|
/**
|
|
15
24
|
* Adjust the site's backup reserve.
|
|
16
25
|
* @param energy_site_id ID field of an energy site from /api/1/products endpoint.ID field of an energy site from /api/1/products endpoint.
|
|
@@ -21,35 +30,32 @@ export default class Energy {
|
|
|
21
30
|
/**
|
|
22
31
|
* Returns the backup (off-grid) event history of the site in duration of seconds.
|
|
23
32
|
* @param energy_site_id ID field of an energy site from /api/1/products endpoint.
|
|
24
|
-
* @param
|
|
33
|
+
* @param period Period of the window to retrieve backup events. This can be day, week, month, year, lifetime and should align with the window requested.
|
|
25
34
|
* @param start_date Start date of the window to retrieve backup events in RFC3339 format. i.e. 2023-01-01T00:00:00-08:00
|
|
26
35
|
* @param end_date End date of the window to retrieve backup events in RFC3339 format. i.e. 2023-01-01T00:00:00-08:00
|
|
27
|
-
* @param period Period of the window to retrieve backup events. This can be day, week, month, year, lifetime and should align with the window requested.
|
|
28
36
|
* @param time_zone Timezone of the requested window in IANA name format. i.e. 'America/Los_Angeles'
|
|
29
37
|
* @returns
|
|
30
38
|
*/
|
|
31
|
-
backup_history(energy_site_id: number,
|
|
39
|
+
backup_history(energy_site_id: number, period: TeslaEnergyPeriod | string | null, start_date?: string | null, end_date?: string | null, time_zone?: string | null): Promise<Record<string, any>>;
|
|
32
40
|
/**
|
|
33
41
|
* Returns the charging history of a wall connector.
|
|
34
42
|
* @param energy_site_id ID field of an energy site from /api/1/products endpoint.
|
|
35
|
-
* @param
|
|
36
|
-
* @param
|
|
37
|
-
* @param end_date End date of the window to retrieve backup events in RFC3339 format. i.e. 2023-01-01T00:00:00-08:00
|
|
43
|
+
* @param start_date Start date of the window to retrieve charging events in RFC3339 format. i.e. 2023-01-01T00:00:00-08:00
|
|
44
|
+
* @param end_date End date of the window to retrieve charging events in RFC3339 format. i.e. 2023-01-01T00:00:00-08:00
|
|
38
45
|
* @param time_zone Timezone of the requested window in IANA name format. i.e. 'America/Los_Angeles'
|
|
39
46
|
* @returns
|
|
40
47
|
*/
|
|
41
|
-
charge_history(energy_site_id: number,
|
|
48
|
+
charge_history(energy_site_id: number, start_date: string, end_date: string, time_zone?: string | null): Promise<Record<string, any>>;
|
|
42
49
|
/**
|
|
43
50
|
* Returns the energy measurements of the site, aggregated to the requested period.
|
|
44
51
|
* @param energy_site_id ID field of an energy site from /api/1/products endpoint.
|
|
45
|
-
* @param
|
|
46
|
-
* @param
|
|
47
|
-
* @param end_date End date of the window to retrieve
|
|
48
|
-
* @param period Period of the window to retrieve backup events. This can be day, week, month, year, lifetime and should align with the window requested.
|
|
52
|
+
* @param period Period of the window to retrieve energy measurements. This can be day, week, month, year, lifetime and should align with the window requested.
|
|
53
|
+
* @param start_date Start date of the window to retrieve energy measurements in RFC3339 format. i.e. 2023-01-01T00:00:00-08:00
|
|
54
|
+
* @param end_date End date of the window to retrieve energy measurements in RFC3339 format. i.e. 2023-01-01T00:00:00-08:00
|
|
49
55
|
* @param time_zone Timezone of the requested window in IANA name format. i.e. 'America/Los_Angeles'
|
|
50
56
|
* @returns
|
|
51
57
|
*/
|
|
52
|
-
energy_history(energy_site_id: number,
|
|
58
|
+
energy_history(energy_site_id: number, period: TeslaEnergyPeriod | string | null, start_date?: string | null, end_date?: string | null, time_zone?: string | null): Promise<Record<string, any>>;
|
|
53
59
|
/**
|
|
54
60
|
* Allow/disallow charging from the grid and exporting energy to the grid.
|
|
55
61
|
* @param energy_site_id
|
|
@@ -63,7 +69,7 @@ export default class Energy {
|
|
|
63
69
|
* @param energy_site_id
|
|
64
70
|
* @returns
|
|
65
71
|
*/
|
|
66
|
-
live_status(energy_site_id: number): Promise<LiveStatusResponse
|
|
72
|
+
live_status(energy_site_id: number): Promise<ResponseEnvelope<LiveStatusResponse>>;
|
|
67
73
|
/**
|
|
68
74
|
* Adjust the site's off-grid vehicle charging backup reserve.
|
|
69
75
|
* @param energy_site_id ID field of an energy site from /api/1/products endpoint.
|
|
@@ -83,7 +89,7 @@ export default class Energy {
|
|
|
83
89
|
* @param energy_site_id ID field of an energy site from /api/1/products endpoint.
|
|
84
90
|
* @returns
|
|
85
91
|
*/
|
|
86
|
-
site_info(energy_site_id: number): Promise<SiteInfoResponse
|
|
92
|
+
site_info(energy_site_id: number): Promise<ResponseEnvelope<SiteInfoResponse>>;
|
|
87
93
|
/**
|
|
88
94
|
* Update storm watch participation.
|
|
89
95
|
* @param energy_site_id ID field of an energy site from /api/1/products endpoint.
|
package/dist/energy.mjs
CHANGED
|
@@ -1,17 +1,25 @@
|
|
|
1
1
|
import EnergySpecific from "./energyspecific.mjs";
|
|
2
2
|
// src/energy.ts
|
|
3
3
|
var Energy = class {
|
|
4
|
+
/** Class `create` instantiates; a subclass overrides it to supply its own site type. */
|
|
5
|
+
static Site = EnergySpecific;
|
|
4
6
|
parent;
|
|
7
|
+
/** Every site created by this factory, keyed by `energy_site_id`; the latest `create` call wins. */
|
|
8
|
+
byId = /* @__PURE__ */ new Map();
|
|
5
9
|
constructor(parent) {
|
|
6
10
|
this.parent = parent;
|
|
7
11
|
}
|
|
8
12
|
/**
|
|
9
13
|
* Create an Energy class for a specific site.
|
|
10
14
|
* @param energy_site_id ID field of an energy site from /api/1/products endpoint.
|
|
15
|
+
* @param private_key RSA key `VERIFIED` on this gateway, for client-signed device commands. Requires `din`. Without one the site is unsigned: unlike vehicles, there is no fallback to the parent's key.
|
|
16
|
+
* @param din Gateway DIN (the energy site's `gateway_id` in `products`).
|
|
11
17
|
* @returns `EnergySpecific` class
|
|
12
18
|
*/
|
|
13
|
-
|
|
14
|
-
|
|
19
|
+
create(energy_site_id, private_key, din) {
|
|
20
|
+
const site = new this.constructor.Site(this, energy_site_id, private_key, din);
|
|
21
|
+
this.byId.set(energy_site_id, site);
|
|
22
|
+
return site;
|
|
15
23
|
}
|
|
16
24
|
/**
|
|
17
25
|
* Adjust the site's backup reserve.
|
|
@@ -25,16 +33,15 @@ var Energy = class {
|
|
|
25
33
|
/**
|
|
26
34
|
* Returns the backup (off-grid) event history of the site in duration of seconds.
|
|
27
35
|
* @param energy_site_id ID field of an energy site from /api/1/products endpoint.
|
|
28
|
-
* @param
|
|
36
|
+
* @param period Period of the window to retrieve backup events. This can be day, week, month, year, lifetime and should align with the window requested.
|
|
29
37
|
* @param start_date Start date of the window to retrieve backup events in RFC3339 format. i.e. 2023-01-01T00:00:00-08:00
|
|
30
38
|
* @param end_date End date of the window to retrieve backup events in RFC3339 format. i.e. 2023-01-01T00:00:00-08:00
|
|
31
|
-
* @param period Period of the window to retrieve backup events. This can be day, week, month, year, lifetime and should align with the window requested.
|
|
32
39
|
* @param time_zone Timezone of the requested window in IANA name format. i.e. 'America/Los_Angeles'
|
|
33
40
|
* @returns
|
|
34
41
|
*/
|
|
35
|
-
async backup_history(energy_site_id,
|
|
42
|
+
async backup_history(energy_site_id, period, start_date, end_date, time_zone) {
|
|
36
43
|
return this.parent._request("GET", `api/1/energy_sites/${energy_site_id}/calendar_history`, {
|
|
37
|
-
kind,
|
|
44
|
+
kind: "backup",
|
|
38
45
|
start_date,
|
|
39
46
|
end_date,
|
|
40
47
|
period,
|
|
@@ -44,15 +51,14 @@ var Energy = class {
|
|
|
44
51
|
/**
|
|
45
52
|
* Returns the charging history of a wall connector.
|
|
46
53
|
* @param energy_site_id ID field of an energy site from /api/1/products endpoint.
|
|
47
|
-
* @param
|
|
48
|
-
* @param
|
|
49
|
-
* @param end_date End date of the window to retrieve backup events in RFC3339 format. i.e. 2023-01-01T00:00:00-08:00
|
|
54
|
+
* @param start_date Start date of the window to retrieve charging events in RFC3339 format. i.e. 2023-01-01T00:00:00-08:00
|
|
55
|
+
* @param end_date End date of the window to retrieve charging events in RFC3339 format. i.e. 2023-01-01T00:00:00-08:00
|
|
50
56
|
* @param time_zone Timezone of the requested window in IANA name format. i.e. 'America/Los_Angeles'
|
|
51
57
|
* @returns
|
|
52
58
|
*/
|
|
53
|
-
async charge_history(energy_site_id,
|
|
59
|
+
async charge_history(energy_site_id, start_date, end_date, time_zone) {
|
|
54
60
|
return this.parent._request("GET", `api/1/energy_sites/${energy_site_id}/telemetry_history`, {
|
|
55
|
-
kind,
|
|
61
|
+
kind: "charge",
|
|
56
62
|
start_date,
|
|
57
63
|
end_date,
|
|
58
64
|
time_zone
|
|
@@ -61,16 +67,15 @@ var Energy = class {
|
|
|
61
67
|
/**
|
|
62
68
|
* Returns the energy measurements of the site, aggregated to the requested period.
|
|
63
69
|
* @param energy_site_id ID field of an energy site from /api/1/products endpoint.
|
|
64
|
-
* @param
|
|
65
|
-
* @param
|
|
66
|
-
* @param end_date End date of the window to retrieve
|
|
67
|
-
* @param period Period of the window to retrieve backup events. This can be day, week, month, year, lifetime and should align with the window requested.
|
|
70
|
+
* @param period Period of the window to retrieve energy measurements. This can be day, week, month, year, lifetime and should align with the window requested.
|
|
71
|
+
* @param start_date Start date of the window to retrieve energy measurements in RFC3339 format. i.e. 2023-01-01T00:00:00-08:00
|
|
72
|
+
* @param end_date End date of the window to retrieve energy measurements in RFC3339 format. i.e. 2023-01-01T00:00:00-08:00
|
|
68
73
|
* @param time_zone Timezone of the requested window in IANA name format. i.e. 'America/Los_Angeles'
|
|
69
74
|
* @returns
|
|
70
75
|
*/
|
|
71
|
-
async energy_history(energy_site_id,
|
|
76
|
+
async energy_history(energy_site_id, period, start_date, end_date, time_zone) {
|
|
72
77
|
return this.parent._request("GET", `api/1/energy_sites/${energy_site_id}/calendar_history`, {
|
|
73
|
-
kind,
|
|
78
|
+
kind: "energy",
|
|
74
79
|
start_date,
|
|
75
80
|
end_date,
|
|
76
81
|
period,
|
|
@@ -96,7 +101,7 @@ var Energy = class {
|
|
|
96
101
|
* @returns
|
|
97
102
|
*/
|
|
98
103
|
async live_status(energy_site_id) {
|
|
99
|
-
return this.parent._request("GET", `api/1/energy_sites/${energy_site_id}/live_status`)
|
|
104
|
+
return this.parent._request("GET", `api/1/energy_sites/${energy_site_id}/live_status`);
|
|
100
105
|
}
|
|
101
106
|
/**
|
|
102
107
|
* Adjust the site's off-grid vehicle charging backup reserve.
|
|
@@ -122,7 +127,7 @@ var Energy = class {
|
|
|
122
127
|
* @returns
|
|
123
128
|
*/
|
|
124
129
|
async site_info(energy_site_id) {
|
|
125
|
-
return this.parent._request("GET", `api/1/energy_sites/${energy_site_id}/site_info`)
|
|
130
|
+
return this.parent._request("GET", `api/1/energy_sites/${energy_site_id}/site_info`);
|
|
126
131
|
}
|
|
127
132
|
/**
|
|
128
133
|
* Update storm watch participation.
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
const require_const = require("./const.cjs");
|
|
2
|
+
let _teslemetry_tesla_protocol_energy_device_teg_api = require("@teslemetry/tesla-protocol/energy_device/teg_api");
|
|
3
|
+
// src/energyisland.ts
|
|
4
|
+
/** The `TEGSetIslandModeResult` values that mean the gateway refused. */
|
|
5
|
+
const REJECTIONS = [
|
|
6
|
+
_teslemetry_tesla_protocol_energy_device_teg_api.TEGSetIslandModeResult.TEG_SET_ISLAND_MODE_RESULT_REJECTED_NOT_READY_FOR_ISLANDING,
|
|
7
|
+
_teslemetry_tesla_protocol_energy_device_teg_api.TEGSetIslandModeResult.TEG_SET_ISLAND_MODE_RESULT_REJECTED_LOAD_DROP_EXPECTED,
|
|
8
|
+
_teslemetry_tesla_protocol_energy_device_teg_api.TEGSetIslandModeResult.TEG_SET_ISLAND_MODE_RESULT_REJECTED_LOW_ENERGY,
|
|
9
|
+
_teslemetry_tesla_protocol_energy_device_teg_api.TEGSetIslandModeResult.TEG_SET_ISLAND_MODE_RESULT_REJECTED_EXCESSIVE_SOLAR
|
|
10
|
+
];
|
|
11
|
+
/**
|
|
12
|
+
* The refusal a `setIslandModeResponse.result` reports, or `null` for anything
|
|
13
|
+
* else, which is not guessed at. Takes the enum's number or its name, because a
|
|
14
|
+
* JSON route may carry either.
|
|
15
|
+
*/
|
|
16
|
+
function island_mode_rejection(result) {
|
|
17
|
+
for (const code of REJECTIONS) {
|
|
18
|
+
const name = (0, _teslemetry_tesla_protocol_energy_device_teg_api.tEGSetIslandModeResultToJSON)(code);
|
|
19
|
+
if (result === code || result === name) return {
|
|
20
|
+
code,
|
|
21
|
+
name
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Check an island command before it is signed. A contactor command takes only the
|
|
28
|
+
* two modes Python's `go_off_grid` and `reconnect_grid` use: `ON_GRID` (1) and
|
|
29
|
+
* `OFF_GRID` (6). There is no coercion and no default, because `"6"` or a missing
|
|
30
|
+
* mode could otherwise close the contactor when the caller meant to open it.
|
|
31
|
+
* @throws TypeError on any other mode, or a `force` that is not a boolean.
|
|
32
|
+
*/
|
|
33
|
+
function validate_island_mode(mode, force) {
|
|
34
|
+
if (mode !== require_const.EnergyIslandMode.ON_GRID && mode !== require_const.EnergyIslandMode.OFF_GRID) throw new TypeError("mode must be EnergyIslandMode.ON_GRID (1) or EnergyIslandMode.OFF_GRID (6)");
|
|
35
|
+
if (force !== void 0 && force !== null && typeof force !== "boolean") throw new TypeError("force must be a boolean");
|
|
36
|
+
}
|
|
37
|
+
exports.island_mode_rejection = island_mode_rejection;
|
|
38
|
+
exports.validate_island_mode = validate_island_mode;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { EnergyIslandMode } from "./const.mjs";
|
|
2
|
+
import { TEGSetIslandModeResult, tEGSetIslandModeResultToJSON } from "@teslemetry/tesla-protocol/energy_device/teg_api";
|
|
3
|
+
// src/energyisland.ts
|
|
4
|
+
/** The `TEGSetIslandModeResult` values that mean the gateway refused. */
|
|
5
|
+
const REJECTIONS = [
|
|
6
|
+
TEGSetIslandModeResult.TEG_SET_ISLAND_MODE_RESULT_REJECTED_NOT_READY_FOR_ISLANDING,
|
|
7
|
+
TEGSetIslandModeResult.TEG_SET_ISLAND_MODE_RESULT_REJECTED_LOAD_DROP_EXPECTED,
|
|
8
|
+
TEGSetIslandModeResult.TEG_SET_ISLAND_MODE_RESULT_REJECTED_LOW_ENERGY,
|
|
9
|
+
TEGSetIslandModeResult.TEG_SET_ISLAND_MODE_RESULT_REJECTED_EXCESSIVE_SOLAR
|
|
10
|
+
];
|
|
11
|
+
/**
|
|
12
|
+
* The refusal a `setIslandModeResponse.result` reports, or `null` for anything
|
|
13
|
+
* else, which is not guessed at. Takes the enum's number or its name, because a
|
|
14
|
+
* JSON route may carry either.
|
|
15
|
+
*/
|
|
16
|
+
function island_mode_rejection(result) {
|
|
17
|
+
for (const code of REJECTIONS) {
|
|
18
|
+
const name = tEGSetIslandModeResultToJSON(code);
|
|
19
|
+
if (result === code || result === name) return {
|
|
20
|
+
code,
|
|
21
|
+
name
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Check an island command before it is signed. A contactor command takes only the
|
|
28
|
+
* two modes Python's `go_off_grid` and `reconnect_grid` use: `ON_GRID` (1) and
|
|
29
|
+
* `OFF_GRID` (6). There is no coercion and no default, because `"6"` or a missing
|
|
30
|
+
* mode could otherwise close the contactor when the caller meant to open it.
|
|
31
|
+
* @throws TypeError on any other mode, or a `force` that is not a boolean.
|
|
32
|
+
*/
|
|
33
|
+
function validate_island_mode(mode, force) {
|
|
34
|
+
if (mode !== EnergyIslandMode.ON_GRID && mode !== EnergyIslandMode.OFF_GRID) throw new TypeError("mode must be EnergyIslandMode.ON_GRID (1) or EnergyIslandMode.OFF_GRID (6)");
|
|
35
|
+
if (force !== void 0 && force !== null && typeof force !== "boolean") throw new TypeError("force must be a boolean");
|
|
36
|
+
}
|
|
37
|
+
export { island_mode_rejection, validate_island_mode };
|