edilkamin 1.7.4 → 1.9.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.
Files changed (40) hide show
  1. package/.github/dependabot.yml +5 -1
  2. package/README.md +92 -4
  3. package/dist/cjs/package.json +16 -5
  4. package/dist/cjs/src/bluetooth-utils.d.ts +13 -0
  5. package/dist/cjs/src/bluetooth-utils.js +28 -0
  6. package/dist/cjs/src/bluetooth-utils.test.d.ts +1 -0
  7. package/dist/cjs/src/bluetooth-utils.test.js +35 -0
  8. package/dist/cjs/src/bluetooth.d.ts +40 -0
  9. package/dist/cjs/src/bluetooth.js +107 -0
  10. package/dist/cjs/src/cli.js +130 -0
  11. package/dist/cjs/src/index.d.ts +2 -1
  12. package/dist/cjs/src/index.js +3 -1
  13. package/dist/cjs/src/library.d.ts +26 -0
  14. package/dist/cjs/src/library.js +361 -0
  15. package/dist/cjs/src/library.test.js +266 -0
  16. package/dist/cjs/src/types.d.ts +30 -1
  17. package/dist/esm/package.json +16 -5
  18. package/dist/esm/src/bluetooth-utils.d.ts +13 -0
  19. package/dist/esm/src/bluetooth-utils.js +25 -0
  20. package/dist/esm/src/bluetooth-utils.test.d.ts +1 -0
  21. package/dist/esm/src/bluetooth-utils.test.js +33 -0
  22. package/dist/esm/src/bluetooth.d.ts +40 -0
  23. package/dist/esm/src/bluetooth.js +100 -0
  24. package/dist/esm/src/cli.js +130 -0
  25. package/dist/esm/src/index.d.ts +2 -1
  26. package/dist/esm/src/index.js +1 -0
  27. package/dist/esm/src/library.d.ts +26 -0
  28. package/dist/esm/src/library.js +361 -0
  29. package/dist/esm/src/library.test.js +266 -0
  30. package/dist/esm/src/types.d.ts +30 -1
  31. package/package.json +16 -5
  32. package/src/bluetooth-utils.test.ts +46 -0
  33. package/src/bluetooth-utils.ts +29 -0
  34. package/src/bluetooth.ts +115 -0
  35. package/src/cli.ts +249 -0
  36. package/src/index.ts +2 -0
  37. package/src/library.test.ts +372 -0
  38. package/src/library.ts +426 -0
  39. package/src/types.ts +35 -0
  40. package/tsconfig.json +1 -0
