edilkamin 1.8.0 → 1.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/library.ts CHANGED
@@ -206,6 +206,224 @@ const setPowerOff =
206
206
  (jwtToken: string, macAddress: string) =>
207
207
  setPower(baseURL)(jwtToken, macAddress, 0);
208
208
 
209
+ const setPowerLevel =
210
+ (baseURL: string) =>
211
+ /**
212
+ * Sets the manual power level of the device.
213
+ *
214
+ * @param {string} jwtToken - The JWT token for authentication.
215
+ * @param {string} macAddress - The MAC address of the device.
216
+ * @param {number} level - The power level (1-5).
217
+ * @returns {Promise<unknown>} - A promise that resolves to the command response.
218
+ */
219
+ (jwtToken: string, macAddress: string, level: number) =>
220
+ mqttCommand(baseURL)(jwtToken, macAddress, {
221
+ name: "power_level",
222
+ value: level,
223
+ });
224
+
225
+ const getPowerLevel =
226
+ (baseURL: string) =>
227
+ /**
228
+ * Retrieves the current manual power level of the device.
229
+ *
230
+ * @param {string} jwtToken - The JWT token for authentication.
231
+ * @param {string} macAddress - The MAC address of the device.
232
+ * @returns {Promise<number>} - A promise that resolves to the power level (1-5).
233
+ */
234
+ async (jwtToken: string, macAddress: string): Promise<number> => {
235
+ const info = await deviceInfo(baseURL)(jwtToken, macAddress);
236
+ return info.nvm.user_parameters.manual_power;
237
+ };
238
+
239
+ const setFanSpeed =
240
+ (baseURL: string) =>
241
+ /**
242
+ * Sets the speed of a fan by index.
243
+ *
244
+ * @param {string} jwtToken - The JWT token for authentication.
245
+ * @param {string} macAddress - The MAC address of the device.
246
+ * @param {1 | 2 | 3} fanIndex - The fan index (1, 2, or 3).
247
+ * @param {number} speed - The fan speed (0-5, 0=auto on some models).
248
+ * @returns {Promise<unknown>} - A promise that resolves to the command response.
249
+ */
250
+ (jwtToken: string, macAddress: string, fanIndex: 1 | 2 | 3, speed: number) =>
251
+ mqttCommand(baseURL)(jwtToken, macAddress, {
252
+ name: `fan_${fanIndex}_speed`,
253
+ value: speed,
254
+ });
255
+
256
+ const getFanSpeed =
257
+ (baseURL: string) =>
258
+ /**
259
+ * Retrieves the current speed of a fan by index.
260
+ *
261
+ * @param {string} jwtToken - The JWT token for authentication.
262
+ * @param {string} macAddress - The MAC address of the device.
263
+ * @param {1 | 2 | 3} fanIndex - The fan index (1, 2, or 3).
264
+ * @returns {Promise<number>} - A promise that resolves to the fan speed.
265
+ */
266
+ async (
267
+ jwtToken: string,
268
+ macAddress: string,
269
+ fanIndex: 1 | 2 | 3,
270
+ ): Promise<number> => {
271
+ const info = await deviceInfo(baseURL)(jwtToken, macAddress);
272
+ const fields: Record<1 | 2 | 3, number> = {
273
+ 1: info.nvm.user_parameters.fan_1_ventilation,
274
+ 2: info.nvm.user_parameters.fan_2_ventilation,
275
+ 3: info.nvm.user_parameters.fan_3_ventilation,
276
+ };
277
+ return fields[fanIndex];
278
+ };
279
+
280
+ // Fan speed aliases for convenience
281
+ const setFan1Speed =
282
+ (baseURL: string) => (jwtToken: string, macAddress: string, speed: number) =>
283
+ setFanSpeed(baseURL)(jwtToken, macAddress, 1, speed);
284
+
285
+ const setFan2Speed =
286
+ (baseURL: string) => (jwtToken: string, macAddress: string, speed: number) =>
287
+ setFanSpeed(baseURL)(jwtToken, macAddress, 2, speed);
288
+
289
+ const setFan3Speed =
290
+ (baseURL: string) => (jwtToken: string, macAddress: string, speed: number) =>
291
+ setFanSpeed(baseURL)(jwtToken, macAddress, 3, speed);
292
+
293
+ const getFan1Speed =
294
+ (baseURL: string) => (jwtToken: string, macAddress: string) =>
295
+ getFanSpeed(baseURL)(jwtToken, macAddress, 1);
296
+
297
+ const getFan2Speed =
298
+ (baseURL: string) => (jwtToken: string, macAddress: string) =>
299
+ getFanSpeed(baseURL)(jwtToken, macAddress, 2);
300
+
301
+ const getFan3Speed =
302
+ (baseURL: string) => (jwtToken: string, macAddress: string) =>
303
+ getFanSpeed(baseURL)(jwtToken, macAddress, 3);
304
+
305
+ const setAirkare =
306
+ (baseURL: string) =>
307
+ /**
308
+ * Enables or disables Airkare (air quality) mode.
309
+ *
310
+ * @param {string} jwtToken - The JWT token for authentication.
311
+ * @param {string} macAddress - The MAC address of the device.
312
+ * @param {boolean} enabled - Whether to enable Airkare mode.
313
+ * @returns {Promise<unknown>} - A promise that resolves to the command response.
314
+ */
315
+ (jwtToken: string, macAddress: string, enabled: boolean) =>
316
+ mqttCommand(baseURL)(jwtToken, macAddress, {
317
+ name: "airkare_function",
318
+ value: enabled ? 1 : 0,
319
+ });
320
+
321
+ const setRelax =
322
+ (baseURL: string) =>
323
+ /**
324
+ * Enables or disables Relax (comfort) mode.
325
+ *
326
+ * @param {string} jwtToken - The JWT token for authentication.
327
+ * @param {string} macAddress - The MAC address of the device.
328
+ * @param {boolean} enabled - Whether to enable Relax mode.
329
+ * @returns {Promise<unknown>} - A promise that resolves to the command response.
330
+ */
331
+ (jwtToken: string, macAddress: string, enabled: boolean) =>
332
+ mqttCommand(baseURL)(jwtToken, macAddress, {
333
+ name: "relax_mode",
334
+ value: enabled,
335
+ });
336
+
337
+ const setStandby =
338
+ (baseURL: string) =>
339
+ /**
340
+ * Enables or disables Standby mode.
341
+ *
342
+ * @param {string} jwtToken - The JWT token for authentication.
343
+ * @param {string} macAddress - The MAC address of the device.
344
+ * @param {boolean} enabled - Whether to enable Standby mode.
345
+ * @returns {Promise<unknown>} - A promise that resolves to the command response.
346
+ */
347
+ (jwtToken: string, macAddress: string, enabled: boolean) =>
348
+ mqttCommand(baseURL)(jwtToken, macAddress, {
349
+ name: "standby_mode",
350
+ value: enabled,
351
+ });
352
+
353
+ const getStandby =
354
+ (baseURL: string) =>
355
+ /**
356
+ * Retrieves the current Standby mode status.
357
+ *
358
+ * @param {string} jwtToken - The JWT token for authentication.
359
+ * @param {string} macAddress - The MAC address of the device.
360
+ * @returns {Promise<boolean>} - A promise that resolves to the standby status.
361
+ */
362
+ async (jwtToken: string, macAddress: string): Promise<boolean> => {
363
+ const info = await deviceInfo(baseURL)(jwtToken, macAddress);
364
+ return info.nvm.user_parameters.is_standby_active;
365
+ };
366
+
367
+ const setStandbyTime =
368
+ (baseURL: string) =>
369
+ /**
370
+ * Sets the standby waiting time in minutes.
371
+ *
372
+ * @param {string} jwtToken - The JWT token for authentication.
373
+ * @param {string} macAddress - The MAC address of the device.
374
+ * @param {number} minutes - The standby waiting time in minutes.
375
+ * @returns {Promise<unknown>} - A promise that resolves to the command response.
376
+ */
377
+ (jwtToken: string, macAddress: string, minutes: number) =>
378
+ mqttCommand(baseURL)(jwtToken, macAddress, {
379
+ name: "standby_time",
380
+ value: minutes,
381
+ });
382
+
383
+ const getStandbyTime =
384
+ (baseURL: string) =>
385
+ /**
386
+ * Retrieves the standby waiting time in minutes.
387
+ *
388
+ * @param {string} jwtToken - The JWT token for authentication.
389
+ * @param {string} macAddress - The MAC address of the device.
390
+ * @returns {Promise<number>} - A promise that resolves to the standby time in minutes.
391
+ */
392
+ async (jwtToken: string, macAddress: string): Promise<number> => {
393
+ const info = await deviceInfo(baseURL)(jwtToken, macAddress);
394
+ return info.nvm.user_parameters.standby_waiting_time;
395
+ };
396
+
397
+ const setAuto =
398
+ (baseURL: string) =>
399
+ /**
400
+ * Enables or disables Auto mode for automatic temperature regulation.
401
+ *
402
+ * @param {string} jwtToken - The JWT token for authentication.
403
+ * @param {string} macAddress - The MAC address of the device.
404
+ * @param {boolean} enabled - Whether to enable Auto mode.
405
+ * @returns {Promise<unknown>} - A promise that resolves to the command response.
406
+ */
407
+ (jwtToken: string, macAddress: string, enabled: boolean) =>
408
+ mqttCommand(baseURL)(jwtToken, macAddress, {
409
+ name: "auto_mode",
410
+ value: enabled,
411
+ });
412
+
413
+ const getAuto =
414
+ (baseURL: string) =>
415
+ /**
416
+ * Retrieves the current Auto mode status.
417
+ *
418
+ * @param {string} jwtToken - The JWT token for authentication.
419
+ * @param {string} macAddress - The MAC address of the device.
420
+ * @returns {Promise<boolean>} - A promise that resolves to the auto mode status.
421
+ */
422
+ async (jwtToken: string, macAddress: string): Promise<boolean> => {
423
+ const info = await deviceInfo(baseURL)(jwtToken, macAddress);
424
+ return info.nvm.user_parameters.is_auto;
425
+ };
426
+
209
427
  const getPower =
