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