@@ -209,9 +209,35 @@ describe("library", () => {
209
209
  "setPowerOff",
210
210
  "setPowerOn",
211
211
  "getPower",
212
+ "setPowerLevel",
213
+ "getPowerLevel",
214
+ "setFan1Speed",
215
+ "setFan2Speed",
216
+ "setFan3Speed",
217
+ "getFan1Speed",
218
+ "getFan2Speed",
219
+ "getFan3Speed",
220
+ "setAirkare",
221
+ "setRelax",
222
+ "setStandby",
223
+ "getStandby",
224
+ "setStandbyTime",
225
+ "getStandbyTime",
226
+ "setAuto",
227
+ "getAuto",
212
228
  "getEnvironmentTemperature",
213
229
  "getTargetTemperature",
214
230
  "setTargetTemperature",
231
+ "setEnvironment2Temperature",
232
+ "getEnvironment2Temperature",
233
+ "setEnvironment3Temperature",
234
+ "getEnvironment3Temperature",
235
+ "setMeasureUnit",
236
+ "getMeasureUnit",
237
+ "setLanguage",
238
+ "getLanguage",
239
+ "getPelletInReserve",
240
+ "getPelletAutonomyTime",
215
241
  ];
216
242
  it("should create API methods with the correct baseURL", async () => {
217
243
  const baseURL = "https://example.com/api/";
@@ -243,10 +269,27 @@ describe("library", () => {
243
269
  temperatures: {
244
270
  enviroment: 19,
245
271
  },
272
+ flags: {
273
+ is_pellet_in_reserve: false,
274
+ },
275
+ pellet: {
276
+ autonomy_time: 180,
277
+ },
246
278
  },
247
279
  nvm: {
248
280
  user_parameters: {
249
281
  enviroment_1_temperature: 22,
282
+ enviroment_2_temperature: 18,
283
+ enviroment_3_temperature: 20,
284
+ manual_power: 3,
285
+ fan_1_ventilation: 2,
286
+ fan_2_ventilation: 3,
287
+ fan_3_ventilation: 4,
288
+ is_standby_active: true,
289
+ standby_waiting_time: 30,
290
+ is_auto: true,
291
+ is_fahrenheit: false,
292
+ language: 2,
250
293
  },
251
294
  },
252
295
  };
@@ -315,6 +358,30 @@ describe("library", () => {
315
358
  api.getPower(token, mac),
316
359
  expectedResult: true,
317
360
  },
361
+ {
362
+ method: "getPowerLevel",
363
+ call: (api: ReturnType<typeof configure>, token: string, mac: string) =>
364
+ api.getPowerLevel(token, mac),
365
+ expectedResult: 3,
366
+ },
367
+ {
368
+ method: "getFan1Speed",
369
+ call: (api: ReturnType<typeof configure>, token: string, mac: string) =>
370
+ api.getFan1Speed(token, mac),
371
+ expectedResult: 2,
372
+ },
373
+ {
374
+ method: "getFan2Speed",
375
+ call: (api: ReturnType<typeof configure>, token: string, mac: string) =>
376
+ api.getFan2Speed(token, mac),
377
+ expectedResult: 3,
378
+ },
379
+ {
380
+ method: "getFan3Speed",
381
+ call: (api: ReturnType<typeof configure>, token: string, mac: string) =>
382
+ api.getFan3Speed(token, mac),
383
+ expectedResult: 4,
384
+ },
318
385
  {
319
386
  method: "getEnvironmentTemperature",
320
387
  call: (api: ReturnType<typeof configure>, token: string, mac: string) =>
@@ -327,6 +394,60 @@ describe("library", () => {
327
394
  api.getTargetTemperature(token, mac),
328
395
  expectedResult: 22,
329
396
  },
397
+ {
398
+ method: "getStandby",
399
+ call: (api: ReturnType<typeof configure>, token: string, mac: string) =>
400
+ api.getStandby(token, mac),
401
+ expectedResult: true,
402
+ },
403
+ {
404
+ method: "getStandbyTime",
405
+ call: (api: ReturnType<typeof configure>, token: string, mac: string) =>
406
+ api.getStandbyTime(token, mac),
407
+ expectedResult: 30,
408
+ },
409
+ {
410
+ method: "getAuto",
411
+ call: (api: ReturnType<typeof configure>, token: string, mac: string) =>
412
+ api.getAuto(token, mac),
413
+ expectedResult: true,
414
+ },
415
+ {
416
+ method: "getEnvironment2Temperature",
417
+ call: (api: ReturnType<typeof configure>, token: string, mac: string) =>
418
+ api.getEnvironment2Temperature(token, mac),
419
+ expectedResult: 18,
420
+ },
421
+ {
422
+ method: "getEnvironment3Temperature",
423
+ call: (api: ReturnType<typeof configure>, token: string, mac: string) =>
424
+ api.getEnvironment3Temperature(token, mac),
425
+ expectedResult: 20,
426
+ },
427
+ {
428
+ method: "getMeasureUnit",
429
+ call: (api: ReturnType<typeof configure>, token: string, mac: string) =>
430
+ api.getMeasureUnit(token, mac),
431
+ expectedResult: false,
432
+ },
433
+ {
434
+ method: "getLanguage",
435
+ call: (api: ReturnType<typeof configure>, token: string, mac: string) =>
436
+ api.getLanguage(token, mac),
437
+ expectedResult: 2,
438
+ },
439
+ {
440
+ method: "getPelletInReserve",
441
+ call: (api: ReturnType<typeof configure>, token: string, mac: string) =>
442
+ api.getPelletInReserve(token, mac),
443
+ expectedResult: false,
444
+ },
445
+ {
446
+ method: "getPelletAutonomyTime",
447
+ call: (api: ReturnType<typeof configure>, token: string, mac: string) =>
448
+ api.getPelletAutonomyTime(token, mac),
449
+ expectedResult: 180,
450
+ },
330
451
  ];
331
452
  getterTests.forEach(({ method, call, expectedResult }) => {
332
453
  it(`should call fetch and return the correct value for ${method}`, async () => {
@@ -349,6 +470,58 @@ describe("library", () => {
349
470
  });
350
471
  // Setter tests
351
472
  const setterTests = [
473
+ {
474
+ method: "setPowerLevel",
475
+ call: (
476
+ api: ReturnType<typeof configure>,
477
+ token: string,
478
+ mac: string,
479
+ value: number,
480
+ ) => api.setPowerLevel(token, mac, value),
481
+ payload: {
482
+ name: "power_level",
483
+ value: 4,
484
+ },
485
+ },
486
+ {
487
+ method: "setFan1Speed",
488
+ call: (
489
+ api: ReturnType<typeof configure>,
490
+ token: string,
491
+ mac: string,
492
+ value: number,
493
+ ) => api.setFan1Speed(token, mac, value),
494
+ payload: {
495
+ name: "fan_1_speed",
496
+ value: 3,
497
+ },
498
+ },
499
+ {
500
+ method: "setFan2Speed",
501
+ call: (
502
+ api: ReturnType<typeof configure>,
503
+ token: string,
504
+ mac: string,
505
+ value: number,
506
+ ) => api.setFan2Speed(token, mac, value),
507
+ payload: {
508
+ name: "fan_2_speed",
509
+ value: 4,
510
+ },
511
+ },
512
+ {
513
+ method: "setFan3Speed",
514
+ call: (
515
+ api: ReturnType<typeof configure>,
516
+ token: string,
517
+ mac: string,
518
+ value: number,
519
+ ) => api.setFan3Speed(token, mac, value),
520
+ payload: {
521
+ name: "fan_3_speed",
522
+ value: 5,
523
+ },
524
+ },
352
525
  {
353
526
  method: "setTargetTemperature",
354
527
  call: (
@@ -362,6 +535,58 @@ describe("library", () => {
362
535
  value: 20,
363
536
  },
364
537
  },
538
+ {
539
+ method: "setStandbyTime",
540
+ call: (
541
+ api: ReturnType<typeof configure>,
542
+ token: string,
543
+ mac: string,
544
+ value: number,
545
+ ) => api.setStandbyTime(token, mac, value),
546
+ payload: {
547
+ name: "standby_time",
548
+ value: 45,
549
+ },
550
+ },
551
+ {
552
+ method: "setEnvironment2Temperature",
553
+ call: (
554
+ api: ReturnType<typeof configure>,
555
+ token: string,
556
+ mac: string,
557
+ value: number,
558
+ ) => api.setEnvironment2Temperature(token, mac, value),
559
+ payload: {
560
+ name: "enviroment_2_temperature",
561
+ value: 21,
562
+ },
563
+ },
564
+ {
565
+ method: "setEnvironment3Temperature",
566
+ call: (
567
+ api: ReturnType<typeof configure>,
568
+ token: string,
569
+ mac: string,
570
+ value: number,
571
+ ) => api.setEnvironment3Temperature(token, mac, value),
572
+ payload: {
573
+ name: "enviroment_3_temperature",
574
+ value: 23,
575
+ },
576
+ },
577
+ {
578
+ method: "setLanguage",
579
+ call: (
580
+ api: ReturnType<typeof configure>,
581
+ token: string,
582
+ mac: string,
583
+ value: number,
584
+ ) => api.setLanguage(token, mac, value),
585
+ payload: {
586
+ name: "language",
587
+ value: 2,
588
+ },
589
+ },
365
590
  ];
366
591
  setterTests.forEach(({ method, call, payload }) => {
367
592
  it(`should call fetch and send the correct payload for ${method}`, async () => {
@@ -388,6 +613,108 @@ describe("library", () => {
388
613
  });
389
614
  });
390
615
  });
616
+
617
+ // Boolean setter tests (for mode controls)
618
+ const booleanSetterTests = [
619
+ {
620
+ method: "setAirkare",
621
+ call: (
622
+ api: ReturnType<typeof configure>,
623
+ token: string,
624
+ mac: string,
625
+ enabled: boolean,
626
+ ) => api.setAirkare(token, mac, enabled),
627
+ truePayload: { name: "airkare_function", value: 1 },
628
+ falsePayload: { name: "airkare_function", value: 0 },
629
+ },
630
+ {
631
+ method: "setRelax",
632
+ call: (
633
+ api: ReturnType<typeof configure>,
634
+ token: string,
635
+ mac: string,
636
+ enabled: boolean,
637
+ ) => api.setRelax(token, mac, enabled),
638
+ truePayload: { name: "relax_mode", value: true },
639
+ falsePayload: { name: "relax_mode", value: false },
640
+ },
641
+ {
642
+ method: "setStandby",
643
+ call: (
644
+ api: ReturnType<typeof configure>,
645
+ token: string,
646
+ mac: string,
647
+ enabled: boolean,
648
+ ) => api.setStandby(token, mac, enabled),
649
+ truePayload: { name: "standby_mode", value: true },
650
+ falsePayload: { name: "standby_mode", value: false },
651
+ },
652
+ {
653
+ method: "setAuto",
654
+ call: (
655
+ api: ReturnType<typeof configure>,
656
+ token: string,
657
+ mac: string,
658
+ enabled: boolean,
659
+ ) => api.setAuto(token, mac, enabled),
660
+ truePayload: { name: "auto_mode", value: true },
661
+ falsePayload: { name: "auto_mode", value: false },
662
+ },
663
+ {
664
+ method: "setMeasureUnit",
665
+ call: (
666
+ api: ReturnType<typeof configure>,
667
+ token: string,
668
+ mac: string,
669
+ enabled: boolean,
670
+ ) => api.setMeasureUnit(token, mac, enabled),
671
+ truePayload: { name: "measure_unit", value: true },
672
+ falsePayload: { name: "measure_unit", value: false },
673
+ },
674
+ ];
675
+ booleanSetterTests.forEach(
676
+ ({ method, call, truePayload, falsePayload }) => {
677
+ it(`should call fetch with correct payload for ${method}(true)`, async () => {
678
+ fetchStub.resolves(mockResponse({ success: true }));
679
+ const api = configure("https://example.com/api/");
680
+
681
+ await call(api, expectedToken, "mockMacAddress", true);
682
+
683
+ assert.ok(fetchStub.calledOnce);
684
+ assert.deepEqual(fetchStub.firstCall.args[1], {
685
+ method: "PUT",
686
+ headers: {
687
+ "Content-Type": "application/json",
688
+ Authorization: `Bearer ${expectedToken}`,
689
+ },
690
+ body: JSON.stringify({
691
+ mac_address: "mockMacAddress",
692
+ ...truePayload,
693
+ }),
694
+ });
695
+ });
696
+
697
+ it(`should call fetch with correct payload for ${method}(false)`, async () => {
698
+ fetchStub.resolves(mockResponse({ success: true }));
699
+ const api = configure("https://example.com/api/");
700
+
701
+ await call(api, expectedToken, "mockMacAddress", false);
702
+
703
+ assert.ok(fetchStub.calledOnce);
704
+ assert.deepEqual(fetchStub.firstCall.args[1], {
705
+ method: "PUT",
706
+ headers: {
707
+ "Content-Type": "application/json",
708
+ Authorization: `Bearer ${expectedToken}`,
709
+ },
710
+ body: JSON.stringify({
711
+ mac_address: "mockMacAddress",
712
+ ...falsePayload,
713
+ }),
714
+ });
715
+ });
716
+ },
717
+ );
391
718
  });
392
719
 
393
720
  describe("registerDevice", () => {
@@ -638,6 +965,51 @@ describe("library", () => {
638
965
 
639
966
  assert.equal(result, 22);
640
967
  });
968
+
969
+ it("should work with getPelletInReserve on compressed response", async () => {
970
+ const statusData = {
971
+ commands: { power: true },
972
+ temperatures: { enviroment: 19 },
973
+ flags: { is_pellet_in_reserve: true },
974
+ pellet: { autonomy_time: 120 },
975
+ };
976
+ const mockResponseData = {
977
+ status: createGzippedBuffer(statusData),
978
+ nvm: { user_parameters: { enviroment_1_temperature: 22 } },
979
+ };
980
+
981
+ fetchStub.resolves(mockResponse(mockResponseData));
982
+ const api = configure("https://example.com/api/");
983
+
984
+ const result = await api.getPelletInReserve(
985
+ expectedToken,
986
+ "mockMacAddress",
987
+ );
988
+
989
+ assert.equal(result, true);
990
+ });
991
+
992
+ it("should work with getPelletAutonomyTime on response", async () => {
993
+ const mockResponseData = {
994
+ status: {
995
+ commands: { power: true },
996
+ temperatures: { enviroment: 19 },
997
+ flags: { is_pellet_in_reserve: false },
998
+ pellet: { autonomy_time: 240 },
999
+ },
1000
+ nvm: { user_parameters: { enviroment_1_temperature: 22 } },
1001
+ };
1002
+
1003
+ fetchStub.resolves(mockResponse(mockResponseData));
1004
+ const api = configure("https://example.com/api/");
1005
+
1006
+ const result = await api.getPelletAutonomyTime(
1007
+ expectedToken,
1008
+ "mockMacAddress",
1009
+ );
1010
+
1011
+ assert.equal(result, 240);
1012
+ });
641
1013
  });
642
1014
 
643
1015
  describe("Error Handling", () => {