edilkamin 1.11.0 → 1.12.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/bluetooth-utils.js +2 -6
- package/dist/cjs/src/cli.js +9 -8
- package/dist/cjs/src/index.d.ts +4 -3
- package/dist/cjs/src/index.js +14 -1
- package/dist/cjs/src/library.d.ts +30 -0
- package/dist/cjs/src/library.js +97 -3
- package/dist/cjs/src/library.test.js +225 -4
- package/dist/cjs/src/mac-utils.d.ts +15 -0
- package/dist/cjs/src/mac-utils.js +24 -0
- package/dist/cjs/src/mac-utils.test.d.ts +1 -0
- package/dist/cjs/src/mac-utils.test.js +41 -0
- package/dist/cjs/src/types.d.ts +94 -2
- package/dist/cjs/src/types.js +95 -1
- package/dist/esm/package.json +1 -1
- package/dist/esm/src/bluetooth-utils.js +2 -6
- package/dist/esm/src/cli.js +9 -8
- package/dist/esm/src/index.d.ts +4 -3
- package/dist/esm/src/index.js +3 -2
- package/dist/esm/src/library.d.ts +30 -0
- package/dist/esm/src/library.js +94 -2
- package/dist/esm/src/library.test.js +226 -5
- package/dist/esm/src/mac-utils.d.ts +15 -0
- package/dist/esm/src/mac-utils.js +21 -0
- package/dist/esm/src/mac-utils.test.d.ts +1 -0
- package/dist/esm/src/mac-utils.test.js +39 -0
- package/dist/esm/src/types.d.ts +94 -2
- package/dist/esm/src/types.js +89 -1
- package/package.json +1 -1
- package/src/bluetooth-utils.ts +3 -7
- package/src/cli.ts +9 -8
- package/src/index.ts +24 -2
- package/src/library.test.ts +325 -4
- package/src/library.ts +109 -2
- package/src/mac-utils.test.ts +60 -0
- package/src/mac-utils.ts +22 -0
- package/src/types.ts +144 -1
package/dist/cjs/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.bleToWifiMac = void 0;
|
|
4
|
+
const mac_utils_1 = require("./mac-utils");
|
|
4
5
|
/**
|
|
5
6
|
* Converts a BLE MAC address to WiFi MAC address.
|
|
6
7
|
* The WiFi MAC is the BLE MAC minus 2 in hexadecimal.
|
|
@@ -13,12 +14,7 @@ exports.bleToWifiMac = void 0;
|
|
|
13
14
|
* bleToWifiMac("a8032afed50a") // returns "a8032afed508"
|
|
14
15
|
*/
|
|
15
16
|
const bleToWifiMac = (bleMac) => {
|
|
16
|
-
|
|
17
|
-
const normalized = bleMac.replace(/[:-]/g, "").toLowerCase();
|
|
18
|
-
// Validate MAC address format (12 hex characters)
|
|
19
|
-
if (!/^[0-9a-f]{12}$/.test(normalized)) {
|
|
20
|
-
throw new Error(`Invalid MAC address format: ${bleMac}`);
|
|
21
|
-
}
|
|
17
|
+
const normalized = (0, mac_utils_1.normalizeMac)(bleMac);
|
|
22
18
|
// Convert to number, subtract 2, convert back to hex
|
|
23
19
|
const bleValue = BigInt(`0x${normalized}`);
|
|
24
20
|
const wifiValue = bleValue - BigInt(2);
|
package/dist/cjs/src/cli.js
CHANGED
|
@@ -19,6 +19,7 @@ const readline_1 = __importDefault(require("readline"));
|
|
|
19
19
|
const package_json_1 = require("../package.json");
|
|
20
20
|
const constants_1 = require("./constants");
|
|
21
21
|
const library_1 = require("./library");
|
|
22
|
+
const mac_utils_1 = require("./mac-utils");
|
|
22
23
|
const token_storage_1 = require("./token-storage");
|
|
23
24
|
const types_1 = require("./types");
|
|
24
25
|
const promptPassword = () => {
|
|
@@ -72,7 +73,7 @@ const addLegacyOption = (command) => command.option("--legacy", "Use legacy API
|
|
|
72
73
|
*/
|
|
73
74
|
const initializeCommand = (options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
74
75
|
const { username, password, mac, legacy = false } = options;
|
|
75
|
-
const normalizedMac =
|
|
76
|
+
const normalizedMac = (0, mac_utils_1.normalizeMac)(mac);
|
|
76
77
|
// Initialize file storage for session persistence
|
|
77
78
|
const storage = (0, token_storage_1.createFileStorage)();
|
|
78
79
|
(0, library_1.configureAmplify)(storage);
|
|
@@ -395,7 +396,7 @@ const createProgram = () => {
|
|
|
395
396
|
.command("getFanSpeed")
|
|
396
397
|
.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* () {
|
|
397
398
|
const { username, password, mac, index, legacy = false } = options;
|
|
398
|
-
const normalizedMac =
|
|
399
|
+
const normalizedMac = (0, mac_utils_1.normalizeMac)(mac);
|
|
399
400
|
const storage = (0, token_storage_1.createFileStorage)();
|
|
400
401
|
(0, library_1.configureAmplify)(storage);
|
|
401
402
|
let jwtToken;
|
|
@@ -418,7 +419,7 @@ const createProgram = () => {
|
|
|
418
419
|
.command("getTargetTemperature")
|
|
419
420
|
.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* () {
|
|
420
421
|
const { username, password, mac, index, legacy = false } = options;
|
|
421
|
-
const normalizedMac =
|
|
422
|
+
const normalizedMac = (0, mac_utils_1.normalizeMac)(mac);
|
|
422
423
|
const storage = (0, token_storage_1.createFileStorage)();
|
|
423
424
|
(0, library_1.configureAmplify)(storage);
|
|
424
425
|
let jwtToken;
|
|
@@ -444,7 +445,7 @@ const createProgram = () => {
|
|
|
444
445
|
.requiredOption("-i, --index <number>", "Fan index (1, 2, or 3)", parseInt)
|
|
445
446
|
.requiredOption("-v, --value <number>", "Fan speed (0-5)", parseFloat))).action((options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
446
447
|
const { username, password, mac, index, value, legacy = false } = options;
|
|
447
|
-
const normalizedMac =
|
|
448
|
+
const normalizedMac = (0, mac_utils_1.normalizeMac)(mac);
|
|
448
449
|
const storage = (0, token_storage_1.createFileStorage)();
|
|
449
450
|
(0, library_1.configureAmplify)(storage);
|
|
450
451
|
let jwtToken;
|
|
@@ -469,7 +470,7 @@ const createProgram = () => {
|
|
|
469
470
|
.requiredOption("-i, --index <number>", "Environment index (1, 2, or 3)", parseInt)
|
|
470
471
|
.requiredOption("-v, --value <number>", "Temperature in degrees Celsius", parseFloat))).action((options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
471
472
|
const { username, password, mac, index, value, legacy = false } = options;
|
|
472
|
-
const normalizedMac =
|
|
473
|
+
const normalizedMac = (0, mac_utils_1.normalizeMac)(mac);
|
|
473
474
|
const storage = (0, token_storage_1.createFileStorage)();
|
|
474
475
|
(0, library_1.configureAmplify)(storage);
|
|
475
476
|
let jwtToken;
|
|
@@ -493,7 +494,7 @@ const createProgram = () => {
|
|
|
493
494
|
.command("getAlarmHistory")
|
|
494
495
|
.description("Get alarm history log with human-readable descriptions")))).action((options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
495
496
|
const { username, password, mac, legacy = false } = options;
|
|
496
|
-
const normalizedMac =
|
|
497
|
+
const normalizedMac = (0, mac_utils_1.normalizeMac)(mac);
|
|
497
498
|
const storage = (0, token_storage_1.createFileStorage)();
|
|
498
499
|
(0, library_1.configureAmplify)(storage);
|
|
499
500
|
let jwtToken;
|
|
@@ -524,7 +525,7 @@ const createProgram = () => {
|
|
|
524
525
|
.requiredOption("-r, --room <deviceRoom>", "Room name")
|
|
525
526
|
.action((options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
526
527
|
const { username, password, mac, serial, name, room, legacy = false, } = options;
|
|
527
|
-
const normalizedMac =
|
|
528
|
+
const normalizedMac = (0, mac_utils_1.normalizeMac)(mac);
|
|
528
529
|
// Initialize file storage for session persistence
|
|
529
530
|
const storage = (0, token_storage_1.createFileStorage)();
|
|
530
531
|
(0, library_1.configureAmplify)(storage);
|
|
@@ -553,7 +554,7 @@ const createProgram = () => {
|
|
|
553
554
|
.requiredOption("-r, --room <deviceRoom>", "Room name")
|
|
554
555
|
.action((options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
555
556
|
const { username, password, mac, name, room, legacy = false } = options;
|
|
556
|
-
const normalizedMac =
|
|
557
|
+
const normalizedMac = (0, mac_utils_1.normalizeMac)(mac);
|
|
557
558
|
// Initialize file storage for session persistence
|
|
558
559
|
const storage = (0, token_storage_1.createFileStorage)();
|
|
559
560
|
(0, library_1.configureAmplify)(storage);
|
package/dist/cjs/src/index.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
export { bleToWifiMac } from "./bluetooth-utils";
|
|
2
2
|
export { decompressBuffer, isBuffer, processResponse } from "./buffer-utils";
|
|
3
3
|
export { API_URL, NEW_API_URL, OLD_API_URL } from "./constants";
|
|
4
|
-
export { configure, deriveUsageAnalytics, getSession, signIn } from "./library";
|
|
4
|
+
export { configure, derivePhaseDescription, deriveUsageAnalytics, getPhaseDescription, getSession, signIn, } from "./library";
|
|
5
|
+
export { normalizeMac } from "./mac-utils";
|
|
5
6
|
export { serialNumberDisplay, serialNumberFromHex, serialNumberToHex, } from "./serial-utils";
|
|
6
|
-
export { AlarmEntryType, AlarmsLogType, BufferEncodedType, CommandsType, DeviceAssociationBody, DeviceAssociationResponse, DeviceInfoRawType, DeviceInfoType, DiscoveredDevice, EditDeviceAssociationBody, PowerDistributionType, RegenerationDataType, ServiceCountersType, ServiceStatusType, StatusCountersType, StatusType, TemperaturesType, TotalCountersType, UsageAnalyticsType, UserParametersType, } from "./types";
|
|
7
|
-
export { AlarmCode, AlarmDescriptions } from "./types";
|
|
7
|
+
export { AlarmEntryType, AlarmsLogType, BufferEncodedType, CommandsType, DeviceAssociationBody, DeviceAssociationResponse, DeviceInfoRawType, DeviceInfoType, DiscoveredDevice, EditDeviceAssociationBody, FansType, PowerDistributionType, RegenerationDataType, ServiceCountersType, ServiceStatusType, StateType, StatusCountersType, StatusType, TemperaturesType, TotalCountersType, UsageAnalyticsType, UserParametersType, } from "./types";
|
|
8
|
+
export { AlarmCode, AlarmDescriptions, getIgnitionSubPhaseDescription, getOperationalPhaseDescription, getStoveStateDescription, IgnitionSubPhase, IgnitionSubPhaseDescriptions, OperationalPhase, OperationalPhaseDescriptions, StoveState, StoveStateDescriptions, } from "./types";
|
|
8
9
|
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>;
|
package/dist/cjs/src/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var _a;
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.setTargetTemperature = exports.getTargetTemperature = exports.getEnvironmentTemperature = exports.getPower = exports.setPowerOn = exports.setPowerOff = exports.setPower = exports.editDevice = exports.registerDevice = exports.deviceInfo = exports.AlarmDescriptions = exports.AlarmCode = exports.serialNumberToHex = exports.serialNumberFromHex = exports.serialNumberDisplay = exports.signIn = exports.getSession = exports.deriveUsageAnalytics = exports.configure = exports.OLD_API_URL = exports.NEW_API_URL = exports.API_URL = exports.processResponse = exports.isBuffer = exports.decompressBuffer = exports.bleToWifiMac = void 0;
|
|
4
|
+
exports.setTargetTemperature = exports.getTargetTemperature = exports.getEnvironmentTemperature = exports.getPower = exports.setPowerOn = exports.setPowerOff = exports.setPower = exports.editDevice = exports.registerDevice = exports.deviceInfo = exports.StoveStateDescriptions = exports.StoveState = exports.OperationalPhaseDescriptions = exports.OperationalPhase = exports.IgnitionSubPhaseDescriptions = exports.IgnitionSubPhase = exports.getStoveStateDescription = exports.getOperationalPhaseDescription = exports.getIgnitionSubPhaseDescription = exports.AlarmDescriptions = exports.AlarmCode = exports.serialNumberToHex = exports.serialNumberFromHex = exports.serialNumberDisplay = exports.normalizeMac = exports.signIn = exports.getSession = exports.getPhaseDescription = exports.deriveUsageAnalytics = exports.derivePhaseDescription = exports.configure = exports.OLD_API_URL = exports.NEW_API_URL = exports.API_URL = exports.processResponse = exports.isBuffer = exports.decompressBuffer = exports.bleToWifiMac = void 0;
|
|
5
5
|
const library_1 = require("./library");
|
|
6
6
|
var bluetooth_utils_1 = require("./bluetooth-utils");
|
|
7
7
|
Object.defineProperty(exports, "bleToWifiMac", { enumerable: true, get: function () { return bluetooth_utils_1.bleToWifiMac; } });
|
|
@@ -15,9 +15,13 @@ Object.defineProperty(exports, "NEW_API_URL", { enumerable: true, get: function
|
|
|
15
15
|
Object.defineProperty(exports, "OLD_API_URL", { enumerable: true, get: function () { return constants_1.OLD_API_URL; } });
|
|
16
16
|
var library_2 = require("./library");
|
|
17
17
|
Object.defineProperty(exports, "configure", { enumerable: true, get: function () { return library_2.configure; } });
|
|
18
|
+
Object.defineProperty(exports, "derivePhaseDescription", { enumerable: true, get: function () { return library_2.derivePhaseDescription; } });
|
|
18
19
|
Object.defineProperty(exports, "deriveUsageAnalytics", { enumerable: true, get: function () { return library_2.deriveUsageAnalytics; } });
|
|
20
|
+
Object.defineProperty(exports, "getPhaseDescription", { enumerable: true, get: function () { return library_2.getPhaseDescription; } });
|
|
19
21
|
Object.defineProperty(exports, "getSession", { enumerable: true, get: function () { return library_2.getSession; } });
|
|
20
22
|
Object.defineProperty(exports, "signIn", { enumerable: true, get: function () { return library_2.signIn; } });
|
|
23
|
+
var mac_utils_1 = require("./mac-utils");
|
|
24
|
+
Object.defineProperty(exports, "normalizeMac", { enumerable: true, get: function () { return mac_utils_1.normalizeMac; } });
|
|
21
25
|
var serial_utils_1 = require("./serial-utils");
|
|
22
26
|
Object.defineProperty(exports, "serialNumberDisplay", { enumerable: true, get: function () { return serial_utils_1.serialNumberDisplay; } });
|
|
23
27
|
Object.defineProperty(exports, "serialNumberFromHex", { enumerable: true, get: function () { return serial_utils_1.serialNumberFromHex; } });
|
|
@@ -25,4 +29,13 @@ Object.defineProperty(exports, "serialNumberToHex", { enumerable: true, get: fun
|
|
|
25
29
|
var types_1 = require("./types");
|
|
26
30
|
Object.defineProperty(exports, "AlarmCode", { enumerable: true, get: function () { return types_1.AlarmCode; } });
|
|
27
31
|
Object.defineProperty(exports, "AlarmDescriptions", { enumerable: true, get: function () { return types_1.AlarmDescriptions; } });
|
|
32
|
+
Object.defineProperty(exports, "getIgnitionSubPhaseDescription", { enumerable: true, get: function () { return types_1.getIgnitionSubPhaseDescription; } });
|
|
33
|
+
Object.defineProperty(exports, "getOperationalPhaseDescription", { enumerable: true, get: function () { return types_1.getOperationalPhaseDescription; } });
|
|
34
|
+
Object.defineProperty(exports, "getStoveStateDescription", { enumerable: true, get: function () { return types_1.getStoveStateDescription; } });
|
|
35
|
+
Object.defineProperty(exports, "IgnitionSubPhase", { enumerable: true, get: function () { return types_1.IgnitionSubPhase; } });
|
|
36
|
+
Object.defineProperty(exports, "IgnitionSubPhaseDescriptions", { enumerable: true, get: function () { return types_1.IgnitionSubPhaseDescriptions; } });
|
|
37
|
+
Object.defineProperty(exports, "OperationalPhase", { enumerable: true, get: function () { return types_1.OperationalPhase; } });
|
|
38
|
+
Object.defineProperty(exports, "OperationalPhaseDescriptions", { enumerable: true, get: function () { return types_1.OperationalPhaseDescriptions; } });
|
|
39
|
+
Object.defineProperty(exports, "StoveState", { enumerable: true, get: function () { return types_1.StoveState; } });
|
|
40
|
+
Object.defineProperty(exports, "StoveStateDescriptions", { enumerable: true, get: function () { return types_1.StoveStateDescriptions; } });
|
|
28
41
|
_a = (0, library_1.configure)(), exports.deviceInfo = _a.deviceInfo, exports.registerDevice = _a.registerDevice, exports.editDevice = _a.editDevice, exports.setPower = _a.setPower, exports.setPowerOff = _a.setPowerOff, exports.setPowerOn = _a.setPowerOn, exports.getPower = _a.getPower, exports.getEnvironmentTemperature = _a.getEnvironmentTemperature, exports.getTargetTemperature = _a.getTargetTemperature, exports.setTargetTemperature = _a.setTargetTemperature;
|
|
@@ -45,6 +45,32 @@ declare const signIn: (username: string, password: string, legacy?: boolean) =>
|
|
|
45
45
|
* const analytics = deriveUsageAnalytics(info);
|
|
46
46
|
*/
|
|
47
47
|
export declare const deriveUsageAnalytics: (deviceInfo: DeviceInfoType, serviceThreshold?: number) => UsageAnalyticsType;
|
|
48
|
+
/**
|
|
49
|
+
* Get human-readable description of the current device phase.
|
|
50
|
+
* Combines operational_phase and sub_operational_phase for context.
|
|
51
|
+
*
|
|
52
|
+
* @param {number} operationalPhase - The main operational phase.
|
|
53
|
+
* @param {number} subOperationalPhase - The sub-phase (used during ignition).
|
|
54
|
+
* @returns {string} - Human-readable phase description.
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* const desc = getPhaseDescription(2, 1);
|
|
58
|
+
* // Returns: "Ignition - Pellet load"
|
|
59
|
+
*/
|
|
60
|
+
export declare const getPhaseDescription: (operationalPhase: number, subOperationalPhase: number) => string;
|
|
61
|
+
/**
|
|
62
|
+
* Derive phase description from existing DeviceInfo.
|
|
63
|
+
* Pure function - no API calls required.
|
|
64
|
+
*
|
|
65
|
+
* @param {DeviceInfoType} deviceInfo - The device info object.
|
|
66
|
+
* @returns {string} - Human-readable phase description.
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* const info = await api.deviceInfo(token, mac);
|
|
70
|
+
* const desc = derivePhaseDescription(info);
|
|
71
|
+
* // Returns: "On" or "Ignition - Warmup" etc.
|
|
72
|
+
*/
|
|
73
|
+
export declare const derivePhaseDescription: (deviceInfo: DeviceInfoType) => string;
|
|
48
74
|
/**
|
|
49
75
|
* Configures the library for API interactions.
|
|
50
76
|
* Initializes API methods with a specified base URL.
|
|
@@ -97,6 +123,10 @@ declare const configure: (baseURL?: string) => {
|
|
|
97
123
|
getLanguage: (jwtToken: string, macAddress: string) => Promise<number>;
|
|
98
124
|
getPelletInReserve: (jwtToken: string, macAddress: string) => Promise<boolean>;
|
|
99
125
|
getPelletAutonomyTime: (jwtToken: string, macAddress: string) => Promise<number>;
|
|
126
|
+
getOperationalPhase: (jwtToken: string, macAddress: string) => Promise<number>;
|
|
127
|
+
getSubOperationalPhase: (jwtToken: string, macAddress: string) => Promise<number>;
|
|
128
|
+
getStoveState: (jwtToken: string, macAddress: string) => Promise<number>;
|
|
129
|
+
getActualPower: (jwtToken: string, macAddress: string) => Promise<number>;
|
|
100
130
|
getTotalCounters: (jwtToken: string, macAddress: string) => Promise<TotalCountersType>;
|
|
101
131
|
getServiceCounters: (jwtToken: string, macAddress: string) => Promise<ServiceCountersType>;
|
|
102
132
|
getAlarmHistory: (jwtToken: string, macAddress: string) => Promise<AlarmsLogType>;
|
package/dist/cjs/src/library.js
CHANGED
|
@@ -42,13 +42,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
42
42
|
});
|
|
43
43
|
};
|
|
44
44
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
|
-
exports.signIn = exports.headers = exports.getSession = exports.createAuthService = exports.configureAmplify = exports.configure = exports.deriveUsageAnalytics = void 0;
|
|
45
|
+
exports.signIn = exports.headers = exports.getSession = exports.createAuthService = exports.configureAmplify = exports.configure = exports.derivePhaseDescription = exports.getPhaseDescription = exports.deriveUsageAnalytics = void 0;
|
|
46
46
|
const assert_1 = require("assert");
|
|
47
47
|
const aws_amplify_1 = require("aws-amplify");
|
|
48
48
|
const amplifyAuth = __importStar(require("aws-amplify/auth"));
|
|
49
49
|
const cognito_1 = require("aws-amplify/auth/cognito");
|
|
50
50
|
const buffer_utils_1 = require("./buffer-utils");
|
|
51
51
|
const constants_1 = require("./constants");
|
|
52
|
+
const mac_utils_1 = require("./mac-utils");
|
|
53
|
+
const types_1 = require("./types");
|
|
52
54
|
/**
|
|
53
55
|
* Makes a fetch request and returns parsed JSON response.
|
|
54
56
|
* Throws an error for non-2xx status codes.
|
|
@@ -514,6 +516,56 @@ const getPelletAutonomyTime = (baseURL) =>
|
|
|
514
516
|
const info = yield deviceInfo(baseURL)(jwtToken, macAddress);
|
|
515
517
|
return info.status.pellet.autonomy_time;
|
|
516
518
|
});
|
|
519
|
+
const getOperationalPhase = (baseURL) =>
|
|
520
|
+
/**
|
|
521
|
+
* Retrieves the current operational phase of the stove.
|
|
522
|
+
*
|
|
523
|
+
* @param {string} jwtToken - The JWT token for authentication.
|
|
524
|
+
* @param {string} macAddress - The MAC address of the device.
|
|
525
|
+
* @returns {Promise<number>} - The operational phase (0=Off, 1=Standby, 2=Ignition, 6=On).
|
|
526
|
+
*/
|
|
527
|
+
(jwtToken, macAddress) => __awaiter(void 0, void 0, void 0, function* () {
|
|
528
|
+
const info = yield deviceInfo(baseURL)(jwtToken, macAddress);
|
|
529
|
+
return info.status.state.operational_phase;
|
|
530
|
+
});
|
|
531
|
+
const getSubOperationalPhase = (baseURL) =>
|
|
532
|
+
/**
|
|
533
|
+
* Retrieves the current sub-operational phase of the stove.
|
|
534
|
+
* Only meaningful during ignition (operational_phase === 2).
|
|
535
|
+
*
|
|
536
|
+
* @param {string} jwtToken - The JWT token for authentication.
|
|
537
|
+
* @param {string} macAddress - The MAC address of the device.
|
|
538
|
+
* @returns {Promise<number>} - The sub-operational phase (0-6 during ignition).
|
|
539
|
+
*/
|
|
540
|
+
(jwtToken, macAddress) => __awaiter(void 0, void 0, void 0, function* () {
|
|
541
|
+
const info = yield deviceInfo(baseURL)(jwtToken, macAddress);
|
|
542
|
+
return info.status.state.sub_operational_phase;
|
|
543
|
+
});
|
|
544
|
+
const getStoveState = (baseURL) =>
|
|
545
|
+
/**
|
|
546
|
+
* Retrieves the combined stove state code.
|
|
547
|
+
*
|
|
548
|
+
* @param {string} jwtToken - The JWT token for authentication.
|
|
549
|
+
* @param {string} macAddress - The MAC address of the device.
|
|
550
|
+
* @returns {Promise<number>} - The stove state code.
|
|
551
|
+
*/
|
|
552
|
+
(jwtToken, macAddress) => __awaiter(void 0, void 0, void 0, function* () {
|
|
553
|
+
const info = yield deviceInfo(baseURL)(jwtToken, macAddress);
|
|
554
|
+
return info.status.state.stove_state;
|
|
555
|
+
});
|
|
556
|
+
const getActualPower = (baseURL) =>
|
|
557
|
+
/**
|
|
558
|
+
* Retrieves the actual power level the stove is currently running at.
|
|
559
|
+
* This may differ from the requested power level during transitions.
|
|
560
|
+
*
|
|
561
|
+
* @param {string} jwtToken - The JWT token for authentication.
|
|
562
|
+
* @param {string} macAddress - The MAC address of the device.
|
|
563
|
+
* @returns {Promise<number>} - The actual power level (1-5).
|
|
564
|
+
*/
|
|
565
|
+
(jwtToken, macAddress) => __awaiter(void 0, void 0, void 0, function* () {
|
|
566
|
+
const info = yield deviceInfo(baseURL)(jwtToken, macAddress);
|
|
567
|
+
return info.status.state.actual_power;
|
|
568
|
+
});
|
|
517
569
|
const getTotalCounters = (baseURL) =>
|
|
518
570
|
/**
|
|
519
571
|
* Retrieves lifetime operating counters.
|
|
@@ -735,7 +787,7 @@ const registerDevice = (baseURL) =>
|
|
|
735
787
|
*/
|
|
736
788
|
(jwtToken_1, macAddress_1, serialNumber_1, ...args_1) => __awaiter(void 0, [jwtToken_1, macAddress_1, serialNumber_1, ...args_1], void 0, function* (jwtToken, macAddress, serialNumber, deviceName = "", deviceRoom = "") {
|
|
737
789
|
const body = {
|
|
738
|
-
macAddress:
|
|
790
|
+
macAddress: (0, mac_utils_1.normalizeMac)(macAddress),
|
|
739
791
|
deviceName,
|
|
740
792
|
deviceRoom,
|
|
741
793
|
serialNumber,
|
|
@@ -757,7 +809,7 @@ const editDevice = (baseURL) =>
|
|
|
757
809
|
* @returns {Promise<DeviceAssociationResponse>} - A promise that resolves to the update response.
|
|
758
810
|
*/
|
|
759
811
|
(jwtToken_1, macAddress_1, ...args_1) => __awaiter(void 0, [jwtToken_1, macAddress_1, ...args_1], void 0, function* (jwtToken, macAddress, deviceName = "", deviceRoom = "") {
|
|
760
|
-
const normalizedMac =
|
|
812
|
+
const normalizedMac = (0, mac_utils_1.normalizeMac)(macAddress);
|
|
761
813
|
const body = {
|
|
762
814
|
deviceName,
|
|
763
815
|
deviceRoom,
|
|
@@ -768,6 +820,43 @@ const editDevice = (baseURL) =>
|
|
|
768
820
|
body: JSON.stringify(body),
|
|
769
821
|
});
|
|
770
822
|
});
|
|
823
|
+
/**
|
|
824
|
+
* Get human-readable description of the current device phase.
|
|
825
|
+
* Combines operational_phase and sub_operational_phase for context.
|
|
826
|
+
*
|
|
827
|
+
* @param {number} operationalPhase - The main operational phase.
|
|
828
|
+
* @param {number} subOperationalPhase - The sub-phase (used during ignition).
|
|
829
|
+
* @returns {string} - Human-readable phase description.
|
|
830
|
+
*
|
|
831
|
+
* @example
|
|
832
|
+
* const desc = getPhaseDescription(2, 1);
|
|
833
|
+
* // Returns: "Ignition - Pellet load"
|
|
834
|
+
*/
|
|
835
|
+
const getPhaseDescription = (operationalPhase, subOperationalPhase) => {
|
|
836
|
+
if (operationalPhase === types_1.OperationalPhase.IGNITION) {
|
|
837
|
+
const subDesc = (0, types_1.getIgnitionSubPhaseDescription)(subOperationalPhase);
|
|
838
|
+
return `Ignition - ${subDesc}`;
|
|
839
|
+
}
|
|
840
|
+
return (0, types_1.getOperationalPhaseDescription)(operationalPhase);
|
|
841
|
+
};
|
|
842
|
+
exports.getPhaseDescription = getPhaseDescription;
|
|
843
|
+
/**
|
|
844
|
+
* Derive phase description from existing DeviceInfo.
|
|
845
|
+
* Pure function - no API calls required.
|
|
846
|
+
*
|
|
847
|
+
* @param {DeviceInfoType} deviceInfo - The device info object.
|
|
848
|
+
* @returns {string} - Human-readable phase description.
|
|
849
|
+
*
|
|
850
|
+
* @example
|
|
851
|
+
* const info = await api.deviceInfo(token, mac);
|
|
852
|
+
* const desc = derivePhaseDescription(info);
|
|
853
|
+
* // Returns: "On" or "Ignition - Warmup" etc.
|
|
854
|
+
*/
|
|
855
|
+
const derivePhaseDescription = (deviceInfo) => {
|
|
856
|
+
const { operational_phase, sub_operational_phase } = deviceInfo.status.state;
|
|
857
|
+
return (0, exports.getPhaseDescription)(operational_phase, sub_operational_phase);
|
|
858
|
+
};
|
|
859
|
+
exports.derivePhaseDescription = derivePhaseDescription;
|
|
771
860
|
/**
|
|
772
861
|
* Configures the library for API interactions.
|
|
773
862
|
* Initializes API methods with a specified base URL.
|
|
@@ -820,6 +909,11 @@ const configure = (baseURL = constants_1.API_URL) => ({
|
|
|
820
909
|
getLanguage: getLanguage(baseURL),
|
|
821
910
|
getPelletInReserve: getPelletInReserve(baseURL),
|
|
822
911
|
getPelletAutonomyTime: getPelletAutonomyTime(baseURL),
|
|
912
|
+
// Phase/state getters
|
|
913
|
+
getOperationalPhase: getOperationalPhase(baseURL),
|
|
914
|
+
getSubOperationalPhase: getSubOperationalPhase(baseURL),
|
|
915
|
+
getStoveState: getStoveState(baseURL),
|
|
916
|
+
getActualPower: getActualPower(baseURL),
|
|
823
917
|
// Statistics getters
|
|
824
918
|
getTotalCounters: getTotalCounters(baseURL),
|
|
825
919
|
getServiceCounters: getServiceCounters(baseURL),
|
|
@@ -16,6 +16,7 @@ const assert_1 = require("assert");
|
|
|
16
16
|
const pako_1 = __importDefault(require("pako"));
|
|
17
17
|
const sinon_1 = __importDefault(require("sinon"));
|
|
18
18
|
const library_1 = require("../src/library");
|
|
19
|
+
const types_1 = require("../src/types");
|
|
19
20
|
const constants_1 = require("./constants");
|
|
20
21
|
/**
|
|
21
22
|
* Helper to create a gzip-compressed Buffer object for testing.
|
|
@@ -220,6 +221,11 @@ describe("library", () => {
|
|
|
220
221
|
"getLanguage",
|
|
221
222
|
"getPelletInReserve",
|
|
222
223
|
"getPelletAutonomyTime",
|
|
224
|
+
// Phase/state getters
|
|
225
|
+
"getOperationalPhase",
|
|
226
|
+
"getSubOperationalPhase",
|
|
227
|
+
"getStoveState",
|
|
228
|
+
"getActualPower",
|
|
223
229
|
// Statistics getters
|
|
224
230
|
"getTotalCounters",
|
|
225
231
|
"getServiceCounters",
|
|
@@ -603,7 +609,7 @@ describe("library", () => {
|
|
|
603
609
|
Authorization: `Bearer ${expectedToken}`,
|
|
604
610
|
},
|
|
605
611
|
body: JSON.stringify({
|
|
606
|
-
macAddress: "
|
|
612
|
+
macAddress: "aabbccddeeff",
|
|
607
613
|
deviceName: "Test Stove",
|
|
608
614
|
deviceRoom: "Living Room",
|
|
609
615
|
serialNumber: "EDK123",
|
|
@@ -611,12 +617,12 @@ describe("library", () => {
|
|
|
611
617
|
});
|
|
612
618
|
assert_1.strict.deepEqual(result, mockResponseData);
|
|
613
619
|
}));
|
|
614
|
-
it("should normalize MAC address by removing colons", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
620
|
+
it("should normalize MAC address by removing colons and converting to lowercase", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
615
621
|
fetchStub.resolves(mockResponse({}));
|
|
616
622
|
const api = (0, library_1.configure)("https://example.com/api/");
|
|
617
623
|
yield api.registerDevice(expectedToken, "AA:BB:CC:DD:EE:FF", "EDK123");
|
|
618
624
|
const body = JSON.parse(fetchStub.firstCall.args[1].body);
|
|
619
|
-
assert_1.strict.equal(body.macAddress, "
|
|
625
|
+
assert_1.strict.equal(body.macAddress, "aabbccddeeff");
|
|
620
626
|
}));
|
|
621
627
|
it("should use empty strings as defaults for name and room", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
622
628
|
fetchStub.resolves(mockResponse({}));
|
|
@@ -639,7 +645,7 @@ describe("library", () => {
|
|
|
639
645
|
const api = (0, library_1.configure)("https://example.com/api/");
|
|
640
646
|
const result = yield api.editDevice(expectedToken, "AA:BB:CC:DD:EE:FF", "Updated Name", "Basement");
|
|
641
647
|
assert_1.strict.ok(fetchStub.calledOnce);
|
|
642
|
-
assert_1.strict.equal(fetchStub.firstCall.args[0], "https://example.com/api/device/
|
|
648
|
+
assert_1.strict.equal(fetchStub.firstCall.args[0], "https://example.com/api/device/aabbccddeeff");
|
|
643
649
|
assert_1.strict.deepEqual(fetchStub.firstCall.args[1], {
|
|
644
650
|
method: "PUT",
|
|
645
651
|
headers: {
|
|
@@ -1147,6 +1153,221 @@ describe("library", () => {
|
|
|
1147
1153
|
assert_1.strict.equal(analytics.lastMaintenanceDate, null);
|
|
1148
1154
|
});
|
|
1149
1155
|
});
|
|
1156
|
+
describe("phase getters", () => {
|
|
1157
|
+
const mockDeviceInfoWithState = {
|
|
1158
|
+
status: {
|
|
1159
|
+
commands: { power: true },
|
|
1160
|
+
temperatures: { board: 25, enviroment: 20 },
|
|
1161
|
+
flags: { is_pellet_in_reserve: false },
|
|
1162
|
+
pellet: { autonomy_time: 900 },
|
|
1163
|
+
counters: { service_time: 1108 },
|
|
1164
|
+
state: {
|
|
1165
|
+
operational_phase: 2,
|
|
1166
|
+
sub_operational_phase: 3,
|
|
1167
|
+
stove_state: 4,
|
|
1168
|
+
alarm_type: 0,
|
|
1169
|
+
actual_power: 3,
|
|
1170
|
+
},
|
|
1171
|
+
fans: { fan_1_speed: 3, fan_2_speed: 0, fan_3_speed: 0 },
|
|
1172
|
+
},
|
|
1173
|
+
nvm: {
|
|
1174
|
+
user_parameters: {
|
|
1175
|
+
language: 1,
|
|
1176
|
+
is_auto: false,
|
|
1177
|
+
is_fahrenheit: false,
|
|
1178
|
+
is_sound_active: false,
|
|
1179
|
+
enviroment_1_temperature: 19,
|
|
1180
|
+
enviroment_2_temperature: 20,
|
|
1181
|
+
enviroment_3_temperature: 20,
|
|
1182
|
+
manual_power: 1,
|
|
1183
|
+
fan_1_ventilation: 3,
|
|
1184
|
+
fan_2_ventilation: 0,
|
|
1185
|
+
fan_3_ventilation: 0,
|
|
1186
|
+
is_standby_active: false,
|
|
1187
|
+
standby_waiting_time: 60,
|
|
1188
|
+
},
|
|
1189
|
+
total_counters: {
|
|
1190
|
+
power_ons: 278,
|
|
1191
|
+
p1_working_time: 833,
|
|
1192
|
+
p2_working_time: 15,
|
|
1193
|
+
p3_working_time: 19,
|
|
1194
|
+
p4_working_time: 8,
|
|
1195
|
+
p5_working_time: 17,
|
|
1196
|
+
},
|
|
1197
|
+
service_counters: {
|
|
1198
|
+
p1_working_time: 100,
|
|
1199
|
+
p2_working_time: 10,
|
|
1200
|
+
p3_working_time: 5,
|
|
1201
|
+
p4_working_time: 2,
|
|
1202
|
+
p5_working_time: 1,
|
|
1203
|
+
},
|
|
1204
|
+
alarms_log: {
|
|
1205
|
+
number: 2,
|
|
1206
|
+
index: 2,
|
|
1207
|
+
alarms: [],
|
|
1208
|
+
},
|
|
1209
|
+
regeneration: {
|
|
1210
|
+
time: 0,
|
|
1211
|
+
last_intervention: 1577836800,
|
|
1212
|
+
daylight_time_flag: 0,
|
|
1213
|
+
blackout_counter: 43,
|
|
1214
|
+
airkare_working_hours_counter: 0,
|
|
1215
|
+
},
|
|
1216
|
+
},
|
|
1217
|
+
};
|
|
1218
|
+
it("should get operational phase", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
1219
|
+
fetchStub.resolves(mockResponse(mockDeviceInfoWithState));
|
|
1220
|
+
const api = (0, library_1.configure)(constants_1.API_URL);
|
|
1221
|
+
const result = yield api.getOperationalPhase(expectedToken, "00:11:22:33:44:55");
|
|
1222
|
+
assert_1.strict.equal(result, 2);
|
|
1223
|
+
}));
|
|
1224
|
+
it("should get sub-operational phase", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
1225
|
+
fetchStub.resolves(mockResponse(mockDeviceInfoWithState));
|
|
1226
|
+
const api = (0, library_1.configure)(constants_1.API_URL);
|
|
1227
|
+
const result = yield api.getSubOperationalPhase(expectedToken, "00:11:22:33:44:55");
|
|
1228
|
+
assert_1.strict.equal(result, 3);
|
|
1229
|
+
}));
|
|
1230
|
+
it("should get stove state", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
1231
|
+
fetchStub.resolves(mockResponse(mockDeviceInfoWithState));
|
|
1232
|
+
const api = (0, library_1.configure)(constants_1.API_URL);
|
|
1233
|
+
const result = yield api.getStoveState(expectedToken, "00:11:22:33:44:55");
|
|
1234
|
+
assert_1.strict.equal(result, 4);
|
|
1235
|
+
}));
|
|
1236
|
+
it("should get actual power", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
1237
|
+
fetchStub.resolves(mockResponse(mockDeviceInfoWithState));
|
|
1238
|
+
const api = (0, library_1.configure)(constants_1.API_URL);
|
|
1239
|
+
const result = yield api.getActualPower(expectedToken, "00:11:22:33:44:55");
|
|
1240
|
+
assert_1.strict.equal(result, 3);
|
|
1241
|
+
}));
|
|
1242
|
+
});
|
|
1243
|
+
describe("getPhaseDescription", () => {
|
|
1244
|
+
it("should return 'Off' for phase 0", () => {
|
|
1245
|
+
assert_1.strict.equal((0, library_1.getPhaseDescription)(0, 0), "Off");
|
|
1246
|
+
});
|
|
1247
|
+
it("should return 'Standby' for phase 1", () => {
|
|
1248
|
+
assert_1.strict.equal((0, library_1.getPhaseDescription)(1, 0), "Standby");
|
|
1249
|
+
});
|
|
1250
|
+
it("should return 'On' for phase 6", () => {
|
|
1251
|
+
assert_1.strict.equal((0, library_1.getPhaseDescription)(6, 0), "On");
|
|
1252
|
+
});
|
|
1253
|
+
it("should return combined description for ignition phase", () => {
|
|
1254
|
+
assert_1.strict.equal((0, library_1.getPhaseDescription)(2, 0), "Ignition - Starting cleaning");
|
|
1255
|
+
assert_1.strict.equal((0, library_1.getPhaseDescription)(2, 1), "Ignition - Pellet load");
|
|
1256
|
+
assert_1.strict.equal((0, library_1.getPhaseDescription)(2, 2), "Ignition - Loading break");
|
|
1257
|
+
assert_1.strict.equal((0, library_1.getPhaseDescription)(2, 3), "Ignition - Smoke temperature check");
|
|
1258
|
+
assert_1.strict.equal((0, library_1.getPhaseDescription)(2, 4), "Ignition - Threshold exceeding check");
|
|
1259
|
+
assert_1.strict.equal((0, library_1.getPhaseDescription)(2, 5), "Ignition - Warmup");
|
|
1260
|
+
assert_1.strict.equal((0, library_1.getPhaseDescription)(2, 6), "Ignition - Starting up");
|
|
1261
|
+
});
|
|
1262
|
+
it("should return fallback for unknown operational phase", () => {
|
|
1263
|
+
assert_1.strict.equal((0, library_1.getPhaseDescription)(99, 0), "Unknown phase (99)");
|
|
1264
|
+
});
|
|
1265
|
+
it("should return fallback for unknown ignition sub-phase", () => {
|
|
1266
|
+
assert_1.strict.equal((0, library_1.getPhaseDescription)(2, 99), "Ignition - Unknown sub-phase (99)");
|
|
1267
|
+
});
|
|
1268
|
+
});
|
|
1269
|
+
describe("derivePhaseDescription", () => {
|
|
1270
|
+
it("should derive phase description from device info", () => {
|
|
1271
|
+
const mockDeviceInfo = {
|
|
1272
|
+
status: {
|
|
1273
|
+
commands: { power: true },
|
|
1274
|
+
temperatures: { board: 25, enviroment: 22 },
|
|
1275
|
+
flags: { is_pellet_in_reserve: true },
|
|
1276
|
+
pellet: { autonomy_time: 120 },
|
|
1277
|
+
counters: { service_time: 100 },
|
|
1278
|
+
state: {
|
|
1279
|
+
operational_phase: 2,
|
|
1280
|
+
sub_operational_phase: 5,
|
|
1281
|
+
stove_state: 5,
|
|
1282
|
+
alarm_type: 0,
|
|
1283
|
+
actual_power: 3,
|
|
1284
|
+
},
|
|
1285
|
+
fans: { fan_1_speed: 3, fan_2_speed: 0, fan_3_speed: 0 },
|
|
1286
|
+
},
|
|
1287
|
+
nvm: {
|
|
1288
|
+
user_parameters: {},
|
|
1289
|
+
total_counters: {},
|
|
1290
|
+
service_counters: {},
|
|
1291
|
+
alarms_log: { number: 0, index: 0, alarms: [] },
|
|
1292
|
+
regeneration: {},
|
|
1293
|
+
},
|
|
1294
|
+
};
|
|
1295
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1296
|
+
const desc = (0, library_1.derivePhaseDescription)(mockDeviceInfo);
|
|
1297
|
+
assert_1.strict.equal(desc, "Ignition - Warmup");
|
|
1298
|
+
});
|
|
1299
|
+
it("should return 'On' for device in On state", () => {
|
|
1300
|
+
const mockDeviceInfo = {
|
|
1301
|
+
status: {
|
|
1302
|
+
commands: { power: true },
|
|
1303
|
+
temperatures: { board: 25, enviroment: 22 },
|
|
1304
|
+
flags: { is_pellet_in_reserve: false },
|
|
1305
|
+
pellet: { autonomy_time: 120 },
|
|
1306
|
+
counters: { service_time: 100 },
|
|
1307
|
+
state: {
|
|
1308
|
+
operational_phase: 6,
|
|
1309
|
+
sub_operational_phase: 0,
|
|
1310
|
+
stove_state: 6,
|
|
1311
|
+
alarm_type: 0,
|
|
1312
|
+
actual_power: 3,
|
|
1313
|
+
},
|
|
1314
|
+
fans: { fan_1_speed: 3, fan_2_speed: 0, fan_3_speed: 0 },
|
|
1315
|
+
},
|
|
1316
|
+
nvm: {
|
|
1317
|
+
user_parameters: {},
|
|
1318
|
+
total_counters: {},
|
|
1319
|
+
service_counters: {},
|
|
1320
|
+
alarms_log: { number: 0, index: 0, alarms: [] },
|
|
1321
|
+
regeneration: {},
|
|
1322
|
+
},
|
|
1323
|
+
};
|
|
1324
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1325
|
+
const desc = (0, library_1.derivePhaseDescription)(mockDeviceInfo);
|
|
1326
|
+
assert_1.strict.equal(desc, "On");
|
|
1327
|
+
});
|
|
1328
|
+
});
|
|
1329
|
+
describe("OperationalPhase descriptions", () => {
|
|
1330
|
+
it("should return descriptions for known phases", () => {
|
|
1331
|
+
assert_1.strict.equal((0, types_1.getOperationalPhaseDescription)(types_1.OperationalPhase.OFF), "Off");
|
|
1332
|
+
assert_1.strict.equal((0, types_1.getOperationalPhaseDescription)(types_1.OperationalPhase.STANDBY), "Standby");
|
|
1333
|
+
assert_1.strict.equal((0, types_1.getOperationalPhaseDescription)(types_1.OperationalPhase.IGNITION), "Ignition");
|
|
1334
|
+
assert_1.strict.equal((0, types_1.getOperationalPhaseDescription)(types_1.OperationalPhase.ON), "On");
|
|
1335
|
+
});
|
|
1336
|
+
it("should return fallback for unknown phases", () => {
|
|
1337
|
+
assert_1.strict.equal((0, types_1.getOperationalPhaseDescription)(3), "Unknown phase (3)");
|
|
1338
|
+
assert_1.strict.equal((0, types_1.getOperationalPhaseDescription)(99), "Unknown phase (99)");
|
|
1339
|
+
});
|
|
1340
|
+
});
|
|
1341
|
+
describe("IgnitionSubPhase descriptions", () => {
|
|
1342
|
+
it("should return descriptions for all ignition sub-phases", () => {
|
|
1343
|
+
assert_1.strict.equal((0, types_1.getIgnitionSubPhaseDescription)(types_1.IgnitionSubPhase.STARTING_CLEANING), "Starting cleaning");
|
|
1344
|
+
assert_1.strict.equal((0, types_1.getIgnitionSubPhaseDescription)(types_1.IgnitionSubPhase.PELLET_LOAD), "Pellet load");
|
|
1345
|
+
assert_1.strict.equal((0, types_1.getIgnitionSubPhaseDescription)(types_1.IgnitionSubPhase.LOADING_BREAK), "Loading break");
|
|
1346
|
+
assert_1.strict.equal((0, types_1.getIgnitionSubPhaseDescription)(types_1.IgnitionSubPhase.SMOKE_TEMPERATURE_CHECK), "Smoke temperature check");
|
|
1347
|
+
assert_1.strict.equal((0, types_1.getIgnitionSubPhaseDescription)(types_1.IgnitionSubPhase.THRESHOLD_EXCEEDING_CHECK), "Threshold exceeding check");
|
|
1348
|
+
assert_1.strict.equal((0, types_1.getIgnitionSubPhaseDescription)(types_1.IgnitionSubPhase.WARMUP), "Warmup");
|
|
1349
|
+
assert_1.strict.equal((0, types_1.getIgnitionSubPhaseDescription)(types_1.IgnitionSubPhase.TRANSITION_TO_ON), "Starting up");
|
|
1350
|
+
});
|
|
1351
|
+
it("should return fallback for unknown sub-phases", () => {
|
|
1352
|
+
assert_1.strict.equal((0, types_1.getIgnitionSubPhaseDescription)(99), "Unknown sub-phase (99)");
|
|
1353
|
+
});
|
|
1354
|
+
});
|
|
1355
|
+
describe("StoveState descriptions", () => {
|
|
1356
|
+
it("should return descriptions for known states", () => {
|
|
1357
|
+
assert_1.strict.equal((0, types_1.getStoveStateDescription)(types_1.StoveState.OFF), "Off");
|
|
1358
|
+
assert_1.strict.equal((0, types_1.getStoveStateDescription)(types_1.StoveState.STANDBY), "Standby");
|
|
1359
|
+
assert_1.strict.equal((0, types_1.getStoveStateDescription)(types_1.StoveState.IGNITION_CLEANING), "Ignition - Cleaning");
|
|
1360
|
+
assert_1.strict.equal((0, types_1.getStoveStateDescription)(types_1.StoveState.IGNITION_LOADING), "Ignition - Loading pellets");
|
|
1361
|
+
assert_1.strict.equal((0, types_1.getStoveStateDescription)(types_1.StoveState.IGNITION_WAITING), "Ignition - Waiting");
|
|
1362
|
+
assert_1.strict.equal((0, types_1.getStoveStateDescription)(types_1.StoveState.IGNITION_WARMUP), "Ignition - Warming up");
|
|
1363
|
+
assert_1.strict.equal((0, types_1.getStoveStateDescription)(types_1.StoveState.ON), "On");
|
|
1364
|
+
assert_1.strict.equal((0, types_1.getStoveStateDescription)(types_1.StoveState.COOLING), "Cooling down");
|
|
1365
|
+
assert_1.strict.equal((0, types_1.getStoveStateDescription)(types_1.StoveState.ALARM), "Alarm");
|
|
1366
|
+
});
|
|
1367
|
+
it("should return fallback for unknown states", () => {
|
|
1368
|
+
assert_1.strict.equal((0, types_1.getStoveStateDescription)(99), "Unknown state (99)");
|
|
1369
|
+
});
|
|
1370
|
+
});
|
|
1150
1371
|
describe("Error Handling", () => {
|
|
1151
1372
|
const errorTests = [
|
|
1152
1373
|
{ status: 400, statusText: "Bad Request" },
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Normalizes a MAC address by removing separators and converting to lowercase.
|
|
3
|
+
* Accepts formats: AA:BB:CC:DD:EE:FF, AA-BB-CC-DD-EE-FF, AABBCCDDEEFF
|
|
4
|
+
*
|
|
5
|
+
* @param mac - MAC address in any common format
|
|
6
|
+
* @returns Normalized MAC address (12 lowercase hex chars, no separators)
|
|
7
|
+
* @throws Error if MAC address format is invalid
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* normalizeMac("AA:BB:CC:DD:EE:FF") // returns "aabbccddeeff"
|
|
11
|
+
* normalizeMac("AA-BB-CC-DD-EE-FF") // returns "aabbccddeeff"
|
|
12
|
+
* normalizeMac("AABBCCDDEEFF") // returns "aabbccddeeff"
|
|
13
|
+
*/
|
|
14
|
+
declare const normalizeMac: (mac: string) => string;
|
|
15
|
+
export { normalizeMac };
|