edilkamin 1.9.0 → 1.10.1

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.
@@ -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",
@@ -238,6 +242,17 @@ describe("library", () => {
238
242
  "getLanguage",
239
243
  "getPelletInReserve",
240
244
  "getPelletAutonomyTime",
245
+ // Statistics getters
246
+ "getTotalCounters",
247
+ "getServiceCounters",
248
+ "getAlarmHistory",
249
+ "getRegenerationData",
250
+ "getServiceTime",
251
+ // Analytics functions
252
+ "getTotalOperatingHours",
253
+ "getPowerDistribution",
254
+ "getServiceStatus",
255
+ "getUsageAnalytics",
241
256
  ];
242
257
  it("should create API methods with the correct baseURL", async () => {
243
258
  const baseURL = "https://example.com/api/";
@@ -391,7 +406,7 @@ describe("library", () => {
391
406
  {
392
407
  method: "getTargetTemperature",
393
408
  call: (api: ReturnType<typeof configure>, token: string, mac: string) =>
394
- api.getTargetTemperature(token, mac),
409
+ api.getTargetTemperature(token, mac, 1),
395
410
  expectedResult: 22,
396
411
  },
397
412
  {
@@ -529,7 +544,7 @@ describe("library", () => {
529
544
  token: string,
530
545
  mac: string,
531
546
  value: number,
532
- ) => api.setTargetTemperature(token, mac, value),
547
+ ) => api.setTargetTemperature(token, mac, 1, value),
533
548
  payload: {
534
549
  name: "enviroment_1_temperature",
535
550
  value: 20,
@@ -961,6 +976,7 @@ describe("library", () => {
961
976
  const result = await api.getTargetTemperature(
962
977
  expectedToken,
963
978
  "mockMacAddress",
979
+ 1,
964
980
  );
965
981
 
966
982
  assert.equal(result, 22);
@@ -1012,6 +1028,285 @@ describe("library", () => {
1012
1028
  });
1013
1029
  });
1014
1030
 
1031
+ describe("statistics getters", () => {
1032
+ const mockDeviceInfoWithStats = {
1033
+ status: {
1034
+ commands: { power: true },
1035
+ temperatures: { board: 25, enviroment: 20 },
1036
+ flags: { is_pellet_in_reserve: false },
1037
+ pellet: { autonomy_time: 900 },
1038
+ counters: { service_time: 1108 },
1039
+ },
1040
+ nvm: {
1041
+ user_parameters: {
1042
+ language: 1,
1043
+ is_auto: false,
1044
+ is_fahrenheit: false,
1045
+ is_sound_active: false,
1046
+ enviroment_1_temperature: 19,
1047
+ enviroment_2_temperature: 20,
1048
+ enviroment_3_temperature: 20,
1049
+ manual_power: 1,
1050
+ fan_1_ventilation: 3,
1051
+ fan_2_ventilation: 0,
1052
+ fan_3_ventilation: 0,
1053
+ is_standby_active: false,
1054
+ standby_waiting_time: 60,
1055
+ },
1056
+ total_counters: {
1057
+ power_ons: 278,
1058
+ p1_working_time: 833,
1059
+ p2_working_time: 15,
1060
+ p3_working_time: 19,
1061
+ p4_working_time: 8,
1062
+ p5_working_time: 17,
1063
+ },
1064
+ service_counters: {
1065
+ p1_working_time: 100,
1066
+ p2_working_time: 10,
1067
+ p3_working_time: 5,
1068
+ p4_working_time: 2,
1069
+ p5_working_time: 1,
1070
+ },
1071
+ alarms_log: {
1072
+ number: 2,
1073
+ index: 2,
1074
+ alarms: [
1075
+ { type: 3, timestamp: 1700000000 },
1076
+ { type: 21, timestamp: 1700001000 },
1077
+ ],
1078
+ },
1079
+ regeneration: {
1080
+ time: 0,
1081
+ last_intervention: 1577836800,
1082
+ daylight_time_flag: 0,
1083
+ blackout_counter: 43,
1084
+ airkare_working_hours_counter: 0,
1085
+ },
1086
+ },
1087
+ };
1088
+
1089
+ it("should get total counters", async () => {
1090
+ fetchStub.resolves(mockResponse(mockDeviceInfoWithStats));
1091
+ const api = configure(API_URL);
1092
+ const result = await api.getTotalCounters(
1093
+ expectedToken,
1094
+ "00:11:22:33:44:55",
1095
+ );
1096
+ assert.deepEqual(result, mockDeviceInfoWithStats.nvm.total_counters);
1097
+ });
1098
+
1099
+ it("should get service counters", async () => {
1100
+ fetchStub.resolves(mockResponse(mockDeviceInfoWithStats));
1101
+ const api = configure(API_URL);
1102
+ const result = await api.getServiceCounters(
1103
+ expectedToken,
1104
+ "00:11:22:33:44:55",
1105
+ );
1106
+ assert.deepEqual(result, mockDeviceInfoWithStats.nvm.service_counters);
1107
+ });
1108
+
1109
+ it("should get alarm history", async () => {
1110
+ fetchStub.resolves(mockResponse(mockDeviceInfoWithStats));
1111
+ const api = configure(API_URL);
1112
+ const result = await api.getAlarmHistory(
1113
+ expectedToken,
1114
+ "00:11:22:33:44:55",
1115
+ );
1116
+ assert.deepEqual(result, mockDeviceInfoWithStats.nvm.alarms_log);
1117
+ });
1118
+
1119
+ it("should get regeneration data", async () => {
1120
+ fetchStub.resolves(mockResponse(mockDeviceInfoWithStats));
1121
+ const api = configure(API_URL);
1122
+ const result = await api.getRegenerationData(
1123
+ expectedToken,
1124
+ "00:11:22:33:44:55",
1125
+ );
1126
+ assert.deepEqual(result, mockDeviceInfoWithStats.nvm.regeneration);
1127
+ });
1128
+
1129
+ it("should get service time", async () => {
1130
+ fetchStub.resolves(mockResponse(mockDeviceInfoWithStats));
1131
+ const api = configure(API_URL);
1132
+ const result = await api.getServiceTime(
1133
+ expectedToken,
1134
+ "00:11:22:33:44:55",
1135
+ );
1136
+ assert.equal(result, 1108);
1137
+ });
1138
+ });
1139
+
1140
+ describe("analytics functions", () => {
1141
+ const mockDeviceInfoWithStats = {
1142
+ status: {
1143
+ commands: { power: true },
1144
+ temperatures: { board: 25, enviroment: 20 },
1145
+ flags: { is_pellet_in_reserve: false },
1146
+ pellet: { autonomy_time: 900 },
1147
+ counters: { service_time: 1108 },
1148
+ },
1149
+ nvm: {
1150
+ user_parameters: {
1151
+ language: 1,
1152
+ is_auto: false,
1153
+ is_fahrenheit: false,
1154
+ is_sound_active: false,
1155
+ enviroment_1_temperature: 19,
1156
+ enviroment_2_temperature: 20,
1157
+ enviroment_3_temperature: 20,
1158
+ manual_power: 1,
1159
+ fan_1_ventilation: 3,
1160
+ fan_2_ventilation: 0,
1161
+ fan_3_ventilation: 0,
1162
+ is_standby_active: false,
1163
+ standby_waiting_time: 60,
1164
+ },
1165
+ total_counters: {
1166
+ power_ons: 278,
1167
+ p1_working_time: 833,
1168
+ p2_working_time: 15,
1169
+ p3_working_time: 19,
1170
+ p4_working_time: 8,
1171
+ p5_working_time: 17,
1172
+ },
1173
+ service_counters: {
1174
+ p1_working_time: 100,
1175
+ p2_working_time: 10,
1176
+ p3_working_time: 5,
1177
+ p4_working_time: 2,
1178
+ p5_working_time: 1,
1179
+ },
1180
+ alarms_log: {
1181
+ number: 2,
1182
+ index: 2,
1183
+ alarms: [
1184
+ { type: 3, timestamp: 1700000000 },
1185
+ { type: 21, timestamp: 1700001000 },
1186
+ ],
1187
+ },
1188
+ regeneration: {
1189
+ time: 0,
1190
+ last_intervention: 1577836800,
1191
+ daylight_time_flag: 0,
1192
+ blackout_counter: 43,
1193
+ airkare_working_hours_counter: 0,
1194
+ },
1195
+ },
1196
+ };
1197
+
1198
+ it("should calculate total operating hours", async () => {
1199
+ fetchStub.resolves(mockResponse(mockDeviceInfoWithStats));
1200
+ const api = configure(API_URL);
1201
+ const result = await api.getTotalOperatingHours(
1202
+ expectedToken,
1203
+ "00:11:22:33:44:55",
1204
+ );
1205
+ // 833 + 15 + 19 + 8 + 17 = 892
1206
+ assert.equal(result, 892);
1207
+ });
1208
+
1209
+ it("should calculate power distribution percentages", async () => {
1210
+ fetchStub.resolves(mockResponse(mockDeviceInfoWithStats));
1211
+ const api = configure(API_URL);
1212
+ const result = await api.getPowerDistribution(
1213
+ expectedToken,
1214
+ "00:11:22:33:44:55",
1215
+ );
1216
+ // Total: 892 hours
1217
+ assert.ok(result.p1 > 90); // 833/892 = 93.4%
1218
+ assert.ok(result.p2 < 5); // 15/892 = 1.7%
1219
+ // Sum should be ~100%
1220
+ const sum = result.p1 + result.p2 + result.p3 + result.p4 + result.p5;
1221
+ assert.ok(Math.abs(sum - 100) < 0.1);
1222
+ });
1223
+
1224
+ it("should handle zero operating hours in power distribution", async () => {
1225
+ const zeroHoursInfo = {
1226
+ ...mockDeviceInfoWithStats,
1227
+ nvm: {
1228
+ ...mockDeviceInfoWithStats.nvm,
1229
+ total_counters: {
1230
+ power_ons: 0,
1231
+ p1_working_time: 0,
1232
+ p2_working_time: 0,
1233
+ p3_working_time: 0,
1234
+ p4_working_time: 0,
1235
+ p5_working_time: 0,
1236
+ },
1237
+ },
1238
+ };
1239
+ fetchStub.resolves(mockResponse(zeroHoursInfo));
1240
+ const api = configure(API_URL);
1241
+ const result = await api.getPowerDistribution(
1242
+ expectedToken,
1243
+ "00:11:22:33:44:55",
1244
+ );
1245
+ assert.deepEqual(result, { p1: 0, p2: 0, p3: 0, p4: 0, p5: 0 });
1246
+ });
1247
+
1248
+ it("should calculate service status", async () => {
1249
+ fetchStub.resolves(mockResponse(mockDeviceInfoWithStats));
1250
+ const api = configure(API_URL);
1251
+ const result = await api.getServiceStatus(
1252
+ expectedToken,
1253
+ "00:11:22:33:44:55",
1254
+ );
1255
+ assert.equal(result.totalServiceHours, 1108);
1256
+ // 100 + 10 + 5 + 2 + 1 = 118 hours since service
1257
+ assert.equal(result.hoursSinceService, 118);
1258
+ assert.equal(result.isServiceDue, false); // 118 < 2000
1259
+ });
1260
+
1261
+ it("should indicate service is due when threshold exceeded", async () => {
1262
+ fetchStub.resolves(mockResponse(mockDeviceInfoWithStats));
1263
+ const api = configure(API_URL);
1264
+ // Use threshold of 100 hours
1265
+ const result = await api.getServiceStatus(
1266
+ expectedToken,
1267
+ "00:11:22:33:44:55",
1268
+ 100,
1269
+ );
1270
+ assert.equal(result.isServiceDue, true); // 118 >= 100
1271
+ });
1272
+
1273
+ it("should get comprehensive usage analytics", async () => {
1274
+ fetchStub.resolves(mockResponse(mockDeviceInfoWithStats));
1275
+ const api = configure(API_URL);
1276
+ const result = await api.getUsageAnalytics(
1277
+ expectedToken,
1278
+ "00:11:22:33:44:55",
1279
+ );
1280
+
1281
+ assert.equal(result.totalPowerOns, 278);
1282
+ assert.equal(result.totalOperatingHours, 892);
1283
+ assert.equal(result.blackoutCount, 43);
1284
+ assert.equal(result.alarmCount, 2);
1285
+ assert.ok(result.lastMaintenanceDate instanceof Date);
1286
+ assert.equal(result.serviceStatus.isServiceDue, false);
1287
+ });
1288
+
1289
+ it("should handle null lastMaintenanceDate when timestamp is 0", async () => {
1290
+ const noMaintenanceInfo = {
1291
+ ...mockDeviceInfoWithStats,
1292
+ nvm: {
1293
+ ...mockDeviceInfoWithStats.nvm,
1294
+ regeneration: {
1295
+ ...mockDeviceInfoWithStats.nvm.regeneration,
1296
+ last_intervention: 0,
1297
+ },
1298
+ },
1299
+ };
1300
+ fetchStub.resolves(mockResponse(noMaintenanceInfo));
1301
+ const api = configure(API_URL);
1302
+ const result = await api.getUsageAnalytics(
1303
+ expectedToken,
1304
+ "00:11:22:33:44:55",
1305
+ );
1306
+ assert.equal(result.lastMaintenanceDate, null);
1307
+ });
1308
+ });
1309
+
1015
1310
  describe("Error Handling", () => {
1016
1311
  const errorTests = [
1017
1312
  { status: 400, statusText: "Bad Request" },