mclimate-payload-helper 1.2.3 → 1.2.4

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.
Files changed (75) hide show
  1. package/dist/decoders/commandsReadingHelper.d.ts.map +1 -1
  2. package/dist/decoders/commandsReadingHelper.js +124 -44
  3. package/dist/decoders/commandsReadingHelper.js.map +1 -1
  4. package/dist/decoders/payloadParsers/index.d.ts +1 -0
  5. package/dist/decoders/payloadParsers/index.d.ts.map +1 -1
  6. package/dist/decoders/payloadParsers/index.js +1 -0
  7. package/dist/decoders/payloadParsers/index.js.map +1 -1
  8. package/dist/decoders/payloadParsers/multisensorPayloadParser.d.ts +2 -0
  9. package/dist/decoders/payloadParsers/multisensorPayloadParser.d.ts.map +1 -0
  10. package/dist/decoders/payloadParsers/multisensorPayloadParser.js +96 -0
  11. package/dist/decoders/payloadParsers/multisensorPayloadParser.js.map +1 -0
  12. package/dist/decoders/payloadParsers/types/allDevices.d.ts +2 -1
  13. package/dist/decoders/payloadParsers/types/allDevices.d.ts.map +1 -1
  14. package/dist/decoders/payloadParsers/types/allDevices.js +1 -0
  15. package/dist/decoders/payloadParsers/types/allDevices.js.map +1 -1
  16. package/dist/encoders/Co2DisplayCommonCommands.d.ts +0 -4
  17. package/dist/encoders/Co2DisplayCommonCommands.d.ts.map +1 -1
  18. package/dist/encoders/Co2DisplayCommonCommands.js +0 -38
  19. package/dist/encoders/Co2DisplayCommonCommands.js.map +1 -1
  20. package/dist/encoders/CommandBuilder.d.ts.map +1 -1
  21. package/dist/encoders/CommandBuilder.js +1 -0
  22. package/dist/encoders/CommandBuilder.js.map +1 -1
  23. package/dist/encoders/FanCoilThermostat.d.ts +61 -0
  24. package/dist/encoders/FanCoilThermostat.d.ts.map +1 -0
  25. package/dist/encoders/FanCoilThermostat.js +719 -0
  26. package/dist/encoders/FanCoilThermostat.js.map +1 -0
  27. package/dist/encoders/MultiSensorCommands.d.ts +25 -0
  28. package/dist/encoders/MultiSensorCommands.d.ts.map +1 -0
  29. package/dist/encoders/MultiSensorCommands.js +256 -0
  30. package/dist/encoders/MultiSensorCommands.js.map +1 -0
  31. package/dist/encoders/SetAqiLed.d.ts +6 -0
  32. package/dist/encoders/SetAqiLed.d.ts.map +1 -0
  33. package/dist/encoders/SetAqiLed.js +46 -0
  34. package/dist/encoders/SetAqiLed.js.map +1 -0
  35. package/dist/encoders/index.d.ts +1 -0
  36. package/dist/encoders/index.d.ts.map +1 -1
  37. package/dist/encoders/index.js +1 -0
  38. package/dist/encoders/index.js.map +1 -1
  39. package/dist/encoders/types/enumValidation.d.ts +6 -0
  40. package/dist/encoders/types/enumValidation.d.ts.map +1 -0
  41. package/dist/encoders/types/enumValidation.js +50 -0
  42. package/dist/encoders/types/enumValidation.js.map +1 -0
  43. package/dist/encoders/types/schemaValidatedEnums.d.ts +40 -0
  44. package/dist/encoders/types/schemaValidatedEnums.d.ts.map +1 -0
  45. package/dist/encoders/types/schemaValidatedEnums.js +181 -0
  46. package/dist/encoders/types/schemaValidatedEnums.js.map +1 -0
  47. package/dist/encoders/types/schemas.d.ts +247 -0
  48. package/dist/encoders/types/schemas.d.ts.map +1 -1
  49. package/dist/encoders/types/schemas.js +24 -3
  50. package/dist/encoders/types/schemas.js.map +1 -1
  51. package/dist/types/deviceTypes.d.ts +19 -0
  52. package/dist/types/deviceTypes.d.ts.map +1 -0
  53. package/dist/types/deviceTypes.js +23 -0
  54. package/dist/types/deviceTypes.js.map +1 -0
  55. package/dist/types/index.d.ts +2 -0
  56. package/dist/types/index.d.ts.map +1 -0
  57. package/dist/types/index.js +18 -0
  58. package/dist/types/index.js.map +1 -0
  59. package/dist/types/types.d.ts +13 -0
  60. package/dist/types/types.d.ts.map +1 -0
  61. package/dist/types/types.js +9 -0
  62. package/dist/types/types.js.map +1 -0
  63. package/dist/validation.d.ts +3 -0
  64. package/dist/validation.d.ts.map +1 -0
  65. package/dist/validation.js +8 -0
  66. package/dist/validation.js.map +1 -0
  67. package/package.json +1 -1
  68. package/src/decoders/commandsReadingHelper.ts +283 -204
  69. package/src/decoders/payloadParsers/index.ts +1 -1
  70. package/src/decoders/payloadParsers/multisensorPayloadParser.ts +97 -0
  71. package/src/decoders/payloadParsers/types/allDevices.ts +1 -0
  72. package/src/encoders/CommandBuilder.ts +2 -0
  73. package/src/encoders/MultiSensorCommands.ts +253 -0
  74. package/src/encoders/index.ts +1 -0
  75. package/src/encoders/types/schemas.ts +62 -9
