openbyd 0.0.0-stage → 0.1.3
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 +147 -2
- package/dist/client.d.ts +168 -0
- package/dist/client.js +374 -0
- package/dist/functions.d.ts +32 -0
- package/dist/functions.js +48 -0
- package/dist/generated/errors.d.ts +114 -0
- package/dist/generated/errors.js +169 -0
- package/dist/generated/methods.d.ts +516 -0
- package/dist/generated/methods.js +1028 -0
- package/dist/generated/models.d.ts +1499 -0
- package/dist/generated/models.js +206 -0
- package/dist/generated/shapes.d.ts +49 -0
- package/dist/generated/shapes.js +168 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.js +51 -0
- package/dist/native.d.ts +32 -0
- package/dist/native.js +53 -0
- package/dist/testing.d.ts +127 -0
- package/dist/testing.js +140 -0
- package/dist/wire.d.ts +32 -0
- package/dist/wire.js +130 -0
- package/package.json +53 -4
|
@@ -0,0 +1,1028 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Generated by bindings/generate.py from bindings/spec.py and pyBYD
|
|
3
|
+
// c1e88052f4f724343507bd8bda0ef990129071ba. Do not edit: change the spec and run the generator.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.CarMethods = exports.TrunkFeature = exports.WindowsFeature = exports.FinderFeature = exports.BatteryFeature = exports.SteeringFeature = exports.SeatFeature = exports.HvacFeature = exports.LockFeature = exports.ClientMethods = void 0;
|
|
6
|
+
exports.encodeClimateStartParams = encodeClimateStartParams;
|
|
7
|
+
exports.encodeClimateScheduleParams = encodeClimateScheduleParams;
|
|
8
|
+
exports.encodeSeatClimateParams = encodeSeatClimateParams;
|
|
9
|
+
exports.encodeBatteryHeatParams = encodeBatteryHeatParams;
|
|
10
|
+
exports.encodeStandbySchedule = encodeStandbySchedule;
|
|
11
|
+
exports.encodeDeviceProfile = encodeDeviceProfile;
|
|
12
|
+
exports.encodeBydConfig = encodeBydConfig;
|
|
13
|
+
/**
|
|
14
|
+
* `ClimateStartParams` as the core takes it: under pyBYD's field names.
|
|
15
|
+
*
|
|
16
|
+
* @internal
|
|
17
|
+
*/
|
|
18
|
+
function encodeClimateStartParams(value) {
|
|
19
|
+
return {
|
|
20
|
+
temperature: value.temperature,
|
|
21
|
+
copilot_temperature: value.copilotTemperature,
|
|
22
|
+
temp_offset: value.tempOffset,
|
|
23
|
+
cycle_mode: value.cycleMode,
|
|
24
|
+
time_span: value.timeSpan,
|
|
25
|
+
remote_mode: value.remoteMode,
|
|
26
|
+
air_accuracy: value.airAccuracy,
|
|
27
|
+
air_conditioning_mode: value.airConditioningMode,
|
|
28
|
+
wind_level: value.windLevel,
|
|
29
|
+
air_set: value.airSet,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* `ClimateScheduleParams` as the core takes it: under pyBYD's field names.
|
|
34
|
+
*
|
|
35
|
+
* @internal
|
|
36
|
+
*/
|
|
37
|
+
function encodeClimateScheduleParams(value) {
|
|
38
|
+
return {
|
|
39
|
+
temperature: value.temperature,
|
|
40
|
+
copilot_temperature: value.copilotTemperature,
|
|
41
|
+
temp_offset: value.tempOffset,
|
|
42
|
+
cycle_mode: value.cycleMode,
|
|
43
|
+
time_span: value.timeSpan,
|
|
44
|
+
remote_mode: value.remoteMode,
|
|
45
|
+
air_accuracy: value.airAccuracy,
|
|
46
|
+
air_conditioning_mode: value.airConditioningMode,
|
|
47
|
+
wind_level: value.windLevel,
|
|
48
|
+
air_set: value.airSet,
|
|
49
|
+
booking_id: value.bookingId,
|
|
50
|
+
booking_time: value.bookingTime,
|
|
51
|
+
ac_switch: value.acSwitch,
|
|
52
|
+
wind_mode: value.windMode,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* `SeatClimateParams` as the core takes it: under pyBYD's field names.
|
|
57
|
+
*
|
|
58
|
+
* @internal
|
|
59
|
+
*/
|
|
60
|
+
function encodeSeatClimateParams(value) {
|
|
61
|
+
return {
|
|
62
|
+
chair_type: value.chairType,
|
|
63
|
+
remote_mode: value.remoteMode,
|
|
64
|
+
main_heat: value.mainHeat,
|
|
65
|
+
main_ventilation: value.mainVentilation,
|
|
66
|
+
copilot_heat: value.copilotHeat,
|
|
67
|
+
copilot_ventilation: value.copilotVentilation,
|
|
68
|
+
lr_seat_heat_state: value.lrSeatHeatState,
|
|
69
|
+
lr_seat_ventilation_state: value.lrSeatVentilationState,
|
|
70
|
+
lr_third_heat_state: value.lrThirdHeatState,
|
|
71
|
+
lr_third_ventilation_state: value.lrThirdVentilationState,
|
|
72
|
+
rr_seat_heat_state: value.rrSeatHeatState,
|
|
73
|
+
rr_seat_ventilation_state: value.rrSeatVentilationState,
|
|
74
|
+
rr_third_heat_state: value.rrThirdHeatState,
|
|
75
|
+
rr_third_ventilation_state: value.rrThirdVentilationState,
|
|
76
|
+
steering_wheel_heat_state: value.steeringWheelHeatState,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* `BatteryHeatParams` as the core takes it: under pyBYD's field names.
|
|
81
|
+
*
|
|
82
|
+
* @internal
|
|
83
|
+
*/
|
|
84
|
+
function encodeBatteryHeatParams(value) {
|
|
85
|
+
return {
|
|
86
|
+
on: value.on,
|
|
87
|
+
heat_type: value.heatType,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* `StandbySchedule` as the core takes it: under pyBYD's field names.
|
|
92
|
+
*
|
|
93
|
+
* @internal
|
|
94
|
+
*/
|
|
95
|
+
function encodeStandbySchedule(value) {
|
|
96
|
+
return {
|
|
97
|
+
repeat: value.repeat,
|
|
98
|
+
at: value.at,
|
|
99
|
+
start_time: value.startTime,
|
|
100
|
+
weekly_days: value.weeklyDays,
|
|
101
|
+
zone: value.zone,
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* `DeviceProfile` as the core takes it: under pyBYD's field names.
|
|
106
|
+
*
|
|
107
|
+
* @internal
|
|
108
|
+
*/
|
|
109
|
+
function encodeDeviceProfile(value) {
|
|
110
|
+
return {
|
|
111
|
+
ostype: value.ostype,
|
|
112
|
+
imei: value.imei,
|
|
113
|
+
mac: value.mac,
|
|
114
|
+
model: value.model,
|
|
115
|
+
sdk: value.sdk,
|
|
116
|
+
mod: value.mod,
|
|
117
|
+
imei_md5: value.imeiMd5,
|
|
118
|
+
mobile_brand: value.mobileBrand,
|
|
119
|
+
mobile_model: value.mobileModel,
|
|
120
|
+
device_type: value.deviceType,
|
|
121
|
+
network_type: value.networkType,
|
|
122
|
+
os_type: value.osType,
|
|
123
|
+
os_version: value.osVersion,
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* `BydConfig` as the core takes it: under pyBYD's field names.
|
|
128
|
+
*
|
|
129
|
+
* @internal
|
|
130
|
+
*/
|
|
131
|
+
function encodeBydConfig(value) {
|
|
132
|
+
return {
|
|
133
|
+
username: value.username,
|
|
134
|
+
password: value.password,
|
|
135
|
+
base_url: value.baseUrl,
|
|
136
|
+
country_code: value.countryCode,
|
|
137
|
+
language: value.language,
|
|
138
|
+
time_zone: value.timeZone,
|
|
139
|
+
app_version: value.appVersion,
|
|
140
|
+
app_inner_version: value.appInnerVersion,
|
|
141
|
+
soft_type: value.softType,
|
|
142
|
+
tbox_version: value.tboxVersion,
|
|
143
|
+
is_auto: value.isAuto,
|
|
144
|
+
identifier_type: value.identifierType,
|
|
145
|
+
control_pin: value.controlPin,
|
|
146
|
+
session_ttl: value.sessionTtl,
|
|
147
|
+
mqtt_enabled: value.mqttEnabled,
|
|
148
|
+
mqtt_keepalive: value.mqttKeepalive,
|
|
149
|
+
mqtt_timeout: value.mqttTimeout,
|
|
150
|
+
device: value.device == null ? value.device : encodeDeviceProfile(value.device),
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
/** The client's methods: pyBYD's `BydClient`. `Client` (client.ts) completes it. */
|
|
154
|
+
class ClientMethods {
|
|
155
|
+
#invoker;
|
|
156
|
+
/** @internal */
|
|
157
|
+
constructor(invoker) {
|
|
158
|
+
this.#invoker = invoker;
|
|
159
|
+
}
|
|
160
|
+
/** Log in with the password and start MQTT. */
|
|
161
|
+
login() {
|
|
162
|
+
return this.#invoker.call("login", {}, null);
|
|
163
|
+
}
|
|
164
|
+
/** The current session, logging in first when there is none or it expired. */
|
|
165
|
+
ensureSession() {
|
|
166
|
+
return this.#invoker.call("ensure_session", {}, ["struct", "SessionInfo"]);
|
|
167
|
+
}
|
|
168
|
+
/** Forget the session; the next call logs in again. Command access stays verified. */
|
|
169
|
+
invalidateSession() {
|
|
170
|
+
this.#invoker.callSync("invalidate_session", {}, null);
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* The session as an application stores it, or null when logged out. Give it to
|
|
174
|
+
* `import_session` to resume without a password login.
|
|
175
|
+
*/
|
|
176
|
+
exportSession() {
|
|
177
|
+
return this.#invoker.callSync("export_session", {}, ["struct", "SessionTokens"]);
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Use a session from `export_session` as if a login had returned it, and start MQTT.
|
|
181
|
+
*
|
|
182
|
+
* @param session - The saved session.
|
|
183
|
+
*/
|
|
184
|
+
importSession(session) {
|
|
185
|
+
return this.#invoker.call("import_session", { session }, null);
|
|
186
|
+
}
|
|
187
|
+
/** Whether remote commands are available: true once `verify_command_access` succeeded. */
|
|
188
|
+
get commandsEnabled() {
|
|
189
|
+
return this.#invoker.callSync("commands_enabled", {}, null);
|
|
190
|
+
}
|
|
191
|
+
/** Whether the MQTT push channel is connected or connecting. */
|
|
192
|
+
get mqttIsRunning() {
|
|
193
|
+
return this.#invoker.callSync("mqtt_is_running", {}, null);
|
|
194
|
+
}
|
|
195
|
+
/** Start MQTT for the current session if it is not running, as a login does. */
|
|
196
|
+
startMqtt() {
|
|
197
|
+
return this.#invoker.call("start_mqtt", {}, null);
|
|
198
|
+
}
|
|
199
|
+
/** Counters of command acknowledgements: pending, matched, expired, uncorrelated. */
|
|
200
|
+
getCommandAckDiagnostics() {
|
|
201
|
+
return this.#invoker.callSync("get_command_ack_diagnostics", {}, null);
|
|
202
|
+
}
|
|
203
|
+
/** The account's vehicles. */
|
|
204
|
+
getVehicles() {
|
|
205
|
+
return this.#invoker.call("get_vehicles", {}, ["list", ["struct", "Vehicle"]]);
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Cache a vehicle's metadata as if the vehicle list had returned it, so realtime, energy and
|
|
209
|
+
* AC-limit reads need no vehicle list.
|
|
210
|
+
*
|
|
211
|
+
* @param vin - The vehicle identification number.
|
|
212
|
+
*
|
|
213
|
+
* @param energyType - The powertrain: EV, ICE or hybrid.
|
|
214
|
+
*/
|
|
215
|
+
seedVehicleMetadata(vin, energyType, options = {}) {
|
|
216
|
+
this.#invoker.callSync("seed_vehicle_metadata", {
|
|
217
|
+
vin,
|
|
218
|
+
energy_type: energyType,
|
|
219
|
+
model_name: options.modelName,
|
|
220
|
+
}, null);
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* The cached metadata of a vehicle, or null when unknown.
|
|
224
|
+
*
|
|
225
|
+
* @param vin - The vehicle identification number.
|
|
226
|
+
*/
|
|
227
|
+
vehicleMetadata(vin) {
|
|
228
|
+
return this.#invoker.callSync("vehicle_metadata", { vin }, ["struct", "Vehicle"]);
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* The latest config of each VIN the cloud knows, by VIN.
|
|
232
|
+
*
|
|
233
|
+
* @param vins - The vehicles to ask about.
|
|
234
|
+
*/
|
|
235
|
+
getLatestConfigs(vins) {
|
|
236
|
+
return this.#invoker.call("get_latest_configs", { vins }, null);
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* The latest config of a vehicle. Fails with `BydDataUnavailableError` when the reply has
|
|
240
|
+
* none.
|
|
241
|
+
*
|
|
242
|
+
* @param vin - The vehicle identification number.
|
|
243
|
+
*/
|
|
244
|
+
getLatestConfig(vin) {
|
|
245
|
+
return this.#invoker.call("get_latest_config", { vin }, null);
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* What the vehicle supports, cached. A failed fetch gives unknown capabilities.
|
|
249
|
+
*
|
|
250
|
+
* @param vin - The vehicle identification number.
|
|
251
|
+
*/
|
|
252
|
+
getVehicleCapabilities(vin, options = {}) {
|
|
253
|
+
return this.#invoker.call("get_vehicle_capabilities", {
|
|
254
|
+
vin,
|
|
255
|
+
force_refresh: options.forceRefresh,
|
|
256
|
+
}, null);
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Realtime data: trigger a refresh, wait for the MQTT push, poll over HTTP if it does not
|
|
260
|
+
* come.
|
|
261
|
+
*
|
|
262
|
+
* @param vin - The vehicle identification number.
|
|
263
|
+
*/
|
|
264
|
+
getVehicleRealtime(vin, options = {}) {
|
|
265
|
+
return this.#invoker.call("get_vehicle_realtime", {
|
|
266
|
+
vin,
|
|
267
|
+
poll_attempts: options.pollAttempts,
|
|
268
|
+
poll_interval: options.pollInterval,
|
|
269
|
+
mqtt_timeout: options.mqttTimeout,
|
|
270
|
+
signal_retries: options.signalRetries,
|
|
271
|
+
}, ["struct", "VehicleRealtimeData"]);
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* The vehicle's position: trigger, wait for the push, poll if it does not come.
|
|
275
|
+
*
|
|
276
|
+
* @param vin - The vehicle identification number.
|
|
277
|
+
*/
|
|
278
|
+
getGpsInfo(vin, options = {}) {
|
|
279
|
+
return this.#invoker.call("get_gps_info", {
|
|
280
|
+
vin,
|
|
281
|
+
poll_attempts: options.pollAttempts,
|
|
282
|
+
poll_interval: options.pollInterval,
|
|
283
|
+
mqtt_timeout: options.mqttTimeout,
|
|
284
|
+
signal_retries: options.signalRetries,
|
|
285
|
+
}, ["struct", "GpsInfo"]);
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* Climate status.
|
|
289
|
+
*
|
|
290
|
+
* @param vin - The vehicle identification number.
|
|
291
|
+
*/
|
|
292
|
+
getHvacStatus(vin) {
|
|
293
|
+
return this.#invoker.call("get_hvac_status", { vin }, ["struct", "HvacStatus"]);
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* Charging status.
|
|
297
|
+
*
|
|
298
|
+
* @param vin - The vehicle identification number.
|
|
299
|
+
*/
|
|
300
|
+
getChargingStatus(vin) {
|
|
301
|
+
return this.#invoker.call("get_charging_status", { vin }, ["struct", "ChargingStatus"]);
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* The smart-charging schedule.
|
|
305
|
+
*
|
|
306
|
+
* @param vin - The vehicle identification number.
|
|
307
|
+
*/
|
|
308
|
+
getChargingSchedule(vin) {
|
|
309
|
+
return this.#invoker.call("get_charging_schedule", { vin }, null);
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* Live charging state and the schedule, from one call.
|
|
313
|
+
*
|
|
314
|
+
* @param vin - The vehicle identification number.
|
|
315
|
+
*/
|
|
316
|
+
getChargingHomepage(vin) {
|
|
317
|
+
return this.#invoker.call("get_charging_homepage", { vin }, ["struct", "ChargingHomepage"]);
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* The supported and active AC charging current limits.
|
|
321
|
+
*
|
|
322
|
+
* @param vin - The vehicle identification number.
|
|
323
|
+
*/
|
|
324
|
+
getAcCurrentLimit(vin, options = {}) {
|
|
325
|
+
return this.#invoker.call("get_ac_current_limit", {
|
|
326
|
+
vin,
|
|
327
|
+
energy_type: options.energyType,
|
|
328
|
+
}, null);
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* Energy consumption, asked with the vehicle's energy type and model.
|
|
332
|
+
*
|
|
333
|
+
* @param vin - The vehicle identification number.
|
|
334
|
+
*/
|
|
335
|
+
getEnergyConsumption(vin) {
|
|
336
|
+
return this.#invoker.call("get_energy_consumption", { vin }, ["struct", "EnergyConsumption"]);
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
339
|
+
* Push notification state.
|
|
340
|
+
*
|
|
341
|
+
* @param vin - The vehicle identification number.
|
|
342
|
+
*/
|
|
343
|
+
getPushState(vin) {
|
|
344
|
+
return this.#invoker.call("get_push_state", { vin }, null);
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* Turn a push notification type on or off.
|
|
348
|
+
*
|
|
349
|
+
* @param vin - The vehicle identification number.
|
|
350
|
+
*
|
|
351
|
+
* @param enable - On or off.
|
|
352
|
+
*/
|
|
353
|
+
setPushState(vin, enable, options = {}) {
|
|
354
|
+
return this.#invoker.call("set_push_state", { vin, enable, push_type: options.pushType }, null);
|
|
355
|
+
}
|
|
356
|
+
/** The account's unread inbox messages of one category. */
|
|
357
|
+
getNotifications(options = {}) {
|
|
358
|
+
return this.#invoker.call("get_notifications", { category: options.category }, null);
|
|
359
|
+
}
|
|
360
|
+
/** The unread inbox messages of every category, by category value. */
|
|
361
|
+
getAllNotifications() {
|
|
362
|
+
return this.#invoker.call("get_all_notifications", {}, null);
|
|
363
|
+
}
|
|
364
|
+
/**
|
|
365
|
+
* Rename the vehicle.
|
|
366
|
+
*
|
|
367
|
+
* @param vin - The vehicle identification number.
|
|
368
|
+
*
|
|
369
|
+
* @param name - The new name.
|
|
370
|
+
*/
|
|
371
|
+
renameVehicle(vin, name) {
|
|
372
|
+
return this.#invoker.call("rename_vehicle", { vin, name }, null);
|
|
373
|
+
}
|
|
374
|
+
/**
|
|
375
|
+
* The scheduled-climate timers.
|
|
376
|
+
*
|
|
377
|
+
* @param vin - The vehicle identification number.
|
|
378
|
+
*/
|
|
379
|
+
getBookingList(vin) {
|
|
380
|
+
return this.#invoker.call("get_booking_list", { vin }, ["struct", "BookingList"]);
|
|
381
|
+
}
|
|
382
|
+
/**
|
|
383
|
+
* The preconditioning plans for a vehicle.
|
|
384
|
+
*
|
|
385
|
+
* @param vin - The vehicle identification number.
|
|
386
|
+
*/
|
|
387
|
+
getStandbyPlans(vin) {
|
|
388
|
+
return this.#invoker.call("get_standby_plans", { vin }, null);
|
|
389
|
+
}
|
|
390
|
+
/**
|
|
391
|
+
* Save a preconditioning plan's name, commands and schedule, then return the fresh plans.
|
|
392
|
+
*
|
|
393
|
+
* @param vin - The vehicle identification number.
|
|
394
|
+
*
|
|
395
|
+
* @param plan - The plan to save.
|
|
396
|
+
*/
|
|
397
|
+
saveStandbyPlan(vin, plan, options = {}) {
|
|
398
|
+
return this.#invoker.call("save_standby_plan", {
|
|
399
|
+
vin,
|
|
400
|
+
plan,
|
|
401
|
+
schedule: options.schedule == null ? options.schedule : encodeStandbySchedule(options.schedule),
|
|
402
|
+
}, null);
|
|
403
|
+
}
|
|
404
|
+
/**
|
|
405
|
+
* Create a user preconditioning plan and return it.
|
|
406
|
+
*
|
|
407
|
+
* @param vin - The vehicle identification number.
|
|
408
|
+
*
|
|
409
|
+
* @param name - The plan name.
|
|
410
|
+
*
|
|
411
|
+
* @param commands - The remote commands in the plan; must include `OPENAIR`.
|
|
412
|
+
*/
|
|
413
|
+
createStandbyPlan(vin, name, commands, options = {}) {
|
|
414
|
+
return this.#invoker.call("create_standby_plan", {
|
|
415
|
+
vin,
|
|
416
|
+
name,
|
|
417
|
+
commands,
|
|
418
|
+
schedule: options.schedule == null ? options.schedule : encodeStandbySchedule(options.schedule),
|
|
419
|
+
}, null);
|
|
420
|
+
}
|
|
421
|
+
/**
|
|
422
|
+
* Make a preconditioning plan the default, then return the fresh plans.
|
|
423
|
+
*
|
|
424
|
+
* @param vin - The vehicle identification number.
|
|
425
|
+
*
|
|
426
|
+
* @param planId - The plan ID.
|
|
427
|
+
*/
|
|
428
|
+
setDefaultStandbyPlan(vin, planId) {
|
|
429
|
+
return this.#invoker.call("set_default_standby_plan", { vin, plan_id: planId }, null);
|
|
430
|
+
}
|
|
431
|
+
/**
|
|
432
|
+
* Delete a user preconditioning plan, then return the fresh plans.
|
|
433
|
+
*
|
|
434
|
+
* @param vin - The vehicle identification number.
|
|
435
|
+
*
|
|
436
|
+
* @param planId - The plan ID.
|
|
437
|
+
*/
|
|
438
|
+
deleteStandbyPlan(vin, planId) {
|
|
439
|
+
return this.#invoker.call("delete_standby_plan", { vin, plan_id: planId }, null);
|
|
440
|
+
}
|
|
441
|
+
/**
|
|
442
|
+
* Run a preconditioning plan now without changing its schedule.
|
|
443
|
+
*
|
|
444
|
+
* @param vin - The vehicle identification number.
|
|
445
|
+
*
|
|
446
|
+
* @param planId - The plan ID.
|
|
447
|
+
*/
|
|
448
|
+
runStandbyPlan(vin, planId, options = {}) {
|
|
449
|
+
return this.#invoker.call("run_standby_plan", {
|
|
450
|
+
vin,
|
|
451
|
+
plan_id: planId,
|
|
452
|
+
poll_attempts: options.pollAttempts,
|
|
453
|
+
poll_interval: options.pollInterval,
|
|
454
|
+
}, null);
|
|
455
|
+
}
|
|
456
|
+
/**
|
|
457
|
+
* Check the control PIN once and enable remote commands.
|
|
458
|
+
*
|
|
459
|
+
* @param vin - The vehicle identification number.
|
|
460
|
+
*/
|
|
461
|
+
verifyCommandAccess(vin, options = {}) {
|
|
462
|
+
return this.#invoker.call("verify_command_access", {
|
|
463
|
+
vin,
|
|
464
|
+
command_pwd: options.commandPwd,
|
|
465
|
+
}, null);
|
|
466
|
+
}
|
|
467
|
+
/**
|
|
468
|
+
* Lock the vehicle.
|
|
469
|
+
*
|
|
470
|
+
* @param vin - The vehicle identification number.
|
|
471
|
+
*/
|
|
472
|
+
lock(vin, options = {}) {
|
|
473
|
+
return this.#invoker.call("lock", { vin, command_pwd: options.commandPwd }, null);
|
|
474
|
+
}
|
|
475
|
+
/**
|
|
476
|
+
* Unlock the vehicle.
|
|
477
|
+
*
|
|
478
|
+
* @param vin - The vehicle identification number.
|
|
479
|
+
*/
|
|
480
|
+
unlock(vin, options = {}) {
|
|
481
|
+
return this.#invoker.call("unlock", { vin, command_pwd: options.commandPwd }, null);
|
|
482
|
+
}
|
|
483
|
+
/**
|
|
484
|
+
* Stop climate control.
|
|
485
|
+
*
|
|
486
|
+
* @param vin - The vehicle identification number.
|
|
487
|
+
*/
|
|
488
|
+
stopClimate(vin, options = {}) {
|
|
489
|
+
return this.#invoker.call("stop_climate", { vin, command_pwd: options.commandPwd }, null);
|
|
490
|
+
}
|
|
491
|
+
/**
|
|
492
|
+
* Flash the lights.
|
|
493
|
+
*
|
|
494
|
+
* @param vin - The vehicle identification number.
|
|
495
|
+
*/
|
|
496
|
+
flashLights(vin, options = {}) {
|
|
497
|
+
return this.#invoker.call("flash_lights", { vin, command_pwd: options.commandPwd }, null);
|
|
498
|
+
}
|
|
499
|
+
/**
|
|
500
|
+
* Close all windows.
|
|
501
|
+
*
|
|
502
|
+
* @param vin - The vehicle identification number.
|
|
503
|
+
*/
|
|
504
|
+
closeWindows(vin, options = {}) {
|
|
505
|
+
return this.#invoker.call("close_windows", { vin, command_pwd: options.commandPwd }, null);
|
|
506
|
+
}
|
|
507
|
+
/**
|
|
508
|
+
* Open the windows to a vent crack of about 10 %.
|
|
509
|
+
*
|
|
510
|
+
* @param vin - The vehicle identification number.
|
|
511
|
+
*/
|
|
512
|
+
openWindows(vin, options = {}) {
|
|
513
|
+
return this.#invoker.call("open_windows", { vin, command_pwd: options.commandPwd }, null);
|
|
514
|
+
}
|
|
515
|
+
/**
|
|
516
|
+
* Horn and lights.
|
|
517
|
+
*
|
|
518
|
+
* @param vin - The vehicle identification number.
|
|
519
|
+
*/
|
|
520
|
+
findCar(vin, options = {}) {
|
|
521
|
+
return this.#invoker.call("find_car", { vin, command_pwd: options.commandPwd }, null);
|
|
522
|
+
}
|
|
523
|
+
/**
|
|
524
|
+
* Release the trunk.
|
|
525
|
+
*
|
|
526
|
+
* @param vin - The vehicle identification number.
|
|
527
|
+
*/
|
|
528
|
+
openTrunk(vin, options = {}) {
|
|
529
|
+
return this.#invoker.call("open_trunk", { vin, command_pwd: options.commandPwd }, null);
|
|
530
|
+
}
|
|
531
|
+
/**
|
|
532
|
+
* Lower the trunk.
|
|
533
|
+
*
|
|
534
|
+
* @param vin - The vehicle identification number.
|
|
535
|
+
*/
|
|
536
|
+
closeTrunk(vin, options = {}) {
|
|
537
|
+
return this.#invoker.call("close_trunk", { vin, command_pwd: options.commandPwd }, null);
|
|
538
|
+
}
|
|
539
|
+
/**
|
|
540
|
+
* Start climate control.
|
|
541
|
+
*
|
|
542
|
+
* @param vin - The vehicle identification number.
|
|
543
|
+
*
|
|
544
|
+
* @param params - The `ClimateStartParams` fields.
|
|
545
|
+
*/
|
|
546
|
+
startClimate(vin, params, options = {}) {
|
|
547
|
+
return this.#invoker.call("start_climate", {
|
|
548
|
+
vin,
|
|
549
|
+
params: encodeClimateStartParams(params),
|
|
550
|
+
command_pwd: options.commandPwd,
|
|
551
|
+
}, null);
|
|
552
|
+
}
|
|
553
|
+
/**
|
|
554
|
+
* Schedule climate control.
|
|
555
|
+
*
|
|
556
|
+
* @param vin - The vehicle identification number.
|
|
557
|
+
*
|
|
558
|
+
* @param params - The `ClimateScheduleParams` fields.
|
|
559
|
+
*/
|
|
560
|
+
scheduleClimate(vin, params, options = {}) {
|
|
561
|
+
return this.#invoker.call("schedule_climate", {
|
|
562
|
+
vin,
|
|
563
|
+
params: encodeClimateScheduleParams(params),
|
|
564
|
+
command_pwd: options.commandPwd,
|
|
565
|
+
}, null);
|
|
566
|
+
}
|
|
567
|
+
/**
|
|
568
|
+
* Set seat heating and ventilation.
|
|
569
|
+
*
|
|
570
|
+
* @param vin - The vehicle identification number.
|
|
571
|
+
*
|
|
572
|
+
* @param params - The `SeatClimateParams` fields.
|
|
573
|
+
*/
|
|
574
|
+
setSeatClimate(vin, params, options = {}) {
|
|
575
|
+
return this.#invoker.call("set_seat_climate", {
|
|
576
|
+
vin,
|
|
577
|
+
params: encodeSeatClimateParams(params),
|
|
578
|
+
command_pwd: options.commandPwd,
|
|
579
|
+
}, null);
|
|
580
|
+
}
|
|
581
|
+
/**
|
|
582
|
+
* Turn battery heating on or off.
|
|
583
|
+
*
|
|
584
|
+
* @param vin - The vehicle identification number.
|
|
585
|
+
*
|
|
586
|
+
* @param params - The `BatteryHeatParams` fields.
|
|
587
|
+
*/
|
|
588
|
+
setBatteryHeat(vin, params, options = {}) {
|
|
589
|
+
return this.#invoker.call("set_battery_heat", {
|
|
590
|
+
vin,
|
|
591
|
+
params: encodeBatteryHeatParams(params),
|
|
592
|
+
command_pwd: options.commandPwd,
|
|
593
|
+
}, null);
|
|
594
|
+
}
|
|
595
|
+
/**
|
|
596
|
+
* Save a smart-charging schedule and wait for the change to settle.
|
|
597
|
+
*
|
|
598
|
+
* @param vin - The vehicle identification number.
|
|
599
|
+
*
|
|
600
|
+
* @param startChargeTime - When charging starts, `HH:MM`.
|
|
601
|
+
*
|
|
602
|
+
* @param endChargeTime - When charging ends, `HH:MM`, or `full`.
|
|
603
|
+
*
|
|
604
|
+
* @param chargeWay - `s` (single), `e` (every day) or weekday indices.
|
|
605
|
+
*/
|
|
606
|
+
saveChargingSchedule(vin, startChargeTime, endChargeTime, chargeWay, options = {}) {
|
|
607
|
+
return this.#invoker.call("save_charging_schedule", {
|
|
608
|
+
vin,
|
|
609
|
+
start_charge_time: startChargeTime,
|
|
610
|
+
end_charge_time: endChargeTime,
|
|
611
|
+
charge_way: chargeWay,
|
|
612
|
+
enabled: options.enabled,
|
|
613
|
+
mqtt_timeout: options.mqttTimeout,
|
|
614
|
+
poll_attempts: options.pollAttempts,
|
|
615
|
+
poll_interval: options.pollInterval,
|
|
616
|
+
}, null);
|
|
617
|
+
}
|
|
618
|
+
/**
|
|
619
|
+
* Turn smart charging on or off.
|
|
620
|
+
*
|
|
621
|
+
* @param vin - The vehicle identification number.
|
|
622
|
+
*
|
|
623
|
+
* @param enable - On or off.
|
|
624
|
+
*/
|
|
625
|
+
toggleSmartCharging(vin, enable) {
|
|
626
|
+
return this.#invoker.call("toggle_smart_charging", { vin, enable }, null);
|
|
627
|
+
}
|
|
628
|
+
/**
|
|
629
|
+
* Start charging now and wait for the change to settle.
|
|
630
|
+
*
|
|
631
|
+
* @param vin - The vehicle identification number.
|
|
632
|
+
*/
|
|
633
|
+
startCharging(vin, options = {}) {
|
|
634
|
+
return this.#invoker.call("start_charging", {
|
|
635
|
+
vin,
|
|
636
|
+
mqtt_timeout: options.mqttTimeout,
|
|
637
|
+
poll_attempts: options.pollAttempts,
|
|
638
|
+
poll_interval: options.pollInterval,
|
|
639
|
+
}, null);
|
|
640
|
+
}
|
|
641
|
+
/**
|
|
642
|
+
* Always fails with `BydEndpointNotSupportedError`: the cloud cannot stop a charge (as pyBYD).
|
|
643
|
+
*
|
|
644
|
+
* @param vin - The vehicle identification number.
|
|
645
|
+
*/
|
|
646
|
+
stopCharging(vin, options = {}) {
|
|
647
|
+
return this.#invoker.call("stop_charging", {
|
|
648
|
+
vin,
|
|
649
|
+
mqtt_timeout: options.mqttTimeout,
|
|
650
|
+
poll_attempts: options.pollAttempts,
|
|
651
|
+
poll_interval: options.pollInterval,
|
|
652
|
+
}, null);
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
exports.ClientMethods = ClientMethods;
|
|
656
|
+
/** `car.lock`: lock and unlock the doors. */
|
|
657
|
+
class LockFeature {
|
|
658
|
+
#invoker;
|
|
659
|
+
#features;
|
|
660
|
+
/** @internal */
|
|
661
|
+
constructor(invoker, features) {
|
|
662
|
+
this.#invoker = invoker;
|
|
663
|
+
this.#features = features;
|
|
664
|
+
}
|
|
665
|
+
/** Whether the car supports locking. */
|
|
666
|
+
get available() {
|
|
667
|
+
return this.#features().lock.available;
|
|
668
|
+
}
|
|
669
|
+
/** Lock all doors; the door locks read locked at once. */
|
|
670
|
+
lock() {
|
|
671
|
+
return this.#invoker.call("car.lock.lock", {}, null);
|
|
672
|
+
}
|
|
673
|
+
/** Unlock all doors; the door locks read unlocked at once. */
|
|
674
|
+
unlock() {
|
|
675
|
+
return this.#invoker.call("car.lock.unlock", {}, null);
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
exports.LockFeature = LockFeature;
|
|
679
|
+
/** `car.hvac`: start, stop and schedule climate control. */
|
|
680
|
+
class HvacFeature {
|
|
681
|
+
#invoker;
|
|
682
|
+
#features;
|
|
683
|
+
/** @internal */
|
|
684
|
+
constructor(invoker, features) {
|
|
685
|
+
this.#invoker = invoker;
|
|
686
|
+
this.#features = features;
|
|
687
|
+
}
|
|
688
|
+
/** Whether the car supports remote climate control. */
|
|
689
|
+
get available() {
|
|
690
|
+
return this.#features().hvac.available;
|
|
691
|
+
}
|
|
692
|
+
/** °C offset of the car's 1-17 temperature scale, from the last HVAC status. */
|
|
693
|
+
get tempOffset() {
|
|
694
|
+
return this.#features().hvac.temp_offset;
|
|
695
|
+
}
|
|
696
|
+
/** The settable temperature range in °C: lowest, highest. */
|
|
697
|
+
get tempRange() {
|
|
698
|
+
return this.#features().hvac.temp_range;
|
|
699
|
+
}
|
|
700
|
+
/**
|
|
701
|
+
* Start climate control, or change a running session's settings. Without a known HVAC status
|
|
702
|
+
* the status is fetched first, as pyBYD does.
|
|
703
|
+
*/
|
|
704
|
+
start(options = {}) {
|
|
705
|
+
return this.#invoker.call("car.hvac.start", {
|
|
706
|
+
temperature: options.temperature,
|
|
707
|
+
duration: options.duration,
|
|
708
|
+
cycle_mode: options.cycleMode,
|
|
709
|
+
fan_level: options.fanLevel,
|
|
710
|
+
}, null);
|
|
711
|
+
}
|
|
712
|
+
/** Stop climate control, including seat and steering wheel heating. */
|
|
713
|
+
stop() {
|
|
714
|
+
return this.#invoker.call("car.hvac.stop", {}, null);
|
|
715
|
+
}
|
|
716
|
+
/**
|
|
717
|
+
* Create, change or remove a climate schedule.
|
|
718
|
+
*
|
|
719
|
+
* @param params - The `ClimateScheduleParams` fields.
|
|
720
|
+
*/
|
|
721
|
+
schedule(params) {
|
|
722
|
+
return this.#invoker.call("car.hvac.schedule", {
|
|
723
|
+
params: encodeClimateScheduleParams(params),
|
|
724
|
+
}, null);
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
exports.HvacFeature = HvacFeature;
|
|
728
|
+
/** `car.seat`: seat heating and ventilation. */
|
|
729
|
+
class SeatFeature {
|
|
730
|
+
#invoker;
|
|
731
|
+
#features;
|
|
732
|
+
/** @internal */
|
|
733
|
+
constructor(invoker, features) {
|
|
734
|
+
this.#invoker = invoker;
|
|
735
|
+
this.#features = features;
|
|
736
|
+
}
|
|
737
|
+
/** Whether a seat can be heated or ventilated. */
|
|
738
|
+
isAvailable(position, mode) {
|
|
739
|
+
return this.#features().seat[position][mode];
|
|
740
|
+
}
|
|
741
|
+
/**
|
|
742
|
+
* Set the heating of one seat.
|
|
743
|
+
*
|
|
744
|
+
* @param position - The seat.
|
|
745
|
+
*
|
|
746
|
+
* @param level - Off, low or high.
|
|
747
|
+
*/
|
|
748
|
+
heat(position, level) {
|
|
749
|
+
return this.#invoker.call("car.seat.heat", { position, level }, null);
|
|
750
|
+
}
|
|
751
|
+
/**
|
|
752
|
+
* Set the ventilation of one seat.
|
|
753
|
+
*
|
|
754
|
+
* @param position - The seat.
|
|
755
|
+
*
|
|
756
|
+
* @param level - Off, low or high.
|
|
757
|
+
*/
|
|
758
|
+
ventilation(position, level) {
|
|
759
|
+
return this.#invoker.call("car.seat.ventilation", { position, level }, null);
|
|
760
|
+
}
|
|
761
|
+
}
|
|
762
|
+
exports.SeatFeature = SeatFeature;
|
|
763
|
+
/** `car.steering`: steering wheel heating. */
|
|
764
|
+
class SteeringFeature {
|
|
765
|
+
#invoker;
|
|
766
|
+
#features;
|
|
767
|
+
/** @internal */
|
|
768
|
+
constructor(invoker, features) {
|
|
769
|
+
this.#invoker = invoker;
|
|
770
|
+
this.#features = features;
|
|
771
|
+
}
|
|
772
|
+
/** Whether the car has steering wheel heating. */
|
|
773
|
+
get available() {
|
|
774
|
+
return this.#features().steering.available;
|
|
775
|
+
}
|
|
776
|
+
/**
|
|
777
|
+
* Turn steering wheel heating on or off.
|
|
778
|
+
*
|
|
779
|
+
* @param on - On or off.
|
|
780
|
+
*/
|
|
781
|
+
heat(on) {
|
|
782
|
+
return this.#invoker.call("car.steering.heat", { on }, null);
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
exports.SteeringFeature = SteeringFeature;
|
|
786
|
+
/** `car.battery`: battery heating. */
|
|
787
|
+
class BatteryFeature {
|
|
788
|
+
#invoker;
|
|
789
|
+
#features;
|
|
790
|
+
/** @internal */
|
|
791
|
+
constructor(invoker, features) {
|
|
792
|
+
this.#invoker = invoker;
|
|
793
|
+
this.#features = features;
|
|
794
|
+
}
|
|
795
|
+
/** Whether the car supports battery heating. */
|
|
796
|
+
get available() {
|
|
797
|
+
return this.#features().battery.available;
|
|
798
|
+
}
|
|
799
|
+
/**
|
|
800
|
+
* Turn battery heating on or off.
|
|
801
|
+
*
|
|
802
|
+
* @param on - On or off.
|
|
803
|
+
*/
|
|
804
|
+
heat(on) {
|
|
805
|
+
return this.#invoker.call("car.battery.heat", { on }, null);
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
exports.BatteryFeature = BatteryFeature;
|
|
809
|
+
/** `car.finder`: find the car, flash the lights. */
|
|
810
|
+
class FinderFeature {
|
|
811
|
+
#invoker;
|
|
812
|
+
#features;
|
|
813
|
+
/** @internal */
|
|
814
|
+
constructor(invoker, features) {
|
|
815
|
+
this.#invoker = invoker;
|
|
816
|
+
this.#features = features;
|
|
817
|
+
}
|
|
818
|
+
/** Whether the car supports find-my-car. */
|
|
819
|
+
get findAvailable() {
|
|
820
|
+
return this.#features().finder.find_available;
|
|
821
|
+
}
|
|
822
|
+
/** Whether the car can flash its lights remotely. */
|
|
823
|
+
get flashAvailable() {
|
|
824
|
+
return this.#features().finder.flash_available;
|
|
825
|
+
}
|
|
826
|
+
/** Horn and lights. */
|
|
827
|
+
find() {
|
|
828
|
+
return this.#invoker.call("car.finder.find", {}, null);
|
|
829
|
+
}
|
|
830
|
+
/** Flash the lights. */
|
|
831
|
+
flashLights() {
|
|
832
|
+
return this.#invoker.call("car.finder.flash_lights", {}, null);
|
|
833
|
+
}
|
|
834
|
+
}
|
|
835
|
+
exports.FinderFeature = FinderFeature;
|
|
836
|
+
/** `car.windows`: close the windows or crack them open. */
|
|
837
|
+
class WindowsFeature {
|
|
838
|
+
#invoker;
|
|
839
|
+
#features;
|
|
840
|
+
/** @internal */
|
|
841
|
+
constructor(invoker, features) {
|
|
842
|
+
this.#invoker = invoker;
|
|
843
|
+
this.#features = features;
|
|
844
|
+
}
|
|
845
|
+
/** Whether the car can close its windows remotely. */
|
|
846
|
+
get closeAvailable() {
|
|
847
|
+
return this.#features().windows.close_available;
|
|
848
|
+
}
|
|
849
|
+
/** Whether the car can open its windows remotely (to a vent crack). */
|
|
850
|
+
get openAvailable() {
|
|
851
|
+
return this.#features().windows.open_available;
|
|
852
|
+
}
|
|
853
|
+
/** Close all windows. */
|
|
854
|
+
close() {
|
|
855
|
+
return this.#invoker.call("car.windows.close", {}, null);
|
|
856
|
+
}
|
|
857
|
+
/** Open the windows to a vent crack of about 10 %. */
|
|
858
|
+
open() {
|
|
859
|
+
return this.#invoker.call("car.windows.open", {}, null);
|
|
860
|
+
}
|
|
861
|
+
}
|
|
862
|
+
exports.WindowsFeature = WindowsFeature;
|
|
863
|
+
/** `car.trunk`: open and close the trunk. */
|
|
864
|
+
class TrunkFeature {
|
|
865
|
+
#invoker;
|
|
866
|
+
#features;
|
|
867
|
+
/** @internal */
|
|
868
|
+
constructor(invoker, features) {
|
|
869
|
+
this.#invoker = invoker;
|
|
870
|
+
this.#features = features;
|
|
871
|
+
}
|
|
872
|
+
/** Whether the trunk can be opened remotely. */
|
|
873
|
+
get openAvailable() {
|
|
874
|
+
return this.#features().trunk.open_available;
|
|
875
|
+
}
|
|
876
|
+
/** Whether the trunk can be closed remotely. */
|
|
877
|
+
get closeAvailable() {
|
|
878
|
+
return this.#features().trunk.close_available;
|
|
879
|
+
}
|
|
880
|
+
/** Release the trunk. */
|
|
881
|
+
open() {
|
|
882
|
+
return this.#invoker.call("car.trunk.open", {}, null);
|
|
883
|
+
}
|
|
884
|
+
/** Lower the trunk. */
|
|
885
|
+
close() {
|
|
886
|
+
return this.#invoker.call("car.trunk.close", {}, null);
|
|
887
|
+
}
|
|
888
|
+
}
|
|
889
|
+
exports.TrunkFeature = TrunkFeature;
|
|
890
|
+
/** A car's methods: pyBYD's `BydCar`. `Car` (car.ts) completes it. */
|
|
891
|
+
class CarMethods {
|
|
892
|
+
#invoker;
|
|
893
|
+
/** Lock and unlock the doors. */
|
|
894
|
+
lock;
|
|
895
|
+
/** Start, stop and schedule climate control. */
|
|
896
|
+
hvac;
|
|
897
|
+
/** Seat heating and ventilation. */
|
|
898
|
+
seat;
|
|
899
|
+
/** Steering wheel heating. */
|
|
900
|
+
steering;
|
|
901
|
+
/** Battery heating. */
|
|
902
|
+
battery;
|
|
903
|
+
/** Find the car, flash the lights. */
|
|
904
|
+
finder;
|
|
905
|
+
/** Close the windows or crack them open. */
|
|
906
|
+
windows;
|
|
907
|
+
/** Open and close the trunk. */
|
|
908
|
+
trunk;
|
|
909
|
+
/** @internal */
|
|
910
|
+
constructor(invoker) {
|
|
911
|
+
this.#invoker = invoker;
|
|
912
|
+
const features = () => this.features;
|
|
913
|
+
this.lock = new LockFeature(invoker, features);
|
|
914
|
+
this.hvac = new HvacFeature(invoker, features);
|
|
915
|
+
this.seat = new SeatFeature(invoker, features);
|
|
916
|
+
this.steering = new SteeringFeature(invoker, features);
|
|
917
|
+
this.battery = new BatteryFeature(invoker, features);
|
|
918
|
+
this.finder = new FinderFeature(invoker, features);
|
|
919
|
+
this.windows = new WindowsFeature(invoker, features);
|
|
920
|
+
this.trunk = new TrunkFeature(invoker, features);
|
|
921
|
+
}
|
|
922
|
+
/** The current state with active projections laid over it, by section. */
|
|
923
|
+
get state() {
|
|
924
|
+
return this.#invoker.callSync("car.state", {}, ["struct", "VehicleSnapshot"]);
|
|
925
|
+
}
|
|
926
|
+
/** The car's capability flags. */
|
|
927
|
+
get capabilities() {
|
|
928
|
+
return this.#invoker.callSync("car.capabilities", {}, null);
|
|
929
|
+
}
|
|
930
|
+
/** Every feature's availability, and the climate scale. */
|
|
931
|
+
get features() {
|
|
932
|
+
return this.#invoker.callSync("car.features", {}, ["struct", "CarFeatures"]);
|
|
933
|
+
}
|
|
934
|
+
/** Fetch realtime data and merge it; returns the data as fetched. */
|
|
935
|
+
updateRealtime() {
|
|
936
|
+
return this.#invoker.call("car.update_realtime", {}, ["struct", "VehicleRealtimeData"]);
|
|
937
|
+
}
|
|
938
|
+
/** Fetch the HVAC status and merge it. */
|
|
939
|
+
updateHvac() {
|
|
940
|
+
return this.#invoker.call("car.update_hvac", {}, ["struct", "HvacStatus"]);
|
|
941
|
+
}
|
|
942
|
+
/** Fetch the location and merge it. */
|
|
943
|
+
updateGps() {
|
|
944
|
+
return this.#invoker.call("car.update_gps", {}, ["struct", "GpsInfo"]);
|
|
945
|
+
}
|
|
946
|
+
/**
|
|
947
|
+
* Fetch the charging state and the schedule in one call and merge both; returns the charging
|
|
948
|
+
* state.
|
|
949
|
+
*/
|
|
950
|
+
updateCharging() {
|
|
951
|
+
return this.#invoker.call("car.update_charging", {}, ["struct", "ChargingStatus"]);
|
|
952
|
+
}
|
|
953
|
+
/** Fetch energy consumption and merge it. */
|
|
954
|
+
updateEnergy() {
|
|
955
|
+
return this.#invoker.call("car.update_energy", {}, ["struct", "EnergyConsumption"]);
|
|
956
|
+
}
|
|
957
|
+
/** Start charging now and wait for the change to settle. */
|
|
958
|
+
startCharging() {
|
|
959
|
+
return this.#invoker.call("car.start_charging", {}, null);
|
|
960
|
+
}
|
|
961
|
+
/** Always fails with `BydEndpointNotSupportedError`: the cloud cannot stop a charge. */
|
|
962
|
+
stopCharging() {
|
|
963
|
+
return this.#invoker.call("car.stop_charging", {}, null);
|
|
964
|
+
}
|
|
965
|
+
/** The supported and active AC charging current limits. */
|
|
966
|
+
getAcCurrentLimit() {
|
|
967
|
+
return this.#invoker.call("car.get_ac_current_limit", {}, null);
|
|
968
|
+
}
|
|
969
|
+
/**
|
|
970
|
+
* Save a smart-charging schedule, wait for it to settle, then refresh the charging state.
|
|
971
|
+
*
|
|
972
|
+
* @param startChargeTime - When charging starts, `HH:MM`.
|
|
973
|
+
*
|
|
974
|
+
* @param endChargeTime - When charging ends, `HH:MM`, or `full`.
|
|
975
|
+
*
|
|
976
|
+
* @param chargeWay - `s` (single), `e` (every day) or weekday indices.
|
|
977
|
+
*/
|
|
978
|
+
saveChargingSchedule(startChargeTime, endChargeTime, chargeWay, options = {}) {
|
|
979
|
+
return this.#invoker.call("car.save_charging_schedule", {
|
|
980
|
+
start_charge_time: startChargeTime,
|
|
981
|
+
end_charge_time: endChargeTime,
|
|
982
|
+
charge_way: chargeWay,
|
|
983
|
+
enabled: options.enabled,
|
|
984
|
+
}, null);
|
|
985
|
+
}
|
|
986
|
+
/**
|
|
987
|
+
* Merge a `vehicleInfo` push (its raw `respondData`), after any command in flight.
|
|
988
|
+
*
|
|
989
|
+
* @param data - The push's `respondData`.
|
|
990
|
+
*/
|
|
991
|
+
handleMqttRealtime(data) {
|
|
992
|
+
this.#invoker.callSync("car.handle_mqtt_realtime", { data }, null);
|
|
993
|
+
}
|
|
994
|
+
/**
|
|
995
|
+
* Merge a partial `vehicleStatusPush` (its raw `respondData`), optionally with HVAC and
|
|
996
|
+
* charging sections.
|
|
997
|
+
*
|
|
998
|
+
* @param data - The push's `respondData`.
|
|
999
|
+
*/
|
|
1000
|
+
handleMqttStatusPush(data, options = {}) {
|
|
1001
|
+
this.#invoker.callSync("car.handle_mqtt_status_push", {
|
|
1002
|
+
data,
|
|
1003
|
+
hvac: options.hvac,
|
|
1004
|
+
charging: options.charging,
|
|
1005
|
+
}, null);
|
|
1006
|
+
}
|
|
1007
|
+
/**
|
|
1008
|
+
* Merge a `smartCharge` push (its raw `respondData`) (live charging state only).
|
|
1009
|
+
*
|
|
1010
|
+
* @param data - The push's `respondData`.
|
|
1011
|
+
*/
|
|
1012
|
+
handleMqttCharging(data) {
|
|
1013
|
+
this.#invoker.callSync("car.handle_mqtt_charging", { data }, null);
|
|
1014
|
+
}
|
|
1015
|
+
/**
|
|
1016
|
+
* Merge a `energyConsumption` push (its raw `respondData`).
|
|
1017
|
+
*
|
|
1018
|
+
* @param data - The push's `respondData`.
|
|
1019
|
+
*/
|
|
1020
|
+
handleMqttEnergy(data) {
|
|
1021
|
+
this.#invoker.callSync("car.handle_mqtt_energy", { data }, null);
|
|
1022
|
+
}
|
|
1023
|
+
/** Release the car's resources (nothing yet; pyBYD's lifecycle hook). */
|
|
1024
|
+
close() {
|
|
1025
|
+
this.#invoker.callSync("car.close", {}, null);
|
|
1026
|
+
}
|
|
1027
|
+
}
|
|
1028
|
+
exports.CarMethods = CarMethods;
|