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/cjs/package.json
CHANGED
package/dist/cjs/src/cli.js
CHANGED
|
@@ -164,9 +164,9 @@ const createProgram = () => {
|
|
|
164
164
|
getter: (api, jwtToken, mac) => api.getEnvironmentTemperature(jwtToken, mac),
|
|
165
165
|
},
|
|
166
166
|
{
|
|
167
|
-
commandName: "
|
|
168
|
-
description: "Retrieve target temperature",
|
|
169
|
-
getter: (api, jwtToken, mac) => api.
|
|
167
|
+
commandName: "getEnvironment1Temperature",
|
|
168
|
+
description: "Retrieve Environment 1 target temperature",
|
|
169
|
+
getter: (api, jwtToken, mac) => api.getEnvironment1Temperature(jwtToken, mac),
|
|
170
170
|
},
|
|
171
171
|
{
|
|
172
172
|
commandName: "getFan1Speed",
|
|
@@ -244,9 +244,9 @@ const createProgram = () => {
|
|
|
244
244
|
setter: (api, jwtToken, mac, value) => api.setPowerLevel(jwtToken, mac, value),
|
|
245
245
|
},
|
|
246
246
|
{
|
|
247
|
-
commandName: "
|
|
248
|
-
description: "Set
|
|
249
|
-
setter: (api, jwtToken, mac, value) => api.
|
|
247
|
+
commandName: "setEnvironment1Temperature",
|
|
248
|
+
description: "Set Environment 1 target temperature (degrees Celsius)",
|
|
249
|
+
setter: (api, jwtToken, mac, value) => api.setEnvironment1Temperature(jwtToken, mac, value),
|
|
250
250
|
},
|
|
251
251
|
{
|
|
252
252
|
commandName: "setFan1Speed",
|
|
@@ -311,6 +311,104 @@ const createProgram = () => {
|
|
|
311
311
|
].forEach(({ commandName, description, setter }) => {
|
|
312
312
|
addLegacyOption(addMacOption(addAuthOptions(program.command(commandName).description(description)).requiredOption("-v, --value <number>", "Value to set", parseFloat))).action((options) => executeSetter(options, setter));
|
|
313
313
|
});
|
|
314
|
+
// Indexed getter commands (require --index parameter)
|
|
315
|
+
addLegacyOption(addMacOption(addAuthOptions(program
|
|
316
|
+
.command("getFanSpeed")
|
|
317
|
+
.description("Retrieve fan speed by index (1-3)")).requiredOption("-i, --index <number>", "Fan index (1, 2, or 3)", parseInt))).action((options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
318
|
+
const { username, password, mac, index, legacy = false } = options;
|
|
319
|
+
const normalizedMac = mac.replace(/:/g, "");
|
|
320
|
+
const storage = (0, token_storage_1.createFileStorage)();
|
|
321
|
+
(0, library_1.configureAmplify)(storage);
|
|
322
|
+
let jwtToken;
|
|
323
|
+
try {
|
|
324
|
+
jwtToken = yield (0, library_1.getSession)(false, legacy);
|
|
325
|
+
}
|
|
326
|
+
catch (_a) {
|
|
327
|
+
if (!username) {
|
|
328
|
+
throw new Error("No session found. Please provide --username to sign in.");
|
|
329
|
+
}
|
|
330
|
+
const pwd = password || (yield promptPassword());
|
|
331
|
+
jwtToken = yield (0, library_1.signIn)(username, pwd, legacy);
|
|
332
|
+
}
|
|
333
|
+
const apiUrl = legacy ? constants_1.OLD_API_URL : constants_1.NEW_API_URL;
|
|
334
|
+
const api = (0, library_1.configure)(apiUrl);
|
|
335
|
+
const result = yield api.getFanSpeed(jwtToken, normalizedMac, index);
|
|
336
|
+
console.log(JSON.stringify(result, null, 2));
|
|
337
|
+
}));
|
|
338
|
+
addLegacyOption(addMacOption(addAuthOptions(program
|
|
339
|
+
.command("getTargetTemperature")
|
|
340
|
+
.description("Retrieve target temperature by environment index (1-3)")).requiredOption("-i, --index <number>", "Environment index (1, 2, or 3)", parseInt))).action((options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
341
|
+
const { username, password, mac, index, legacy = false } = options;
|
|
342
|
+
const normalizedMac = mac.replace(/:/g, "");
|
|
343
|
+
const storage = (0, token_storage_1.createFileStorage)();
|
|
344
|
+
(0, library_1.configureAmplify)(storage);
|
|
345
|
+
let jwtToken;
|
|
346
|
+
try {
|
|
347
|
+
jwtToken = yield (0, library_1.getSession)(false, legacy);
|
|
348
|
+
}
|
|
349
|
+
catch (_a) {
|
|
350
|
+
if (!username) {
|
|
351
|
+
throw new Error("No session found. Please provide --username to sign in.");
|
|
352
|
+
}
|
|
353
|
+
const pwd = password || (yield promptPassword());
|
|
354
|
+
jwtToken = yield (0, library_1.signIn)(username, pwd, legacy);
|
|
355
|
+
}
|
|
356
|
+
const apiUrl = legacy ? constants_1.OLD_API_URL : constants_1.NEW_API_URL;
|
|
357
|
+
const api = (0, library_1.configure)(apiUrl);
|
|
358
|
+
const result = yield api.getTargetTemperature(jwtToken, normalizedMac, index);
|
|
359
|
+
console.log(JSON.stringify(result, null, 2));
|
|
360
|
+
}));
|
|
361
|
+
// Indexed setter commands (require --index and --value parameters)
|
|
362
|
+
addLegacyOption(addMacOption(addAuthOptions(program
|
|
363
|
+
.command("setFanSpeed")
|
|
364
|
+
.description("Set fan speed by index (1-3)"))
|
|
365
|
+
.requiredOption("-i, --index <number>", "Fan index (1, 2, or 3)", parseInt)
|
|
366
|
+
.requiredOption("-v, --value <number>", "Fan speed (0-5)", parseFloat))).action((options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
367
|
+
const { username, password, mac, index, value, legacy = false } = options;
|
|
368
|
+
const normalizedMac = mac.replace(/:/g, "");
|
|
369
|
+
const storage = (0, token_storage_1.createFileStorage)();
|
|
370
|
+
(0, library_1.configureAmplify)(storage);
|
|
371
|
+
let jwtToken;
|
|
372
|
+
try {
|
|
373
|
+
jwtToken = yield (0, library_1.getSession)(false, legacy);
|
|
374
|
+
}
|
|
375
|
+
catch (_a) {
|
|
376
|
+
if (!username) {
|
|
377
|
+
throw new Error("No session found. Please provide --username to sign in.");
|
|
378
|
+
}
|
|
379
|
+
const pwd = password || (yield promptPassword());
|
|
380
|
+
jwtToken = yield (0, library_1.signIn)(username, pwd, legacy);
|
|
381
|
+
}
|
|
382
|
+
const apiUrl = legacy ? constants_1.OLD_API_URL : constants_1.NEW_API_URL;
|
|
383
|
+
const api = (0, library_1.configure)(apiUrl);
|
|
384
|
+
const result = yield api.setFanSpeed(jwtToken, normalizedMac, index, value);
|
|
385
|
+
console.log(JSON.stringify(result, null, 2));
|
|
386
|
+
}));
|
|
387
|
+
addLegacyOption(addMacOption(addAuthOptions(program
|
|
388
|
+
.command("setTargetTemperature")
|
|
389
|
+
.description("Set target temperature by environment index (1-3)"))
|
|
390
|
+
.requiredOption("-i, --index <number>", "Environment index (1, 2, or 3)", parseInt)
|
|
391
|
+
.requiredOption("-v, --value <number>", "Temperature in degrees Celsius", parseFloat))).action((options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
392
|
+
const { username, password, mac, index, value, legacy = false } = options;
|
|
393
|
+
const normalizedMac = mac.replace(/:/g, "");
|
|
394
|
+
const storage = (0, token_storage_1.createFileStorage)();
|
|
395
|
+
(0, library_1.configureAmplify)(storage);
|
|
396
|
+
let jwtToken;
|
|
397
|
+
try {
|
|
398
|
+
jwtToken = yield (0, library_1.getSession)(false, legacy);
|
|
399
|
+
}
|
|
400
|
+
catch (_a) {
|
|
401
|
+
if (!username) {
|
|
402
|
+
throw new Error("No session found. Please provide --username to sign in.");
|
|
403
|
+
}
|
|
404
|
+
const pwd = password || (yield promptPassword());
|
|
405
|
+
jwtToken = yield (0, library_1.signIn)(username, pwd, legacy);
|
|
406
|
+
}
|
|
407
|
+
const apiUrl = legacy ? constants_1.OLD_API_URL : constants_1.NEW_API_URL;
|
|
408
|
+
const api = (0, library_1.configure)(apiUrl);
|
|
409
|
+
const result = yield api.setTargetTemperature(jwtToken, normalizedMac, index, value);
|
|
410
|
+
console.log(JSON.stringify(result, null, 2));
|
|
411
|
+
}));
|
|
314
412
|
// Command: register
|
|
315
413
|
addLegacyOption(addAuthOptions(program
|
|
316
414
|
.command("register")
|
package/dist/cjs/src/index.d.ts
CHANGED
|
@@ -4,4 +4,4 @@ export { API_URL, NEW_API_URL, OLD_API_URL } from "./constants";
|
|
|
4
4
|
export { configure, getSession, signIn } from "./library";
|
|
5
5
|
export { serialNumberDisplay, serialNumberFromHex, serialNumberToHex, } from "./serial-utils";
|
|
6
6
|
export { BufferEncodedType, CommandsType, DeviceAssociationBody, DeviceAssociationResponse, DeviceInfoRawType, DeviceInfoType, DiscoveredDevice, EditDeviceAssociationBody, StatusType, TemperaturesType, UserParametersType, } from "./types";
|
|
7
|
-
export declare const deviceInfo: (jwtToken: string, macAddress: string) => Promise<import("./types").DeviceInfoType>, registerDevice: (jwtToken: string, macAddress: string, serialNumber: string, deviceName?: string, deviceRoom?: string) => Promise<import("./types").DeviceAssociationResponse>, editDevice: (jwtToken: string, macAddress: string, deviceName?: string, deviceRoom?: string) => Promise<import("./types").DeviceAssociationResponse>, setPower: (jwtToken: string, macAddress: string, value: number) => Promise<unknown>, setPowerOff: (jwtToken: string, macAddress: string) => Promise<unknown>, setPowerOn: (jwtToken: string, macAddress: string) => Promise<unknown>, getPower: (jwtToken: string, macAddress: string) => Promise<boolean>, getEnvironmentTemperature: (jwtToken: string, macAddress: string) => Promise<number>, getTargetTemperature: (jwtToken: string, macAddress: string) => Promise<number>, setTargetTemperature: (jwtToken: string, macAddress: string, temperature: number) => Promise<unknown>;
|
|
7
|
+
export declare const deviceInfo: (jwtToken: string, macAddress: string) => Promise<import("./types").DeviceInfoType>, registerDevice: (jwtToken: string, macAddress: string, serialNumber: string, deviceName?: string, deviceRoom?: string) => Promise<import("./types").DeviceAssociationResponse>, editDevice: (jwtToken: string, macAddress: string, deviceName?: string, deviceRoom?: string) => Promise<import("./types").DeviceAssociationResponse>, setPower: (jwtToken: string, macAddress: string, value: number) => Promise<unknown>, setPowerOff: (jwtToken: string, macAddress: string) => Promise<unknown>, setPowerOn: (jwtToken: string, macAddress: string) => Promise<unknown>, getPower: (jwtToken: string, macAddress: string) => Promise<boolean>, getEnvironmentTemperature: (jwtToken: string, macAddress: string) => Promise<number>, getTargetTemperature: (jwtToken: string, macAddress: string, envIndex: 1 | 2 | 3) => Promise<number>, setTargetTemperature: (jwtToken: string, macAddress: string, envIndex: 1 | 2 | 3, temperature: number) => Promise<unknown>;
|
|
@@ -50,6 +50,8 @@ declare const configure: (baseURL?: string) => {
|
|
|
50
50
|
getPower: (jwtToken: string, macAddress: string) => Promise<boolean>;
|
|
51
51
|
setPowerLevel: (jwtToken: string, macAddress: string, level: number) => Promise<unknown>;
|
|
52
52
|
getPowerLevel: (jwtToken: string, macAddress: string) => Promise<number>;
|
|
53
|
+
setFanSpeed: (jwtToken: string, macAddress: string, fanIndex: 1 | 2 | 3, speed: number) => Promise<unknown>;
|
|
54
|
+
getFanSpeed: (jwtToken: string, macAddress: string, fanIndex: 1 | 2 | 3) => Promise<number>;
|
|
53
55
|
setFan1Speed: (jwtToken: string, macAddress: string, speed: number) => Promise<unknown>;
|
|
54
56
|
setFan2Speed: (jwtToken: string, macAddress: string, speed: number) => Promise<unknown>;
|
|
55
57
|
setFan3Speed: (jwtToken: string, macAddress: string, speed: number) => Promise<unknown>;
|
|
@@ -65,8 +67,10 @@ declare const configure: (baseURL?: string) => {
|
|
|
65
67
|
setAuto: (jwtToken: string, macAddress: string, enabled: boolean) => Promise<unknown>;
|
|
66
68
|
getAuto: (jwtToken: string, macAddress: string) => Promise<boolean>;
|
|
67
69
|
getEnvironmentTemperature: (jwtToken: string, macAddress: string) => Promise<number>;
|
|
68
|
-
getTargetTemperature: (jwtToken: string, macAddress: string) => Promise<number>;
|
|
69
|
-
setTargetTemperature: (jwtToken: string, macAddress: string, temperature: number) => Promise<unknown>;
|
|
70
|
+
getTargetTemperature: (jwtToken: string, macAddress: string, envIndex: 1 | 2 | 3) => Promise<number>;
|
|
71
|
+
setTargetTemperature: (jwtToken: string, macAddress: string, envIndex: 1 | 2 | 3, temperature: number) => Promise<unknown>;
|
|
72
|
+
setEnvironment1Temperature: (jwtToken: string, macAddress: string, temperature: number) => Promise<unknown>;
|
|
73
|
+
getEnvironment1Temperature: (jwtToken: string, macAddress: string) => Promise<number>;
|
|
70
74
|
setEnvironment2Temperature: (jwtToken: string, macAddress: string, temperature: number) => Promise<unknown>;
|
|
71
75
|
getEnvironment2Temperature: (jwtToken: string, macAddress: string) => Promise<number>;
|
|
72
76
|
setEnvironment3Temperature: (jwtToken: string, macAddress: string, temperature: number) => Promise<unknown>;
|
package/dist/cjs/src/library.js
CHANGED
|
@@ -227,81 +227,45 @@ const getPowerLevel = (baseURL) =>
|
|
|
227
227
|
const info = yield deviceInfo(baseURL)(jwtToken, macAddress);
|
|
228
228
|
return info.nvm.user_parameters.manual_power;
|
|
229
229
|
});
|
|
230
|
-
const
|
|
230
|
+
const setFanSpeed = (baseURL) =>
|
|
231
231
|
/**
|
|
232
|
-
* Sets the speed of fan
|
|
232
|
+
* Sets the speed of a fan by index.
|
|
233
233
|
*
|
|
234
234
|
* @param {string} jwtToken - The JWT token for authentication.
|
|
235
235
|
* @param {string} macAddress - The MAC address of the device.
|
|
236
|
+
* @param {1 | 2 | 3} fanIndex - The fan index (1, 2, or 3).
|
|
236
237
|
* @param {number} speed - The fan speed (0-5, 0=auto on some models).
|
|
237
238
|
* @returns {Promise<unknown>} - A promise that resolves to the command response.
|
|
238
239
|
*/
|
|
239
|
-
(jwtToken, macAddress, speed) => mqttCommand(baseURL)(jwtToken, macAddress, {
|
|
240
|
-
name:
|
|
240
|
+
(jwtToken, macAddress, fanIndex, speed) => mqttCommand(baseURL)(jwtToken, macAddress, {
|
|
241
|
+
name: `fan_${fanIndex}_speed`,
|
|
241
242
|
value: speed,
|
|
242
243
|
});
|
|
243
|
-
const
|
|
244
|
+
const getFanSpeed = (baseURL) =>
|
|
244
245
|
/**
|
|
245
|
-
*
|
|
246
|
-
*
|
|
247
|
-
* @param {string} jwtToken - The JWT token for authentication.
|
|
248
|
-
* @param {string} macAddress - The MAC address of the device.
|
|
249
|
-
* @param {number} speed - The fan speed (0-5, 0=auto on some models).
|
|
250
|
-
* @returns {Promise<unknown>} - A promise that resolves to the command response.
|
|
251
|
-
*/
|
|
252
|
-
(jwtToken, macAddress, speed) => mqttCommand(baseURL)(jwtToken, macAddress, {
|
|
253
|
-
name: "fan_2_speed",
|
|
254
|
-
value: speed,
|
|
255
|
-
});
|
|
256
|
-
const setFan3Speed = (baseURL) =>
|
|
257
|
-
/**
|
|
258
|
-
* Sets the speed of fan 3.
|
|
259
|
-
*
|
|
260
|
-
* @param {string} jwtToken - The JWT token for authentication.
|
|
261
|
-
* @param {string} macAddress - The MAC address of the device.
|
|
262
|
-
* @param {number} speed - The fan speed (0-5, 0=auto on some models).
|
|
263
|
-
* @returns {Promise<unknown>} - A promise that resolves to the command response.
|
|
264
|
-
*/
|
|
265
|
-
(jwtToken, macAddress, speed) => mqttCommand(baseURL)(jwtToken, macAddress, {
|
|
266
|
-
name: "fan_3_speed",
|
|
267
|
-
value: speed,
|
|
268
|
-
});
|
|
269
|
-
const getFan1Speed = (baseURL) =>
|
|
270
|
-
/**
|
|
271
|
-
* Retrieves the current speed of fan 1.
|
|
246
|
+
* Retrieves the current speed of a fan by index.
|
|
272
247
|
*
|
|
273
248
|
* @param {string} jwtToken - The JWT token for authentication.
|
|
274
249
|
* @param {string} macAddress - The MAC address of the device.
|
|
250
|
+
* @param {1 | 2 | 3} fanIndex - The fan index (1, 2, or 3).
|
|
275
251
|
* @returns {Promise<number>} - A promise that resolves to the fan speed.
|
|
276
252
|
*/
|
|
277
|
-
(jwtToken, macAddress) => __awaiter(void 0, void 0, void 0, function* () {
|
|
278
|
-
const info = yield deviceInfo(baseURL)(jwtToken, macAddress);
|
|
279
|
-
return info.nvm.user_parameters.fan_1_ventilation;
|
|
280
|
-
});
|
|
281
|
-
const getFan2Speed = (baseURL) =>
|
|
282
|
-
/**
|
|
283
|
-
* Retrieves the current speed of fan 2.
|
|
284
|
-
*
|
|
285
|
-
* @param {string} jwtToken - The JWT token for authentication.
|
|
286
|
-
* @param {string} macAddress - The MAC address of the device.
|
|
287
|
-
* @returns {Promise<number>} - A promise that resolves to the fan speed.
|
|
288
|
-
*/
|
|
289
|
-
(jwtToken, macAddress) => __awaiter(void 0, void 0, void 0, function* () {
|
|
290
|
-
const info = yield deviceInfo(baseURL)(jwtToken, macAddress);
|
|
291
|
-
return info.nvm.user_parameters.fan_2_ventilation;
|
|
292
|
-
});
|
|
293
|
-
const getFan3Speed = (baseURL) =>
|
|
294
|
-
/**
|
|
295
|
-
* Retrieves the current speed of fan 3.
|
|
296
|
-
*
|
|
297
|
-
* @param {string} jwtToken - The JWT token for authentication.
|
|
298
|
-
* @param {string} macAddress - The MAC address of the device.
|
|
299
|
-
* @returns {Promise<number>} - A promise that resolves to the fan speed.
|
|
300
|
-
*/
|
|
301
|
-
(jwtToken, macAddress) => __awaiter(void 0, void 0, void 0, function* () {
|
|
253
|
+
(jwtToken, macAddress, fanIndex) => __awaiter(void 0, void 0, void 0, function* () {
|
|
302
254
|
const info = yield deviceInfo(baseURL)(jwtToken, macAddress);
|
|
303
|
-
|
|
304
|
-
|
|
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);
|
|
305
269
|
const setAirkare = (baseURL) =>
|
|
306
270
|
/**
|
|
307
271
|
* Enables or disables Airkare (air quality) mode.
|
|
@@ -429,79 +393,43 @@ const getEnvironmentTemperature = (baseURL) =>
|
|
|
429
393
|
});
|
|
430
394
|
const getTargetTemperature = (baseURL) =>
|
|
431
395
|
/**
|
|
432
|
-
* Retrieves the target temperature
|
|
396
|
+
* Retrieves the target temperature for an environment zone.
|
|
433
397
|
*
|
|
434
398
|
* @param {string} jwtToken - The JWT token for authentication.
|
|
435
399
|
* @param {string} macAddress - The MAC address of the device.
|
|
436
|
-
* @
|
|
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).
|
|
437
402
|
*/
|
|
438
|
-
(jwtToken, macAddress) => __awaiter(void 0, void 0, void 0, function* () {
|
|
403
|
+
(jwtToken, macAddress, envIndex) => __awaiter(void 0, void 0, void 0, function* () {
|
|
439
404
|
const info = yield deviceInfo(baseURL)(jwtToken, macAddress);
|
|
440
|
-
|
|
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];
|
|
441
411
|
});
|
|
442
412
|
const setTargetTemperature = (baseURL) =>
|
|
443
413
|
/**
|
|
444
|
-
*
|
|
445
|
-
*
|
|
446
|
-
* @param {string} jwtToken - The JWT token for authentication.
|
|
447
|
-
* @param {string} macAddress - The MAC address of the device.
|
|
448
|
-
* @param {number} temperature - The desired target temperature (degree celsius).
|
|
449
|
-
* @returns {Promise<string>} - A promise that resolves to the command response.
|
|
450
|
-
*/
|
|
451
|
-
(jwtToken, macAddress, temperature) => mqttCommand(baseURL)(jwtToken, macAddress, {
|
|
452
|
-
name: "enviroment_1_temperature",
|
|
453
|
-
value: temperature,
|
|
454
|
-
});
|
|
455
|
-
const setEnvironment2Temperature = (baseURL) =>
|
|
456
|
-
/**
|
|
457
|
-
* Sets the target temperature for Environment 2 zone.
|
|
458
|
-
*
|
|
459
|
-
* @param {string} jwtToken - The JWT token for authentication.
|
|
460
|
-
* @param {string} macAddress - The MAC address of the device.
|
|
461
|
-
* @param {number} temperature - The target temperature in degrees Celsius.
|
|
462
|
-
* @returns {Promise<unknown>} - A promise that resolves to the command response.
|
|
463
|
-
*/
|
|
464
|
-
(jwtToken, macAddress, temperature) => mqttCommand(baseURL)(jwtToken, macAddress, {
|
|
465
|
-
name: "enviroment_2_temperature",
|
|
466
|
-
value: temperature,
|
|
467
|
-
});
|
|
468
|
-
const getEnvironment2Temperature = (baseURL) =>
|
|
469
|
-
/**
|
|
470
|
-
* Retrieves the target temperature for Environment 2 zone.
|
|
471
|
-
*
|
|
472
|
-
* @param {string} jwtToken - The JWT token for authentication.
|
|
473
|
-
* @param {string} macAddress - The MAC address of the device.
|
|
474
|
-
* @returns {Promise<number>} - A promise that resolves to the temperature in degrees Celsius.
|
|
475
|
-
*/
|
|
476
|
-
(jwtToken, macAddress) => __awaiter(void 0, void 0, void 0, function* () {
|
|
477
|
-
const info = yield deviceInfo(baseURL)(jwtToken, macAddress);
|
|
478
|
-
return info.nvm.user_parameters.enviroment_2_temperature;
|
|
479
|
-
});
|
|
480
|
-
const setEnvironment3Temperature = (baseURL) =>
|
|
481
|
-
/**
|
|
482
|
-
* Sets the target temperature for Environment 3 zone.
|
|
414
|
+
* Sets the target temperature for an environment zone.
|
|
483
415
|
*
|
|
484
416
|
* @param {string} jwtToken - The JWT token for authentication.
|
|
485
417
|
* @param {string} macAddress - The MAC address of the device.
|
|
486
|
-
* @param {
|
|
418
|
+
* @param {1 | 2 | 3} envIndex - The environment zone index (1, 2, or 3).
|
|
419
|
+
* @param {number} temperature - The desired target temperature (degrees Celsius).
|
|
487
420
|
* @returns {Promise<unknown>} - A promise that resolves to the command response.
|
|
488
421
|
*/
|
|
489
|
-
(jwtToken, macAddress, temperature) => mqttCommand(baseURL)(jwtToken, macAddress, {
|
|
490
|
-
name:
|
|
422
|
+
(jwtToken, macAddress, envIndex, temperature) => mqttCommand(baseURL)(jwtToken, macAddress, {
|
|
423
|
+
name: `enviroment_${envIndex}_temperature`,
|
|
491
424
|
value: temperature,
|
|
492
425
|
});
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
*/
|
|
501
|
-
(jwtToken, macAddress) => __awaiter(void 0, void 0, void 0, function* () {
|
|
502
|
-
const info = yield deviceInfo(baseURL)(jwtToken, macAddress);
|
|
503
|
-
return info.nvm.user_parameters.enviroment_3_temperature;
|
|
504
|
-
});
|
|
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);
|
|
505
433
|
const setMeasureUnit = (baseURL) =>
|
|
506
434
|
/**
|
|
507
435
|
* Sets the temperature measurement unit (Celsius or Fahrenheit).
|
|
@@ -654,6 +582,8 @@ const configure = (baseURL = constants_1.API_URL) => ({
|
|
|
654
582
|
getPower: getPower(baseURL),
|
|
655
583
|
setPowerLevel: setPowerLevel(baseURL),
|
|
656
584
|
getPowerLevel: getPowerLevel(baseURL),
|
|
585
|
+
setFanSpeed: setFanSpeed(baseURL),
|
|
586
|
+
getFanSpeed: getFanSpeed(baseURL),
|
|
657
587
|
setFan1Speed: setFan1Speed(baseURL),
|
|
658
588
|
setFan2Speed: setFan2Speed(baseURL),
|
|
659
589
|
setFan3Speed: setFan3Speed(baseURL),
|
|
@@ -671,6 +601,8 @@ const configure = (baseURL = constants_1.API_URL) => ({
|
|
|
671
601
|
getEnvironmentTemperature: getEnvironmentTemperature(baseURL),
|
|
672
602
|
getTargetTemperature: getTargetTemperature(baseURL),
|
|
673
603
|
setTargetTemperature: setTargetTemperature(baseURL),
|
|
604
|
+
setEnvironment1Temperature: setEnvironment1Temperature(baseURL),
|
|
605
|
+
getEnvironment1Temperature: getEnvironment1Temperature(baseURL),
|
|
674
606
|
setEnvironment2Temperature: setEnvironment2Temperature(baseURL),
|
|
675
607
|
getEnvironment2Temperature: getEnvironment2Temperature(baseURL),
|
|
676
608
|
setEnvironment3Temperature: setEnvironment3Temperature(baseURL),
|
|
@@ -189,6 +189,8 @@ describe("library", () => {
|
|
|
189
189
|
"getPower",
|
|
190
190
|
"setPowerLevel",
|
|
191
191
|
"getPowerLevel",
|
|
192
|
+
"setFanSpeed",
|
|
193
|
+
"getFanSpeed",
|
|
192
194
|
"setFan1Speed",
|
|
193
195
|
"setFan2Speed",
|
|
194
196
|
"setFan3Speed",
|
|
@@ -206,6 +208,8 @@ describe("library", () => {
|
|
|
206
208
|
"getEnvironmentTemperature",
|
|
207
209
|
"getTargetTemperature",
|
|
208
210
|
"setTargetTemperature",
|
|
211
|
+
"setEnvironment1Temperature",
|
|
212
|
+
"getEnvironment1Temperature",
|
|
209
213
|
"setEnvironment2Temperature",
|
|
210
214
|
"getEnvironment2Temperature",
|
|
211
215
|
"setEnvironment3Temperature",
|
|
@@ -349,7 +353,7 @@ describe("library", () => {
|
|
|
349
353
|
},
|
|
350
354
|
{
|
|
351
355
|
method: "getTargetTemperature",
|
|
352
|
-
call: (api, token, mac) => api.getTargetTemperature(token, mac),
|
|
356
|
+
call: (api, token, mac) => api.getTargetTemperature(token, mac, 1),
|
|
353
357
|
expectedResult: 22,
|
|
354
358
|
},
|
|
355
359
|
{
|
|
@@ -448,7 +452,7 @@ describe("library", () => {
|
|
|
448
452
|
},
|
|
449
453
|
{
|
|
450
454
|
method: "setTargetTemperature",
|
|
451
|
-
call: (api, token, mac, value) => api.setTargetTemperature(token, mac, value),
|
|
455
|
+
call: (api, token, mac, value) => api.setTargetTemperature(token, mac, 1, value),
|
|
452
456
|
payload: {
|
|
453
457
|
name: "enviroment_1_temperature",
|
|
454
458
|
value: 20,
|
|
@@ -752,7 +756,7 @@ describe("library", () => {
|
|
|
752
756
|
};
|
|
753
757
|
fetchStub.resolves(mockResponse(mockResponseData));
|
|
754
758
|
const api = (0, library_1.configure)("https://example.com/api/");
|
|
755
|
-
const result = yield api.getTargetTemperature(expectedToken, "mockMacAddress");
|
|
759
|
+
const result = yield api.getTargetTemperature(expectedToken, "mockMacAddress", 1);
|
|
756
760
|
assert_1.strict.equal(result, 22);
|
|
757
761
|
}));
|
|
758
762
|
it("should work with getPelletInReserve on compressed response", () => __awaiter(void 0, void 0, void 0, function* () {
|
package/dist/esm/package.json
CHANGED
package/dist/esm/src/cli.js
CHANGED
|
@@ -158,9 +158,9 @@ const createProgram = () => {
|
|
|
158
158
|
getter: (api, jwtToken, mac) => api.getEnvironmentTemperature(jwtToken, mac),
|
|
159
159
|
},
|
|
160
160
|
{
|
|
161
|
-
commandName: "
|
|
162
|
-
description: "Retrieve target temperature",
|
|
163
|
-
getter: (api, jwtToken, mac) => api.
|
|
161
|
+
commandName: "getEnvironment1Temperature",
|
|
162
|
+
description: "Retrieve Environment 1 target temperature",
|
|
163
|
+
getter: (api, jwtToken, mac) => api.getEnvironment1Temperature(jwtToken, mac),
|
|
164
164
|
},
|
|
165
165
|
{
|
|
166
166
|
commandName: "getFan1Speed",
|
|
@@ -238,9 +238,9 @@ const createProgram = () => {
|
|
|
238
238
|
setter: (api, jwtToken, mac, value) => api.setPowerLevel(jwtToken, mac, value),
|
|
239
239
|
},
|
|
240
240
|
{
|
|
241
|
-
commandName: "
|
|
242
|
-
description: "Set
|
|
243
|
-
setter: (api, jwtToken, mac, value) => api.
|
|
241
|
+
commandName: "setEnvironment1Temperature",
|
|
242
|
+
description: "Set Environment 1 target temperature (degrees Celsius)",
|
|
243
|
+
setter: (api, jwtToken, mac, value) => api.setEnvironment1Temperature(jwtToken, mac, value),
|
|
244
244
|
},
|
|
245
245
|
{
|
|
246
246
|
commandName: "setFan1Speed",
|
|
@@ -305,6 +305,104 @@ const createProgram = () => {
|
|
|
305
305
|
].forEach(({ commandName, description, setter }) => {
|
|
306
306
|
addLegacyOption(addMacOption(addAuthOptions(program.command(commandName).description(description)).requiredOption("-v, --value <number>", "Value to set", parseFloat))).action((options) => executeSetter(options, setter));
|
|
307
307
|
});
|
|
308
|
+
// Indexed getter commands (require --index parameter)
|
|
309
|
+
addLegacyOption(addMacOption(addAuthOptions(program
|
|
310
|
+
.command("getFanSpeed")
|
|
311
|
+
.description("Retrieve fan speed by index (1-3)")).requiredOption("-i, --index <number>", "Fan index (1, 2, or 3)", parseInt))).action((options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
312
|
+
const { username, password, mac, index, legacy = false } = options;
|
|
313
|
+
const normalizedMac = mac.replace(/:/g, "");
|
|
314
|
+
const storage = createFileStorage();
|
|
315
|
+
configureAmplify(storage);
|
|
316
|
+
let jwtToken;
|
|
317
|
+
try {
|
|
318
|
+
jwtToken = yield getSession(false, legacy);
|
|
319
|
+
}
|
|
320
|
+
catch (_a) {
|
|
321
|
+
if (!username) {
|
|
322
|
+
throw new Error("No session found. Please provide --username to sign in.");
|
|
323
|
+
}
|
|
324
|
+
const pwd = password || (yield promptPassword());
|
|
325
|
+
jwtToken = yield signIn(username, pwd, legacy);
|
|
326
|
+
}
|
|
327
|
+
const apiUrl = legacy ? OLD_API_URL : NEW_API_URL;
|
|
328
|
+
const api = configure(apiUrl);
|
|
329
|
+
const result = yield api.getFanSpeed(jwtToken, normalizedMac, index);
|
|
330
|
+
console.log(JSON.stringify(result, null, 2));
|
|
331
|
+
}));
|
|
332
|
+
addLegacyOption(addMacOption(addAuthOptions(program
|
|
333
|
+
.command("getTargetTemperature")
|
|
334
|
+
.description("Retrieve target temperature by environment index (1-3)")).requiredOption("-i, --index <number>", "Environment index (1, 2, or 3)", parseInt))).action((options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
335
|
+
const { username, password, mac, index, legacy = false } = options;
|
|
336
|
+
const normalizedMac = mac.replace(/:/g, "");
|
|
337
|
+
const storage = createFileStorage();
|
|
338
|
+
configureAmplify(storage);
|
|
339
|
+
let jwtToken;
|
|
340
|
+
try {
|
|
341
|
+
jwtToken = yield getSession(false, legacy);
|
|
342
|
+
}
|
|
343
|
+
catch (_a) {
|
|
344
|
+
if (!username) {
|
|
345
|
+
throw new Error("No session found. Please provide --username to sign in.");
|
|
346
|
+
}
|
|
347
|
+
const pwd = password || (yield promptPassword());
|
|
348
|
+
jwtToken = yield signIn(username, pwd, legacy);
|
|
349
|
+
}
|
|
350
|
+
const apiUrl = legacy ? OLD_API_URL : NEW_API_URL;
|
|
351
|
+
const api = configure(apiUrl);
|
|
352
|
+
const result = yield api.getTargetTemperature(jwtToken, normalizedMac, index);
|
|
353
|
+
console.log(JSON.stringify(result, null, 2));
|
|
354
|
+
}));
|
|
355
|
+
// Indexed setter commands (require --index and --value parameters)
|
|
356
|
+
addLegacyOption(addMacOption(addAuthOptions(program
|
|
357
|
+
.command("setFanSpeed")
|
|
358
|
+
.description("Set fan speed by index (1-3)"))
|
|
359
|
+
.requiredOption("-i, --index <number>", "Fan index (1, 2, or 3)", parseInt)
|
|
360
|
+
.requiredOption("-v, --value <number>", "Fan speed (0-5)", parseFloat))).action((options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
361
|
+
const { username, password, mac, index, value, legacy = false } = options;
|
|
362
|
+
const normalizedMac = mac.replace(/:/g, "");
|
|
363
|
+
const storage = createFileStorage();
|
|
364
|
+
configureAmplify(storage);
|
|
365
|
+
let jwtToken;
|
|
366
|
+
try {
|
|
367
|
+
jwtToken = yield getSession(false, legacy);
|
|
368
|
+
}
|
|
369
|
+
catch (_a) {
|
|
370
|
+
if (!username) {
|
|
371
|
+
throw new Error("No session found. Please provide --username to sign in.");
|
|
372
|
+
}
|
|
373
|
+
const pwd = password || (yield promptPassword());
|
|
374
|
+
jwtToken = yield signIn(username, pwd, legacy);
|
|
375
|
+
}
|
|
376
|
+
const apiUrl = legacy ? OLD_API_URL : NEW_API_URL;
|
|
377
|
+
const api = configure(apiUrl);
|
|
378
|
+
const result = yield api.setFanSpeed(jwtToken, normalizedMac, index, value);
|
|
379
|
+
console.log(JSON.stringify(result, null, 2));
|
|
380
|
+
}));
|
|
381
|
+
addLegacyOption(addMacOption(addAuthOptions(program
|
|
382
|
+
.command("setTargetTemperature")
|
|
383
|
+
.description("Set target temperature by environment index (1-3)"))
|
|
384
|
+
.requiredOption("-i, --index <number>", "Environment index (1, 2, or 3)", parseInt)
|
|
385
|
+
.requiredOption("-v, --value <number>", "Temperature in degrees Celsius", parseFloat))).action((options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
386
|
+
const { username, password, mac, index, value, legacy = false } = options;
|
|
387
|
+
const normalizedMac = mac.replace(/:/g, "");
|
|
388
|
+
const storage = createFileStorage();
|
|
389
|
+
configureAmplify(storage);
|
|
390
|
+
let jwtToken;
|
|
391
|
+
try {
|
|
392
|
+
jwtToken = yield getSession(false, legacy);
|
|
393
|
+
}
|
|
394
|
+
catch (_a) {
|
|
395
|
+
if (!username) {
|
|
396
|
+
throw new Error("No session found. Please provide --username to sign in.");
|
|
397
|
+
}
|
|
398
|
+
const pwd = password || (yield promptPassword());
|
|
399
|
+
jwtToken = yield signIn(username, pwd, legacy);
|
|
400
|
+
}
|
|
401
|
+
const apiUrl = legacy ? OLD_API_URL : NEW_API_URL;
|
|
402
|
+
const api = configure(apiUrl);
|
|
403
|
+
const result = yield api.setTargetTemperature(jwtToken, normalizedMac, index, value);
|
|
404
|
+
console.log(JSON.stringify(result, null, 2));
|
|
405
|
+
}));
|
|
308
406
|
// Command: register
|
|
309
407
|
addLegacyOption(addAuthOptions(program
|
|
310
408
|
.command("register")
|
package/dist/esm/src/index.d.ts
CHANGED
|
@@ -4,4 +4,4 @@ export { API_URL, NEW_API_URL, OLD_API_URL } from "./constants";
|
|
|
4
4
|
export { configure, getSession, signIn } from "./library";
|
|
5
5
|
export { serialNumberDisplay, serialNumberFromHex, serialNumberToHex, } from "./serial-utils";
|
|
6
6
|
export { BufferEncodedType, CommandsType, DeviceAssociationBody, DeviceAssociationResponse, DeviceInfoRawType, DeviceInfoType, DiscoveredDevice, EditDeviceAssociationBody, StatusType, TemperaturesType, UserParametersType, } from "./types";
|
|
7
|
-
export declare const deviceInfo: (jwtToken: string, macAddress: string) => Promise<import("./types").DeviceInfoType>, registerDevice: (jwtToken: string, macAddress: string, serialNumber: string, deviceName?: string, deviceRoom?: string) => Promise<import("./types").DeviceAssociationResponse>, editDevice: (jwtToken: string, macAddress: string, deviceName?: string, deviceRoom?: string) => Promise<import("./types").DeviceAssociationResponse>, setPower: (jwtToken: string, macAddress: string, value: number) => Promise<unknown>, setPowerOff: (jwtToken: string, macAddress: string) => Promise<unknown>, setPowerOn: (jwtToken: string, macAddress: string) => Promise<unknown>, getPower: (jwtToken: string, macAddress: string) => Promise<boolean>, getEnvironmentTemperature: (jwtToken: string, macAddress: string) => Promise<number>, getTargetTemperature: (jwtToken: string, macAddress: string) => Promise<number>, setTargetTemperature: (jwtToken: string, macAddress: string, temperature: number) => Promise<unknown>;
|
|
7
|
+
export declare const deviceInfo: (jwtToken: string, macAddress: string) => Promise<import("./types").DeviceInfoType>, registerDevice: (jwtToken: string, macAddress: string, serialNumber: string, deviceName?: string, deviceRoom?: string) => Promise<import("./types").DeviceAssociationResponse>, editDevice: (jwtToken: string, macAddress: string, deviceName?: string, deviceRoom?: string) => Promise<import("./types").DeviceAssociationResponse>, setPower: (jwtToken: string, macAddress: string, value: number) => Promise<unknown>, setPowerOff: (jwtToken: string, macAddress: string) => Promise<unknown>, setPowerOn: (jwtToken: string, macAddress: string) => Promise<unknown>, getPower: (jwtToken: string, macAddress: string) => Promise<boolean>, getEnvironmentTemperature: (jwtToken: string, macAddress: string) => Promise<number>, getTargetTemperature: (jwtToken: string, macAddress: string, envIndex: 1 | 2 | 3) => Promise<number>, setTargetTemperature: (jwtToken: string, macAddress: string, envIndex: 1 | 2 | 3, temperature: number) => Promise<unknown>;
|
|
@@ -50,6 +50,8 @@ declare const configure: (baseURL?: string) => {
|
|
|
50
50
|
getPower: (jwtToken: string, macAddress: string) => Promise<boolean>;
|
|
51
51
|
setPowerLevel: (jwtToken: string, macAddress: string, level: number) => Promise<unknown>;
|
|
52
52
|
getPowerLevel: (jwtToken: string, macAddress: string) => Promise<number>;
|
|
53
|
+
setFanSpeed: (jwtToken: string, macAddress: string, fanIndex: 1 | 2 | 3, speed: number) => Promise<unknown>;
|
|
54
|
+
getFanSpeed: (jwtToken: string, macAddress: string, fanIndex: 1 | 2 | 3) => Promise<number>;
|
|
53
55
|
setFan1Speed: (jwtToken: string, macAddress: string, speed: number) => Promise<unknown>;
|
|
54
56
|
setFan2Speed: (jwtToken: string, macAddress: string, speed: number) => Promise<unknown>;
|
|
55
57
|
setFan3Speed: (jwtToken: string, macAddress: string, speed: number) => Promise<unknown>;
|
|
@@ -65,8 +67,10 @@ declare const configure: (baseURL?: string) => {
|
|
|
65
67
|
setAuto: (jwtToken: string, macAddress: string, enabled: boolean) => Promise<unknown>;
|
|
66
68
|
getAuto: (jwtToken: string, macAddress: string) => Promise<boolean>;
|
|
67
69
|
getEnvironmentTemperature: (jwtToken: string, macAddress: string) => Promise<number>;
|
|
68
|
-
getTargetTemperature: (jwtToken: string, macAddress: string) => Promise<number>;
|
|
69
|
-
setTargetTemperature: (jwtToken: string, macAddress: string, temperature: number) => Promise<unknown>;
|
|
70
|
+
getTargetTemperature: (jwtToken: string, macAddress: string, envIndex: 1 | 2 | 3) => Promise<number>;
|
|
71
|
+
setTargetTemperature: (jwtToken: string, macAddress: string, envIndex: 1 | 2 | 3, temperature: number) => Promise<unknown>;
|
|
72
|
+
setEnvironment1Temperature: (jwtToken: string, macAddress: string, temperature: number) => Promise<unknown>;
|
|
73
|
+
getEnvironment1Temperature: (jwtToken: string, macAddress: string) => Promise<number>;
|
|
70
74
|
setEnvironment2Temperature: (jwtToken: string, macAddress: string, temperature: number) => Promise<unknown>;
|
|
71
75
|
getEnvironment2Temperature: (jwtToken: string, macAddress: string) => Promise<number>;
|
|
72
76
|
setEnvironment3Temperature: (jwtToken: string, macAddress: string, temperature: number) => Promise<unknown>;
|