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.
@@ -202,6 +202,171 @@ const setPowerOff = (baseURL) =>
202
202
  * console.log(response);
203
203
  */
204
204
  (jwtToken, macAddress) => setPower(baseURL)(jwtToken, macAddress, 0);
205
+ const setPowerLevel = (baseURL) =>
206
+ /**
207
+ * Sets the manual power level of the device.
208
+ *
209
+ * @param {string} jwtToken - The JWT token for authentication.
210
+ * @param {string} macAddress - The MAC address of the device.
211
+ * @param {number} level - The power level (1-5).
212
+ * @returns {Promise<unknown>} - A promise that resolves to the command response.
213
+ */
214
+ (jwtToken, macAddress, level) => mqttCommand(baseURL)(jwtToken, macAddress, {
215
+ name: "power_level",
216
+ value: level,
217
+ });
218
+ const getPowerLevel = (baseURL) =>
219
+ /**
220
+ * Retrieves the current manual power level of the device.
221
+ *
222
+ * @param {string} jwtToken - The JWT token for authentication.
223
+ * @param {string} macAddress - The MAC address of the device.
224
+ * @returns {Promise<number>} - A promise that resolves to the power level (1-5).
225
+ */
226
+ (jwtToken, macAddress) => __awaiter(void 0, void 0, void 0, function* () {
227
+ const info = yield deviceInfo(baseURL)(jwtToken, macAddress);
228
+ return info.nvm.user_parameters.manual_power;
229
+ });
230
+ const setFanSpeed = (baseURL) =>
231
+ /**
232
+ * Sets the speed of a fan by index.
233
+ *
234
+ * @param {string} jwtToken - The JWT token for authentication.
235
+ * @param {string} macAddress - The MAC address of the device.
236
+ * @param {1 | 2 | 3} fanIndex - The fan index (1, 2, or 3).
237
+ * @param {number} speed - The fan speed (0-5, 0=auto on some models).
238
+ * @returns {Promise<unknown>} - A promise that resolves to the command response.
239
+ */
240
+ (jwtToken, macAddress, fanIndex, speed) => mqttCommand(baseURL)(jwtToken, macAddress, {
241
+ name: `fan_${fanIndex}_speed`,
242
+ value: speed,
243
+ });
244
+ const getFanSpeed = (baseURL) =>
245
+ /**
246
+ * Retrieves the current speed of a fan by index.
247
+ *
248
+ * @param {string} jwtToken - The JWT token for authentication.
249
+ * @param {string} macAddress - The MAC address of the device.
250
+ * @param {1 | 2 | 3} fanIndex - The fan index (1, 2, or 3).
251
+ * @returns {Promise<number>} - A promise that resolves to the fan speed.
252
+ */
253
+ (jwtToken, macAddress, fanIndex) => __awaiter(void 0, void 0, void 0, function* () {
254
+ const info = yield deviceInfo(baseURL)(jwtToken, macAddress);
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);
269
+ const setAirkare = (baseURL) =>
270
+ /**
271
+ * Enables or disables Airkare (air quality) mode.
272
+ *
273
+ * @param {string} jwtToken - The JWT token for authentication.
274
+ * @param {string} macAddress - The MAC address of the device.
275
+ * @param {boolean} enabled - Whether to enable Airkare mode.
276
+ * @returns {Promise<unknown>} - A promise that resolves to the command response.
277
+ */
278
+ (jwtToken, macAddress, enabled) => mqttCommand(baseURL)(jwtToken, macAddress, {
279
+ name: "airkare_function",
280
+ value: enabled ? 1 : 0,
281
+ });
282
+ const setRelax = (baseURL) =>
283
+ /**
284
+ * Enables or disables Relax (comfort) mode.
285
+ *
286
+ * @param {string} jwtToken - The JWT token for authentication.
287
+ * @param {string} macAddress - The MAC address of the device.
288
+ * @param {boolean} enabled - Whether to enable Relax mode.
289
+ * @returns {Promise<unknown>} - A promise that resolves to the command response.
290
+ */
291
+ (jwtToken, macAddress, enabled) => mqttCommand(baseURL)(jwtToken, macAddress, {
292
+ name: "relax_mode",
293
+ value: enabled,
294
+ });
295
+ const setStandby = (baseURL) =>
296
+ /**
297
+ * Enables or disables Standby mode.
298
+ *
299
+ * @param {string} jwtToken - The JWT token for authentication.
300
+ * @param {string} macAddress - The MAC address of the device.
301
+ * @param {boolean} enabled - Whether to enable Standby mode.
302
+ * @returns {Promise<unknown>} - A promise that resolves to the command response.
303
+ */
304
+ (jwtToken, macAddress, enabled) => mqttCommand(baseURL)(jwtToken, macAddress, {
305
+ name: "standby_mode",
306
+ value: enabled,
307
+ });
308
+ const getStandby = (baseURL) =>
309
+ /**
310
+ * Retrieves the current Standby mode status.
311
+ *
312
+ * @param {string} jwtToken - The JWT token for authentication.
313
+ * @param {string} macAddress - The MAC address of the device.
314
+ * @returns {Promise<boolean>} - A promise that resolves to the standby status.
315
+ */
316
+ (jwtToken, macAddress) => __awaiter(void 0, void 0, void 0, function* () {
317
+ const info = yield deviceInfo(baseURL)(jwtToken, macAddress);
318
+ return info.nvm.user_parameters.is_standby_active;
319
+ });
320
+ const setStandbyTime = (baseURL) =>
321
+ /**
322
+ * Sets the standby waiting time in minutes.
323
+ *
324
+ * @param {string} jwtToken - The JWT token for authentication.
325
+ * @param {string} macAddress - The MAC address of the device.
326
+ * @param {number} minutes - The standby waiting time in minutes.
327
+ * @returns {Promise<unknown>} - A promise that resolves to the command response.
328
+ */
329
+ (jwtToken, macAddress, minutes) => mqttCommand(baseURL)(jwtToken, macAddress, {
330
+ name: "standby_time",
331
+ value: minutes,
332
+ });
333
+ const getStandbyTime = (baseURL) =>
334
+ /**
335
+ * Retrieves the standby waiting time in minutes.
336
+ *
337
+ * @param {string} jwtToken - The JWT token for authentication.
338
+ * @param {string} macAddress - The MAC address of the device.
339
+ * @returns {Promise<number>} - A promise that resolves to the standby time in minutes.
340
+ */
341
+ (jwtToken, macAddress) => __awaiter(void 0, void 0, void 0, function* () {
342
+ const info = yield deviceInfo(baseURL)(jwtToken, macAddress);
343
+ return info.nvm.user_parameters.standby_waiting_time;
344
+ });
345
+ const setAuto = (baseURL) =>
346
+ /**
347
+ * Enables or disables Auto mode for automatic temperature regulation.
348
+ *
349
+ * @param {string} jwtToken - The JWT token for authentication.
350
+ * @param {string} macAddress - The MAC address of the device.
351
+ * @param {boolean} enabled - Whether to enable Auto mode.
352
+ * @returns {Promise<unknown>} - A promise that resolves to the command response.
353
+ */
354
+ (jwtToken, macAddress, enabled) => mqttCommand(baseURL)(jwtToken, macAddress, {
355
+ name: "auto_mode",
356
+ value: enabled,
357
+ });
358
+ const getAuto = (baseURL) =>
359
+ /**
360
+ * Retrieves the current Auto mode status.
361
+ *
362
+ * @param {string} jwtToken - The JWT token for authentication.
363
+ * @param {string} macAddress - The MAC address of the device.
364
+ * @returns {Promise<boolean>} - A promise that resolves to the auto mode status.
365
+ */
366
+ (jwtToken, macAddress) => __awaiter(void 0, void 0, void 0, function* () {
367
+ const info = yield deviceInfo(baseURL)(jwtToken, macAddress);
368
+ return info.nvm.user_parameters.is_auto;
369
+ });
205
370
  const getPower = (baseURL) =>
206
371
  /**
207
372
  * Retrieves the power status of the device.
@@ -228,29 +393,127 @@ const getEnvironmentTemperature = (baseURL) =>
228
393
  });
229
394
  const getTargetTemperature = (baseURL) =>
230
395
  /**
231
- * Retrieves the target temperature value set on the device.
396
+ * Retrieves the target temperature for an environment zone.
232
397
  *
233
398
  * @param {string} jwtToken - The JWT token for authentication.
234
399
  * @param {string} macAddress - The MAC address of the device.
235
- * @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).
236
402
  */
237
- (jwtToken, macAddress) => __awaiter(void 0, void 0, void 0, function* () {
403
+ (jwtToken, macAddress, envIndex) => __awaiter(void 0, void 0, void 0, function* () {
238
404
  const info = yield deviceInfo(baseURL)(jwtToken, macAddress);
239
- 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];
240
411
  });
241
412
  const setTargetTemperature = (baseURL) =>
242
413
  /**
243
- * Sends a command to set the target temperature (degree celsius) of a device.
414
+ * Sets the target temperature for an environment zone.
244
415
  *
245
416
  * @param {string} jwtToken - The JWT token for authentication.
246
417
  * @param {string} macAddress - The MAC address of the device.
247
- * @param {number} temperature - The desired target temperature (degree celsius).
248
- * @returns {Promise<string>} - A promise that resolves to the command response.
418
+ * @param {1 | 2 | 3} envIndex - The environment zone index (1, 2, or 3).
419
+ * @param {number} temperature - The desired target temperature (degrees Celsius).
420
+ * @returns {Promise<unknown>} - A promise that resolves to the command response.
249
421
  */
250
- (jwtToken, macAddress, temperature) => mqttCommand(baseURL)(jwtToken, macAddress, {
251
- name: "enviroment_1_temperature",
422
+ (jwtToken, macAddress, envIndex, temperature) => mqttCommand(baseURL)(jwtToken, macAddress, {
423
+ name: `enviroment_${envIndex}_temperature`,
252
424
  value: temperature,
253
425
  });
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);
433
+ const setMeasureUnit = (baseURL) =>
434
+ /**
435
+ * Sets the temperature measurement unit (Celsius or Fahrenheit).
436
+ *
437
+ * @param {string} jwtToken - The JWT token for authentication.
438
+ * @param {string} macAddress - The MAC address of the device.
439
+ * @param {boolean} isFahrenheit - true for Fahrenheit, false for Celsius.
440
+ * @returns {Promise<unknown>} - A promise that resolves to the command response.
441
+ */
442
+ (jwtToken, macAddress, isFahrenheit) => mqttCommand(baseURL)(jwtToken, macAddress, {
443
+ name: "measure_unit",
444
+ value: isFahrenheit,
445
+ });
446
+ const getMeasureUnit = (baseURL) =>
447
+ /**
448
+ * Retrieves the current temperature measurement unit setting.
449
+ *
450
+ * @param {string} jwtToken - The JWT token for authentication.
451
+ * @param {string} macAddress - The MAC address of the device.
452
+ * @returns {Promise<boolean>} - A promise that resolves to true if Fahrenheit, false if Celsius.
453
+ */
454
+ (jwtToken, macAddress) => __awaiter(void 0, void 0, void 0, function* () {
455
+ const info = yield deviceInfo(baseURL)(jwtToken, macAddress);
456
+ return info.nvm.user_parameters.is_fahrenheit;
457
+ });
458
+ const setLanguage = (baseURL) =>
459
+ /**
460
+ * Sets the display language of the device.
461
+ *
462
+ * Language codes:
463
+ * 0=Italian, 1=French, 2=English, 3=Spanish, 4=Portuguese,
464
+ * 5=Danish, 6=Dutch, 7=German, 8=Hungarian, 9=Polish
465
+ *
466
+ * @param {string} jwtToken - The JWT token for authentication.
467
+ * @param {string} macAddress - The MAC address of the device.
468
+ * @param {number} languageCode - The language code (0-9).
469
+ * @returns {Promise<unknown>} - A promise that resolves to the command response.
470
+ */
471
+ (jwtToken, macAddress, languageCode) => mqttCommand(baseURL)(jwtToken, macAddress, {
472
+ name: "language",
473
+ value: languageCode,
474
+ });
475
+ const getLanguage = (baseURL) =>
476
+ /**
477
+ * Retrieves the current display language setting.
478
+ *
479
+ * Language codes:
480
+ * 0=Italian, 1=French, 2=English, 3=Spanish, 4=Portuguese,
481
+ * 5=Danish, 6=Dutch, 7=German, 8=Hungarian, 9=Polish
482
+ *
483
+ * @param {string} jwtToken - The JWT token for authentication.
484
+ * @param {string} macAddress - The MAC address of the device.
485
+ * @returns {Promise<number>} - A promise that resolves to the language code (0-9).
486
+ */
487
+ (jwtToken, macAddress) => __awaiter(void 0, void 0, void 0, function* () {
488
+ const info = yield deviceInfo(baseURL)(jwtToken, macAddress);
489
+ return info.nvm.user_parameters.language;
490
+ });
491
+ const getPelletInReserve = (baseURL) =>
492
+ /**
493
+ * Retrieves the pellet reserve status.
494
+ * Returns true if pellet level is low (in reserve), false if pellet level is ok.
495
+ *
496
+ * @param {string} jwtToken - The JWT token for authentication.
497
+ * @param {string} macAddress - The MAC address of the device.
498
+ * @returns {Promise<boolean>} - A promise that resolves to the pellet reserve status.
499
+ */
500
+ (jwtToken, macAddress) => __awaiter(void 0, void 0, void 0, function* () {
501
+ const info = yield deviceInfo(baseURL)(jwtToken, macAddress);
502
+ return info.status.flags.is_pellet_in_reserve;
503
+ });
504
+ const getPelletAutonomyTime = (baseURL) =>
505
+ /**
506
+ * Retrieves the estimated pellet autonomy time.
507
+ * Represents the estimated time remaining with current pellet level.
508
+ *
509
+ * @param {string} jwtToken - The JWT token for authentication.
510
+ * @param {string} macAddress - The MAC address of the device.
511
+ * @returns {Promise<number>} - A promise that resolves to the autonomy time (likely in minutes or hours).
512
+ */
513
+ (jwtToken, macAddress) => __awaiter(void 0, void 0, void 0, function* () {
514
+ const info = yield deviceInfo(baseURL)(jwtToken, macAddress);
515
+ return info.status.pellet.autonomy_time;
516
+ });
254
517
  const registerDevice = (baseURL) =>
255
518
  /**
256
519
  * Registers a device with the user's account.
@@ -317,8 +580,38 @@ const configure = (baseURL = constants_1.API_URL) => ({
317
580
  setPowerOff: setPowerOff(baseURL),
318
581
  setPowerOn: setPowerOn(baseURL),
319
582
  getPower: getPower(baseURL),
583
+ setPowerLevel: setPowerLevel(baseURL),
584
+ getPowerLevel: getPowerLevel(baseURL),
585
+ setFanSpeed: setFanSpeed(baseURL),
586
+ getFanSpeed: getFanSpeed(baseURL),
587
+ setFan1Speed: setFan1Speed(baseURL),
588
+ setFan2Speed: setFan2Speed(baseURL),
589
+ setFan3Speed: setFan3Speed(baseURL),
590
+ getFan1Speed: getFan1Speed(baseURL),
591
+ getFan2Speed: getFan2Speed(baseURL),
592
+ getFan3Speed: getFan3Speed(baseURL),
593
+ setAirkare: setAirkare(baseURL),
594
+ setRelax: setRelax(baseURL),
595
+ setStandby: setStandby(baseURL),
596
+ getStandby: getStandby(baseURL),
597
+ setStandbyTime: setStandbyTime(baseURL),
598
+ getStandbyTime: getStandbyTime(baseURL),
599
+ setAuto: setAuto(baseURL),
600
+ getAuto: getAuto(baseURL),
320
601
  getEnvironmentTemperature: getEnvironmentTemperature(baseURL),
321
602
  getTargetTemperature: getTargetTemperature(baseURL),
322
603
  setTargetTemperature: setTargetTemperature(baseURL),
604
+ setEnvironment1Temperature: setEnvironment1Temperature(baseURL),
605
+ getEnvironment1Temperature: getEnvironment1Temperature(baseURL),
606
+ setEnvironment2Temperature: setEnvironment2Temperature(baseURL),
607
+ getEnvironment2Temperature: getEnvironment2Temperature(baseURL),
608
+ setEnvironment3Temperature: setEnvironment3Temperature(baseURL),
609
+ getEnvironment3Temperature: getEnvironment3Temperature(baseURL),
610
+ setMeasureUnit: setMeasureUnit(baseURL),
611
+ getMeasureUnit: getMeasureUnit(baseURL),
612
+ setLanguage: setLanguage(baseURL),
613
+ getLanguage: getLanguage(baseURL),
614
+ getPelletInReserve: getPelletInReserve(baseURL),
615
+ getPelletAutonomyTime: getPelletAutonomyTime(baseURL),
323
616
  });
324
617
  exports.configure = configure;
@@ -187,9 +187,39 @@ describe("library", () => {
187
187
  "setPowerOff",
188
188
  "setPowerOn",
189
189
  "getPower",
190
+ "setPowerLevel",
191
+ "getPowerLevel",
192
+ "setFanSpeed",
193
+ "getFanSpeed",
194
+ "setFan1Speed",
195
+ "setFan2Speed",
196
+ "setFan3Speed",
197
+ "getFan1Speed",
198
+ "getFan2Speed",
199
+ "getFan3Speed",
200
+ "setAirkare",
201
+ "setRelax",
202
+ "setStandby",
203
+ "getStandby",
204
+ "setStandbyTime",
205
+ "getStandbyTime",
206
+ "setAuto",
207
+ "getAuto",
190
208
  "getEnvironmentTemperature",
191
209
  "getTargetTemperature",
192
210
  "setTargetTemperature",
211
+ "setEnvironment1Temperature",
212
+ "getEnvironment1Temperature",
213
+ "setEnvironment2Temperature",
214
+ "getEnvironment2Temperature",
215
+ "setEnvironment3Temperature",
216
+ "getEnvironment3Temperature",
217
+ "setMeasureUnit",
218
+ "getMeasureUnit",
219
+ "setLanguage",
220
+ "getLanguage",
221
+ "getPelletInReserve",
222
+ "getPelletAutonomyTime",
193
223
  ];
194
224
  it("should create API methods with the correct baseURL", () => __awaiter(void 0, void 0, void 0, function* () {
195
225
  const baseURL = "https://example.com/api/";
@@ -220,10 +250,27 @@ describe("library", () => {
220
250
  temperatures: {
221
251
  enviroment: 19,
222
252
  },
253
+ flags: {
254
+ is_pellet_in_reserve: false,
255
+ },
256
+ pellet: {
257
+ autonomy_time: 180,
258
+ },
223
259
  },
224
260
  nvm: {
225
261
  user_parameters: {
226
262
  enviroment_1_temperature: 22,
263
+ enviroment_2_temperature: 18,
264
+ enviroment_3_temperature: 20,
265
+ manual_power: 3,
266
+ fan_1_ventilation: 2,
267
+ fan_2_ventilation: 3,
268
+ fan_3_ventilation: 4,
269
+ is_standby_active: true,
270
+ standby_waiting_time: 30,
271
+ is_auto: true,
272
+ is_fahrenheit: false,
273
+ language: 2,
227
274
  },
228
275
  },
229
276
  };
@@ -279,6 +326,26 @@ describe("library", () => {
279
326
  call: (api, token, mac) => api.getPower(token, mac),
280
327
  expectedResult: true,
281
328
  },
329
+ {
330
+ method: "getPowerLevel",
331
+ call: (api, token, mac) => api.getPowerLevel(token, mac),
332
+ expectedResult: 3,
333
+ },
334
+ {
335
+ method: "getFan1Speed",
336
+ call: (api, token, mac) => api.getFan1Speed(token, mac),
337
+ expectedResult: 2,
338
+ },
339
+ {
340
+ method: "getFan2Speed",
341
+ call: (api, token, mac) => api.getFan2Speed(token, mac),
342
+ expectedResult: 3,
343
+ },
344
+ {
345
+ method: "getFan3Speed",
346
+ call: (api, token, mac) => api.getFan3Speed(token, mac),
347
+ expectedResult: 4,
348
+ },
282
349
  {
283
350
  method: "getEnvironmentTemperature",
284
351
  call: (api, token, mac) => api.getEnvironmentTemperature(token, mac),
@@ -286,9 +353,54 @@ describe("library", () => {
286
353
  },
287
354
  {
288
355
  method: "getTargetTemperature",
289
- call: (api, token, mac) => api.getTargetTemperature(token, mac),
356
+ call: (api, token, mac) => api.getTargetTemperature(token, mac, 1),
290
357
  expectedResult: 22,
291
358
  },
359
+ {
360
+ method: "getStandby",
361
+ call: (api, token, mac) => api.getStandby(token, mac),
362
+ expectedResult: true,
363
+ },
364
+ {
365
+ method: "getStandbyTime",
366
+ call: (api, token, mac) => api.getStandbyTime(token, mac),
367
+ expectedResult: 30,
368
+ },
369
+ {
370
+ method: "getAuto",
371
+ call: (api, token, mac) => api.getAuto(token, mac),
372
+ expectedResult: true,
373
+ },
374
+ {
375
+ method: "getEnvironment2Temperature",
376
+ call: (api, token, mac) => api.getEnvironment2Temperature(token, mac),
377
+ expectedResult: 18,
378
+ },
379
+ {
380
+ method: "getEnvironment3Temperature",
381
+ call: (api, token, mac) => api.getEnvironment3Temperature(token, mac),
382
+ expectedResult: 20,
383
+ },
384
+ {
385
+ method: "getMeasureUnit",
386
+ call: (api, token, mac) => api.getMeasureUnit(token, mac),
387
+ expectedResult: false,
388
+ },
389
+ {
390
+ method: "getLanguage",
391
+ call: (api, token, mac) => api.getLanguage(token, mac),
392
+ expectedResult: 2,
393
+ },
394
+ {
395
+ method: "getPelletInReserve",
396
+ call: (api, token, mac) => api.getPelletInReserve(token, mac),
397
+ expectedResult: false,
398
+ },
399
+ {
400
+ method: "getPelletAutonomyTime",
401
+ call: (api, token, mac) => api.getPelletAutonomyTime(token, mac),
402
+ expectedResult: 180,
403
+ },
292
404
  ];
293
405
  getterTests.forEach(({ method, call, expectedResult }) => {
294
406
  it(`should call fetch and return the correct value for ${method}`, () => __awaiter(void 0, void 0, void 0, function* () {
@@ -306,14 +418,78 @@ describe("library", () => {
306
418
  });
307
419
  // Setter tests
308
420
  const setterTests = [
421
+ {
422
+ method: "setPowerLevel",
423
+ call: (api, token, mac, value) => api.setPowerLevel(token, mac, value),
424
+ payload: {
425
+ name: "power_level",
426
+ value: 4,
427
+ },
428
+ },
429
+ {
430
+ method: "setFan1Speed",
431
+ call: (api, token, mac, value) => api.setFan1Speed(token, mac, value),
432
+ payload: {
433
+ name: "fan_1_speed",
434
+ value: 3,
435
+ },
436
+ },
437
+ {
438
+ method: "setFan2Speed",
439
+ call: (api, token, mac, value) => api.setFan2Speed(token, mac, value),
440
+ payload: {
441
+ name: "fan_2_speed",
442
+ value: 4,
443
+ },
444
+ },
445
+ {
446
+ method: "setFan3Speed",
447
+ call: (api, token, mac, value) => api.setFan3Speed(token, mac, value),
448
+ payload: {
449
+ name: "fan_3_speed",
450
+ value: 5,
451
+ },
452
+ },
309
453
  {
310
454
  method: "setTargetTemperature",
311
- call: (api, token, mac, value) => api.setTargetTemperature(token, mac, value),
455
+ call: (api, token, mac, value) => api.setTargetTemperature(token, mac, 1, value),
312
456
  payload: {
313
457
  name: "enviroment_1_temperature",
314
458
  value: 20,
315
459
  },
316
460
  },
461
+ {
462
+ method: "setStandbyTime",
463
+ call: (api, token, mac, value) => api.setStandbyTime(token, mac, value),
464
+ payload: {
465
+ name: "standby_time",
466
+ value: 45,
467
+ },
468
+ },
469
+ {
470
+ method: "setEnvironment2Temperature",
471
+ call: (api, token, mac, value) => api.setEnvironment2Temperature(token, mac, value),
472
+ payload: {
473
+ name: "enviroment_2_temperature",
474
+ value: 21,
475
+ },
476
+ },
477
+ {
478
+ method: "setEnvironment3Temperature",
479
+ call: (api, token, mac, value) => api.setEnvironment3Temperature(token, mac, value),
480
+ payload: {
481
+ name: "enviroment_3_temperature",
482
+ value: 23,
483
+ },
484
+ },
485
+ {
486
+ method: "setLanguage",
487
+ call: (api, token, mac, value) => api.setLanguage(token, mac, value),
488
+ payload: {
489
+ name: "language",
490
+ value: 2,
491
+ },
492
+ },
317
493
  ];
318
494
  setterTests.forEach(({ method, call, payload }) => {
319
495
  it(`should call fetch and send the correct payload for ${method}`, () => __awaiter(void 0, void 0, void 0, function* () {
@@ -332,6 +508,69 @@ describe("library", () => {
332
508
  });
333
509
  }));
334
510
  });
511
+ // Boolean setter tests (for mode controls)
512
+ const booleanSetterTests = [
513
+ {
514
+ method: "setAirkare",
515
+ call: (api, token, mac, enabled) => api.setAirkare(token, mac, enabled),
516
+ truePayload: { name: "airkare_function", value: 1 },
517
+ falsePayload: { name: "airkare_function", value: 0 },
518
+ },
519
+ {
520
+ method: "setRelax",
521
+ call: (api, token, mac, enabled) => api.setRelax(token, mac, enabled),
522
+ truePayload: { name: "relax_mode", value: true },
523
+ falsePayload: { name: "relax_mode", value: false },
524
+ },
525
+ {
526
+ method: "setStandby",
527
+ call: (api, token, mac, enabled) => api.setStandby(token, mac, enabled),
528
+ truePayload: { name: "standby_mode", value: true },
529
+ falsePayload: { name: "standby_mode", value: false },
530
+ },
531
+ {
532
+ method: "setAuto",
533
+ call: (api, token, mac, enabled) => api.setAuto(token, mac, enabled),
534
+ truePayload: { name: "auto_mode", value: true },
535
+ falsePayload: { name: "auto_mode", value: false },
536
+ },
537
+ {
538
+ method: "setMeasureUnit",
539
+ call: (api, token, mac, enabled) => api.setMeasureUnit(token, mac, enabled),
540
+ truePayload: { name: "measure_unit", value: true },
541
+ falsePayload: { name: "measure_unit", value: false },
542
+ },
543
+ ];
544
+ booleanSetterTests.forEach(({ method, call, truePayload, falsePayload }) => {
545
+ it(`should call fetch with correct payload for ${method}(true)`, () => __awaiter(void 0, void 0, void 0, function* () {
546
+ fetchStub.resolves(mockResponse({ success: true }));
547
+ const api = (0, library_1.configure)("https://example.com/api/");
548
+ yield call(api, expectedToken, "mockMacAddress", true);
549
+ assert_1.strict.ok(fetchStub.calledOnce);
550
+ assert_1.strict.deepEqual(fetchStub.firstCall.args[1], {
551
+ method: "PUT",
552
+ headers: {
553
+ "Content-Type": "application/json",
554
+ Authorization: `Bearer ${expectedToken}`,
555
+ },
556
+ body: JSON.stringify(Object.assign({ mac_address: "mockMacAddress" }, truePayload)),
557
+ });
558
+ }));
559
+ it(`should call fetch with correct payload for ${method}(false)`, () => __awaiter(void 0, void 0, void 0, function* () {
560
+ fetchStub.resolves(mockResponse({ success: true }));
561
+ const api = (0, library_1.configure)("https://example.com/api/");
562
+ yield call(api, expectedToken, "mockMacAddress", false);
563
+ assert_1.strict.ok(fetchStub.calledOnce);
564
+ assert_1.strict.deepEqual(fetchStub.firstCall.args[1], {
565
+ method: "PUT",
566
+ headers: {
567
+ "Content-Type": "application/json",
568
+ Authorization: `Bearer ${expectedToken}`,
569
+ },
570
+ body: JSON.stringify(Object.assign({ mac_address: "mockMacAddress" }, falsePayload)),
571
+ });
572
+ }));
573
+ });
335
574
  });
336
575
  describe("registerDevice", () => {
337
576
  it("should call POST /device with correct payload", () => __awaiter(void 0, void 0, void 0, function* () {
@@ -517,9 +756,40 @@ describe("library", () => {
517
756
  };
518
757
  fetchStub.resolves(mockResponse(mockResponseData));
519
758
  const api = (0, library_1.configure)("https://example.com/api/");
520
- const result = yield api.getTargetTemperature(expectedToken, "mockMacAddress");
759
+ const result = yield api.getTargetTemperature(expectedToken, "mockMacAddress", 1);
521
760
  assert_1.strict.equal(result, 22);
522
761
  }));
762
+ it("should work with getPelletInReserve on compressed response", () => __awaiter(void 0, void 0, void 0, function* () {
763
+ const statusData = {
764
+ commands: { power: true },
765
+ temperatures: { enviroment: 19 },
766
+ flags: { is_pellet_in_reserve: true },
767
+ pellet: { autonomy_time: 120 },
768
+ };
769
+ const mockResponseData = {
770
+ status: createGzippedBuffer(statusData),
771
+ nvm: { user_parameters: { enviroment_1_temperature: 22 } },
772
+ };
773
+ fetchStub.resolves(mockResponse(mockResponseData));
774
+ const api = (0, library_1.configure)("https://example.com/api/");
775
+ const result = yield api.getPelletInReserve(expectedToken, "mockMacAddress");
776
+ assert_1.strict.equal(result, true);
777
+ }));
778
+ it("should work with getPelletAutonomyTime on response", () => __awaiter(void 0, void 0, void 0, function* () {
779
+ const mockResponseData = {
780
+ status: {
781
+ commands: { power: true },
782
+ temperatures: { enviroment: 19 },
783
+ flags: { is_pellet_in_reserve: false },
784
+ pellet: { autonomy_time: 240 },
785
+ },
786
+ nvm: { user_parameters: { enviroment_1_temperature: 22 } },
787
+ };
788
+ fetchStub.resolves(mockResponse(mockResponseData));
789
+ const api = (0, library_1.configure)("https://example.com/api/");
790
+ const result = yield api.getPelletAutonomyTime(expectedToken, "mockMacAddress");
791
+ assert_1.strict.equal(result, 240);
792
+ }));
523
793
  });
524
794
  describe("Error Handling", () => {
525
795
  const errorTests = [