210
428
  (baseURL: string) =>
211
429
  /**
@@ -237,33 +455,175 @@ const getEnvironmentTemperature =
237
455
  const getTargetTemperature =
238
456
  (baseURL: string) =>
239
457
  /**
240
- * Retrieves the target temperature value set on the device.
458
+ * Retrieves the target temperature for an environment zone.
241
459
  *
242
460
  * @param {string} jwtToken - The JWT token for authentication.
243
461
  * @param {string} macAddress - The MAC address of the device.
244
- * @returns {Promise<number>} - A promise that resolves to the target temperature (degree celsius).
462
+ * @param {1 | 2 | 3} envIndex - The environment zone index (1, 2, or 3).
463
+ * @returns {Promise<number>} - A promise that resolves to the target temperature (degrees Celsius).
245
464
  */
246
- async (jwtToken: string, macAddress: string): Promise<number> => {
465
+ async (
466
+ jwtToken: string,
467
+ macAddress: string,
468
+ envIndex: 1 | 2 | 3,
469
+ ): Promise<number> => {
247
470
  const info = await deviceInfo(baseURL)(jwtToken, macAddress);
248
- return info.nvm.user_parameters.enviroment_1_temperature;
471
+ const fields: Record<1 | 2 | 3, number> = {
472
+ 1: info.nvm.user_parameters.enviroment_1_temperature,
473
+ 2: info.nvm.user_parameters.enviroment_2_temperature,
474
+ 3: info.nvm.user_parameters.enviroment_3_temperature,
475
+ };
476
+ return fields[envIndex];
249
477
  };
250
478
 
251
479
  const setTargetTemperature =
252
480
  (baseURL: string) =>
253
481
  /**
254
- * Sends a command to set the target temperature (degree celsius) of a device.
482
+ * Sets the target temperature for an environment zone.
255
483
  *
256
484
  * @param {string} jwtToken - The JWT token for authentication.
257
485
  * @param {string} macAddress - The MAC address of the device.
258
- * @param {number} temperature - The desired target temperature (degree celsius).
259
- * @returns {Promise<string>} - A promise that resolves to the command response.
486
+ * @param {1 | 2 | 3} envIndex - The environment zone index (1, 2, or 3).
487
+ * @param {number} temperature - The desired target temperature (degrees Celsius).
488
+ * @returns {Promise<unknown>} - A promise that resolves to the command response.
260
489
  */
261
- (jwtToken: string, macAddress: string, temperature: number) =>
490
+ (
491
+ jwtToken: string,
492
+ macAddress: string,
493
+ envIndex: 1 | 2 | 3,
494
+ temperature: number,
495
+ ) =>
262
496
  mqttCommand(baseURL)(jwtToken, macAddress, {
263
- name: "enviroment_1_temperature",
497
+ name: `enviroment_${envIndex}_temperature`,
264
498
  value: temperature,
265
499
  });
266
500
 
501
+ // Environment temperature aliases for convenience
502
+ const setEnvironment1Temperature =
503
+ (baseURL: string) =>
504
+ (jwtToken: string, macAddress: string, temperature: number) =>
505
+ setTargetTemperature(baseURL)(jwtToken, macAddress, 1, temperature);
506
+
507
+ const setEnvironment2Temperature =
508
+ (baseURL: string) =>
509
+ (jwtToken: string, macAddress: string, temperature: number) =>
510
+ setTargetTemperature(baseURL)(jwtToken, macAddress, 2, temperature);
511
+
512
+ const setEnvironment3Temperature =
513
+ (baseURL: string) =>
514
+ (jwtToken: string, macAddress: string, temperature: number) =>
515
+ setTargetTemperature(baseURL)(jwtToken, macAddress, 3, temperature);
516
+
517
+ const getEnvironment1Temperature =
518
+ (baseURL: string) => (jwtToken: string, macAddress: string) =>
519
+ getTargetTemperature(baseURL)(jwtToken, macAddress, 1);
520
+
521
+ const getEnvironment2Temperature =
522
+ (baseURL: string) => (jwtToken: string, macAddress: string) =>
523
+ getTargetTemperature(baseURL)(jwtToken, macAddress, 2);
524
+
525
+ const getEnvironment3Temperature =
526
+ (baseURL: string) => (jwtToken: string, macAddress: string) =>
527
+ getTargetTemperature(baseURL)(jwtToken, macAddress, 3);
528
+
529
+ const setMeasureUnit =
530
+ (baseURL: string) =>
531
+ /**
532
+ * Sets the temperature measurement unit (Celsius or Fahrenheit).
533
+ *
534
+ * @param {string} jwtToken - The JWT token for authentication.
535
+ * @param {string} macAddress - The MAC address of the device.
536
+ * @param {boolean} isFahrenheit - true for Fahrenheit, false for Celsius.
537
+ * @returns {Promise<unknown>} - A promise that resolves to the command response.
538
+ */
539
+ (jwtToken: string, macAddress: string, isFahrenheit: boolean) =>
540
+ mqttCommand(baseURL)(jwtToken, macAddress, {
541
+ name: "measure_unit",
542
+ value: isFahrenheit,
543
+ });
544
+
545
+ const getMeasureUnit =
546
+ (baseURL: string) =>
547
+ /**
548
+ * Retrieves the current temperature measurement unit setting.
549
+ *
550
+ * @param {string} jwtToken - The JWT token for authentication.
551
+ * @param {string} macAddress - The MAC address of the device.
552
+ * @returns {Promise<boolean>} - A promise that resolves to true if Fahrenheit, false if Celsius.
553
+ */
554
+ async (jwtToken: string, macAddress: string): Promise<boolean> => {
555
+ const info = await deviceInfo(baseURL)(jwtToken, macAddress);
556
+ return info.nvm.user_parameters.is_fahrenheit;
557
+ };
558
+
559
+ const setLanguage =
560
+ (baseURL: string) =>
561
+ /**
562
+ * Sets the display language of the device.
563
+ *
564
+ * Language codes:
565
+ * 0=Italian, 1=French, 2=English, 3=Spanish, 4=Portuguese,
566
+ * 5=Danish, 6=Dutch, 7=German, 8=Hungarian, 9=Polish
567
+ *
568
+ * @param {string} jwtToken - The JWT token for authentication.
569
+ * @param {string} macAddress - The MAC address of the device.
570
+ * @param {number} languageCode - The language code (0-9).
571
+ * @returns {Promise<unknown>} - A promise that resolves to the command response.
572
+ */
573
+ (jwtToken: string, macAddress: string, languageCode: number) =>
574
+ mqttCommand(baseURL)(jwtToken, macAddress, {
575
+ name: "language",
576
+ value: languageCode,
577
+ });
578
+
579
+ const getLanguage =
580
+ (baseURL: string) =>
581
+ /**
582
+ * Retrieves the current display language setting.
583
+ *
584
+ * Language codes:
585
+ * 0=Italian, 1=French, 2=English, 3=Spanish, 4=Portuguese,
586
+ * 5=Danish, 6=Dutch, 7=German, 8=Hungarian, 9=Polish
587
+ *
588
+ * @param {string} jwtToken - The JWT token for authentication.
589
+ * @param {string} macAddress - The MAC address of the device.
590
+ * @returns {Promise<number>} - A promise that resolves to the language code (0-9).
591
+ */
592
+ async (jwtToken: string, macAddress: string): Promise<number> => {
593
+ const info = await deviceInfo(baseURL)(jwtToken, macAddress);
594
+ return info.nvm.user_parameters.language;
595
+ };
596
+
597
+ const getPelletInReserve =
598
+ (baseURL: string) =>
599
+ /**
600
+ * Retrieves the pellet reserve status.
601
+ * Returns true if pellet level is low (in reserve), false if pellet level is ok.
602
+ *
603
+ * @param {string} jwtToken - The JWT token for authentication.
604
+ * @param {string} macAddress - The MAC address of the device.
605
+ * @returns {Promise<boolean>} - A promise that resolves to the pellet reserve status.
606
+ */
607
+ async (jwtToken: string, macAddress: string): Promise<boolean> => {
608
+ const info = await deviceInfo(baseURL)(jwtToken, macAddress);
609
+ return info.status.flags.is_pellet_in_reserve;
610
+ };
611
+
612
+ const getPelletAutonomyTime =
613
+ (baseURL: string) =>
614
+ /**
615
+ * Retrieves the estimated pellet autonomy time.
616
+ * Represents the estimated time remaining with current pellet level.
617
+ *
618
+ * @param {string} jwtToken - The JWT token for authentication.
619
+ * @param {string} macAddress - The MAC address of the device.
620
+ * @returns {Promise<number>} - A promise that resolves to the autonomy time (likely in minutes or hours).
621
+ */
622
+ async (jwtToken: string, macAddress: string): Promise<number> => {
623
+ const info = await deviceInfo(baseURL)(jwtToken, macAddress);
624
+ return info.status.pellet.autonomy_time;
625
+ };
626
+
267
627
  const registerDevice =
268
628
  (baseURL: string) =>
269
629
  /**
@@ -355,9 +715,39 @@ const configure = (baseURL: string = API_URL) => ({
355
715
  setPowerOff: setPowerOff(baseURL),
356
716
  setPowerOn: setPowerOn(baseURL),
357
717
  getPower: getPower(baseURL),
718
+ setPowerLevel: setPowerLevel(baseURL),
719
+ getPowerLevel: getPowerLevel(baseURL),
720
+ setFanSpeed: setFanSpeed(baseURL),
721
+ getFanSpeed: getFanSpeed(baseURL),
722
+ setFan1Speed: setFan1Speed(baseURL),
723
+ setFan2Speed: setFan2Speed(baseURL),
724
+ setFan3Speed: setFan3Speed(baseURL),
725
+ getFan1Speed: getFan1Speed(baseURL),
726
+ getFan2Speed: getFan2Speed(baseURL),
727
+ getFan3Speed: getFan3Speed(baseURL),
728
+ setAirkare: setAirkare(baseURL),
729
+ setRelax: setRelax(baseURL),
730
+ setStandby: setStandby(baseURL),
731
+ getStandby: getStandby(baseURL),
732
+ setStandbyTime: setStandbyTime(baseURL),
733
+ getStandbyTime: getStandbyTime(baseURL),
734
+ setAuto: setAuto(baseURL),
735
+ getAuto: getAuto(baseURL),
358
736
  getEnvironmentTemperature: getEnvironmentTemperature(baseURL),
359
737
  getTargetTemperature: getTargetTemperature(baseURL),
360
738
  setTargetTemperature: setTargetTemperature(baseURL),
739
+ setEnvironment1Temperature: setEnvironment1Temperature(baseURL),
740
+ getEnvironment1Temperature: getEnvironment1Temperature(baseURL),
741
+ setEnvironment2Temperature: setEnvironment2Temperature(baseURL),
742
+ getEnvironment2Temperature: getEnvironment2Temperature(baseURL),
743
+ setEnvironment3Temperature: setEnvironment3Temperature(baseURL),
744
+ getEnvironment3Temperature: getEnvironment3Temperature(baseURL),
745
+ setMeasureUnit: setMeasureUnit(baseURL),
746
+ getMeasureUnit: getMeasureUnit(baseURL),
747
+ setLanguage: setLanguage(baseURL),
748
+ getLanguage: getLanguage(baseURL),
749
+ getPelletInReserve: getPelletInReserve(baseURL),
750
+ getPelletAutonomyTime: getPelletAutonomyTime(baseURL),
361
751
  });
362
752
 
363
753
  export {
package/src/types.ts CHANGED
@@ -16,9 +16,19 @@ interface TemperaturesType {
16
16
  enviroment: number;
17
17
  }
18
18
 
19
+ interface GeneralFlagsType {
20
+ is_pellet_in_reserve: boolean;
21
+ }
22
+
23
+ interface PelletAutonomyType {
24
+ autonomy_time: number;
25
+ }
26
+
19
27
  interface StatusType {
20
28
  commands: CommandsType;
21
29
  temperatures: TemperaturesType;
30
+ flags: GeneralFlagsType;
31
+ pellet: PelletAutonomyType;
22
32
  }
23
33
 
24
34
  interface UserParametersType {
@@ -27,6 +37,14 @@ interface UserParametersType {
27
37
  enviroment_3_temperature: number;
28
38
  is_auto: boolean;
29
39
  is_sound_active: boolean;
40
+ manual_power: number;
41
+ fan_1_ventilation: number;
42
+ fan_2_ventilation: number;
43
+ fan_3_ventilation: number;
44
+ is_standby_active: boolean;
45
+ standby_waiting_time: number;
46
+ is_fahrenheit: boolean;
47
+ language: number;
30
48
  }
31
49
 
32
50
  interface DeviceInfoType {
@@ -105,6 +123,8 @@ export type {
105
123
  DeviceInfoType,
106
124
  DiscoveredDevice,
107
125
  EditDeviceAssociationBody,
126
+ GeneralFlagsType,
127
+ PelletAutonomyType,
108
128
  StatusType,
109
129
  TemperaturesType,
110
130
  UserParametersType,