edilkamin 1.9.0 → 1.10.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/dist/cjs/package.json +1 -1
- package/dist/cjs/src/cli.js +209 -6
- package/dist/cjs/src/index.d.ts +3 -2
- package/dist/cjs/src/index.js +4 -1
- package/dist/cjs/src/library.d.ts +16 -3
- package/dist/cjs/src/library.js +248 -117
- package/dist/cjs/src/library.test.js +230 -3
- package/dist/cjs/src/types.d.ts +127 -1
- package/dist/cjs/src/types.js +64 -0
- package/dist/esm/package.json +1 -1
- package/dist/esm/src/cli.js +209 -6
- package/dist/esm/src/index.d.ts +3 -2
- package/dist/esm/src/index.js +1 -0
- package/dist/esm/src/library.d.ts +16 -3
- package/dist/esm/src/library.js +248 -117
- package/dist/esm/src/library.test.js +230 -3
- package/dist/esm/src/types.d.ts +127 -1
- package/dist/esm/src/types.js +63 -1
- package/package.json +1 -1
- package/src/cli.ts +332 -6
- package/src/index.ts +10 -0
- package/src/library.test.ts +297 -2
- package/src/library.ts +343 -121
- package/src/types.ts +180 -0
package/dist/esm/src/library.js
CHANGED
|
@@ -186,81 +186,45 @@ const getPowerLevel = (baseURL) =>
|
|
|
186
186
|
const info = yield deviceInfo(baseURL)(jwtToken, macAddress);
|
|
187
187
|
return info.nvm.user_parameters.manual_power;
|
|
188
188
|
});
|
|
189
|
-
const
|
|
189
|
+
const setFanSpeed = (baseURL) =>
|
|
190
190
|
/**
|
|
191
|
-
* Sets the speed of fan
|
|
191
|
+
* Sets the speed of a fan by index.
|
|
192
192
|
*
|
|
193
193
|
* @param {string} jwtToken - The JWT token for authentication.
|
|
194
194
|
* @param {string} macAddress - The MAC address of the device.
|
|
195
|
+
* @param {1 | 2 | 3} fanIndex - The fan index (1, 2, or 3).
|
|
195
196
|
* @param {number} speed - The fan speed (0-5, 0=auto on some models).
|
|
196
197
|
* @returns {Promise<unknown>} - A promise that resolves to the command response.
|
|
197
198
|
*/
|
|
198
|
-
(jwtToken, macAddress, speed) => mqttCommand(baseURL)(jwtToken, macAddress, {
|
|
199
|
-
name:
|
|
199
|
+
(jwtToken, macAddress, fanIndex, speed) => mqttCommand(baseURL)(jwtToken, macAddress, {
|
|
200
|
+
name: `fan_${fanIndex}_speed`,
|
|
200
201
|
value: speed,
|
|
201
202
|
});
|
|
202
|
-
const
|
|
203
|
+
const getFanSpeed = (baseURL) =>
|
|
203
204
|
/**
|
|
204
|
-
*
|
|
205
|
-
*
|
|
206
|
-
* @param {string} jwtToken - The JWT token for authentication.
|
|
207
|
-
* @param {string} macAddress - The MAC address of the device.
|
|
208
|
-
* @param {number} speed - The fan speed (0-5, 0=auto on some models).
|
|
209
|
-
* @returns {Promise<unknown>} - A promise that resolves to the command response.
|
|
210
|
-
*/
|
|
211
|
-
(jwtToken, macAddress, speed) => mqttCommand(baseURL)(jwtToken, macAddress, {
|
|
212
|
-
name: "fan_2_speed",
|
|
213
|
-
value: speed,
|
|
214
|
-
});
|
|
215
|
-
const setFan3Speed = (baseURL) =>
|
|
216
|
-
/**
|
|
217
|
-
* Sets the speed of fan 3.
|
|
218
|
-
*
|
|
219
|
-
* @param {string} jwtToken - The JWT token for authentication.
|
|
220
|
-
* @param {string} macAddress - The MAC address of the device.
|
|
221
|
-
* @param {number} speed - The fan speed (0-5, 0=auto on some models).
|
|
222
|
-
* @returns {Promise<unknown>} - A promise that resolves to the command response.
|
|
223
|
-
*/
|
|
224
|
-
(jwtToken, macAddress, speed) => mqttCommand(baseURL)(jwtToken, macAddress, {
|
|
225
|
-
name: "fan_3_speed",
|
|
226
|
-
value: speed,
|
|
227
|
-
});
|
|
228
|
-
const getFan1Speed = (baseURL) =>
|
|
229
|
-
/**
|
|
230
|
-
* Retrieves the current speed of fan 1.
|
|
205
|
+
* Retrieves the current speed of a fan by index.
|
|
231
206
|
*
|
|
232
207
|
* @param {string} jwtToken - The JWT token for authentication.
|
|
233
208
|
* @param {string} macAddress - The MAC address of the device.
|
|
209
|
+
* @param {1 | 2 | 3} fanIndex - The fan index (1, 2, or 3).
|
|
234
210
|
* @returns {Promise<number>} - A promise that resolves to the fan speed.
|
|
235
211
|
*/
|
|
236
|
-
(jwtToken, macAddress) => __awaiter(void 0, void 0, void 0, function* () {
|
|
237
|
-
const info = yield deviceInfo(baseURL)(jwtToken, macAddress);
|
|
238
|
-
return info.nvm.user_parameters.fan_1_ventilation;
|
|
239
|
-
});
|
|
240
|
-
const getFan2Speed = (baseURL) =>
|
|
241
|
-
/**
|
|
242
|
-
* Retrieves the current speed of fan 2.
|
|
243
|
-
*
|
|
244
|
-
* @param {string} jwtToken - The JWT token for authentication.
|
|
245
|
-
* @param {string} macAddress - The MAC address of the device.
|
|
246
|
-
* @returns {Promise<number>} - A promise that resolves to the fan speed.
|
|
247
|
-
*/
|
|
248
|
-
(jwtToken, macAddress) => __awaiter(void 0, void 0, void 0, function* () {
|
|
249
|
-
const info = yield deviceInfo(baseURL)(jwtToken, macAddress);
|
|
250
|
-
return info.nvm.user_parameters.fan_2_ventilation;
|
|
251
|
-
});
|
|
252
|
-
const getFan3Speed = (baseURL) =>
|
|
253
|
-
/**
|
|
254
|
-
* Retrieves the current speed of fan 3.
|
|
255
|
-
*
|
|
256
|
-
* @param {string} jwtToken - The JWT token for authentication.
|
|
257
|
-
* @param {string} macAddress - The MAC address of the device.
|
|
258
|
-
* @returns {Promise<number>} - A promise that resolves to the fan speed.
|
|
259
|
-
*/
|
|
260
|
-
(jwtToken, macAddress) => __awaiter(void 0, void 0, void 0, function* () {
|
|
212
|
+
(jwtToken, macAddress, fanIndex) => __awaiter(void 0, void 0, void 0, function* () {
|
|
261
213
|
const info = yield deviceInfo(baseURL)(jwtToken, macAddress);
|
|
262
|
-
|
|
263
|
-
|
|
214
|
+
const fields = {
|
|
215
|
+
1: info.nvm.user_parameters.fan_1_ventilation,
|
|
216
|
+
2: info.nvm.user_parameters.fan_2_ventilation,
|
|
217
|
+
3: info.nvm.user_parameters.fan_3_ventilation,
|
|
218
|
+
};
|
|
219
|
+
return fields[fanIndex];
|
|
220
|
+
});
|
|
221
|
+
// Fan speed aliases for convenience
|
|
222
|
+
const setFan1Speed = (baseURL) => (jwtToken, macAddress, speed) => setFanSpeed(baseURL)(jwtToken, macAddress, 1, speed);
|
|
223
|
+
const setFan2Speed = (baseURL) => (jwtToken, macAddress, speed) => setFanSpeed(baseURL)(jwtToken, macAddress, 2, speed);
|
|
224
|
+
const setFan3Speed = (baseURL) => (jwtToken, macAddress, speed) => setFanSpeed(baseURL)(jwtToken, macAddress, 3, speed);
|
|
225
|
+
const getFan1Speed = (baseURL) => (jwtToken, macAddress) => getFanSpeed(baseURL)(jwtToken, macAddress, 1);
|
|
226
|
+
const getFan2Speed = (baseURL) => (jwtToken, macAddress) => getFanSpeed(baseURL)(jwtToken, macAddress, 2);
|
|
227
|
+
const getFan3Speed = (baseURL) => (jwtToken, macAddress) => getFanSpeed(baseURL)(jwtToken, macAddress, 3);
|
|
264
228
|
const setAirkare = (baseURL) =>
|
|
265
229
|
/**
|
|
266
230
|
* Enables or disables Airkare (air quality) mode.
|
|
@@ -388,79 +352,43 @@ const getEnvironmentTemperature = (baseURL) =>
|
|
|
388
352
|
});
|
|
389
353
|
const getTargetTemperature = (baseURL) =>
|
|
390
354
|
/**
|
|
391
|
-
* Retrieves the target temperature
|
|
355
|
+
* Retrieves the target temperature for an environment zone.
|
|
392
356
|
*
|
|
393
357
|
* @param {string} jwtToken - The JWT token for authentication.
|
|
394
358
|
* @param {string} macAddress - The MAC address of the device.
|
|
395
|
-
* @
|
|
359
|
+
* @param {1 | 2 | 3} envIndex - The environment zone index (1, 2, or 3).
|
|
360
|
+
* @returns {Promise<number>} - A promise that resolves to the target temperature (degrees Celsius).
|
|
396
361
|
*/
|
|
397
|
-
(jwtToken, macAddress) => __awaiter(void 0, void 0, void 0, function* () {
|
|
362
|
+
(jwtToken, macAddress, envIndex) => __awaiter(void 0, void 0, void 0, function* () {
|
|
398
363
|
const info = yield deviceInfo(baseURL)(jwtToken, macAddress);
|
|
399
|
-
|
|
364
|
+
const fields = {
|
|
365
|
+
1: info.nvm.user_parameters.enviroment_1_temperature,
|
|
366
|
+
2: info.nvm.user_parameters.enviroment_2_temperature,
|
|
367
|
+
3: info.nvm.user_parameters.enviroment_3_temperature,
|
|
368
|
+
};
|
|
369
|
+
return fields[envIndex];
|
|
400
370
|
});
|
|
401
371
|
const setTargetTemperature = (baseURL) =>
|
|
402
372
|
/**
|
|
403
|
-
*
|
|
373
|
+
* Sets the target temperature for an environment zone.
|
|
404
374
|
*
|
|
405
375
|
* @param {string} jwtToken - The JWT token for authentication.
|
|
406
376
|
* @param {string} macAddress - The MAC address of the device.
|
|
407
|
-
* @param {
|
|
408
|
-
* @
|
|
409
|
-
*/
|
|
410
|
-
(jwtToken, macAddress, temperature) => mqttCommand(baseURL)(jwtToken, macAddress, {
|
|
411
|
-
name: "enviroment_1_temperature",
|
|
412
|
-
value: temperature,
|
|
413
|
-
});
|
|
414
|
-
const setEnvironment2Temperature = (baseURL) =>
|
|
415
|
-
/**
|
|
416
|
-
* Sets the target temperature for Environment 2 zone.
|
|
417
|
-
*
|
|
418
|
-
* @param {string} jwtToken - The JWT token for authentication.
|
|
419
|
-
* @param {string} macAddress - The MAC address of the device.
|
|
420
|
-
* @param {number} temperature - The target temperature in degrees Celsius.
|
|
377
|
+
* @param {1 | 2 | 3} envIndex - The environment zone index (1, 2, or 3).
|
|
378
|
+
* @param {number} temperature - The desired target temperature (degrees Celsius).
|
|
421
379
|
* @returns {Promise<unknown>} - A promise that resolves to the command response.
|
|
422
380
|
*/
|
|
423
|
-
(jwtToken, macAddress, temperature) => mqttCommand(baseURL)(jwtToken, macAddress, {
|
|
424
|
-
name:
|
|
381
|
+
(jwtToken, macAddress, envIndex, temperature) => mqttCommand(baseURL)(jwtToken, macAddress, {
|
|
382
|
+
name: `enviroment_${envIndex}_temperature`,
|
|
425
383
|
value: temperature,
|
|
426
384
|
});
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
*/
|
|
435
|
-
(jwtToken, macAddress) => __awaiter(void 0, void 0, void 0, function* () {
|
|
436
|
-
const info = yield deviceInfo(baseURL)(jwtToken, macAddress);
|
|
437
|
-
return info.nvm.user_parameters.enviroment_2_temperature;
|
|
438
|
-
});
|
|
439
|
-
const setEnvironment3Temperature = (baseURL) =>
|
|
440
|
-
/**
|
|
441
|
-
* Sets the target temperature for Environment 3 zone.
|
|
442
|
-
*
|
|
443
|
-
* @param {string} jwtToken - The JWT token for authentication.
|
|
444
|
-
* @param {string} macAddress - The MAC address of the device.
|
|
445
|
-
* @param {number} temperature - The target temperature in degrees Celsius.
|
|
446
|
-
* @returns {Promise<unknown>} - A promise that resolves to the command response.
|
|
447
|
-
*/
|
|
448
|
-
(jwtToken, macAddress, temperature) => mqttCommand(baseURL)(jwtToken, macAddress, {
|
|
449
|
-
name: "enviroment_3_temperature",
|
|
450
|
-
value: temperature,
|
|
451
|
-
});
|
|
452
|
-
const getEnvironment3Temperature = (baseURL) =>
|
|
453
|
-
/**
|
|
454
|
-
* Retrieves the target temperature for Environment 3 zone.
|
|
455
|
-
*
|
|
456
|
-
* @param {string} jwtToken - The JWT token for authentication.
|
|
457
|
-
* @param {string} macAddress - The MAC address of the device.
|
|
458
|
-
* @returns {Promise<number>} - A promise that resolves to the temperature in degrees Celsius.
|
|
459
|
-
*/
|
|
460
|
-
(jwtToken, macAddress) => __awaiter(void 0, void 0, void 0, function* () {
|
|
461
|
-
const info = yield deviceInfo(baseURL)(jwtToken, macAddress);
|
|
462
|
-
return info.nvm.user_parameters.enviroment_3_temperature;
|
|
463
|
-
});
|
|
385
|
+
// Environment temperature aliases for convenience
|
|
386
|
+
const setEnvironment1Temperature = (baseURL) => (jwtToken, macAddress, temperature) => setTargetTemperature(baseURL)(jwtToken, macAddress, 1, temperature);
|
|
387
|
+
const setEnvironment2Temperature = (baseURL) => (jwtToken, macAddress, temperature) => setTargetTemperature(baseURL)(jwtToken, macAddress, 2, temperature);
|
|
388
|
+
const setEnvironment3Temperature = (baseURL) => (jwtToken, macAddress, temperature) => setTargetTemperature(baseURL)(jwtToken, macAddress, 3, temperature);
|
|
389
|
+
const getEnvironment1Temperature = (baseURL) => (jwtToken, macAddress) => getTargetTemperature(baseURL)(jwtToken, macAddress, 1);
|
|
390
|
+
const getEnvironment2Temperature = (baseURL) => (jwtToken, macAddress) => getTargetTemperature(baseURL)(jwtToken, macAddress, 2);
|
|
391
|
+
const getEnvironment3Temperature = (baseURL) => (jwtToken, macAddress) => getTargetTemperature(baseURL)(jwtToken, macAddress, 3);
|
|
464
392
|
const setMeasureUnit = (baseURL) =>
|
|
465
393
|
/**
|
|
466
394
|
* Sets the temperature measurement unit (Celsius or Fahrenheit).
|
|
@@ -545,6 +473,194 @@ const getPelletAutonomyTime = (baseURL) =>
|
|
|
545
473
|
const info = yield deviceInfo(baseURL)(jwtToken, macAddress);
|
|
546
474
|
return info.status.pellet.autonomy_time;
|
|
547
475
|
});
|
|
476
|
+
const getTotalCounters = (baseURL) =>
|
|
477
|
+
/**
|
|
478
|
+
* Retrieves lifetime operating counters.
|
|
479
|
+
* Includes power-on count and runtime hours per power level.
|
|
480
|
+
* These counters are never reset.
|
|
481
|
+
*
|
|
482
|
+
* @param {string} jwtToken - The JWT token for authentication.
|
|
483
|
+
* @param {string} macAddress - The MAC address of the device.
|
|
484
|
+
* @returns {Promise<TotalCountersType>} - Lifetime operating statistics.
|
|
485
|
+
*/
|
|
486
|
+
(jwtToken, macAddress) => __awaiter(void 0, void 0, void 0, function* () {
|
|
487
|
+
const info = yield deviceInfo(baseURL)(jwtToken, macAddress);
|
|
488
|
+
return info.nvm.total_counters;
|
|
489
|
+
});
|
|
490
|
+
const getServiceCounters = (baseURL) =>
|
|
491
|
+
/**
|
|
492
|
+
* Retrieves service counters (runtime since last maintenance).
|
|
493
|
+
* These counters track hours per power level since last service reset.
|
|
494
|
+
*
|
|
495
|
+
* @param {string} jwtToken - The JWT token for authentication.
|
|
496
|
+
* @param {string} macAddress - The MAC address of the device.
|
|
497
|
+
* @returns {Promise<ServiceCountersType>} - Service tracking statistics.
|
|
498
|
+
*/
|
|
499
|
+
(jwtToken, macAddress) => __awaiter(void 0, void 0, void 0, function* () {
|
|
500
|
+
const info = yield deviceInfo(baseURL)(jwtToken, macAddress);
|
|
501
|
+
return info.nvm.service_counters;
|
|
502
|
+
});
|
|
503
|
+
const getAlarmHistory = (baseURL) =>
|
|
504
|
+
/**
|
|
505
|
+
* Retrieves the alarm history log.
|
|
506
|
+
* Contains a circular buffer of recent alarms with timestamps.
|
|
507
|
+
*
|
|
508
|
+
* @param {string} jwtToken - The JWT token for authentication.
|
|
509
|
+
* @param {string} macAddress - The MAC address of the device.
|
|
510
|
+
* @returns {Promise<AlarmsLogType>} - Alarm history log.
|
|
511
|
+
*/
|
|
512
|
+
(jwtToken, macAddress) => __awaiter(void 0, void 0, void 0, function* () {
|
|
513
|
+
const info = yield deviceInfo(baseURL)(jwtToken, macAddress);
|
|
514
|
+
return info.nvm.alarms_log;
|
|
515
|
+
});
|
|
516
|
+
const getRegenerationData = (baseURL) =>
|
|
517
|
+
/**
|
|
518
|
+
* Retrieves regeneration and maintenance data.
|
|
519
|
+
* Includes blackout counter and last intervention timestamp.
|
|
520
|
+
*
|
|
521
|
+
* @param {string} jwtToken - The JWT token for authentication.
|
|
522
|
+
* @param {string} macAddress - The MAC address of the device.
|
|
523
|
+
* @returns {Promise<RegenerationDataType>} - Maintenance tracking data.
|
|
524
|
+
*/
|
|
525
|
+
(jwtToken, macAddress) => __awaiter(void 0, void 0, void 0, function* () {
|
|
526
|
+
const info = yield deviceInfo(baseURL)(jwtToken, macAddress);
|
|
527
|
+
return info.nvm.regeneration;
|
|
528
|
+
});
|
|
529
|
+
const getServiceTime = (baseURL) =>
|
|
530
|
+
/**
|
|
531
|
+
* Retrieves the total service time in hours.
|
|
532
|
+
*
|
|
533
|
+
* @param {string} jwtToken - The JWT token for authentication.
|
|
534
|
+
* @param {string} macAddress - The MAC address of the device.
|
|
535
|
+
* @returns {Promise<number>} - Total service hours.
|
|
536
|
+
*/
|
|
537
|
+
(jwtToken, macAddress) => __awaiter(void 0, void 0, void 0, function* () {
|
|
538
|
+
const info = yield deviceInfo(baseURL)(jwtToken, macAddress);
|
|
539
|
+
return info.status.counters.service_time;
|
|
540
|
+
});
|
|
541
|
+
/**
|
|
542
|
+
* Default service threshold in hours (from OEM parameters).
|
|
543
|
+
* Most devices use 2000 hours.
|
|
544
|
+
*/
|
|
545
|
+
const DEFAULT_SERVICE_THRESHOLD = 2000;
|
|
546
|
+
const getTotalOperatingHours = (baseURL) =>
|
|
547
|
+
/**
|
|
548
|
+
* Calculates total operating hours across all power levels.
|
|
549
|
+
*
|
|
550
|
+
* @param {string} jwtToken - The JWT token for authentication.
|
|
551
|
+
* @param {string} macAddress - The MAC address of the device.
|
|
552
|
+
* @returns {Promise<number>} - Total operating hours.
|
|
553
|
+
*/
|
|
554
|
+
(jwtToken, macAddress) => __awaiter(void 0, void 0, void 0, function* () {
|
|
555
|
+
const counters = yield getTotalCounters(baseURL)(jwtToken, macAddress);
|
|
556
|
+
return (counters.p1_working_time +
|
|
557
|
+
counters.p2_working_time +
|
|
558
|
+
counters.p3_working_time +
|
|
559
|
+
counters.p4_working_time +
|
|
560
|
+
counters.p5_working_time);
|
|
561
|
+
});
|
|
562
|
+
const getPowerDistribution = (baseURL) =>
|
|
563
|
+
/**
|
|
564
|
+
* Calculates power level usage distribution as percentages.
|
|
565
|
+
*
|
|
566
|
+
* @param {string} jwtToken - The JWT token for authentication.
|
|
567
|
+
* @param {string} macAddress - The MAC address of the device.
|
|
568
|
+
* @returns {Promise<PowerDistributionType>} - Percentage time at each power level.
|
|
569
|
+
*/
|
|
570
|
+
(jwtToken, macAddress) => __awaiter(void 0, void 0, void 0, function* () {
|
|
571
|
+
const counters = yield getTotalCounters(baseURL)(jwtToken, macAddress);
|
|
572
|
+
const total = counters.p1_working_time +
|
|
573
|
+
counters.p2_working_time +
|
|
574
|
+
counters.p3_working_time +
|
|
575
|
+
counters.p4_working_time +
|
|
576
|
+
counters.p5_working_time;
|
|
577
|
+
if (total === 0) {
|
|
578
|
+
return { p1: 0, p2: 0, p3: 0, p4: 0, p5: 0 };
|
|
579
|
+
}
|
|
580
|
+
return {
|
|
581
|
+
p1: (counters.p1_working_time / total) * 100,
|
|
582
|
+
p2: (counters.p2_working_time / total) * 100,
|
|
583
|
+
p3: (counters.p3_working_time / total) * 100,
|
|
584
|
+
p4: (counters.p4_working_time / total) * 100,
|
|
585
|
+
p5: (counters.p5_working_time / total) * 100,
|
|
586
|
+
};
|
|
587
|
+
});
|
|
588
|
+
const getServiceStatus = (baseURL) =>
|
|
589
|
+
/**
|
|
590
|
+
* Calculates service status including whether maintenance is due.
|
|
591
|
+
*
|
|
592
|
+
* @param {string} jwtToken - The JWT token for authentication.
|
|
593
|
+
* @param {string} macAddress - The MAC address of the device.
|
|
594
|
+
* @param {number} [thresholdHours=2000] - Service threshold in hours.
|
|
595
|
+
* @returns {Promise<ServiceStatusType>} - Service status with computed fields.
|
|
596
|
+
*/
|
|
597
|
+
(jwtToken_1, macAddress_1, ...args_1) => __awaiter(void 0, [jwtToken_1, macAddress_1, ...args_1], void 0, function* (jwtToken, macAddress, thresholdHours = DEFAULT_SERVICE_THRESHOLD) {
|
|
598
|
+
const info = yield deviceInfo(baseURL)(jwtToken, macAddress);
|
|
599
|
+
const serviceCounters = info.nvm.service_counters;
|
|
600
|
+
const hoursSinceService = serviceCounters.p1_working_time +
|
|
601
|
+
serviceCounters.p2_working_time +
|
|
602
|
+
serviceCounters.p3_working_time +
|
|
603
|
+
serviceCounters.p4_working_time +
|
|
604
|
+
serviceCounters.p5_working_time;
|
|
605
|
+
return {
|
|
606
|
+
totalServiceHours: info.status.counters.service_time,
|
|
607
|
+
hoursSinceService,
|
|
608
|
+
serviceThresholdHours: thresholdHours,
|
|
609
|
+
isServiceDue: hoursSinceService >= thresholdHours,
|
|
610
|
+
};
|
|
611
|
+
});
|
|
612
|
+
const getUsageAnalytics = (baseURL) =>
|
|
613
|
+
/**
|
|
614
|
+
* Retrieves comprehensive usage analytics in a single call.
|
|
615
|
+
* Combines multiple statistics into a unified analytics object.
|
|
616
|
+
*
|
|
617
|
+
* @param {string} jwtToken - The JWT token for authentication.
|
|
618
|
+
* @param {string} macAddress - The MAC address of the device.
|
|
619
|
+
* @param {number} [serviceThreshold=2000] - Service threshold in hours.
|
|
620
|
+
* @returns {Promise<UsageAnalyticsType>} - Comprehensive usage analytics.
|
|
621
|
+
*/
|
|
622
|
+
(jwtToken_1, macAddress_1, ...args_1) => __awaiter(void 0, [jwtToken_1, macAddress_1, ...args_1], void 0, function* (jwtToken, macAddress, serviceThreshold = DEFAULT_SERVICE_THRESHOLD) {
|
|
623
|
+
const info = yield deviceInfo(baseURL)(jwtToken, macAddress);
|
|
624
|
+
const totalCounters = info.nvm.total_counters;
|
|
625
|
+
const serviceCounters = info.nvm.service_counters;
|
|
626
|
+
const regeneration = info.nvm.regeneration;
|
|
627
|
+
const alarmsLog = info.nvm.alarms_log;
|
|
628
|
+
const totalOperatingHours = totalCounters.p1_working_time +
|
|
629
|
+
totalCounters.p2_working_time +
|
|
630
|
+
totalCounters.p3_working_time +
|
|
631
|
+
totalCounters.p4_working_time +
|
|
632
|
+
totalCounters.p5_working_time;
|
|
633
|
+
const hoursSinceService = serviceCounters.p1_working_time +
|
|
634
|
+
serviceCounters.p2_working_time +
|
|
635
|
+
serviceCounters.p3_working_time +
|
|
636
|
+
serviceCounters.p4_working_time +
|
|
637
|
+
serviceCounters.p5_working_time;
|
|
638
|
+
const powerDistribution = totalOperatingHours === 0
|
|
639
|
+
? { p1: 0, p2: 0, p3: 0, p4: 0, p5: 0 }
|
|
640
|
+
: {
|
|
641
|
+
p1: (totalCounters.p1_working_time / totalOperatingHours) * 100,
|
|
642
|
+
p2: (totalCounters.p2_working_time / totalOperatingHours) * 100,
|
|
643
|
+
p3: (totalCounters.p3_working_time / totalOperatingHours) * 100,
|
|
644
|
+
p4: (totalCounters.p4_working_time / totalOperatingHours) * 100,
|
|
645
|
+
p5: (totalCounters.p5_working_time / totalOperatingHours) * 100,
|
|
646
|
+
};
|
|
647
|
+
return {
|
|
648
|
+
totalPowerOns: totalCounters.power_ons,
|
|
649
|
+
totalOperatingHours,
|
|
650
|
+
powerDistribution,
|
|
651
|
+
serviceStatus: {
|
|
652
|
+
totalServiceHours: info.status.counters.service_time,
|
|
653
|
+
hoursSinceService,
|
|
654
|
+
serviceThresholdHours: serviceThreshold,
|
|
655
|
+
isServiceDue: hoursSinceService >= serviceThreshold,
|
|
656
|
+
},
|
|
657
|
+
blackoutCount: regeneration.blackout_counter,
|
|
658
|
+
lastMaintenanceDate: regeneration.last_intervention > 0
|
|
659
|
+
? new Date(regeneration.last_intervention * 1000)
|
|
660
|
+
: null,
|
|
661
|
+
alarmCount: alarmsLog.number,
|
|
662
|
+
};
|
|
663
|
+
});
|
|
548
664
|
const registerDevice = (baseURL) =>
|
|
549
665
|
/**
|
|
550
666
|
* Registers a device with the user's account.
|
|
@@ -613,6 +729,8 @@ const configure = (baseURL = API_URL) => ({
|
|
|
613
729
|
getPower: getPower(baseURL),
|
|
614
730
|
setPowerLevel: setPowerLevel(baseURL),
|
|
615
731
|
getPowerLevel: getPowerLevel(baseURL),
|
|
732
|
+
setFanSpeed: setFanSpeed(baseURL),
|
|
733
|
+
getFanSpeed: getFanSpeed(baseURL),
|
|
616
734
|
setFan1Speed: setFan1Speed(baseURL),
|
|
617
735
|
setFan2Speed: setFan2Speed(baseURL),
|
|
618
736
|
setFan3Speed: setFan3Speed(baseURL),
|
|
@@ -630,6 +748,8 @@ const configure = (baseURL = API_URL) => ({
|
|
|
630
748
|
getEnvironmentTemperature: getEnvironmentTemperature(baseURL),
|
|
631
749
|
getTargetTemperature: getTargetTemperature(baseURL),
|
|
632
750
|
setTargetTemperature: setTargetTemperature(baseURL),
|
|
751
|
+
setEnvironment1Temperature: setEnvironment1Temperature(baseURL),
|
|
752
|
+
getEnvironment1Temperature: getEnvironment1Temperature(baseURL),
|
|
633
753
|
setEnvironment2Temperature: setEnvironment2Temperature(baseURL),
|
|
634
754
|
getEnvironment2Temperature: getEnvironment2Temperature(baseURL),
|
|
635
755
|
setEnvironment3Temperature: setEnvironment3Temperature(baseURL),
|
|
@@ -640,5 +760,16 @@ const configure = (baseURL = API_URL) => ({
|
|
|
640
760
|
getLanguage: getLanguage(baseURL),
|
|
641
761
|
getPelletInReserve: getPelletInReserve(baseURL),
|
|
642
762
|
getPelletAutonomyTime: getPelletAutonomyTime(baseURL),
|
|
763
|
+
// Statistics getters
|
|
764
|
+
getTotalCounters: getTotalCounters(baseURL),
|
|
765
|
+
getServiceCounters: getServiceCounters(baseURL),
|
|
766
|
+
getAlarmHistory: getAlarmHistory(baseURL),
|
|
767
|
+
getRegenerationData: getRegenerationData(baseURL),
|
|
768
|
+
getServiceTime: getServiceTime(baseURL),
|
|
769
|
+
// Analytics functions
|
|
770
|
+
getTotalOperatingHours: getTotalOperatingHours(baseURL),
|
|
771
|
+
getPowerDistribution: getPowerDistribution(baseURL),
|
|
772
|
+
getServiceStatus: getServiceStatus(baseURL),
|
|
773
|
+
getUsageAnalytics: getUsageAnalytics(baseURL),
|
|
643
774
|
});
|
|
644
775
|
export { configure, configureAmplify, createAuthService, getSession, headers, signIn, };
|