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.
@@ -227,81 +227,45 @@ const getPowerLevel = (baseURL) =>
227
227
  const info = yield deviceInfo(baseURL)(jwtToken, macAddress);
228
228
  return info.nvm.user_parameters.manual_power;
229
229
  });
230
- const setFan1Speed = (baseURL) =>
230
+ const setFanSpeed = (baseURL) =>
231
231
  /**
232
- * Sets the speed of fan 1.
232
+ * Sets the speed of a fan by index.
233
233
  *
234
234
  * @param {string} jwtToken - The JWT token for authentication.
235
235
  * @param {string} macAddress - The MAC address of the device.
236
+ * @param {1 | 2 | 3} fanIndex - The fan index (1, 2, or 3).
236
237
  * @param {number} speed - The fan speed (0-5, 0=auto on some models).
237
238
  * @returns {Promise<unknown>} - A promise that resolves to the command response.
238
239
  */
239
- (jwtToken, macAddress, speed) => mqttCommand(baseURL)(jwtToken, macAddress, {
240
- name: "fan_1_speed",
240
+ (jwtToken, macAddress, fanIndex, speed) => mqttCommand(baseURL)(jwtToken, macAddress, {
241
+ name: `fan_${fanIndex}_speed`,
241
242
  value: speed,
242
243
  });
243
- const setFan2Speed = (baseURL) =>
244
+ const getFanSpeed = (baseURL) =>
244
245
  /**
245
- * Sets the speed of fan 2.
246
- *
247
- * @param {string} jwtToken - The JWT token for authentication.
248
- * @param {string} macAddress - The MAC address of the device.
249
- * @param {number} speed - The fan speed (0-5, 0=auto on some models).
250
- * @returns {Promise<unknown>} - A promise that resolves to the command response.
251
- */
252
- (jwtToken, macAddress, speed) => mqttCommand(baseURL)(jwtToken, macAddress, {
253
- name: "fan_2_speed",
254
- value: speed,
255
- });
256
- const setFan3Speed = (baseURL) =>
257
- /**
258
- * Sets the speed of fan 3.
259
- *
260
- * @param {string} jwtToken - The JWT token for authentication.
261
- * @param {string} macAddress - The MAC address of the device.
262
- * @param {number} speed - The fan speed (0-5, 0=auto on some models).
263
- * @returns {Promise<unknown>} - A promise that resolves to the command response.
264
- */
265
- (jwtToken, macAddress, speed) => mqttCommand(baseURL)(jwtToken, macAddress, {
266
- name: "fan_3_speed",
267
- value: speed,
268
- });
269
- const getFan1Speed = (baseURL) =>
270
- /**
271
- * Retrieves the current speed of fan 1.
246
+ * Retrieves the current speed of a fan by index.
272
247
  *
273
248
  * @param {string} jwtToken - The JWT token for authentication.
274
249
  * @param {string} macAddress - The MAC address of the device.
250
+ * @param {1 | 2 | 3} fanIndex - The fan index (1, 2, or 3).
275
251
  * @returns {Promise<number>} - A promise that resolves to the fan speed.
276
252
  */
277
- (jwtToken, macAddress) => __awaiter(void 0, void 0, void 0, function* () {
278
- const info = yield deviceInfo(baseURL)(jwtToken, macAddress);
279
- return info.nvm.user_parameters.fan_1_ventilation;
280
- });
281
- const getFan2Speed = (baseURL) =>
282
- /**
283
- * Retrieves the current speed of fan 2.
284
- *
285
- * @param {string} jwtToken - The JWT token for authentication.
286
- * @param {string} macAddress - The MAC address of the device.
287
- * @returns {Promise<number>} - A promise that resolves to the fan speed.
288
- */
289
- (jwtToken, macAddress) => __awaiter(void 0, void 0, void 0, function* () {
290
- const info = yield deviceInfo(baseURL)(jwtToken, macAddress);
291
- return info.nvm.user_parameters.fan_2_ventilation;
292
- });
293
- const getFan3Speed = (baseURL) =>
294
- /**
295
- * Retrieves the current speed of fan 3.
296
- *
297
- * @param {string} jwtToken - The JWT token for authentication.
298
- * @param {string} macAddress - The MAC address of the device.
299
- * @returns {Promise<number>} - A promise that resolves to the fan speed.
300
- */
301
- (jwtToken, macAddress) => __awaiter(void 0, void 0, void 0, function* () {
253
+ (jwtToken, macAddress, fanIndex) => __awaiter(void 0, void 0, void 0, function* () {
302
254
  const info = yield deviceInfo(baseURL)(jwtToken, macAddress);
303
- return info.nvm.user_parameters.fan_3_ventilation;
304
- });
255
+ const fields = {
256
+ 1: info.nvm.user_parameters.fan_1_ventilation,
257
+ 2: info.nvm.user_parameters.fan_2_ventilation,
258
+ 3: info.nvm.user_parameters.fan_3_ventilation,
259
+ };
260
+ return fields[fanIndex];
261
+ });
262
+ // Fan speed aliases for convenience
263
+ const setFan1Speed = (baseURL) => (jwtToken, macAddress, speed) => setFanSpeed(baseURL)(jwtToken, macAddress, 1, speed);
264
+ const setFan2Speed = (baseURL) => (jwtToken, macAddress, speed) => setFanSpeed(baseURL)(jwtToken, macAddress, 2, speed);
265
+ const setFan3Speed = (baseURL) => (jwtToken, macAddress, speed) => setFanSpeed(baseURL)(jwtToken, macAddress, 3, speed);
266
+ const getFan1Speed = (baseURL) => (jwtToken, macAddress) => getFanSpeed(baseURL)(jwtToken, macAddress, 1);
267
+ const getFan2Speed = (baseURL) => (jwtToken, macAddress) => getFanSpeed(baseURL)(jwtToken, macAddress, 2);
268
+ const getFan3Speed = (baseURL) => (jwtToken, macAddress) => getFanSpeed(baseURL)(jwtToken, macAddress, 3);
305
269
  const setAirkare = (baseURL) =>
306
270
  /**
307
271
  * Enables or disables Airkare (air quality) mode.
@@ -429,79 +393,43 @@ const getEnvironmentTemperature = (baseURL) =>
429
393
  });
430
394
  const getTargetTemperature = (baseURL) =>
431
395
  /**
432
- * Retrieves the target temperature value set on the device.
396
+ * Retrieves the target temperature for an environment zone.
433
397
  *
434
398
  * @param {string} jwtToken - The JWT token for authentication.
435
399
  * @param {string} macAddress - The MAC address of the device.
436
- * @returns {Promise<number>} - A promise that resolves to the target temperature (degree celsius).
400
+ * @param {1 | 2 | 3} envIndex - The environment zone index (1, 2, or 3).
401
+ * @returns {Promise<number>} - A promise that resolves to the target temperature (degrees Celsius).
437
402
  */
438
- (jwtToken, macAddress) => __awaiter(void 0, void 0, void 0, function* () {
403
+ (jwtToken, macAddress, envIndex) => __awaiter(void 0, void 0, void 0, function* () {
439
404
  const info = yield deviceInfo(baseURL)(jwtToken, macAddress);
440
- return info.nvm.user_parameters.enviroment_1_temperature;
405
+ const fields = {
406
+ 1: info.nvm.user_parameters.enviroment_1_temperature,
407
+ 2: info.nvm.user_parameters.enviroment_2_temperature,
408
+ 3: info.nvm.user_parameters.enviroment_3_temperature,
409
+ };
410
+ return fields[envIndex];
441
411
  });
442
412
  const setTargetTemperature = (baseURL) =>
443
413
  /**
444
- * Sends a command to set the target temperature (degree celsius) of a device.
414
+ * Sets the target temperature for an environment zone.
445
415
  *
446
416
  * @param {string} jwtToken - The JWT token for authentication.
447
417
  * @param {string} macAddress - The MAC address of the device.
448
- * @param {number} temperature - The desired target temperature (degree celsius).
449
- * @returns {Promise<string>} - A promise that resolves to the command response.
450
- */
451
- (jwtToken, macAddress, temperature) => mqttCommand(baseURL)(jwtToken, macAddress, {
452
- name: "enviroment_1_temperature",
453
- value: temperature,
454
- });
455
- const setEnvironment2Temperature = (baseURL) =>
456
- /**
457
- * Sets the target temperature for Environment 2 zone.
458
- *
459
- * @param {string} jwtToken - The JWT token for authentication.
460
- * @param {string} macAddress - The MAC address of the device.
461
- * @param {number} temperature - The target temperature in degrees Celsius.
418
+ * @param {1 | 2 | 3} envIndex - The environment zone index (1, 2, or 3).
419
+ * @param {number} temperature - The desired target temperature (degrees Celsius).
462
420
  * @returns {Promise<unknown>} - A promise that resolves to the command response.
463
421
  */
464
- (jwtToken, macAddress, temperature) => mqttCommand(baseURL)(jwtToken, macAddress, {
465
- name: "enviroment_2_temperature",
422
+ (jwtToken, macAddress, envIndex, temperature) => mqttCommand(baseURL)(jwtToken, macAddress, {
423
+ name: `enviroment_${envIndex}_temperature`,
466
424
  value: temperature,
467
425
  });
468
- const getEnvironment2Temperature = (baseURL) =>
469
- /**
470
- * Retrieves the target temperature for Environment 2 zone.
471
- *
472
- * @param {string} jwtToken - The JWT token for authentication.
473
- * @param {string} macAddress - The MAC address of the device.
474
- * @returns {Promise<number>} - A promise that resolves to the temperature in degrees Celsius.
475
- */
476
- (jwtToken, macAddress) => __awaiter(void 0, void 0, void 0, function* () {
477
- const info = yield deviceInfo(baseURL)(jwtToken, macAddress);
478
- return info.nvm.user_parameters.enviroment_2_temperature;
479
- });
480
- const setEnvironment3Temperature = (baseURL) =>
481
- /**
482
- * Sets the target temperature for Environment 3 zone.
483
- *
484
- * @param {string} jwtToken - The JWT token for authentication.
485
- * @param {string} macAddress - The MAC address of the device.
486
- * @param {number} temperature - The target temperature in degrees Celsius.
487
- * @returns {Promise<unknown>} - A promise that resolves to the command response.
488
- */
489
- (jwtToken, macAddress, temperature) => mqttCommand(baseURL)(jwtToken, macAddress, {
490
- name: "enviroment_3_temperature",
491
- value: temperature,
492
- });
493
- const getEnvironment3Temperature = (baseURL) =>
494
- /**
495
- * Retrieves the target temperature for Environment 3 zone.
496
- *
497
- * @param {string} jwtToken - The JWT token for authentication.
498
- * @param {string} macAddress - The MAC address of the device.
499
- * @returns {Promise<number>} - A promise that resolves to the temperature in degrees Celsius.
500
- */
501
- (jwtToken, macAddress) => __awaiter(void 0, void 0, void 0, function* () {
502
- const info = yield deviceInfo(baseURL)(jwtToken, macAddress);
503
- return info.nvm.user_parameters.enviroment_3_temperature;
504
- });
426
+ // Environment temperature aliases for convenience
427
+ const setEnvironment1Temperature = (baseURL) => (jwtToken, macAddress, temperature) => setTargetTemperature(baseURL)(jwtToken, macAddress, 1, temperature);
428
+ const setEnvironment2Temperature = (baseURL) => (jwtToken, macAddress, temperature) => setTargetTemperature(baseURL)(jwtToken, macAddress, 2, temperature);
429
+ const setEnvironment3Temperature = (baseURL) => (jwtToken, macAddress, temperature) => setTargetTemperature(baseURL)(jwtToken, macAddress, 3, temperature);
430
+ const getEnvironment1Temperature = (baseURL) => (jwtToken, macAddress) => getTargetTemperature(baseURL)(jwtToken, macAddress, 1);
431
+ const getEnvironment2Temperature = (baseURL) => (jwtToken, macAddress) => getTargetTemperature(baseURL)(jwtToken, macAddress, 2);
432
+ const getEnvironment3Temperature = (baseURL) => (jwtToken, macAddress) => getTargetTemperature(baseURL)(jwtToken, macAddress, 3);
505
433
  const setMeasureUnit = (baseURL) =>
506
434
  /**
507
435
  * Sets the temperature measurement unit (Celsius or Fahrenheit).
@@ -586,6 +514,194 @@ const getPelletAutonomyTime = (baseURL) =>
586
514
  const info = yield deviceInfo(baseURL)(jwtToken, macAddress);
587
515
  return info.status.pellet.autonomy_time;
588
516
  });
517
+ const getTotalCounters = (baseURL) =>
518
+ /**
519
+ * Retrieves lifetime operating counters.
520
+ * Includes power-on count and runtime hours per power level.
521
+ * These counters are never reset.
522
+ *
523
+ * @param {string} jwtToken - The JWT token for authentication.
524
+ * @param {string} macAddress - The MAC address of the device.
525
+ * @returns {Promise<TotalCountersType>} - Lifetime operating statistics.
526
+ */
527
+ (jwtToken, macAddress) => __awaiter(void 0, void 0, void 0, function* () {
528
+ const info = yield deviceInfo(baseURL)(jwtToken, macAddress);
529
+ return info.nvm.total_counters;
530
+ });
531
+ const getServiceCounters = (baseURL) =>
532
+ /**
533
+ * Retrieves service counters (runtime since last maintenance).
534
+ * These counters track hours per power level since last service reset.
535
+ *
536
+ * @param {string} jwtToken - The JWT token for authentication.
537
+ * @param {string} macAddress - The MAC address of the device.
538
+ * @returns {Promise<ServiceCountersType>} - Service tracking statistics.
539
+ */
540
+ (jwtToken, macAddress) => __awaiter(void 0, void 0, void 0, function* () {
541
+ const info = yield deviceInfo(baseURL)(jwtToken, macAddress);
542
+ return info.nvm.service_counters;
543
+ });
544
+ const getAlarmHistory = (baseURL) =>
545
+ /**
546
+ * Retrieves the alarm history log.
547
+ * Contains a circular buffer of recent alarms with timestamps.
548
+ *
549
+ * @param {string} jwtToken - The JWT token for authentication.
550
+ * @param {string} macAddress - The MAC address of the device.
551
+ * @returns {Promise<AlarmsLogType>} - Alarm history log.
552
+ */
553
+ (jwtToken, macAddress) => __awaiter(void 0, void 0, void 0, function* () {
554
+ const info = yield deviceInfo(baseURL)(jwtToken, macAddress);
555
+ return info.nvm.alarms_log;
556
+ });
557
+ const getRegenerationData = (baseURL) =>
558
+ /**
559
+ * Retrieves regeneration and maintenance data.
560
+ * Includes blackout counter and last intervention timestamp.
561
+ *
562
+ * @param {string} jwtToken - The JWT token for authentication.
563
+ * @param {string} macAddress - The MAC address of the device.
564
+ * @returns {Promise<RegenerationDataType>} - Maintenance tracking data.
565
+ */
566
+ (jwtToken, macAddress) => __awaiter(void 0, void 0, void 0, function* () {
567
+ const info = yield deviceInfo(baseURL)(jwtToken, macAddress);
568
+ return info.nvm.regeneration;
569
+ });
570
+ const getServiceTime = (baseURL) =>
571
+ /**
572
+ * Retrieves the total service time in hours.
573
+ *
574
+ * @param {string} jwtToken - The JWT token for authentication.
575
+ * @param {string} macAddress - The MAC address of the device.
576
+ * @returns {Promise<number>} - Total service hours.
577
+ */
578
+ (jwtToken, macAddress) => __awaiter(void 0, void 0, void 0, function* () {
579
+ const info = yield deviceInfo(baseURL)(jwtToken, macAddress);
580
+ return info.status.counters.service_time;
581
+ });
582
+ /**
583
+ * Default service threshold in hours (from OEM parameters).
584
+ * Most devices use 2000 hours.
585
+ */
586
+ const DEFAULT_SERVICE_THRESHOLD = 2000;
587
+ const getTotalOperatingHours = (baseURL) =>
588
+ /**
589
+ * Calculates total operating hours across all power levels.
590
+ *
591
+ * @param {string} jwtToken - The JWT token for authentication.
592
+ * @param {string} macAddress - The MAC address of the device.
593
+ * @returns {Promise<number>} - Total operating hours.
594
+ */
595
+ (jwtToken, macAddress) => __awaiter(void 0, void 0, void 0, function* () {
596
+ const counters = yield getTotalCounters(baseURL)(jwtToken, macAddress);
597
+ return (counters.p1_working_time +
598
+ counters.p2_working_time +
599
+ counters.p3_working_time +
600
+ counters.p4_working_time +
601
+ counters.p5_working_time);
602
+ });
603
+ const getPowerDistribution = (baseURL) =>
604
+ /**
605
+ * Calculates power level usage distribution as percentages.
606
+ *
607
+ * @param {string} jwtToken - The JWT token for authentication.
608
+ * @param {string} macAddress - The MAC address of the device.
609
+ * @returns {Promise<PowerDistributionType>} - Percentage time at each power level.
610
+ */
611
+ (jwtToken, macAddress) => __awaiter(void 0, void 0, void 0, function* () {
612
+ const counters = yield getTotalCounters(baseURL)(jwtToken, macAddress);
613
+ const total = counters.p1_working_time +
614
+ counters.p2_working_time +
615
+ counters.p3_working_time +
616
+ counters.p4_working_time +
617
+ counters.p5_working_time;
618
+ if (total === 0) {
619
+ return { p1: 0, p2: 0, p3: 0, p4: 0, p5: 0 };
620
+ }
621
+ return {
622
+ p1: (counters.p1_working_time / total) * 100,
623
+ p2: (counters.p2_working_time / total) * 100,
624
+ p3: (counters.p3_working_time / total) * 100,
625
+ p4: (counters.p4_working_time / total) * 100,
626
+ p5: (counters.p5_working_time / total) * 100,
627
+ };
628
+ });
629
+ const getServiceStatus = (baseURL) =>
630
+ /**
631
+ * Calculates service status including whether maintenance is due.
632
+ *
633
+ * @param {string} jwtToken - The JWT token for authentication.
634
+ * @param {string} macAddress - The MAC address of the device.
635
+ * @param {number} [thresholdHours=2000] - Service threshold in hours.
636
+ * @returns {Promise<ServiceStatusType>} - Service status with computed fields.
637
+ */
638
+ (jwtToken_1, macAddress_1, ...args_1) => __awaiter(void 0, [jwtToken_1, macAddress_1, ...args_1], void 0, function* (jwtToken, macAddress, thresholdHours = DEFAULT_SERVICE_THRESHOLD) {
639
+ const info = yield deviceInfo(baseURL)(jwtToken, macAddress);
640
+ const serviceCounters = info.nvm.service_counters;
641
+ const hoursSinceService = serviceCounters.p1_working_time +
642
+ serviceCounters.p2_working_time +
643
+ serviceCounters.p3_working_time +
644
+ serviceCounters.p4_working_time +
645
+ serviceCounters.p5_working_time;
646
+ return {
647
+ totalServiceHours: info.status.counters.service_time,
648
+ hoursSinceService,
649
+ serviceThresholdHours: thresholdHours,
650
+ isServiceDue: hoursSinceService >= thresholdHours,
651
+ };
652
+ });
653
+ const getUsageAnalytics = (baseURL) =>
654
+ /**
655
+ * Retrieves comprehensive usage analytics in a single call.
656
+ * Combines multiple statistics into a unified analytics object.
657
+ *
658
+ * @param {string} jwtToken - The JWT token for authentication.
659
+ * @param {string} macAddress - The MAC address of the device.
660
+ * @param {number} [serviceThreshold=2000] - Service threshold in hours.
661
+ * @returns {Promise<UsageAnalyticsType>} - Comprehensive usage analytics.
662
+ */
663
+ (jwtToken_1, macAddress_1, ...args_1) => __awaiter(void 0, [jwtToken_1, macAddress_1, ...args_1], void 0, function* (jwtToken, macAddress, serviceThreshold = DEFAULT_SERVICE_THRESHOLD) {
664
+ const info = yield deviceInfo(baseURL)(jwtToken, macAddress);
665
+ const totalCounters = info.nvm.total_counters;
666
+ const serviceCounters = info.nvm.service_counters;
667
+ const regeneration = info.nvm.regeneration;
668
+ const alarmsLog = info.nvm.alarms_log;
669
+ const totalOperatingHours = totalCounters.p1_working_time +
670
+ totalCounters.p2_working_time +
671
+ totalCounters.p3_working_time +
672
+ totalCounters.p4_working_time +
673
+ totalCounters.p5_working_time;
674
+ const hoursSinceService = serviceCounters.p1_working_time +
675
+ serviceCounters.p2_working_time +
676
+ serviceCounters.p3_working_time +
677
+ serviceCounters.p4_working_time +
678
+ serviceCounters.p5_working_time;
679
+ const powerDistribution = totalOperatingHours === 0
680
+ ? { p1: 0, p2: 0, p3: 0, p4: 0, p5: 0 }
681
+ : {
682
+ p1: (totalCounters.p1_working_time / totalOperatingHours) * 100,
683
+ p2: (totalCounters.p2_working_time / totalOperatingHours) * 100,
684
+ p3: (totalCounters.p3_working_time / totalOperatingHours) * 100,
685
+ p4: (totalCounters.p4_working_time / totalOperatingHours) * 100,
686
+ p5: (totalCounters.p5_working_time / totalOperatingHours) * 100,
687
+ };
688
+ return {
689
+ totalPowerOns: totalCounters.power_ons,
690
+ totalOperatingHours,
691
+ powerDistribution,
692
+ serviceStatus: {
693
+ totalServiceHours: info.status.counters.service_time,
694
+ hoursSinceService,
695
+ serviceThresholdHours: serviceThreshold,
696
+ isServiceDue: hoursSinceService >= serviceThreshold,
697
+ },
698
+ blackoutCount: regeneration.blackout_counter,
699
+ lastMaintenanceDate: regeneration.last_intervention > 0
700
+ ? new Date(regeneration.last_intervention * 1000)
701
+ : null,
702
+ alarmCount: alarmsLog.number,
703
+ };
704
+ });
589
705
  const registerDevice = (baseURL) =>
590
706
  /**
591
707
  * Registers a device with the user's account.
@@ -654,6 +770,8 @@ const configure = (baseURL = constants_1.API_URL) => ({
654
770
  getPower: getPower(baseURL),
655
771
  setPowerLevel: setPowerLevel(baseURL),
656
772
  getPowerLevel: getPowerLevel(baseURL),
773
+ setFanSpeed: setFanSpeed(baseURL),
774
+ getFanSpeed: getFanSpeed(baseURL),
657
775
  setFan1Speed: setFan1Speed(baseURL),
658
776
  setFan2Speed: setFan2Speed(baseURL),
659
777
  setFan3Speed: setFan3Speed(baseURL),
@@ -671,6 +789,8 @@ const configure = (baseURL = constants_1.API_URL) => ({
671
789
  getEnvironmentTemperature: getEnvironmentTemperature(baseURL),
672
790
  getTargetTemperature: getTargetTemperature(baseURL),
673
791
  setTargetTemperature: setTargetTemperature(baseURL),
792
+ setEnvironment1Temperature: setEnvironment1Temperature(baseURL),
793
+ getEnvironment1Temperature: getEnvironment1Temperature(baseURL),
674
794
  setEnvironment2Temperature: setEnvironment2Temperature(baseURL),
675
795
  getEnvironment2Temperature: getEnvironment2Temperature(baseURL),
676
796
  setEnvironment3Temperature: setEnvironment3Temperature(baseURL),
@@ -681,5 +801,16 @@ const configure = (baseURL = constants_1.API_URL) => ({
681
801
  getLanguage: getLanguage(baseURL),
682
802
  getPelletInReserve: getPelletInReserve(baseURL),
683
803
  getPelletAutonomyTime: getPelletAutonomyTime(baseURL),
804
+ // Statistics getters
805
+ getTotalCounters: getTotalCounters(baseURL),
806
+ getServiceCounters: getServiceCounters(baseURL),
807
+ getAlarmHistory: getAlarmHistory(baseURL),
808
+ getRegenerationData: getRegenerationData(baseURL),
809
+ getServiceTime: getServiceTime(baseURL),
810
+ // Analytics functions
811
+ getTotalOperatingHours: getTotalOperatingHours(baseURL),
812
+ getPowerDistribution: getPowerDistribution(baseURL),
813
+ getServiceStatus: getServiceStatus(baseURL),
814
+ getUsageAnalytics: getUsageAnalytics(baseURL),
684
815
  });
685
816
  exports.configure = configure;