edilkamin 1.9.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
@@ -236,95 +236,71 @@ const getPowerLevel =
236
236
  return info.nvm.user_parameters.manual_power;
237
237
  };
238
238
 
239
- const setFan1Speed =
239
+ const setFanSpeed =
240
240
  (baseURL: string) =>
241
241
  /**
242
- * Sets the speed of fan 1.
242
+ * Sets the speed of a fan by index.
243
243
  *
244
244
  * @param {string} jwtToken - The JWT token for authentication.
245
245
  * @param {string} macAddress - The MAC address of the device.
246
+ * @param {1 | 2 | 3} fanIndex - The fan index (1, 2, or 3).
246
247
  * @param {number} speed - The fan speed (0-5, 0=auto on some models).
247
248
  * @returns {Promise<unknown>} - A promise that resolves to the command response.
248
249
  */
249
- (jwtToken: string, macAddress: string, speed: number) =>
250
+ (jwtToken: string, macAddress: string, fanIndex: 1 | 2 | 3, speed: number) =>
250
251
  mqttCommand(baseURL)(jwtToken, macAddress, {
251
- name: "fan_1_speed",
252
+ name: `fan_${fanIndex}_speed`,
252
253
  value: speed,
253
254
  });
254
255
 
255
- const setFan2Speed =
256
+ const getFanSpeed =
256
257
  (baseURL: string) =>
257
258
  /**
258
- * Sets the speed of fan 2.
259
+ * Retrieves the current speed of a fan by index.
259
260
  *
260
261
  * @param {string} jwtToken - The JWT token for authentication.
261
262
  * @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.
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.
264
265
  */
265
- (jwtToken: string, macAddress: string, speed: number) =>
266
- mqttCommand(baseURL)(jwtToken, macAddress, {
267
- name: "fan_2_speed",
268
- value: speed,
269
- });
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);
270
288
 
271
289
  const setFan3Speed =
272
- (baseURL: string) =>
273
- /**
274
- * Sets the speed of fan 3.
275
- *
276
- * @param {string} jwtToken - The JWT token for authentication.
277
- * @param {string} macAddress - The MAC address of the device.
278
- * @param {number} speed - The fan speed (0-5, 0=auto on some models).
279
- * @returns {Promise<unknown>} - A promise that resolves to the command response.
280
- */
281
- (jwtToken: string, macAddress: string, speed: number) =>
282
- mqttCommand(baseURL)(jwtToken, macAddress, {
283
- name: "fan_3_speed",
284
- value: speed,
285
- });
290
+ (baseURL: string) => (jwtToken: string, macAddress: string, speed: number) =>
291
+ setFanSpeed(baseURL)(jwtToken, macAddress, 3, speed);
286
292
 
287
293
  const getFan1Speed =
288
- (baseURL: string) =>
289
- /**
290
- * Retrieves the current speed of fan 1.
291
- *
292
- * @param {string} jwtToken - The JWT token for authentication.
293
- * @param {string} macAddress - The MAC address of the device.
294
- * @returns {Promise<number>} - A promise that resolves to the fan speed.
295
- */
296
- async (jwtToken: string, macAddress: string): Promise<number> => {
297
- const info = await deviceInfo(baseURL)(jwtToken, macAddress);
298
- return info.nvm.user_parameters.fan_1_ventilation;
299
- };
294
+ (baseURL: string) => (jwtToken: string, macAddress: string) =>
295
+ getFanSpeed(baseURL)(jwtToken, macAddress, 1);
300
296
 
301
297
  const getFan2Speed =
302
- (baseURL: string) =>
303
- /**
304
- * Retrieves the current speed of fan 2.
305
- *
306
- * @param {string} jwtToken - The JWT token for authentication.
307
- * @param {string} macAddress - The MAC address of the device.
308
- * @returns {Promise<number>} - A promise that resolves to the fan speed.
309
- */
310
- async (jwtToken: string, macAddress: string): Promise<number> => {
311
- const info = await deviceInfo(baseURL)(jwtToken, macAddress);
312
- return info.nvm.user_parameters.fan_2_ventilation;
313
- };
298
+ (baseURL: string) => (jwtToken: string, macAddress: string) =>
299
+ getFanSpeed(baseURL)(jwtToken, macAddress, 2);
314
300
 
