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/dist/cjs/package.json +1 -1
- package/dist/cjs/src/cli.js +104 -6
- package/dist/cjs/src/index.d.ts +1 -1
- package/dist/cjs/src/library.d.ts +6 -2
- package/dist/cjs/src/library.js +49 -117
- package/dist/cjs/src/library.test.js +7 -3
- package/dist/esm/package.json +1 -1
- package/dist/esm/src/cli.js +104 -6
- package/dist/esm/src/index.d.ts +1 -1
- package/dist/esm/src/library.d.ts +6 -2
- package/dist/esm/src/library.js +49 -117
- package/dist/esm/src/library.test.js +7 -3
- package/package.json +1 -1
- package/src/cli.ts +176 -6
- package/src/library.test.ts +7 -2
- package/src/library.ts +85 -121
package/dist/esm/src/library.js
CHANGED
|
@@ -186,81 +186,45 @@ const getPowerLevel = (baseURL) =>
|
|
|
186
186
|
const info = yield deviceInfo(baseURL)(jwtToken, macAddress);
|
|
187
187
|
return info.nvm.user_parameters.manual_power;
|
|
188
188
|
});
|
|
189
|
-
const
|
|
189
|
+
const setFanSpeed = (baseURL) =>
|
|
190
190
|
/**
|
|
191
|
-
* Sets the speed of fan
|
|
191
|
+
* Sets the speed of a fan by index.
|
|
192
192
|
*
|
|
193
193
|
* @param {string} jwtToken - The JWT token for authentication.
|
|
194
194
|
* @param {string} macAddress - The MAC address of the device.
|
|
195
|
+
* @param {1 | 2 | 3} fanIndex - The fan index (1, 2, or 3).
|
|
195
196
|
* @param {number} speed - The fan speed (0-5, 0=auto on some models).
|
|
196
197
|
* @returns {Promise<unknown>} - A promise that resolves to the command response.
|
|
197
198
|
*/
|
|
198
|
-
(jwtToken, macAddress, speed) => mqttCommand(baseURL)(jwtToken, macAddress, {
|
|
199
|
-
name:
|
|
199
|
+
(jwtToken, macAddress, fanIndex, speed) => mqttCommand(baseURL)(jwtToken, macAddress, {
|
|
200
|
+
name: `fan_${fanIndex}_speed`,
|
|
200
201
|
value: speed,
|
|
201
202
|
});
|
|
202
|
-
const
|
|
203
|
+
const getFanSpeed = (baseURL) =>
|
|
203
204
|
/**
|
|
204
|
-
*
|
|
205
|
-
*
|
|
206
|
-
* @param {string} jwtToken - The JWT token for authentication.
|
|
207
|
-
* @param {string} macAddress - The MAC address of the device.
|
|
208
|
-
* @param {number} speed - The fan speed (0-5, 0=auto on some models).
|
|
209
|
-
* @returns {Promise<unknown>} - A promise that resolves to the command response.
|
|
210
|
-
*/
|
|
211
|
-
(jwtToken, macAddress, speed) => mqttCommand(baseURL)(jwtToken, macAddress, {
|
|
212
|
-
name: "fan_2_speed",
|
|
213
|
-
value: speed,
|
|
214
|
-
});
|
|
215
|
-
const setFan3Speed = (baseURL) =>
|
|
216
|
-
/**
|
|
217
|
-
* Sets the speed of fan 3.
|
|
218
|
-
*
|
|
219
|
-
* @param {string} jwtToken - The JWT token for authentication.
|
|
220
|
-
* @param {string} macAddress - The MAC address of the device.
|
|
221
|
-
* @param {number} speed - The fan speed (0-5, 0=auto on some models).
|
|
222
|
-
* @returns {Promise<unknown>} - A promise that resolves to the command response.
|
|
223
|
-
*/
|
|
224
|
-
(jwtToken, macAddress, speed) => mqttCommand(baseURL)(jwtToken, macAddress, {
|
|
225
|
-
name: "fan_3_speed",
|
|
226
|
-
value: speed,
|
|
227
|
-
});
|
|
228
|
-
const getFan1Speed = (baseURL) =>
|
|
229
|
-
/**
|
|
230
|
-
* Retrieves the current speed of fan 1.
|
|
205
|
+
* Retrieves the current speed of a fan by index.
|
|
231
206
|
*
|
|
232
207
|
* @param {string} jwtToken - The JWT token for authentication.
|
|
233
208
|
* @param {string} macAddress - The MAC address of the device.
|
|
209
|
+
* @param {1 | 2 | 3} fanIndex - The fan index (1, 2, or 3).
|
|
234
210
|
* @returns {Promise<number>} - A promise that resolves to the fan speed.
|
|
235
211
|
*/
|
|
236
|
-
(jwtToken, macAddress) => __awaiter(void 0, void 0, void 0, function* () {
|
|
237
|
-
const info = yield deviceInfo(baseURL)(jwtToken, macAddress);
|
|
238
|
-
return info.nvm.user_parameters.fan_1_ventilation;
|
|
239
|
-
});
|
|
240
|
-
const getFan2Speed = (baseURL) =>
|
|
241
|
-
/**
|
|
242
|
-
* Retrieves the current speed of fan 2.
|
|
243
|
-
*
|
|
244
|
-
* @param {string} jwtToken - The JWT token for authentication.
|
|
245
|
-
* @param {string} macAddress - The MAC address of the device.
|
|
246
|
-
* @returns {Promise<number>} - A promise that resolves to the fan speed.
|
|
247
|
-
*/
|
|
248
|
-
(jwtToken, macAddress) => __awaiter(void 0, void 0, void 0, function* () {
|
|
249
|
-
const info = yield deviceInfo(baseURL)(jwtToken, macAddress);
|
|
250
|
-
return info.nvm.user_parameters.fan_2_ventilation;
|
|
251
|
-
});
|
|
252
|
-
const getFan3Speed = (baseURL) =>
|
|
253
|
-
/**
|
|
254
|
-
* Retrieves the current speed of fan 3.
|
|
255
|
-
*
|
|
256
|
-
* @param {string} jwtToken - The JWT token for authentication.
|
|
257
|
-
* @param {string} macAddress - The MAC address of the device.
|
|
258
|
-
* @returns {Promise<number>} - A promise that resolves to the fan speed.
|
|
259
|
-
*/
|
|
260
|
-
(jwtToken, macAddress) => __awaiter(void 0, void 0, void 0, function* () {
|
|
212
|
+
(jwtToken, macAddress, fanIndex) => __awaiter(void 0, void 0, void 0, function* () {
|
|
261
213
|
const info = yield deviceInfo(baseURL)(jwtToken, macAddress);
|
|
262
|
-
|
|
263
|
-
|
|
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);
|
|
264
228
|
const setAirkare = (baseURL) =>
|
|
265
229
|
/**
|
|
266
230
|
* Enables or disables Airkare (air quality) mode.
|
|
@@ -388,79 +352,43 @@ const getEnvironmentTemperature = (baseURL) =>
|
|
|
388
352
|
});
|
|
389
353
|
const getTargetTemperature = (baseURL) =>
|
|
390
354
|
/**
|
|
391
|
-
* Retrieves the target temperature
|
|
355
|
+
* Retrieves the target temperature for an environment zone.
|
|
392
356
|
*
|
|
393
357
|
* @param {string} jwtToken - The JWT token for authentication.
|
|
394
358
|
* @param {string} macAddress - The MAC address of the device.
|
|
395
|
-
* @
|
|
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).
|
|
396
361
|
*/
|
|
397
|
-
(jwtToken, macAddress) => __awaiter(void 0, void 0, void 0, function* () {
|
|
362
|
+
(jwtToken, macAddress, envIndex) => __awaiter(void 0, void 0, void 0, function* () {
|
|
398
363
|
const info = yield deviceInfo(baseURL)(jwtToken, macAddress);
|
|
399
|
-
|
|
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];
|
|
400
370
|
});
|
|
401
371
|
const setTargetTemperature = (baseURL) =>
|
|
402
372
|
/**
|
|
403
|
-
*
|
|
404
|
-
*
|
|
405
|
-
* @param {string} jwtToken - The JWT token for authentication.
|
|
406
|
-
* @param {string} macAddress - The MAC address of the device.
|
|
407
|
-
* @param {number} temperature - The desired target temperature (degree celsius).
|
|
408
|
-
* @returns {Promise<string>} - A promise that resolves to the command response.
|
|
409
|
-
*/
|
|
410
|
-
(jwtToken, macAddress, temperature) => mqttCommand(baseURL)(jwtToken, macAddress, {
|
|
411
|
-
name: "enviroment_1_temperature",
|
|
412
|
-
value: temperature,
|
|
413
|
-
});
|
|
414
|
-
const setEnvironment2Temperature = (baseURL) =>
|
|
415
|
-
/**
|
|
416
|
-
* Sets the target temperature for Environment 2 zone.
|
|
417
|
-
*
|
|
418
|
-
* @param {string} jwtToken - The JWT token for authentication.
|
|
419
|
-
* @param {string} macAddress - The MAC address of the device.
|
|
420
|
-
* @param {number} temperature - The target temperature in degrees Celsius.
|
|
421
|
-
* @returns {Promise<unknown>} - A promise that resolves to the command response.
|
|
422
|
-
*/
|
|
423
|
-
(jwtToken, macAddress, temperature) => mqttCommand(baseURL)(jwtToken, macAddress, {
|
|
424
|
-
name: "enviroment_2_temperature",
|
|
425
|
-
value: temperature,
|
|
426
|
-
});
|
|
427
|
-
const getEnvironment2Temperature = (baseURL) =>
|
|
428
|
-
/**
|
|
429
|
-
* Retrieves the target temperature for Environment 2 zone.
|
|
430
|
-
*
|
|
431
|
-
* @param {string} jwtToken - The JWT token for authentication.
|
|
432
|
-
* @param {string} macAddress - The MAC address of the device.
|
|
433
|
-
* @returns {Promise<number>} - A promise that resolves to the temperature in degrees Celsius.
|
|
434
|
-
*/
|
|
435
|
-
(jwtToken, macAddress) => __awaiter(void 0, void 0, void 0, function* () {
|
|
436
|
-
const info = yield deviceInfo(baseURL)(jwtToken, macAddress);
|
|
437
|
-
return info.nvm.user_parameters.enviroment_2_temperature;
|
|
438
|
-
});
|
|
439
|
-
const setEnvironment3Temperature = (baseURL) =>
|
|
440
|
-
/**
|
|
441
|
-
* Sets the target temperature for Environment 3 zone.
|
|
373
|
+
* Sets the target temperature for an environment zone.
|
|
442
374
|
*
|
|
443
375
|
* @param {string} jwtToken - The JWT token for authentication.
|
|
444
376
|
* @param {string} macAddress - The MAC address of the device.
|
|
445
|
-
* @param {
|
|
377
|
+
* @param {1 | 2 | 3} envIndex - The environment zone index (1, 2, or 3).
|
|
378
|
+
* @param {number} temperature - The desired target temperature (degrees Celsius).
|
|
446
379
|
* @returns {Promise<unknown>} - A promise that resolves to the command response.
|
|
447
380
|
*/
|
|
448
|
-
(jwtToken, macAddress, temperature) => mqttCommand(baseURL)(jwtToken, macAddress, {
|
|
449
|
-
name:
|
|
381
|
+
(jwtToken, macAddress, envIndex, temperature) => mqttCommand(baseURL)(jwtToken, macAddress, {
|
|
382
|
+
name: `enviroment_${envIndex}_temperature`,
|
|
450
383
|
value: temperature,
|
|
451
384
|
});
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
*/
|
|
460
|
-
(jwtToken, macAddress) => __awaiter(void 0, void 0, void 0, function* () {
|
|
461
|
-
const info = yield deviceInfo(baseURL)(jwtToken, macAddress);
|
|
462
|
-
return info.nvm.user_parameters.enviroment_3_temperature;
|
|
463
|
-
});
|
|
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);
|
|
464
392
|
const setMeasureUnit = (baseURL) =>
|
|
465
393
|
/**
|
|
466
394
|
* Sets the temperature measurement unit (Celsius or Fahrenheit).
|
|
@@ -613,6 +541,8 @@ const configure = (baseURL = API_URL) => ({
|
|
|
613
541
|
getPower: getPower(baseURL),
|
|
614
542
|
setPowerLevel: setPowerLevel(baseURL),
|
|
615
543
|
getPowerLevel: getPowerLevel(baseURL),
|
|
544
|
+
setFanSpeed: setFanSpeed(baseURL),
|
|
545
|
+
getFanSpeed: getFanSpeed(baseURL),
|
|
616
546
|
setFan1Speed: setFan1Speed(baseURL),
|
|
617
547
|
setFan2Speed: setFan2Speed(baseURL),
|
|
618
548
|
setFan3Speed: setFan3Speed(baseURL),
|
|
@@ -630,6 +560,8 @@ const configure = (baseURL = API_URL) => ({
|
|
|
630
560
|
getEnvironmentTemperature: getEnvironmentTemperature(baseURL),
|
|
631
561
|
getTargetTemperature: getTargetTemperature(baseURL),
|
|
632
562
|
setTargetTemperature: setTargetTemperature(baseURL),
|
|
563
|
+
setEnvironment1Temperature: setEnvironment1Temperature(baseURL),
|
|
564
|
+
getEnvironment1Temperature: getEnvironment1Temperature(baseURL),
|
|
633
565
|
setEnvironment2Temperature: setEnvironment2Temperature(baseURL),
|
|
634
566
|
getEnvironment2Temperature: getEnvironment2Temperature(baseURL),
|
|
635
567
|
setEnvironment3Temperature: setEnvironment3Temperature(baseURL),
|
|
@@ -184,6 +184,8 @@ describe("library", () => {
|
|
|
184
184
|
"getPower",
|
|
185
185
|
"setPowerLevel",
|
|
186
186
|
"getPowerLevel",
|
|
187
|
+
"setFanSpeed",
|
|
188
|
+
"getFanSpeed",
|
|
187
189
|
"setFan1Speed",
|
|
188
190
|
"setFan2Speed",
|
|
189
191
|
"setFan3Speed",
|
|
@@ -201,6 +203,8 @@ describe("library", () => {
|
|
|
201
203
|
"getEnvironmentTemperature",
|
|
202
204
|
"getTargetTemperature",
|
|
203
205
|
"setTargetTemperature",
|
|
206
|
+
"setEnvironment1Temperature",
|
|
207
|
+
"getEnvironment1Temperature",
|
|
204
208
|
"setEnvironment2Temperature",
|
|
205
209
|
"getEnvironment2Temperature",
|
|
206
210
|
"setEnvironment3Temperature",
|
|
@@ -344,7 +348,7 @@ describe("library", () => {
|
|
|
344
348
|
},
|
|
345
349
|
{
|
|
346
350
|
method: "getTargetTemperature",
|
|
347
|
-
call: (api, token, mac) => api.getTargetTemperature(token, mac),
|
|
351
|
+
call: (api, token, mac) => api.getTargetTemperature(token, mac, 1),
|
|
348
352
|
expectedResult: 22,
|
|
349
353
|
},
|
|
350
354
|
{
|
|
@@ -443,7 +447,7 @@ describe("library", () => {
|
|
|
443
447
|
},
|
|
444
448
|
{
|
|
445
449
|
method: "setTargetTemperature",
|
|
446
|
-
call: (api, token, mac, value) => api.setTargetTemperature(token, mac, value),
|
|
450
|
+
call: (api, token, mac, value) => api.setTargetTemperature(token, mac, 1, value),
|
|
447
451
|
payload: {
|
|
448
452
|
name: "enviroment_1_temperature",
|
|
449
453
|
value: 20,
|
|
@@ -747,7 +751,7 @@ describe("library", () => {
|
|
|
747
751
|
};
|
|
748
752
|
fetchStub.resolves(mockResponse(mockResponseData));
|
|
749
753
|
const api = configure("https://example.com/api/");
|
|
750
|
-
const result = yield api.getTargetTemperature(expectedToken, "mockMacAddress");
|
|
754
|
+
const result = yield api.getTargetTemperature(expectedToken, "mockMacAddress", 1);
|
|
751
755
|
assert.equal(result, 22);
|
|
752
756
|
}));
|
|
753
757
|
it("should work with getPelletInReserve on compressed response", () => __awaiter(void 0, void 0, void 0, function* () {
|
package/package.json
CHANGED
package/src/cli.ts
CHANGED
|
@@ -219,13 +219,13 @@ const createProgram = (): Command => {
|
|
|
219
219
|
) => api.getEnvironmentTemperature(jwtToken, mac),
|
|
220
220
|
},
|
|
221
221
|
{
|
|
222
|
-
commandName: "
|
|
223
|
-
description: "Retrieve target temperature",
|
|
222
|
+
commandName: "getEnvironment1Temperature",
|
|
223
|
+
description: "Retrieve Environment 1 target temperature",
|
|
224
224
|
getter: (
|
|
225
225
|
api: ReturnType<typeof configure>,
|
|
226
226
|
jwtToken: string,
|
|
227
227
|
mac: string,
|
|
228
|
-
) => api.
|
|
228
|
+
) => api.getEnvironment1Temperature(jwtToken, mac),
|
|
229
229
|
},
|
|
230
230
|
{
|
|
231
231
|
commandName: "getFan1Speed",
|
|
@@ -366,14 +366,14 @@ const createProgram = (): Command => {
|
|
|
366
366
|
) => api.setPowerLevel(jwtToken, mac, value),
|
|
367
367
|
},
|
|
368
368
|
{
|
|
369
|
-
commandName: "
|
|
370
|
-
description: "Set
|
|
369
|
+
commandName: "setEnvironment1Temperature",
|
|
370
|
+
description: "Set Environment 1 target temperature (degrees Celsius)",
|
|
371
371
|
setter: (
|
|
372
372
|
api: ReturnType<typeof configure>,
|
|
373
373
|
jwtToken: string,
|
|
374
374
|
mac: string,
|
|
375
375
|
value: number,
|
|
376
|
-
) => api.
|
|
376
|
+
) => api.setEnvironment1Temperature(jwtToken, mac, value),
|
|
377
377
|
},
|
|
378
378
|
{
|
|
379
379
|
commandName: "setFan1Speed",
|
|
@@ -506,6 +506,176 @@ const createProgram = (): Command => {
|
|
|
506
506
|
).action((options) => executeSetter(options, setter));
|
|
507
507
|
});
|
|
508
508
|
|
|
509
|
+
// Indexed getter commands (require --index parameter)
|
|
510
|
+
addLegacyOption(
|
|
511
|
+
addMacOption(
|
|
512
|
+
addAuthOptions(
|
|
513
|
+
program
|
|
514
|
+
.command("getFanSpeed")
|
|
515
|
+
.description("Retrieve fan speed by index (1-3)"),
|
|
516
|
+
).requiredOption(
|
|
517
|
+
"-i, --index <number>",
|
|
518
|
+
"Fan index (1, 2, or 3)",
|
|
519
|
+
parseInt,
|
|
520
|
+
),
|
|
521
|
+
),
|
|
522
|
+
).action(async (options) => {
|
|
523
|
+
const { username, password, mac, index, legacy = false } = options;
|
|
524
|
+
const normalizedMac = mac.replace(/:/g, "");
|
|
525
|
+
const storage = createFileStorage();
|
|
526
|
+
configureAmplify(storage);
|
|
527
|
+
let jwtToken: string;
|
|
528
|
+
try {
|
|
529
|
+
jwtToken = await getSession(false, legacy);
|
|
530
|
+
} catch {
|
|
531
|
+
if (!username) {
|
|
532
|
+
throw new Error(
|
|
533
|
+
"No session found. Please provide --username to sign in.",
|
|
534
|
+
);
|
|
535
|
+
}
|
|
536
|
+
const pwd = password || (await promptPassword());
|
|
537
|
+
jwtToken = await signIn(username, pwd, legacy);
|
|
538
|
+
}
|
|
539
|
+
const apiUrl = legacy ? OLD_API_URL : NEW_API_URL;
|
|
540
|
+
const api = configure(apiUrl);
|
|
541
|
+
const result = await api.getFanSpeed(
|
|
542
|
+
jwtToken,
|
|
543
|
+
normalizedMac,
|
|
544
|
+
index as 1 | 2 | 3,
|
|
545
|
+
);
|
|
546
|
+
console.log(JSON.stringify(result, null, 2));
|
|
547
|
+
});
|
|
548
|
+
|
|
549
|
+
addLegacyOption(
|
|
550
|
+
addMacOption(
|
|
551
|
+
addAuthOptions(
|
|
552
|
+
program
|
|
553
|
+
.command("getTargetTemperature")
|
|
554
|
+
.description(
|
|
555
|
+
"Retrieve target temperature by environment index (1-3)",
|
|
556
|
+
),
|
|
557
|
+
).requiredOption(
|
|
558
|
+
"-i, --index <number>",
|
|
559
|
+
"Environment index (1, 2, or 3)",
|
|
560
|
+
parseInt,
|
|
561
|
+
),
|
|
562
|
+
),
|
|
563
|
+
).action(async (options) => {
|
|
564
|
+
const { username, password, mac, index, legacy = false } = options;
|
|
565
|
+
const normalizedMac = mac.replace(/:/g, "");
|
|
566
|
+
const storage = createFileStorage();
|
|
567
|
+
configureAmplify(storage);
|
|
568
|
+
let jwtToken: string;
|
|
569
|
+
try {
|
|
570
|
+
jwtToken = await getSession(false, legacy);
|
|
571
|
+
} catch {
|
|
572
|
+
if (!username) {
|
|
573
|
+
throw new Error(
|
|
574
|
+
"No session found. Please provide --username to sign in.",
|
|
575
|
+
);
|
|
576
|
+
}
|
|
577
|
+
const pwd = password || (await promptPassword());
|
|
578
|
+
jwtToken = await signIn(username, pwd, legacy);
|
|
579
|
+
}
|
|
580
|
+
const apiUrl = legacy ? OLD_API_URL : NEW_API_URL;
|
|
581
|
+
const api = configure(apiUrl);
|
|
582
|
+
const result = await api.getTargetTemperature(
|
|
583
|
+
jwtToken,
|
|
584
|
+
normalizedMac,
|
|
585
|
+
index as 1 | 2 | 3,
|
|
586
|
+
);
|
|
587
|
+
console.log(JSON.stringify(result, null, 2));
|
|
588
|
+
});
|
|
589
|
+
|
|
590
|
+
// Indexed setter commands (require --index and --value parameters)
|
|
591
|
+
addLegacyOption(
|
|
592
|
+
addMacOption(
|
|
593
|
+
addAuthOptions(
|
|
594
|
+
program
|
|
595
|
+
.command("setFanSpeed")
|
|
596
|
+
.description("Set fan speed by index (1-3)"),
|
|
597
|
+
)
|
|
598
|
+
.requiredOption(
|
|
599
|
+
"-i, --index <number>",
|
|
600
|
+
"Fan index (1, 2, or 3)",
|
|
601
|
+
parseInt,
|
|
602
|
+
)
|
|
603
|
+
.requiredOption("-v, --value <number>", "Fan speed (0-5)", parseFloat),
|
|
604
|
+
),
|
|
605
|
+
).action(async (options) => {
|
|
606
|
+
const { username, password, mac, index, value, legacy = false } = options;
|
|
607
|
+
const normalizedMac = mac.replace(/:/g, "");
|
|
608
|
+
const storage = createFileStorage();
|
|
609
|
+
configureAmplify(storage);
|
|
610
|
+
let jwtToken: string;
|
|
611
|
+
try {
|
|
612
|
+
jwtToken = await getSession(false, legacy);
|
|
613
|
+
} catch {
|
|
614
|
+
if (!username) {
|
|
615
|
+
throw new Error(
|
|
616
|
+
"No session found. Please provide --username to sign in.",
|
|
617
|
+
);
|
|
618
|
+
}
|
|
619
|
+
const pwd = password || (await promptPassword());
|
|
620
|
+
jwtToken = await signIn(username, pwd, legacy);
|
|
621
|
+
}
|
|
622
|
+
const apiUrl = legacy ? OLD_API_URL : NEW_API_URL;
|
|
623
|
+
const api = configure(apiUrl);
|
|
624
|
+
const result = await api.setFanSpeed(
|
|
625
|
+
jwtToken,
|
|
626
|
+
normalizedMac,
|
|
627
|
+
index as 1 | 2 | 3,
|
|
628
|
+
value,
|
|
629
|
+
);
|
|
630
|
+
console.log(JSON.stringify(result, null, 2));
|
|
631
|
+
});
|
|
632
|
+
|
|
633
|
+
addLegacyOption(
|
|
634
|
+
addMacOption(
|
|
635
|
+
addAuthOptions(
|
|
636
|
+
program
|
|
637
|
+
.command("setTargetTemperature")
|
|
638
|
+
.description("Set target temperature by environment index (1-3)"),
|
|
639
|
+
)
|
|
640
|
+
.requiredOption(
|
|
641
|
+
"-i, --index <number>",
|
|
642
|
+
"Environment index (1, 2, or 3)",
|
|
643
|
+
parseInt,
|
|
644
|
+
)
|
|
645
|
+
.requiredOption(
|
|
646
|
+
"-v, --value <number>",
|
|
647
|
+
"Temperature in degrees Celsius",
|
|
648
|
+
parseFloat,
|
|
649
|
+
),
|
|
650
|
+
),
|
|
651
|
+
).action(async (options) => {
|
|
652
|
+
const { username, password, mac, index, value, legacy = false } = options;
|
|
653
|
+
const normalizedMac = mac.replace(/:/g, "");
|
|
654
|
+
const storage = createFileStorage();
|
|
655
|
+
configureAmplify(storage);
|
|
656
|
+
let jwtToken: string;
|
|
657
|
+
try {
|
|
658
|
+
jwtToken = await getSession(false, legacy);
|
|
659
|
+
} catch {
|
|
660
|
+
if (!username) {
|
|
661
|
+
throw new Error(
|
|
662
|
+
"No session found. Please provide --username to sign in.",
|
|
663
|
+
);
|
|
664
|
+
}
|
|
665
|
+
const pwd = password || (await promptPassword());
|
|
666
|
+
jwtToken = await signIn(username, pwd, legacy);
|
|
667
|
+
}
|
|
668
|
+
const apiUrl = legacy ? OLD_API_URL : NEW_API_URL;
|
|
669
|
+
const api = configure(apiUrl);
|
|
670
|
+
const result = await api.setTargetTemperature(
|
|
671
|
+
jwtToken,
|
|
672
|
+
normalizedMac,
|
|
673
|
+
index as 1 | 2 | 3,
|
|
674
|
+
value,
|
|
675
|
+
);
|
|
676
|
+
console.log(JSON.stringify(result, null, 2));
|
|
677
|
+
});
|
|
678
|
+
|
|
509
679
|
// Command: register
|
|
510
680
|
addLegacyOption(
|
|
511
681
|
addAuthOptions(
|
package/src/library.test.ts
CHANGED
|
@@ -211,6 +211,8 @@ describe("library", () => {
|
|
|
211
211
|
"getPower",
|
|
212
212
|
"setPowerLevel",
|
|
213
213
|
"getPowerLevel",
|
|
214
|
+
"setFanSpeed",
|
|
215
|
+
"getFanSpeed",
|
|
214
216
|
"setFan1Speed",
|
|
215
217
|
"setFan2Speed",
|
|
216
218
|
"setFan3Speed",
|
|
@@ -228,6 +230,8 @@ describe("library", () => {
|
|
|
228
230
|
"getEnvironmentTemperature",
|
|
229
231
|
"getTargetTemperature",
|
|
230
232
|
"setTargetTemperature",
|
|
233
|
+
"setEnvironment1Temperature",
|
|
234
|
+
"getEnvironment1Temperature",
|
|
231
235
|
"setEnvironment2Temperature",
|
|
232
236
|
"getEnvironment2Temperature",
|
|
233
237
|
"setEnvironment3Temperature",
|
|
@@ -391,7 +395,7 @@ describe("library", () => {
|
|
|
391
395
|
{
|
|
392
396
|
method: "getTargetTemperature",
|
|
393
397
|
call: (api: ReturnType<typeof configure>, token: string, mac: string) =>
|
|
394
|
-
api.getTargetTemperature(token, mac),
|
|
398
|
+
api.getTargetTemperature(token, mac, 1),
|
|
395
399
|
expectedResult: 22,
|
|
396
400
|
},
|
|
397
401
|
{
|
|
@@ -529,7 +533,7 @@ describe("library", () => {
|
|
|
529
533
|
token: string,
|
|
530
534
|
mac: string,
|
|
531
535
|
value: number,
|
|
532
|
-
) => api.setTargetTemperature(token, mac, value),
|
|
536
|
+
) => api.setTargetTemperature(token, mac, 1, value),
|
|
533
537
|
payload: {
|
|
534
538
|
name: "enviroment_1_temperature",
|
|
535
539
|
value: 20,
|
|
@@ -961,6 +965,7 @@ describe("library", () => {
|
|
|
961
965
|
const result = await api.getTargetTemperature(
|
|
962
966
|
expectedToken,
|
|
963
967
|
"mockMacAddress",
|
|
968
|
+
1,
|
|
964
969
|
);
|
|
965
970
|
|
|
966
971
|
assert.equal(result, 22);
|