@@ -22,6 +22,8 @@ export const commandsReadingHelper = (hexData: string, payloadLength: number, de
22
22
  decodeKeepalive = true
23
23
  } else if ((potentialKeepAlive[0] === '00' || potentialKeepAlive[0] === '88') && deviceType === DeviceType.TFlood) {
24
24
  decodeKeepalive = true
25
+ } else if (potentialKeepAlive[0] === '82' && deviceType === DeviceType.MultiSensor) {
26
+ decodeKeepalive = true
25
27
  } else if (
26
28
  (potentialKeepAlive[0] === '01' || potentialKeepAlive[0] === '20' || potentialKeepAlive[0] === '21') &&
27
29
  deviceType === DeviceType.OpenCloseSensor
@@ -201,9 +203,9 @@ export const commandsReadingHelper = (hexData: string, payloadLength: number, de
201
203
  case '0a':
202
204
  {
203
205
  try {
204
- let data;
206
+ let data
205
207
  if (deviceType === DeviceType.MelissaLorawan) {
206
- command_len = 4;
208
+ command_len = 4
207
209
  let recordedIrCodeSize = (parseInt(commands[i + 1], 16) << 8) | parseInt(commands[i + 2], 16)
208
210
  let bytesSent = `${commands[i + 3]}${commands[i + 4]}`
209
211
  data = { recordedIrInfo: { recordedIrCodeSize, bytesSent } }
@@ -219,35 +221,36 @@ export const commandsReadingHelper = (hexData: string, payloadLength: number, de
219
221
  })
220
222
  }
221
223
  }
222
- break;
224
+ break
223
225
  case '0b':
224
226
  {
225
227
  try {
226
- let data;
228
+ let data
227
229
  if (deviceType === DeviceType.MelissaLorawan) {
228
230
  // First byte after command indicates how many bytes follow
229
- const bytesCount = parseInt(commands[i + 1], 16);
230
- command_len = 1 + bytesCount; // 1 for bytesCount + the actual bytes
231
+ const bytesCount = parseInt(commands[i + 1], 16)
232
+ command_len = 1 + bytesCount // 1 for bytesCount + the actual bytes
231
233
 
232
234
  // Next two bytes are buffer offset
233
- const bufferOffsetMSB = parseInt(commands[i + 2], 16);
234
- const bufferOffsetLSB = parseInt(commands[i + 3], 16);
235
- const address = (bufferOffsetMSB << 8) | bufferOffsetLSB;
235
+ const bufferOffsetMSB = parseInt(commands[i + 2], 16)
236
+ const bufferOffsetLSB = parseInt(commands[i + 3], 16)
237
+ const address = (bufferOffsetMSB << 8) | bufferOffsetLSB
236
238
 
237
239
  // The rest is IR code data
238
- let irCodeDataString = '';
239
- for (let j = 4; j < 4 + bytesCount - 2; j++) { // -2 to account for the offset bytes
240
- irCodeDataString += commands[i + j];
240
+ let irCodeDataString = ''
241
+ for (let j = 4; j < 4 + bytesCount - 2; j++) {
242
+ // -2 to account for the offset bytes
243
+ irCodeDataString += commands[i + j]
241
244
  }
242
245
 
243
- data = {
246
+ data = {
244
247
  irCodeData: {
245
248
  bytesCount: bytesCount - 2,
246
249
  address,
247
- data: irCodeDataString
248
- }
249
- };
250
- Object.assign(resultToPass, { ...resultToPass }, { ...data });
250
+ data: irCodeDataString,
251
+ },
252
+ }
253
+ Object.assign(resultToPass, { ...resultToPass }, { ...data })
251
254
  }
252
255
  } catch (e) {
253
256
  throw new CustomError({
@@ -259,7 +262,7 @@ export const commandsReadingHelper = (hexData: string, payloadLength: number, de
259
262
  })
260
263
  }
261
264
  }
262
- break;
265
+ break
263
266
  case '0e':
264
267
  {
265
268
  try {
@@ -609,6 +612,10 @@ export const commandsReadingHelper = (hexData: string, payloadLength: number, de
609
612
  overheatingThresholds: { trigger: parseInt(commands[i + 1], 16), recovery: parseInt(commands[i + 2], 16) },
610
613
  }
611
614
  Object.assign(resultToPass, { ...resultToPass }, { ...data })
615
+ } else if (deviceType === DeviceType.MultiSensor) {
616
+ command_len = 1
617
+ let data = { lightEnabled: parseInt(commands[i + 1], 16) === 1 }
618
+ Object.assign(resultToPass, { ...resultToPass }, { ...data })
612
619
  } else {
613
620
  command_len = 4
614
621
  let good_medium = parseInt(`${commands[i + 1]}${commands[i + 2]}`, 16)
@@ -649,6 +656,10 @@ export const commandsReadingHelper = (hexData: string, payloadLength: number, de
649
656
  },
650
657
  }
651
658
  Object.assign(resultToPass, { ...resultToPass }, { ...data })
659
+ } else if (deviceType === DeviceType.MultiSensor) {
660
+ command_len = 1
661
+ let data = { hallEnabled: parseInt(commands[i + 1], 16) === 1 }
662
+ Object.assign(resultToPass, { ...resultToPass }, { ...data })
652
663
  } else if (deviceType !== DeviceType.OpenCloseSensor) {
653
664
  command_len = 2
654
665
  let data = { autoZeroValue: parseInt(`${commands[i + 1]}${commands[i + 2]}`, 16) }
@@ -705,11 +716,16 @@ export const commandsReadingHelper = (hexData: string, payloadLength: number, de
705
716
  command_len = 1
706
717
  let data = { overcurrentThreshold: parseInt(commands[i + 1], 16) }
707
718
  Object.assign(resultToPass, { ...resultToPass }, { ...data })
719
+ } else if (deviceType === DeviceType.MultiSensor) {
720
+ command_len = 2
721
+ let data = { hallBlindPeriod: (parseInt(commands[i + 1], 16) << 8) | parseInt(commands[i + 2], 16) }
722
+ Object.assign(resultToPass, { ...resultToPass }, { ...data })
708
723
  } else {
709
724
  command_len = 3
710
725
  let good_zone = parseInt(commands[i + 1], 16)
711
726
  let medium_zone = parseInt(commands[i + 2], 16)
712
727
  let bad_zone = parseInt(commands[i + 3], 16)
728
+
713
729
  let data = {
714
730
  notifyPeriod: { good_zone: Number(good_zone), medium_zone: Number(medium_zone), bad_zone: Number(bad_zone) },
715
731
  }
@@ -729,7 +745,7 @@ export const commandsReadingHelper = (hexData: string, payloadLength: number, de
729
745
  case '25':
730
746
  {
731
747
  try {
732
- let data = {}
748
+ let data
733
749
  if (deviceType == DeviceType.Relay16) {
734
750
  command_len = 2
735
751
  data = { overpowerThreshold: (parseInt(commands[i + 1], 16) << 8) | parseInt(commands[i + 2], 16) }
@@ -779,6 +795,10 @@ export const commandsReadingHelper = (hexData: string, payloadLength: number, de
779
795
  parseInt(commands[i + 31], 16),
780
796
  },
781
797
  }
798
+ } else if (deviceType === DeviceType.MultiSensor) {
799
+ command_len = 1
800
+ data = { microphoneEnabled: parseInt(commands[i + 1], 16) === 1 }
801
+ Object.assign(resultToPass, { ...resultToPass }, { ...data })
782
802
  } else {
783
803
  command_len = 3
784
804
  let good_zone = parseInt(commands[i + 1], 16)
@@ -792,8 +812,8 @@ export const commandsReadingHelper = (hexData: string, payloadLength: number, de
792
812
  bad_zone: Number(bad_zone),
793
813
  },
794
814
  }
815
+ Object.assign(resultToPass, { ...resultToPass }, { ...data })
795
816
  }
796
- Object.assign(resultToPass, { ...resultToPass }, { ...data })
797
817
  } catch (e) {
798
818
  throw new CustomError({
799
819
  message: `Failed to process command '25'`,
@@ -812,6 +832,12 @@ export const commandsReadingHelper = (hexData: string, payloadLength: number, de
812
832
  command_len = 1
813
833
  let data = { OVAC: parseInt(commands[i + 1], 16) }
814
834
  Object.assign(resultToPass, { ...resultToPass }, { ...data })
835
+ } else if (deviceType === DeviceType.MultiSensor) {
836
+ command_len = 2
837
+ let data = {
838
+ microphoneSamplingPeriod: (parseInt(commands[i + 1], 16) << 8) | parseInt(commands[i + 2], 16),
839
+ }
840
+ Object.assign(resultToPass, { ...resultToPass }, { ...data })
815
841
  } else {
816
842
  command_len = 9
817
843
  let duration_good_beeping = parseInt(commands[i + 1], 16)
@@ -865,6 +891,10 @@ export const commandsReadingHelper = (hexData: string, payloadLength: number, de
865
891
  let period = parseInt(commands[i + 2], 16)
866
892
  let data = { proportionalAlgorithmParameters: { coefficient: Number(coefficient), period: Number(period) } }
867
893
  Object.assign(resultToPass, { ...resultToPass }, { ...data })
894
+ } else if (deviceType === DeviceType.MultiSensor) {
895
+ command_len = 1
896
+ let data = { gasEnabled: parseInt(commands[i + 1], 16) === 1 }
897
+ Object.assign(resultToPass, { ...resultToPass }, { ...data })
868
898
  } else {
869
899
  command_len = 15
870
900
  let red_good = parseInt(commands[i + 1], 16)
@@ -927,6 +957,10 @@ export const commandsReadingHelper = (hexData: string, payloadLength: number, de
927
957
  }
928
958
  let data = { temperatureControlAlgorithm: algo }
929
959
  Object.assign(resultToPass, { ...resultToPass }, { ...data })
960
+ } else if (deviceType === DeviceType.MultiSensor) {
961
+ command_len = 1
962
+ let data = { gasMeasurementPeriodMinutes: parseInt(commands[i + 1], 16) }
963
+ Object.assign(resultToPass, { ...resultToPass }, { ...data })
930
964
  } else {
931
965
  command_len = 1
932
966
  let data = { autoZeroPeriod: parseInt(commands[i + 1], 16) }
@@ -943,11 +977,34 @@ export const commandsReadingHelper = (hexData: string, payloadLength: number, de
943
977
  }
944
978
  }
945
979
  break
980
+ case '2d':
981
+ {
982
+ try {
983
+ if (deviceType === DeviceType.MultiSensor) {
984
+ command_len = 1
985
+ let data = { pirEnabled: parseInt(commands[i + 1], 16) === 1 }
986
+ Object.assign(resultToPass, { ...resultToPass }, { ...data })
987
+ }
988
+ } catch (e) {
989
+ throw new CustomError({
990
+ message: `Failed to process command '2d'`,
991
+ hexData,
992
+ command,
993
+ deviceType,
994
+ originalError: e as Error,
995
+ })
996
+ }
997
+ }
998
+ break
946
999
  case '2f':
947
1000
  {
948
1001
  try {
949
1002
  let data
950
- if (
1003
+ if (deviceType === DeviceType.MultiSensor) {
1004
+ command_len = 2
1005
+ data = { pirBlindPeriod: (parseInt(commands[i + 1], 16) << 8) | parseInt(commands[i + 2], 16) }
1006
+ Object.assign(resultToPass, { ...resultToPass }, { ...data })
1007
+ } else if (
951
1008
  deviceType === DeviceType.CO2DisplayLite ||
952
1009
  deviceType === DeviceType.CO2PirLite ||
953
1010
  deviceType === DeviceType.HTPirLite
@@ -995,6 +1052,24 @@ export const commandsReadingHelper = (hexData: string, payloadLength: number, de
995
1052
  }
996
1053
  }
997
1054
  break
1055
+
1056
+ case 'a4':
1057
+ {
1058
+ try {
1059
+ command_len = 1
1060
+ let data = { region: parseInt(commands[i + 1], 16) }
1061
+ Object.assign(resultToPass, { ...resultToPass }, { ...data })
1062
+ } catch (e) {
1063
+ throw new CustomError({
1064
+ message: `Failed to process command 'a4'`,
1065
+ hexData,
1066
+ command,
1067
+ deviceType,
1068
+ originalError: e as Error,
1069
+ })
1070
+ }
1071
+ }
1072
+ break
998
1073
  case '32':
999
1074
  {
1000
1075
  try {
@@ -1651,18 +1726,18 @@ export const commandsReadingHelper = (hexData: string, payloadLength: number, de
1651
1726
  try {
1652
1727
  let data
1653
1728
  if (deviceType === DeviceType.Vicki) {
1654
- command_len = 2;
1655
- let notificationByte = parseInt(commands[i + 1], 16);
1729
+ command_len = 2
1730
+ let notificationByte = parseInt(commands[i + 1], 16)
1656
1731
  // Extract notification flags from bits
1657
- let temperatureRestoredAfterManualBoost = !!(notificationByte & 0x01); // Bit 0
1658
- let temperatureChangedByHeatingSchedule = !!(notificationByte & 0x02); // Bit 1
1732
+ let temperatureRestoredAfterManualBoost = !!(notificationByte & 0x01) // Bit 0
1733
+ let temperatureChangedByHeatingSchedule = !!(notificationByte & 0x02) // Bit 1
1659
1734
  data = {
1660
1735
  notifications: {
1661
1736
  temperatureRestoredAfterManualBoost: temperatureRestoredAfterManualBoost,
1662
- temperatureChangedByHeatingSchedule: temperatureChangedByHeatingSchedule
1663
- }
1664
- };
1665
- }else{
1737
+ temperatureChangedByHeatingSchedule: temperatureChangedByHeatingSchedule,
1738
+ },
1739
+ }
1740
+ } else {
1666
1741
  command_len = 3
1667
1742
  let state = parseInt(commands[i + 1], 16)
1668
1743
  let time = (parseInt(commands[i + 2], 16) << 8) | parseInt(commands[i + 3], 16)
@@ -1732,7 +1807,7 @@ export const commandsReadingHelper = (hexData: string, payloadLength: number, de
1732
1807
  if (deviceType === DeviceType.FanCoilThermostat) {
1733
1808
  command_len = 1
1734
1809
  data = { fanSpeedNotOccupied: parseInt(commands[i + 1], 16) }
1735
- }else{
1810
+ } else {
1736
1811
  command_len = 1
1737
1812
  data = { manualChangeRelayState: parseInt(commands[i + 1], 16) }
1738
1813
  }
@@ -1781,10 +1856,10 @@ export const commandsReadingHelper = (hexData: string, payloadLength: number, de
1781
1856
  overheatingEvents: { events: parseInt(commands[i + 1], 16), temperature: parseInt(commands[i + 2], 16) },
1782
1857
  }
1783
1858
  } else if (deviceType === DeviceType.Vicki) {
1784
- command_len = 1;
1785
- let offsetByte = parseInt(commands[i + 1], 16);
1786
- let offsetHours = (offsetByte & 0x80) ? (offsetByte - 256) : offsetByte;
1787
- data = { deviceTimeZone: offsetHours };
1859
+ command_len = 1
1860
+ let offsetByte = parseInt(commands[i + 1], 16)
1861
+ let offsetHours = offsetByte & 0x80 ? offsetByte - 256 : offsetByte
1862
+ data = { deviceTimeZone: offsetHours }
1788
1863
  }
1789
1864
  Object.assign(resultToPass, { ...resultToPass }, { ...data })
1790
1865
  } catch (e) {
@@ -1838,10 +1913,10 @@ export const commandsReadingHelper = (hexData: string, payloadLength: number, de
1838
1913
  current: (parseInt(commands[i + 2], 16) << 8) | parseInt(commands[i + 3], 16),
1839
1914
  },
1840
1915
  }
1841
- }else{
1842
- command_len = 1;
1843
- let timeValue = parseInt(commands[i + 1], 16);
1844
- data = { autoSetpointRestoreStatus: timeValue === 0 ? 0 : timeValue * 10 };
1916
+ } else {
1917
+ command_len = 1
1918
+ let timeValue = parseInt(commands[i + 1], 16)
1919
+ data = { autoSetpointRestoreStatus: timeValue === 0 ? 0 : timeValue * 10 }
1845
1920
  }
1846
1921
  Object.assign(resultToPass, { ...resultToPass }, { ...data })
1847
1922
  } catch (e) {
@@ -1981,9 +2056,9 @@ export const commandsReadingHelper = (hexData: string, payloadLength: number, de
1981
2056
  if (deviceType === DeviceType.FanCoilThermostat) {
1982
2057
  command_len = 1
1983
2058
  data = { frostProtectionStatus: parseInt(commands[i + 1], 16) }
1984
- }else{
1985
- command_len = 1;
1986
- data = { timeRequestByMACcommand: parseInt(commands[i + 1], 16) };
2059
+ } else {
2060
+ command_len = 1
2061
+ data = { timeRequestByMACcommand: parseInt(commands[i + 1], 16) }
1987
2062
  }
1988
2063
  Object.assign(resultToPass, { ...resultToPass }, { ...data })
1989
2064
  } catch (e) {
@@ -2364,23 +2439,6 @@ export const commandsReadingHelper = (hexData: string, payloadLength: number, de
2364
2439
  }
2365
2440
  }
2366
2441
  break
2367
- case 'a4':
2368
- {
2369
- try {
2370
- command_len = 1
2371
- let data = { region: parseInt(commands[i + 1], 16) }
2372
- Object.assign(resultToPass, { ...resultToPass }, { ...data })
2373
- } catch (e) {
2374
- throw new CustomError({
2375
- message: `Failed to process command 'a4'`,
2376
- hexData,
2377
- command,
2378
- deviceType,
2379
- originalError: e as Error,
2380
- })
2381
- }
2382
- }
2383
- break
2384
2442
  case 'a6':
2385
2443
  {
2386
2444
  try {
@@ -2401,66 +2459,72 @@ export const commandsReadingHelper = (hexData: string, payloadLength: number, de
2401
2459
  case '5a':
2402
2460
  {
2403
2461
  try {
2404
- let data;
2462
+ let data
2405
2463
  if (deviceType === DeviceType.Relay16 || deviceType === DeviceType.Relay16Dry) {
2406
2464
  command_len = 1
2407
2465
  data = { afterOverheatingProtectionRecovery: parseInt(commands[i + 1], 16) }
2408
2466
  } else {
2409
- command_len = 41;
2410
- let eventsGroup = parseInt(commands[i + 1], 16); // 0 = events 0-7, 1 = events 8-15, 2 = events 16-19
2411
- let eventGroupIndex = ['0-7', '8-15', '16-19'];
2412
- let heatingEvents = [];
2467
+ command_len = 41
2468
+ let eventsGroup = parseInt(commands[i + 1], 16) // 0 = events 0-7, 1 = events 8-15, 2 = events 16-19
2469
+ let eventGroupIndex = ['0-7', '8-15', '16-19']
2470
+ let heatingEvents = []
2413
2471
 
2414
2472
  // Process up to 8 events for groups 0 and 1, but only 4 events for group 2
2415
- let eventsToProcess = (eventsGroup === 2) ? 4 : 8;
2473
+ let eventsToProcess = eventsGroup === 2 ? 4 : 8
2416
2474
  for (let eventIdx = 0; eventIdx < eventsToProcess; eventIdx++) {
2417
2475
  // Each event takes 5 bytes (hour, minute, temp high, temp low, weekday bitmask)
2418
- let offset = i + 2 + (eventIdx * 5);
2476
+ let offset = i + 2 + eventIdx * 5
2419
2477
 
2420
2478
  // Check if this event is configured
2421
2479
  // Make sure we have valid values at this offset
2422
2480
  if (offset >= commands.length || offset + 4 >= commands.length) {
2423
- continue;
2481
+ continue
2424
2482
  }
2425
2483
 
2426
- let hour = parseInt(commands[offset], 16);
2427
- let minute = parseInt(commands[offset + 1], 16);
2428
- let tempHigh = parseInt(commands[offset + 2], 16);
2429
- let tempLow = parseInt(commands[offset + 3], 16);
2430
- let weekdayByte = parseInt(commands[offset + 4], 16);
2484
+ let hour = parseInt(commands[offset], 16)
2485
+ let minute = parseInt(commands[offset + 1], 16)
2486
+ let tempHigh = parseInt(commands[offset + 2], 16)
2487
+ let tempLow = parseInt(commands[offset + 3], 16)
2488
+ let weekdayByte = parseInt(commands[offset + 4], 16)
2431
2489
 
2432
2490
  // Skip events that are not configured (zeros or NaN values)
2433
- if (isNaN(hour) || isNaN(minute) || isNaN(tempHigh) || isNaN(tempLow) || isNaN(weekdayByte) ||
2434
- (hour === 0 && minute === 0 && tempHigh === 0 && tempLow === 0 && weekdayByte === 0)) {
2435
- continue;
2491
+ if (
2492
+ isNaN(hour) ||
2493
+ isNaN(minute) ||
2494
+ isNaN(tempHigh) ||
2495
+ isNaN(tempLow) ||
2496
+ isNaN(weekdayByte) ||
2497
+ (hour === 0 && minute === 0 && tempHigh === 0 && tempLow === 0 && weekdayByte === 0)
2498
+ ) {
2499
+ continue
2436
2500
  }
2437
2501
 
2438
2502
  // Calculate actual event index in the full range (0-23)
2439
- let globalEventIndex = (eventsGroup * 8) + eventIdx;
2503
+ let globalEventIndex = eventsGroup * 8 + eventIdx
2440
2504
  // Decode weekday bitmask (bit 0=Mon, bit 1=Tue, bit 2=Wed, bit 3=Thu, bit 4=Fri, bit 5=Sat, bit 6=Sun)
2441
2505
  let weekdays = {
2442
- monday: !!(weekdayByte & 0x01), // bit 0
2443
- tuesday: !!(weekdayByte & 0x02), // bit 1
2444
- wednesday: !!(weekdayByte & 0x04), // bit 2
2445
- thursday: !!(weekdayByte & 0x08), // bit 3
2446
- friday: !!(weekdayByte & 0x10), // bit 4
2447
- saturday: !!(weekdayByte & 0x20), // bit 5
2448
- sunday: !!(weekdayByte & 0x40) // bit 6
2449
- };
2506
+ monday: !!(weekdayByte & 0x01), // bit 0
2507
+ tuesday: !!(weekdayByte & 0x02), // bit 1
2508
+ wednesday: !!(weekdayByte & 0x04), // bit 2
2509
+ thursday: !!(weekdayByte & 0x08), // bit 3
2510
+ friday: !!(weekdayByte & 0x10), // bit 4
2511
+ saturday: !!(weekdayByte & 0x20), // bit 5
2512
+ sunday: !!(weekdayByte & 0x40), // bit 6
2513
+ }
2450
2514
 
2451
2515
  // Create heating event object
2452
2516
  let heatingEvent = {
2453
2517
  index: globalEventIndex,
2454
2518
  start: (hour < 10 ? '0' + hour : hour) + ':' + (minute < 10 ? '0' + minute : minute),
2455
2519
  targetTemperature: ((tempHigh << 8) | tempLow) / 10,
2456
- weekdays: weekdays
2457
- };
2458
- heatingEvents.push(heatingEvent);
2520
+ weekdays: weekdays,
2521
+ }
2522
+ heatingEvents.push(heatingEvent)
2459
2523
  }
2460
2524
  data = {
2461
2525
  heatingEventGroup: eventGroupIndex[eventsGroup],
2462
- heatingEvents: heatingEvents
2463
- };
2526
+ heatingEvents: heatingEvents,
2527
+ }
2464
2528
  }
2465
2529
  Object.assign(resultToPass, { ...resultToPass }, { ...data })
2466
2530
  } catch (e) {
@@ -2477,30 +2541,40 @@ export const commandsReadingHelper = (hexData: string, payloadLength: number, de
2477
2541
  case '5c':
2478
2542
  {
2479
2543
  try {
2480
- let data;
2544
+ let data
2481
2545
  if (deviceType === DeviceType.Vicki) {
2482
- command_len = 4;
2546
+ command_len = 4
2483
2547
  // Note: Months are 0-11 (January=0, December=11)
2484
- let startMonth = parseInt(commands[i + 1], 16);
2485
- let startDay = parseInt(commands[i + 2], 16);
2486
- let endMonth = parseInt(commands[i + 3], 16);
2487
- let endDay = parseInt(commands[i + 4], 16);
2548
+ let startMonth = parseInt(commands[i + 1], 16)
2549
+ let startDay = parseInt(commands[i + 2], 16)
2550
+ let endMonth = parseInt(commands[i + 3], 16)
2551
+ let endDay = parseInt(commands[i + 4], 16)
2488
2552
 
2489
2553
  // Convert to human-readable month names
2490
2554
  let monthNames = [
2491
- 'January', 'February', 'March', 'April', 'May', 'June',
2492
- 'July', 'August', 'September', 'October', 'November', 'December'
2493
- ];
2555
+ 'January',
2556
+ 'February',
2557
+ 'March',
2558
+ 'April',
2559
+ 'May',
2560
+ 'June',
2561
+ 'July',
2562
+ 'August',
2563
+ 'September',
2564
+ 'October',
2565
+ 'November',
2566
+ 'December',
2567
+ ]
2494
2568
 
2495
2569
  data = {
2496
2570
  heatingSchedule: {
2497
2571
  start: startDay + ' ' + monthNames[startMonth],
2498
2572
  end: endDay + ' ' + monthNames[endMonth],
2499
- }
2500
- };
2501
- Object.assign(resultToPass, { ...resultToPass }, { ...data });
2573
+ },
2574
+ }
2575
+ Object.assign(resultToPass, { ...resultToPass }, { ...data })
2502
2576
  } else {
2503
- command_len = 1;
2577
+ command_len = 1
2504
2578
  data = { ledIndicationMode: parseInt(commands[i + 1], 16) }
2505
2579
  }
2506
2580
  Object.assign(resultToPass, { ...resultToPass }, { ...data })
@@ -2518,20 +2592,21 @@ export const commandsReadingHelper = (hexData: string, payloadLength: number, de
2518
2592
  case '5e':
2519
2593
  {
2520
2594
  try {
2521
- command_len = 4;
2595
+ command_len = 4
2522
2596
  // Parse 32-bit UNIX timestamp (4 bytes)
2523
- var unixTimestamp = (parseInt(commands[i + 1], 16) << 24) |
2597
+ var unixTimestamp =
2598
+ (parseInt(commands[i + 1], 16) << 24) |
2524
2599
  (parseInt(commands[i + 2], 16) << 16) |
2525
2600
  (parseInt(commands[i + 3], 16) << 8) |
2526
- parseInt(commands[i + 4], 16);
2601
+ parseInt(commands[i + 4], 16)
2527
2602
 
2528
2603
  // Convert UNIX timestamp to JavaScript Date
2529
- let dateObj = new Date(unixTimestamp * 1000); // Convert seconds to milliseconds
2604
+ let dateObj = new Date(unixTimestamp * 1000) // Convert seconds to milliseconds
2530
2605
  let date = dateObj.getUTCDate() + '/' + (dateObj.getUTCMonth() + 1) + '/' + dateObj.getUTCFullYear()
2531
2606
  let time = dateObj.getUTCHours() + ':' + (dateObj.getUTCMinutes() < 10 ? '0' : '') + dateObj.getUTCMinutes()
2532
2607
  let data = {
2533
- deviceTime: "" + date + " " + time
2534
- };
2608
+ deviceTime: '' + date + ' ' + time,
2609
+ }
2535
2610
  Object.assign(resultToPass, { ...resultToPass }, { ...data })
2536
2611
  } catch (e) {
2537
2612
  throw new CustomError({
@@ -2543,131 +2618,135 @@ export const commandsReadingHelper = (hexData: string, payloadLength: number, de
2543
2618
  })
2544
2619
  }
2545
2620
  }
2546
- break;
2547
- case '64': {
2548
- try {
2549
- command_len = 1;
2550
- let ledDurationValue = parseInt(commands[i + 1], 16);
2551
- let durationInSeconds = ledDurationValue / 2; // As per the docs, value is divided by 2 to get seconds
2621
+ break
2622
+ case '64':
2623
+ {
2624
+ try {
2625
+ command_len = 1
2626
+ let ledDurationValue = parseInt(commands[i + 1], 16)
2627
+ let durationInSeconds = ledDurationValue / 2 // As per the docs, value is divided by 2 to get seconds
2552
2628
 
2553
- let data = {
2554
- ledIndicationDuration: durationInSeconds
2555
- };
2556
- Object.assign(resultToPass, { ...resultToPass }, { ...data })
2557
- } catch (e) {
2558
- throw new CustomError({
2559
- message: `Failed to process command '64'`,
2560
- hexData,
2561
- command,
2562
- deviceType,
2563
- originalError: e as Error,
2564
- })
2629
+ let data = {
2630
+ ledIndicationDuration: durationInSeconds,
2631
+ }
2632
+ Object.assign(resultToPass, { ...resultToPass }, { ...data })
2633
+ } catch (e) {
2634
+ throw new CustomError({
2635
+ message: `Failed to process command '64'`,
2636
+ hexData,
2637
+ command,
2638
+ deviceType,
2639
+ originalError: e as Error,
2640
+ })
2641
+ }
2565
2642
  }
2566
- }
2567
- break;
2568
- case '66': {
2569
- try {
2570
- command_len = 2;
2643
+ break
2644
+ case '66':
2645
+ {
2646
+ try {
2647
+ command_len = 2
2571
2648
 
2572
- let tempHigh = parseInt(commands[i + 1], 16);
2573
- let tempLow = parseInt(commands[i + 2], 16);
2574
- let targetTemp = (tempHigh << 8) | tempLow;
2575
- let data = {
2576
- offlineTargetTemperature: targetTemp === 0 ? 0 : targetTemp / 10
2577
- };
2578
- Object.assign(resultToPass, { ...resultToPass }, { ...data })
2579
- } catch (e) {
2580
- throw new CustomError({
2581
- message: `Failed to process command '66'`,
2582
- hexData,
2583
- command,
2584
- deviceType,
2585
- originalError: e as Error,
2586
- })
2649
+ let tempHigh = parseInt(commands[i + 1], 16)
2650
+ let tempLow = parseInt(commands[i + 2], 16)
2651
+ let targetTemp = (tempHigh << 8) | tempLow
2652
+ let data = {
2653
+ offlineTargetTemperature: targetTemp === 0 ? 0 : targetTemp / 10,
2654
+ }
2655
+ Object.assign(resultToPass, { ...resultToPass }, { ...data })
2656
+ } catch (e) {
2657
+ throw new CustomError({
2658
+ message: `Failed to process command '66'`,
2659
+ hexData,
2660
+ command,
2661
+ deviceType,
2662
+ originalError: e as Error,
2663
+ })
2664
+ }
2587
2665
  }
2588
- }
2589
- break;
2590
- case '68': {
2591
- try {
2592
- command_len = 1;
2593
- let data = { internalAlgoTemporaryState: parseInt(commands[i + 1], 16) === 0 ? true : false };
2594
- Object.assign(resultToPass, { ...resultToPass }, { ...data })
2595
- } catch (e) {
2596
- throw new CustomError({
2597
- message: `Failed to process command '68'`,
2598
- hexData,
2599
- command,
2600
- deviceType,
2601
- originalError: e as Error,
2602
- })
2666
+ break
2667
+ case '68':
2668
+ {
2669
+ try {
2670
+ command_len = 1
2671
+ let data = { internalAlgoTemporaryState: parseInt(commands[i + 1], 16) === 0 ? true : false }
2672
+ Object.assign(resultToPass, { ...resultToPass }, { ...data })
2673
+ } catch (e) {
2674
+ throw new CustomError({
2675
+ message: `Failed to process command '68'`,
2676
+ hexData,
2677
+ command,
2678
+ deviceType,
2679
+ originalError: e as Error,
2680
+ })
2681
+ }
2603
2682
  }
2604
- }
2605
- break;
2606
- case '6a': {
2607
- try {
2608
- command_len = 12;
2609
- let temperatureLevels: { [key: string]: number } = {};
2683
+ break
2684
+ case '6a':
2685
+ {
2686
+ try {
2687
+ command_len = 12
2688
+ let temperatureLevels: { [key: string]: number } = {}
2610
2689
 
2611
- // Process 6 scale levels (0-5), each with a 2-byte temperature value
2612
- for (let level = 0; level < 6; level++) {
2613
- let tempHighByte = parseInt(commands[i + 1 + (level * 2)], 16);
2614
- let tempLowByte = parseInt(commands[i + 2 + (level * 2)], 16);
2615
- let tempValue = (tempHighByte << 8) | tempLowByte;
2690
+ // Process 6 scale levels (0-5), each with a 2-byte temperature value
2691
+ for (let level = 0; level < 6; level++) {
2692
+ let tempHighByte = parseInt(commands[i + 1 + level * 2], 16)
2693
+ let tempLowByte = parseInt(commands[i + 2 + level * 2], 16)
2694
+ let tempValue = (tempHighByte << 8) | tempLowByte
2616
2695
 
2617
- // The temperature values are pre-multiplied by 10
2618
- temperatureLevels['level' + level] = tempValue / 10;
2619
- }
2696
+ // The temperature values are pre-multiplied by 10
2697
+ temperatureLevels['level' + level] = tempValue / 10
2698
+ }
2620
2699
 
2621
- let data = {
2622
- temperatureLevels: temperatureLevels
2623
- };
2700
+ let data = {
2701
+ temperatureLevels: temperatureLevels,
2702
+ }
2624
2703
 
2625
- Object.assign(resultToPass, { ...resultToPass }, { ...data })
2626
- } catch (e) {
2627
- throw new CustomError({
2628
- message: `Failed to process command '6a'`,
2629
- hexData,
2630
- command,
2631
- deviceType,
2632
- originalError: e as Error,
2633
- })
2704
+ Object.assign(resultToPass, { ...resultToPass }, { ...data })
2705
+ } catch (e) {
2706
+ throw new CustomError({
2707
+ message: `Failed to process command '6a'`,
2708
+ hexData,
2709
+ command,
2710
+ deviceType,
2711
+ originalError: e as Error,
2712
+ })
2713
+ }
2634
2714
  }
2635
- }
2636
- break;
2715
+ break
2637
2716
  case '6c': {
2638
2717
  try {
2639
- command_len = 4;
2640
- let eventsHighByte = parseInt(commands[i + 2], 16); // Events 19-16
2641
- let eventsMidByte = parseInt(commands[i + 3], 16); // Events 15-8
2642
- let eventsLowByte = parseInt(commands[i + 4], 16); // Events 7-0
2718
+ command_len = 4
2719
+ let eventsHighByte = parseInt(commands[i + 2], 16) // Events 19-16
2720
+ let eventsMidByte = parseInt(commands[i + 3], 16) // Events 15-8
2721
+ let eventsLowByte = parseInt(commands[i + 4], 16) // Events 7-0
2643
2722
 
2644
2723
  // Create a more structured and readable format for heating events
2645
- let heatingEventStates: { [key: string]: boolean } = {};
2724
+ let heatingEventStates: { [key: string]: boolean } = {}
2646
2725
 
2647
2726
  // Process all 20 events (0-19) in a single loop
2648
2727
  for (let eventIdx = 0; eventIdx < 20; eventIdx++) {
2649
2728
  // Calculate which bit to check
2650
- let bitPosition;
2729
+ let bitPosition
2651
2730
  if (eventIdx >= 16) {
2652
2731
  // Events 16-19 in high byte
2653
- bitPosition = eventIdx - 16;
2654
- heatingEventStates[eventIdx] = !!(eventsHighByte & (1 << bitPosition));
2732
+ bitPosition = eventIdx - 16
2733
+ heatingEventStates[eventIdx] = !!(eventsHighByte & (1 << bitPosition))
2655
2734
  } else if (eventIdx >= 8) {
2656
2735
  // Events 8-15 in mid byte
2657
- bitPosition = eventIdx - 8;
2658
- heatingEventStates[eventIdx] = !!(eventsMidByte & (1 << bitPosition));
2736
+ bitPosition = eventIdx - 8
2737
+ heatingEventStates[eventIdx] = !!(eventsMidByte & (1 << bitPosition))
2659
2738
  } else {
2660
2739
  // Events 0-7 in low byte
2661
- bitPosition = eventIdx;
2662
- heatingEventStates[eventIdx] = !!(eventsLowByte & (1 << bitPosition));
2740
+ bitPosition = eventIdx
2741
+ heatingEventStates[eventIdx] = !!(eventsLowByte & (1 << bitPosition))
2663
2742
  }
2664
2743
  }
2665
2744
 
2666
2745
  let data = {
2667
- heatingEventStates: heatingEventStates
2668
- };
2746
+ heatingEventStates: heatingEventStates,
2747
+ }
2669
2748
 
2670
- Object.assign(resultToPass, { ...resultToPass }, { ...data });
2749
+ Object.assign(resultToPass, { ...resultToPass }, { ...data })
2671
2750
  } catch (e) {
2672
2751
  throw new CustomError({
2673
2752
  message: `Failed to process command '6c'`,
@@ -2677,7 +2756,7 @@ export const commandsReadingHelper = (hexData: string, payloadLength: number, de
2677
2756
  originalError: e as Error,
2678
2757
  })
2679
2758
  }
2680
- break;
2759
+ break
2681
2760
  }
2682
2761
  case '9b':
2683
2762
  {