315
301
  const getFan3Speed =
316
- (baseURL: string) =>
317
- /**
318
- * Retrieves the current speed of fan 3.
319
- *
320
- * @param {string} jwtToken - The JWT token for authentication.
321
- * @param {string} macAddress - The MAC address of the device.
322
- * @returns {Promise<number>} - A promise that resolves to the fan speed.
323
- */
324
- async (jwtToken: string, macAddress: string): Promise<number> => {
325
- const info = await deviceInfo(baseURL)(jwtToken, macAddress);
326
- return info.nvm.user_parameters.fan_3_ventilation;
327
- };
302
+ (baseURL: string) => (jwtToken: string, macAddress: string) =>
303
+ getFanSpeed(baseURL)(jwtToken, macAddress, 3);
328
304
 
329
305
  const setAirkare =
330
306
  (baseURL: string) =>
@@ -479,92 +455,76 @@ const getEnvironmentTemperature =
479
455
  const getTargetTemperature =
480
456
  (baseURL: string) =>
481
457
  /**
482
- * Retrieves the target temperature value set on the device.
458
+ * Retrieves the target temperature for an environment zone.
483
459
  *
484
460
  * @param {string} jwtToken - The JWT token for authentication.
485
461
  * @param {string} macAddress - The MAC address of the device.
486
- * @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).
487
464
  */
488
- async (jwtToken: string, macAddress: string): Promise<number> => {
465
+ async (
466
+ jwtToken: string,
467
+ macAddress: string,
468
+ envIndex: 1 | 2 | 3,
469
+ ): Promise<number> => {
489
470
  const info = await deviceInfo(baseURL)(jwtToken, macAddress);
490
- 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];
491
477
  };
492
478
 
493
479
  const setTargetTemperature =
494
480
  (baseURL: string) =>
495
481
  /**
496
- * Sends a command to set the target temperature (degree celsius) of a device.
482
+ * Sets the target temperature for an environment zone.
497
483
  *
498
484
  * @param {string} jwtToken - The JWT token for authentication.
499
485
  * @param {string} macAddress - The MAC address of the device.
500
- * @param {number} temperature - The desired target temperature (degree celsius).
501
- * @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.
502
489
  */
503
- (jwtToken: string, macAddress: string, temperature: number) =>
490
+ (
491
+ jwtToken: string,
492
+ macAddress: string,
493
+ envIndex: 1 | 2 | 3,
494
+ temperature: number,
495
+ ) =>
504
496
  mqttCommand(baseURL)(jwtToken, macAddress, {
505
- name: "enviroment_1_temperature",
497
+ name: `enviroment_${envIndex}_temperature`,
506
498
  value: temperature,
507
499
  });
508
500
 
509
- const setEnvironment2Temperature =
501
+ // Environment temperature aliases for convenience
502
+ const setEnvironment1Temperature =
510
503
  (baseURL: string) =>
511
- /**
512
- * Sets the target temperature for Environment 2 zone.
513
- *
514
- * @param {string} jwtToken - The JWT token for authentication.
515
- * @param {string} macAddress - The MAC address of the device.
516
- * @param {number} temperature - The target temperature in degrees Celsius.
517
- * @returns {Promise<unknown>} - A promise that resolves to the command response.
518
- */
519
504
  (jwtToken: string, macAddress: string, temperature: number) =>
520
- mqttCommand(baseURL)(jwtToken, macAddress, {
521
- name: "enviroment_2_temperature",
522
- value: temperature,
523
- });
505
+ setTargetTemperature(baseURL)(jwtToken, macAddress, 1, temperature);
524
506
 
