node-chargepoint 0.0.1
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/LICENSE +21 -0
- package/README.md +460 -0
- package/dist/cli.cjs +814 -0
- package/dist/index.cjs +712 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +438 -0
- package/dist/index.d.ts +438 -0
- package/dist/index.js +700 -0
- package/dist/index.js.map +1 -0
- package/package.json +67 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,438 @@
|
|
|
1
|
+
interface ZoomBounds {
|
|
2
|
+
neLon: number;
|
|
3
|
+
neLat: number;
|
|
4
|
+
swLon: number;
|
|
5
|
+
swLat: number;
|
|
6
|
+
}
|
|
7
|
+
interface Country {
|
|
8
|
+
id: number;
|
|
9
|
+
name: string;
|
|
10
|
+
code: string;
|
|
11
|
+
callingCode: number;
|
|
12
|
+
phoneFormat: string;
|
|
13
|
+
zoomBounds: ZoomBounds;
|
|
14
|
+
}
|
|
15
|
+
interface Currency {
|
|
16
|
+
code: string;
|
|
17
|
+
name: string;
|
|
18
|
+
cardCost: number;
|
|
19
|
+
symbol: string;
|
|
20
|
+
initialDeposit: number;
|
|
21
|
+
replenishmentThreshold: number;
|
|
22
|
+
maxDecimalPlaces: number;
|
|
23
|
+
}
|
|
24
|
+
interface APIEndpoints {
|
|
25
|
+
accountsEndpoint: string;
|
|
26
|
+
internalApiGatewayEndpoint: string;
|
|
27
|
+
mapcacheEndpoint: string;
|
|
28
|
+
pandaWebsocketEndpoint: string;
|
|
29
|
+
paymentJavaEndpoint: string;
|
|
30
|
+
paymentPhpEndpoint: string;
|
|
31
|
+
portalDomainEndpoint: string;
|
|
32
|
+
portalSubdomain: string;
|
|
33
|
+
ssoEndpoint: string;
|
|
34
|
+
webservicesEndpoint: string;
|
|
35
|
+
websocketEndpoint: string;
|
|
36
|
+
hcpoHcmEndpoint: string;
|
|
37
|
+
}
|
|
38
|
+
interface GlobalConfiguration {
|
|
39
|
+
region: string;
|
|
40
|
+
defaultCountry: Country;
|
|
41
|
+
supportedCountries: Country[];
|
|
42
|
+
defaultCurrency: Currency;
|
|
43
|
+
supportedCurrencies: Currency[];
|
|
44
|
+
endpoints: APIEndpoints;
|
|
45
|
+
}
|
|
46
|
+
interface User {
|
|
47
|
+
userId: number;
|
|
48
|
+
email: string;
|
|
49
|
+
username: string;
|
|
50
|
+
fullName: string;
|
|
51
|
+
givenName: string;
|
|
52
|
+
familyName: string;
|
|
53
|
+
phone: string;
|
|
54
|
+
phoneCountryId: number;
|
|
55
|
+
evatarUrl: string;
|
|
56
|
+
}
|
|
57
|
+
interface AccountBalance {
|
|
58
|
+
accountNumber: string;
|
|
59
|
+
accountState: string;
|
|
60
|
+
balance: {
|
|
61
|
+
currency: string;
|
|
62
|
+
amount: string;
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
interface Account {
|
|
66
|
+
user: User;
|
|
67
|
+
accountBalance: AccountBalance;
|
|
68
|
+
}
|
|
69
|
+
interface ElectricVehicle {
|
|
70
|
+
make: string;
|
|
71
|
+
model: string;
|
|
72
|
+
year: number;
|
|
73
|
+
primaryVehicle: boolean;
|
|
74
|
+
color: string;
|
|
75
|
+
imageUrl: string;
|
|
76
|
+
chargingSpeed: number;
|
|
77
|
+
dcChargingSpeed: number;
|
|
78
|
+
}
|
|
79
|
+
interface PowerUtilityPlan {
|
|
80
|
+
code: string;
|
|
81
|
+
id: number;
|
|
82
|
+
name: string;
|
|
83
|
+
isEvPlan: boolean;
|
|
84
|
+
}
|
|
85
|
+
interface PowerUtility {
|
|
86
|
+
id: number;
|
|
87
|
+
name: string;
|
|
88
|
+
plans: PowerUtilityPlan[];
|
|
89
|
+
}
|
|
90
|
+
interface HomeChargerStatus {
|
|
91
|
+
chargerId: number;
|
|
92
|
+
brand: string;
|
|
93
|
+
model: string;
|
|
94
|
+
macAddress: string;
|
|
95
|
+
chargingStatus: string;
|
|
96
|
+
isPluggedIn: boolean;
|
|
97
|
+
isConnected: boolean;
|
|
98
|
+
isReminderEnabled: boolean;
|
|
99
|
+
plugInReminderTime: string;
|
|
100
|
+
amperageLimit: number;
|
|
101
|
+
possibleAmperageLimits: number[];
|
|
102
|
+
hasUtilityInfo: boolean;
|
|
103
|
+
isDuringScheduledTime: boolean;
|
|
104
|
+
}
|
|
105
|
+
interface HomeChargerTechnicalInfo {
|
|
106
|
+
modelNumber: string;
|
|
107
|
+
serialNumber: string;
|
|
108
|
+
wifiMac: string;
|
|
109
|
+
macAddress: string;
|
|
110
|
+
softwareVersion: string;
|
|
111
|
+
lastOtaUpdate: string;
|
|
112
|
+
lastConnectedAt: string;
|
|
113
|
+
deviceIp: string;
|
|
114
|
+
stopChargeSupported: boolean;
|
|
115
|
+
}
|
|
116
|
+
interface LEDBrightness {
|
|
117
|
+
level: number;
|
|
118
|
+
inProgress: boolean;
|
|
119
|
+
supportedLevels: number[];
|
|
120
|
+
isEnabled: boolean;
|
|
121
|
+
}
|
|
122
|
+
interface HomeChargerConfiguration {
|
|
123
|
+
serialNumber: string;
|
|
124
|
+
macAddress: string;
|
|
125
|
+
stationNickname: string;
|
|
126
|
+
streetAddress: string;
|
|
127
|
+
hasUtilityInfo: boolean;
|
|
128
|
+
utility: PowerUtility | null;
|
|
129
|
+
indicatorLightEcoMode: boolean;
|
|
130
|
+
flashlightReset: boolean;
|
|
131
|
+
worksWithNest: boolean;
|
|
132
|
+
isPairedWithNest: boolean;
|
|
133
|
+
isInstalledByInstaller: boolean;
|
|
134
|
+
ledBrightness: LEDBrightness;
|
|
135
|
+
}
|
|
136
|
+
interface ChargeScheduleWindow {
|
|
137
|
+
startTime: string;
|
|
138
|
+
endTime: string;
|
|
139
|
+
startWeekday?: string;
|
|
140
|
+
endWeekday?: string;
|
|
141
|
+
}
|
|
142
|
+
interface ChargeSchedule {
|
|
143
|
+
weekdays: ChargeScheduleWindow;
|
|
144
|
+
weekends: ChargeScheduleWindow;
|
|
145
|
+
}
|
|
146
|
+
interface HomeChargerSchedule {
|
|
147
|
+
hasTouPricing: boolean;
|
|
148
|
+
scheduleEnabled: boolean;
|
|
149
|
+
hasUtilityInfo: boolean;
|
|
150
|
+
basedOnUtility: PowerUtility | null;
|
|
151
|
+
defaultSchedule: ChargeSchedule;
|
|
152
|
+
userSchedule: ChargeSchedule;
|
|
153
|
+
utilitySchedule: ChargeSchedule | null;
|
|
154
|
+
}
|
|
155
|
+
interface ChargingSessionUpdate {
|
|
156
|
+
energyKwh: number;
|
|
157
|
+
powerKw: number;
|
|
158
|
+
timestamp: Date;
|
|
159
|
+
}
|
|
160
|
+
interface VehicleInfo {
|
|
161
|
+
vehicleId: number;
|
|
162
|
+
batteryCapacity: number;
|
|
163
|
+
make: string;
|
|
164
|
+
model: string;
|
|
165
|
+
year: number;
|
|
166
|
+
evRange: number;
|
|
167
|
+
isPrimaryVehicle: boolean;
|
|
168
|
+
}
|
|
169
|
+
interface Station {
|
|
170
|
+
id: number;
|
|
171
|
+
name: string;
|
|
172
|
+
latitude: number;
|
|
173
|
+
longitude: number;
|
|
174
|
+
}
|
|
175
|
+
interface UserChargingStatus {
|
|
176
|
+
sessionId: number;
|
|
177
|
+
startTime: Date;
|
|
178
|
+
state: string;
|
|
179
|
+
stations: Station[];
|
|
180
|
+
}
|
|
181
|
+
interface MaxPower {
|
|
182
|
+
unit: string;
|
|
183
|
+
max: number;
|
|
184
|
+
}
|
|
185
|
+
interface StationAddress {
|
|
186
|
+
address1: string;
|
|
187
|
+
city: string;
|
|
188
|
+
state: string;
|
|
189
|
+
}
|
|
190
|
+
interface StationConnector {
|
|
191
|
+
status: string;
|
|
192
|
+
statusV2: string;
|
|
193
|
+
displayPlugType: string;
|
|
194
|
+
plugType: string;
|
|
195
|
+
}
|
|
196
|
+
interface StationPortDetail {
|
|
197
|
+
outletNumber: number;
|
|
198
|
+
status: string;
|
|
199
|
+
statusV2: string;
|
|
200
|
+
displayLevel: number;
|
|
201
|
+
level: number;
|
|
202
|
+
parkingAccessibility: string;
|
|
203
|
+
powerRange: MaxPower;
|
|
204
|
+
connectorList: StationConnector[];
|
|
205
|
+
}
|
|
206
|
+
interface StationNetwork {
|
|
207
|
+
name: string;
|
|
208
|
+
displayName: string;
|
|
209
|
+
logoUrl: string;
|
|
210
|
+
}
|
|
211
|
+
interface StationPortsInfo {
|
|
212
|
+
totalCount: number;
|
|
213
|
+
availableCount: number;
|
|
214
|
+
ports: StationPortDetail[];
|
|
215
|
+
}
|
|
216
|
+
interface StationTouEntry {
|
|
217
|
+
description: string;
|
|
218
|
+
price: number;
|
|
219
|
+
}
|
|
220
|
+
interface StationPricingFee {
|
|
221
|
+
amount: number;
|
|
222
|
+
currency: string;
|
|
223
|
+
}
|
|
224
|
+
interface StationTax {
|
|
225
|
+
name: string;
|
|
226
|
+
rate: number;
|
|
227
|
+
}
|
|
228
|
+
interface StationPrice {
|
|
229
|
+
currencyCode: string;
|
|
230
|
+
touFees: StationTouEntry[];
|
|
231
|
+
guestFee: StationPricingFee | null;
|
|
232
|
+
taxes: StationTax[];
|
|
233
|
+
}
|
|
234
|
+
interface StationInfo {
|
|
235
|
+
deviceId: number;
|
|
236
|
+
name: string[];
|
|
237
|
+
address: StationAddress;
|
|
238
|
+
description: string;
|
|
239
|
+
modelNumber: string;
|
|
240
|
+
network: StationNetwork;
|
|
241
|
+
portsInfo: StationPortsInfo;
|
|
242
|
+
stationStatus: string;
|
|
243
|
+
stationStatusV2: string;
|
|
244
|
+
latitude: number;
|
|
245
|
+
longitude: number;
|
|
246
|
+
hostName: string;
|
|
247
|
+
openCloseStatus: string;
|
|
248
|
+
maxPower: MaxPower | null;
|
|
249
|
+
accessRestriction: string;
|
|
250
|
+
parkingAccessibility: string;
|
|
251
|
+
stopChargeSupported: boolean;
|
|
252
|
+
remoteStartCharge: boolean;
|
|
253
|
+
sharedPower: boolean;
|
|
254
|
+
reducedPower: boolean;
|
|
255
|
+
stationPrice: StationPrice | null;
|
|
256
|
+
deviceSoftwareVersion: string;
|
|
257
|
+
lastChargedDate: string;
|
|
258
|
+
}
|
|
259
|
+
interface StationPort {
|
|
260
|
+
statusV2: string;
|
|
261
|
+
portType: string;
|
|
262
|
+
outletNumber: number;
|
|
263
|
+
parkingAccessibility: string;
|
|
264
|
+
availablePower: number;
|
|
265
|
+
status: string;
|
|
266
|
+
}
|
|
267
|
+
interface MapChargingInfo {
|
|
268
|
+
sessionId: number;
|
|
269
|
+
startTime: Date;
|
|
270
|
+
powerKw: number;
|
|
271
|
+
}
|
|
272
|
+
interface MapStation {
|
|
273
|
+
deviceId: number;
|
|
274
|
+
lat: number;
|
|
275
|
+
lon: number;
|
|
276
|
+
name1: string;
|
|
277
|
+
name2: string;
|
|
278
|
+
address1: string;
|
|
279
|
+
city: string;
|
|
280
|
+
networkDisplayName: string;
|
|
281
|
+
networkLogoUrl: string;
|
|
282
|
+
stationStatus: string;
|
|
283
|
+
stationStatusV2: string;
|
|
284
|
+
paymentType: string;
|
|
285
|
+
parkingAccessibility: string;
|
|
286
|
+
totalPortCount: number;
|
|
287
|
+
ports: StationPort[];
|
|
288
|
+
hasL2: boolean;
|
|
289
|
+
maxPower: number;
|
|
290
|
+
currencyIsoCode: string;
|
|
291
|
+
canRemoteStartCharge: boolean;
|
|
292
|
+
companyId: number;
|
|
293
|
+
touStatus: string;
|
|
294
|
+
displayLevel: number;
|
|
295
|
+
waitlistAllowed: boolean;
|
|
296
|
+
accessRestriction: string;
|
|
297
|
+
isHome: boolean;
|
|
298
|
+
chargingStatus: string;
|
|
299
|
+
chargingInfo: MapChargingInfo | null;
|
|
300
|
+
}
|
|
301
|
+
interface MapFilter {
|
|
302
|
+
disabledParking?: boolean;
|
|
303
|
+
vanAccessible?: boolean;
|
|
304
|
+
networkChargepoint?: boolean;
|
|
305
|
+
networkEvgo?: boolean;
|
|
306
|
+
networkBlink?: boolean;
|
|
307
|
+
networkFlo?: boolean;
|
|
308
|
+
networkIonna?: boolean;
|
|
309
|
+
networkEvconnect?: boolean;
|
|
310
|
+
networkEvgateway?: boolean;
|
|
311
|
+
networkBchydro?: boolean;
|
|
312
|
+
networkGreenlots?: boolean;
|
|
313
|
+
networkMercedes?: boolean;
|
|
314
|
+
networkCircuitelectric?: boolean;
|
|
315
|
+
connectorL1?: boolean;
|
|
316
|
+
connectorL2?: boolean;
|
|
317
|
+
connectorL2Nema1450?: boolean;
|
|
318
|
+
connectorL2Tesla?: boolean;
|
|
319
|
+
connectorTesla?: boolean;
|
|
320
|
+
connectorCombo?: boolean;
|
|
321
|
+
connectorChademo?: boolean;
|
|
322
|
+
dcFastCharging?: boolean;
|
|
323
|
+
statusAvailable?: boolean;
|
|
324
|
+
priceFree?: boolean;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
type RawObj = Record<string, unknown>;
|
|
328
|
+
declare class ChargingSession {
|
|
329
|
+
sessionId: number;
|
|
330
|
+
deviceId: number;
|
|
331
|
+
deviceName: string;
|
|
332
|
+
chargingState: string;
|
|
333
|
+
chargingTime: number;
|
|
334
|
+
energyKwh: number;
|
|
335
|
+
milesAdded: number;
|
|
336
|
+
milesAddedPerHour: number;
|
|
337
|
+
outletNumber: number;
|
|
338
|
+
portLevel: number;
|
|
339
|
+
powerKw: number;
|
|
340
|
+
purpose: string;
|
|
341
|
+
currencyIsoCode: string;
|
|
342
|
+
paymentCompleted: boolean;
|
|
343
|
+
paymentType: string;
|
|
344
|
+
pricingSpecId: number;
|
|
345
|
+
totalAmount: number;
|
|
346
|
+
apiFlag: boolean;
|
|
347
|
+
enableStopCharging: boolean;
|
|
348
|
+
hasChargingReceipt: boolean;
|
|
349
|
+
hasUtilityInfo: boolean;
|
|
350
|
+
isHomeCharger: boolean;
|
|
351
|
+
isPurposeFinalized: boolean;
|
|
352
|
+
stopChargeSupported: boolean;
|
|
353
|
+
companyId: number;
|
|
354
|
+
companyName: string;
|
|
355
|
+
latitude: number;
|
|
356
|
+
longitude: number;
|
|
357
|
+
address: string;
|
|
358
|
+
city: string;
|
|
359
|
+
stateName: string;
|
|
360
|
+
country: string;
|
|
361
|
+
zipcode: string;
|
|
362
|
+
updatePeriod: number;
|
|
363
|
+
startTime: Date | null;
|
|
364
|
+
lastUpdateDataTimestamp: Date | null;
|
|
365
|
+
updateData: ChargingSessionUpdate[] | null;
|
|
366
|
+
utility: PowerUtility | null;
|
|
367
|
+
vehicleInfo: VehicleInfo | null;
|
|
368
|
+
private _client;
|
|
369
|
+
constructor(sessionId: number);
|
|
370
|
+
/** @internal */
|
|
371
|
+
_setClient(client: ChargePoint): void;
|
|
372
|
+
/** @internal Apply raw session data from the driver-bff API (snake_case keys). */
|
|
373
|
+
_apply(data: RawObj): void;
|
|
374
|
+
refresh(): Promise<void>;
|
|
375
|
+
stop(): Promise<void>;
|
|
376
|
+
static start(deviceId: number, client: ChargePoint): Promise<ChargingSession>;
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
interface ChargePointOptions {
|
|
380
|
+
coulombToken?: string;
|
|
381
|
+
region?: string;
|
|
382
|
+
}
|
|
383
|
+
declare class ChargePoint {
|
|
384
|
+
globalConfig: GlobalConfiguration;
|
|
385
|
+
private _username;
|
|
386
|
+
private _coulombToken;
|
|
387
|
+
private _region;
|
|
388
|
+
private _userId;
|
|
389
|
+
/** The current session token. Save this after login to avoid re-authenticating. */
|
|
390
|
+
get coulombToken(): string | null;
|
|
391
|
+
private constructor();
|
|
392
|
+
static create(username: string, options?: ChargePointOptions): Promise<ChargePoint>;
|
|
393
|
+
private _setToken;
|
|
394
|
+
/** @internal Used by session.ts and tests. */
|
|
395
|
+
_request(method: string, url: string, init?: RequestInit): Promise<Response>;
|
|
396
|
+
loginWithPassword(password: string): Promise<void>;
|
|
397
|
+
loginWithSsoSession(ssoJwt: string): Promise<void>;
|
|
398
|
+
logout(): Promise<void>;
|
|
399
|
+
getAccount(): Promise<Account>;
|
|
400
|
+
getVehicles(): Promise<ElectricVehicle[]>;
|
|
401
|
+
getUserChargingStatus(): Promise<UserChargingStatus | null>;
|
|
402
|
+
private ensureUserId;
|
|
403
|
+
getHomeChargers(): Promise<number[]>;
|
|
404
|
+
getHomeChargerStatus(chargerId: number): Promise<HomeChargerStatus>;
|
|
405
|
+
getHomeChargerTechnicalInfo(chargerId: number): Promise<HomeChargerTechnicalInfo>;
|
|
406
|
+
getHomeChargerConfig(chargerId: number): Promise<HomeChargerConfiguration>;
|
|
407
|
+
getHomeChargerSchedule(chargerId: number): Promise<HomeChargerSchedule>;
|
|
408
|
+
setHomeChargerSchedule(chargerId: number, weekdayStart: string, weekdayEnd: string, weekendStart: string, weekendEnd: string): Promise<HomeChargerSchedule>;
|
|
409
|
+
disableHomeChargerSchedule(chargerId: number): Promise<void>;
|
|
410
|
+
setAmperageLimit(chargerId: number, amperageLimit: number): Promise<void>;
|
|
411
|
+
setLedBrightness(chargerId: number, level: number): Promise<void>;
|
|
412
|
+
restartHomeCharger(chargerId: number): Promise<void>;
|
|
413
|
+
getChargingSession(sessionId: number): Promise<ChargingSession>;
|
|
414
|
+
startChargingSession(deviceId: number): Promise<ChargingSession>;
|
|
415
|
+
getStation(deviceId: number): Promise<StationInfo>;
|
|
416
|
+
getNearbyStations(bounds: ZoomBounds, filter?: MapFilter): Promise<MapStation[]>;
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
declare class APIError extends Error {
|
|
420
|
+
constructor(message: string);
|
|
421
|
+
}
|
|
422
|
+
declare class CommunicationError extends APIError {
|
|
423
|
+
readonly statusCode: number;
|
|
424
|
+
readonly body?: unknown | undefined;
|
|
425
|
+
constructor(statusCode: number, message: string, body?: unknown | undefined);
|
|
426
|
+
}
|
|
427
|
+
declare class LoginError extends CommunicationError {
|
|
428
|
+
constructor(statusCode: number, message: string, body?: unknown);
|
|
429
|
+
}
|
|
430
|
+
declare class InvalidSession extends CommunicationError {
|
|
431
|
+
constructor(statusCode?: number, message?: string, body?: unknown);
|
|
432
|
+
}
|
|
433
|
+
declare class DatadomeCaptcha extends APIError {
|
|
434
|
+
readonly captchaUrl: string;
|
|
435
|
+
constructor(captchaUrl: string, message?: string);
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
export { type APIEndpoints, APIError, type Account, type AccountBalance, ChargePoint, type ChargePointOptions, type ChargeSchedule, type ChargeScheduleWindow, ChargingSession, type ChargingSessionUpdate, CommunicationError, type Country, type Currency, DatadomeCaptcha, type ElectricVehicle, type GlobalConfiguration, type HomeChargerConfiguration, type HomeChargerSchedule, type HomeChargerStatus, type HomeChargerTechnicalInfo, InvalidSession, type LEDBrightness, LoginError, type MapChargingInfo, type MapFilter, type MapStation, type MaxPower, type PowerUtility, type PowerUtilityPlan, type Station, type StationAddress, type StationConnector, type StationInfo, type StationNetwork, type StationPort, type StationPortDetail, type StationPortsInfo, type StationPrice, type StationPricingFee, type StationTax, type StationTouEntry, type User, type UserChargingStatus, type VehicleInfo, type ZoomBounds };
|