525
- const getEnvironment2Temperature =
507
+ const setEnvironment2Temperature =
526
508
  (baseURL: string) =>
527
- /**
528
- * Retrieves the target temperature for Environment 2 zone.
529
- *
530
- * @param {string} jwtToken - The JWT token for authentication.
531
- * @param {string} macAddress - The MAC address of the device.
532
- * @returns {Promise<number>} - A promise that resolves to the temperature in degrees Celsius.
533
- */
534
- async (jwtToken: string, macAddress: string): Promise<number> => {
535
- const info = await deviceInfo(baseURL)(jwtToken, macAddress);
536
- return info.nvm.user_parameters.enviroment_2_temperature;
537
- };
509
+ (jwtToken: string, macAddress: string, temperature: number) =>
510
+ setTargetTemperature(baseURL)(jwtToken, macAddress, 2, temperature);
538
511
 
539
512
  const setEnvironment3Temperature =
540
513
  (baseURL: string) =>
541
- /**
542
- * Sets the target temperature for Environment 3 zone.
543
- *
544
- * @param {string} jwtToken - The JWT token for authentication.
545
- * @param {string} macAddress - The MAC address of the device.
546
- * @param {number} temperature - The target temperature in degrees Celsius.
547
- * @returns {Promise<unknown>} - A promise that resolves to the command response.
548
- */
549
514
  (jwtToken: string, macAddress: string, temperature: number) =>
550
- mqttCommand(baseURL)(jwtToken, macAddress, {
551
- name: "enviroment_3_temperature",
552
- value: temperature,
553
- });
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);
554
524
 
555
525
  const getEnvironment3Temperature =
556
- (baseURL: string) =>
557
- /**
558
- * Retrieves the target temperature for Environment 3 zone.
559
- *
560
- * @param {string} jwtToken - The JWT token for authentication.
561
- * @param {string} macAddress - The MAC address of the device.
562
- * @returns {Promise<number>} - A promise that resolves to the temperature in degrees Celsius.
563
- */
564
- async (jwtToken: string, macAddress: string): Promise<number> => {
565
- const info = await deviceInfo(baseURL)(jwtToken, macAddress);
566
- return info.nvm.user_parameters.enviroment_3_temperature;
567
- };
526
+ (baseURL: string) => (jwtToken: string, macAddress: string) =>
527
+ getTargetTemperature(baseURL)(jwtToken, macAddress, 3);
568
528
 
569
529
  const setMeasureUnit =
570
530
  (baseURL: string) =>
@@ -757,6 +717,8 @@ const configure = (baseURL: string = API_URL) => ({
757
717
  getPower: getPower(baseURL),
758
718
  setPowerLevel: setPowerLevel(baseURL),
759
719
  getPowerLevel: getPowerLevel(baseURL),
720
+ setFanSpeed: setFanSpeed(baseURL),
721
+ getFanSpeed: getFanSpeed(baseURL),
760
722
  setFan1Speed: setFan1Speed(baseURL),
761
723
  setFan2Speed: setFan2Speed(baseURL),
762
724
  setFan3Speed: setFan3Speed(baseURL),
@@ -774,6 +736,8 @@ const configure = (baseURL: string = API_URL) => ({
774
736
  getEnvironmentTemperature: getEnvironmentTemperature(baseURL),
775
737
  getTargetTemperature: getTargetTemperature(baseURL),
776
738
  setTargetTemperature: setTargetTemperature(baseURL),
739
+ setEnvironment1Temperature: setEnvironment1Temperature(baseURL),
740
+ getEnvironment1Temperature: getEnvironment1Temperature(baseURL),
777
741
  setEnvironment2Temperature: setEnvironment2Temperature(baseURL),
778
742
  getEnvironment2Temperature: getEnvironment2Temperature(baseURL),
779
743
  setEnvironment3Temperature: setEnvironment3Temperature(baseURL),