homebridge-tasmota-control 1.6.15-beta.2 → 1.6.15-beta.20

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.
@@ -399,6 +399,12 @@
399
399
  "type": "string",
400
400
  "default": "swing",
401
401
  "oneOf": [
402
+ {
403
+ "title": "AIR DIRECTION",
404
+ "enum": [
405
+ "airdirection"
406
+ ]
407
+ },
402
408
  {
403
409
  "title": "LEFT",
404
410
  "enum": [
@@ -411,12 +417,24 @@
411
417
  "left_middle"
412
418
  ]
413
419
  },
420
+ {
421
+ "title": "LEFT CENTER",
422
+ "enum": [
423
+ "left_center"
424
+ ]
425
+ },
414
426
  {
415
427
  "title": "CENTER",
416
428
  "enum": [
417
429
  "center"
418
430
  ]
419
431
  },
432
+ {
433
+ "title": "RIGHT CENTER",
434
+ "enum": [
435
+ "right_center"
436
+ ]
437
+ },
420
438
  {
421
439
  "title": "RIGHT MIDDLE",
422
440
  "enum": [
@@ -519,7 +537,7 @@
519
537
  "title": "Mode",
520
538
  "type": "integer",
521
539
  "minimum": 0,
522
- "maximum": 53,
540
+ "maximum": 63,
523
541
  "default": 0,
524
542
  "description": "Here select function.",
525
543
  "oneOf": [
@@ -560,19 +578,19 @@
560
578
  ]
561
579
  },
562
580
  {
563
- "title": "MODE PURIFY (not implemented)",
581
+ "title": "VANE H LEFT",
564
582
  "enum": [
565
- 6
583
+ 10
566
584
  ]
567
585
  },
568
586
  {
569
- "title": "VANE H LEFT",
587
+ "title": "VANE H LEFT MIDDLE",
570
588
  "enum": [
571
589
  11
572
590
  ]
573
591
  },
574
592
  {
575
- "title": "VANE H LEFT MIDDLE",
593
+ "title": "VANE H LEFT CENTER",
576
594
  "enum": [
577
595
  12
578
596
  ]
@@ -584,29 +602,35 @@
584
602
  ]
585
603
  },
586
604
  {
587
- "title": "VANE H RIGHT MIDDLE",
605
+ "title": "VANE H RIGHT CENTER",
588
606
  "enum": [
589
607
  14
590
608
  ]
591
609
  },
592
610
  {
593
- "title": "VANE H RIGHT",
611
+ "title": "VANE H RIGHT MIDDLE",
594
612
  "enum": [
595
613
  15
596
614
  ]
597
615
  },
598
616
  {
599
- "title": "VANE H SPLIT",
617
+ "title": "VANE H RIGHT",
600
618
  "enum": [
601
619
  16
602
620
  ]
603
621
  },
604
622
  {
605
- "title": "VANE H SWING",
623
+ "title": "VANE H SPLIT",
606
624
  "enum": [
607
625
  17
608
626
  ]
609
627
  },
628
+ {
629
+ "title": "VANE H SWING",
630
+ "enum": [
631
+ 18
632
+ ]
633
+ },
610
634
  {
611
635
  "title": "VANE V AUTO",
612
636
  "enum": [
@@ -704,34 +728,52 @@
704
728
  ]
705
729
  },
706
730
  {
707
- "title": "AIR DIRECTION OFF",
708
- "enum": [
709
- 43
710
- ]
711
- },
712
- {
713
- "title": "LOCK CONTROL All (only as sensor now)",
731
+ "title": "LOCK CONTROL All",
714
732
  "enum": [
715
733
  50
716
734
  ]
717
735
  },
718
736
  {
719
- "title": "LOCK CONTROL POWER (only as sensor now)",
737
+ "title": "LOCK CONTROL POWER",
720
738
  "enum": [
721
739
  51
722
740
  ]
723
741
  },
724
742
  {
725
- "title": "LOCK CONTROL MODE (only as sensor now)",
743
+ "title": "LOCK CONTROL MODE",
726
744
  "enum": [
727
745
  52
728
746
  ]
729
747
  },
730
748
  {
731
- "title": "LOCK CONTROL TEMPERATURE (only as sensor now)",
749
+ "title": "LOCK CONTROL TEMPERATURE",
732
750
  "enum": [
733
751
  53
734
752
  ]
753
+ },
754
+ {
755
+ "title": "PURIFY",
756
+ "enum": [
757
+ 60
758
+ ]
759
+ },
760
+ {
761
+ "title": "ECONO COOL",
762
+ "enum": [
763
+ 61
764
+ ]
765
+ },
766
+ {
767
+ "title": "POWER FULL",
768
+ "enum": [
769
+ 62
770
+ ]
771
+ },
772
+ {
773
+ "title": "NIGHT MODE",
774
+ "enum": [
775
+ 63
776
+ ]
735
777
  }
736
778
  ],
737
779
  "required": false
@@ -833,25 +875,25 @@
833
875
  ]
834
876
  },
835
877
  {
836
- "title": "MODE PURIFY (not implemented)",
878
+ "title": "PURIFY",
837
879
  "enum": [
838
880
  6
839
881
  ]
840
882
  },
841
883
  {
842
- "title": "VANE H AUTO",
884
+ "title": "VANE H LEFT",
843
885
  "enum": [
844
886
  10
845
887
  ]
846
888
  },
847
889
  {
848
- "title": "VANE H LEFT",
890
+ "title": "VANE H LEFT MIDDLE",
849
891
  "enum": [
850
892
  11
851
893
  ]
852
894
  },
853
895
  {
854
- "title": "VANE H LEFT MIDDLE",
896
+ "title": "VANE H LEFT CENTER",
855
897
  "enum": [
856
898
  12
857
899
  ]
@@ -863,29 +905,41 @@
863
905
  ]
864
906
  },
865
907
  {
866
- "title": "VANE H RIGHT MIDDLE",
908
+ "title": "VANE H RIGHT CENTER",
867
909
  "enum": [
868
910
  14
869
911
  ]
870
912
  },
871
913
  {
872
- "title": "VANE H RIGHT",
914
+ "title": "VANE H RIGHT MIDDLE",
873
915
  "enum": [
874
916
  15
875
917
  ]
876
918
  },
877
919
  {
878
- "title": "VANE H SPLIT",
920
+ "title": "VANE H RIGHT",
879
921
  "enum": [
880
922
  16
881
923
  ]
882
924
  },
883
925
  {
884
- "title": "VANE H SWING",
926
+ "title": "VANE H SPLIT",
885
927
  "enum": [
886
928
  17
887
929
  ]
888
930
  },
931
+ {
932
+ "title": "VANE H SWING",
933
+ "enum": [
934
+ 18
935
+ ]
936
+ },
937
+ {
938
+ "title": "VANE H AIR DIRECTION",
939
+ "enum": [
940
+ 19
941
+ ]
942
+ },
889
943
  {
890
944
  "title": "VANE V AUTO",
891
945
  "enum": [
@@ -1013,97 +1067,103 @@
1013
1067
  ]
1014
1068
  },
1015
1069
  {
1016
- "title": "OPERATION STAGE NORMAL",
1070
+ "title": "OPERATION STATUS NORMAL",
1017
1071
  "enum": [
1018
1072
  70
1019
1073
  ]
1020
1074
  },
1021
1075
  {
1022
- "title": "OPERATION STAGE DEFROST",
1076
+ "title": "OPERATION STATUS FILTER",
1023
1077
  "enum": [
1024
1078
  71
1025
1079
  ]
1026
1080
  },
1027
1081
  {
1028
- "title": "OPERATION STAGE PREHEAT",
1082
+ "title": "OPERATION STATUS DEFROST",
1029
1083
  "enum": [
1030
1084
  72
1031
1085
  ]
1032
1086
  },
1033
1087
  {
1034
- "title": "OPERATION STAGE STANDBY",
1088
+ "title": "OPERATION STATUS STANDBY",
1035
1089
  "enum": [
1036
1090
  73
1037
1091
  ]
1038
1092
  },
1039
1093
  {
1040
- "title": "FAN STAGE OFF",
1094
+ "title": "OPERATION STATUS PREHEAT",
1095
+ "enum": [
1096
+ 74
1097
+ ]
1098
+ },
1099
+ {
1100
+ "title": "FAN STATUS OFF",
1041
1101
  "enum": [
1042
1102
  80
1043
1103
  ]
1044
1104
  },
1045
1105
  {
1046
- "title": "FAN STAGE QUIET",
1106
+ "title": "FAN STATUS QUIET",
1047
1107
  "enum": [
1048
1108
  81
1049
1109
  ]
1050
1110
  },
1051
1111
  {
1052
- "title": "FAN STAGE 1",
1112
+ "title": "FAN STATUS 1",
1053
1113
  "enum": [
1054
1114
  82
1055
1115
  ]
1056
1116
  },
1057
1117
  {
1058
- "title": "FAN STAGE 2",
1118
+ "title": "FAN STATUS 2",
1059
1119
  "enum": [
1060
1120
  83
1061
1121
  ]
1062
1122
  },
1063
1123
  {
1064
- "title": "FAN STAGE 3",
1124
+ "title": "FAN STATUS 3",
1065
1125
  "enum": [
1066
1126
  84
1067
1127
  ]
1068
1128
  },
1069
1129
  {
1070
- "title": "FAN STAGE 4",
1130
+ "title": "FAN STATUS 4",
1071
1131
  "enum": [
1072
1132
  85
1073
1133
  ]
1074
1134
  },
1075
1135
  {
1076
- "title": "FAN STAGE 5",
1136
+ "title": "FAN STATUS 5",
1077
1137
  "enum": [
1078
1138
  86
1079
1139
  ]
1080
1140
  },
1081
1141
  {
1082
- "title": "MODE STAGE AUTO OFF",
1142
+ "title": "MODE STATUS AUTO OFF",
1083
1143
  "enum": [
1084
1144
  90
1085
1145
  ]
1086
1146
  },
1087
1147
  {
1088
- "title": "MODE STAGE AUTO FAN",
1148
+ "title": "MODE STATUS AUTO FAN",
1089
1149
  "enum": [
1090
1150
  91
1091
1151
  ]
1092
1152
  },
1093
1153
  {
1094
- "title": "MODE STAGE AUTO HEAT",
1154
+ "title": "MODE STATUS AUTO HEAT",
1095
1155
  "enum": [
1096
1156
  92
1097
1157
  ]
1098
1158
  },
1099
1159
  {
1100
- "title": "MODE STAGE AUTO COOL",
1160
+ "title": "MODE STATUS AUTO COOL",
1101
1161
  "enum": [
1102
1162
  93
1103
1163
  ]
1104
1164
  },
1105
1165
  {
1106
- "title": "MODE STAGE AUTO LEADER",
1166
+ "title": "MODE STATUS AUTO LEADER",
1107
1167
  "enum": [
1108
1168
  94
1109
1169
  ]
package/index.js CHANGED
@@ -158,20 +158,20 @@ class tasmotaPlatform {
158
158
  });
159
159
 
160
160
  //create impulse generator
161
- const impulseGenerator = new ImpulseGenerator();
162
- impulseGenerator.on('start', async () => {
163
- try {
164
- const startDone = await deviceType.start();
165
- const stopImpulseGenerator = startDone ? await impulseGenerator.stop() : false;
166
-
167
- //start impulse generator
168
- const startImpulseGenerator = stopImpulseGenerator ? await deviceType.startImpulseGenerator() : false
169
- } catch (error) {
170
- const emitLog = disableLogError ? false : log.error(`Device: ${host} ${deviceName}, ${error}, trying again.`);
171
- }
172
- }).on('state', (state) => {
173
- const emitLog = !enableDebugMode ? false : state ? log.info(`Device: ${host} ${deviceName}, Start impulse generator started.`) : log.info(`Device: ${host} ${deviceName}, Start impulse generator stopped.`);
174
- });
161
+ const impulseGenerator = new ImpulseGenerator()
162
+ .on('start', async () => {
163
+ try {
164
+ const startDone = await deviceType.start();
165
+ const stopImpulseGenerator = startDone ? await impulseGenerator.stop() : false;
166
+
167
+ //start impulse generator
168
+ const startImpulseGenerator = stopImpulseGenerator ? await deviceType.startImpulseGenerator() : false
169
+ } catch (error) {
170
+ const emitLog = disableLogError ? false : log.error(`Device: ${host} ${deviceName}, ${error}, trying again.`);
171
+ }
172
+ }).on('state', (state) => {
173
+ const emitLog = !enableDebugMode ? false : state ? log.info(`Device: ${host} ${deviceName}, Start impulse generator started.`) : log.info(`Device: ${host} ${deviceName}, Start impulse generator stopped.`);
174
+ });
175
175
 
176
176
  //start impulse generator
177
177
  await impulseGenerator.start([{ name: 'start', sampling: 45000 }]);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "displayName": "Tasmota Control",
3
3
  "name": "homebridge-tasmota-control",
4
- "version": "1.6.15-beta.2",
4
+ "version": "1.6.15-beta.20",
5
5
  "description": "Homebridge plugin to control Tasmota flashed devices.",
6
6
  "license": "MIT",
7
7
  "author": "grzegorz914",
package/src/constants.js CHANGED
@@ -34,7 +34,6 @@ export const MiElHVAC = {
34
34
  "cool": "HVACSetMode%20cool",
35
35
  "fan": "HVACSetMode%20fan",
36
36
  "auto": "HVACSetMode%20auto",
37
- "purify": "HVACSetMode%20purify"
38
37
  },
39
38
  "SetFanSpeed": {
40
39
  "auto": "HVACSetFanSpeed%20auto",
@@ -57,17 +56,18 @@ export const MiElHVAC = {
57
56
  "SetSwingH": {
58
57
  "left": "HVACSetSwingH%20left",
59
58
  "left_middle": "HVACSetSwingH%20left_middle",
59
+ "left_center": "HVACSetSwingH%20left_center",
60
60
  "center": "HVACSetSwingH%20center",
61
+ "right_center": "HVACSetSwingH%20right_center",
61
62
  "right_middle": "HVACSetSwingH%20right_middle",
62
63
  "right": "HVACSetSwingH%20right",
63
64
  "split": "HVACSetSwingH%20split",
64
65
  "swing": "HVACSetSwingH%20swing",
65
66
  },
66
67
  "SetAirDirection": {
67
- "even": "HVACSetSwingH%20even",
68
- "indirect": "HVACSetSwingH%20indirect",
69
- "direct": "HVACSetSwingH%20direct",
70
- "off": "HVACSetSwingH%20off"
68
+ "indirect": "HVACSetAirDirection%20indirect",
69
+ "direct": "HVACSetAirDirection%20direct",
70
+ "even": "HVACSetAirDirection%20even",
71
71
  },
72
72
  "SetProhibit": {
73
73
  "off": "HVACSetProhibit%20off",
@@ -83,6 +83,18 @@ export const MiElHVAC = {
83
83
  "c": "HVACSetDisplayUnit%20c",
84
84
  "f": "HVACSetDisplayUnit%20f"
85
85
  },
86
+ "SetPurify": {
87
+ "purify": "HVACSetPurify%20on"
88
+ },
89
+ "SetEconoCool": {
90
+ "econocool": "HVACSetPurify%20on"
91
+ },
92
+ "SetPowerFull": {
93
+ "powerfull": "HVACSetPurify%20on"
94
+ },
95
+ "SetNightMode": {
96
+ "nightmode": "HVACSetPurify%20on"
97
+ },
86
98
  "RemoteTemp": "HVACRemoteTemp%20",
87
99
  "RemoteTempClearTime": "HVACRemoteTempClearTime%20",
88
100
  "OperationMode": [
@@ -107,7 +119,7 @@ export const MiElHVAC = {
107
119
  "1": "WEAK",
108
120
  "2": "NORMAL",
109
121
  "3": "STRONG",
110
- "4": "ERY STRONG",
122
+ "4": "VERY STRONG",
111
123
  "6": "OFF"
112
124
  },
113
125
  "VerticalVane": {
@@ -120,10 +132,12 @@ export const MiElHVAC = {
120
132
  "swing": "SWING"
121
133
  },
122
134
  "HorizontalVane": {
123
- "auto": "AUTO",
135
+ "airdirection": "AIR DIRECTION",
124
136
  "left_middle": "LEFT",
125
137
  "left": "LEFT MIDDLE",
138
+ "left_center": "LEFT CENTER",
126
139
  "center": "CENTER",
140
+ "right_center": "RIGHT CENTER",
127
141
  "right_middle": "RIGHT MIDDLE",
128
142
  "right": "RIGHT",
129
143
  "split": "SPLIT",
package/src/mielhvac.js CHANGED
@@ -205,24 +205,33 @@ class MiElHvac extends EventEmitter {
205
205
  const temperatureUnit = statusSns.TempUnit === 'C' ? '°C' : 'F';
206
206
 
207
207
  //mielhvac
208
- const miElHvac = statusSns.MiElHVAC ?? {};
208
+ const miElHvac = statusSns.MiElHVAC;
209
+
210
+ if (!miElHvac || Object.keys(miElHvac).length === 0) {
211
+ this.emit('warn', "Empty data received");
212
+ return null;
213
+ }
214
+
209
215
  const power = miElHvac.Power === 'on' ? 1 : 0;
210
216
  const roomTemperature = miElHvac.Temperature ?? null;
217
+ if (!roomTemperature) return null;
218
+
211
219
  const outdoorTemperature = miElHvac.OutdoorTemperature ?? null;
212
220
  const setTemperature = miElHvac.SetTemperature;
213
221
  const operationMode = miElHvac.Mode ?? 'Unknown';
214
- const operationModeStage = miElHvac.ModeStage ?? 'Unknown';
222
+ const operationModeStatus = miElHvac.ModeStatus ?? 'Unknown';
215
223
  const fanSpeed = miElHvac.FanSpeed ?? 'Unknown';
216
- const fanSpeedStage = miElHvac.FanStage ?? 'Unknown';
224
+ const fanSpeedStatus = miElHvac.FanStatus ?? 'Unknown';
217
225
  const vaneVerticalDirection = miElHvac.SwingV ?? 'Unknown';
218
226
  const vaneHorizontalDirection = miElHvac.SwingH ?? 'Unknown';
219
227
  const prohibit = miElHvac.Prohibit ?? 'Unknown';
228
+ const purify = miElHvac.Purify ?? 'Unknown';
220
229
  const airDirection = miElHvac.AirDirection ?? 'Unknown';
221
230
  const compressor = miElHvac.Compressor ?? 'Unknown';
222
231
  const compressorFrequency = miElHvac.CompressorFrequency ?? 0;
223
232
  const operationPower = miElHvac.OperationPower ?? 0;
224
233
  const operationEnergy = miElHvac.OperationEnergy ?? 0;
225
- const operationStage = miElHvac.OperationStage ?? 'Unknown';
234
+ const operationStatus = miElHvac.OperationStatus ?? 'Unknown';
226
235
  const swingMode = vaneVerticalDirection === 'swing' && vaneHorizontalDirection === 'swing' ? 1 : 0;
227
236
  const defaultCoolingSetTemperature = parseFloat(await this.readData(this.info.defaultCoolingSetTemperatureFile));
228
237
  const defaultHeatingSetTemperature = parseFloat(await this.readData(this.info.defaultHeatingSetTemperatureFile));
@@ -250,19 +259,20 @@ class MiElHvac extends EventEmitter {
250
259
  outdoorTemperature: outdoorTemperature,
251
260
  setTemperature: setTemperature,
252
261
  operationMode: operationMode,
253
- operationModeStage: operationModeStage,
262
+ operationModeStatus: operationModeStatus,
254
263
  currentOperationMode: 0,
255
264
  targetOperationMode: 0,
256
265
  vaneVerticalDirection: vaneVerticalDirection,
257
266
  vaneHorizontalDirection: vaneHorizontalDirection,
258
267
  prohibit: prohibit,
268
+ purify: purify,
259
269
  airDirection: airDirection,
260
270
  swingMode: swingMode,
261
271
  compressor: compressor,
262
272
  compressorFrequency: compressorFrequency,
263
273
  operationPower: operationPower,
264
274
  operationEnergy: operationEnergy,
265
- operationStage: operationStage,
275
+ operationStatus: operationStatus,
266
276
  defaultCoolingSetTemperature: defaultCoolingSetTemperature,
267
277
  defaultHeatingSetTemperature: defaultHeatingSetTemperature,
268
278
  remoteTemperatureSensorState: remoteTemperatureSensorState,
@@ -282,8 +292,8 @@ class MiElHvac extends EventEmitter {
282
292
  hideVaneControls: hideVaneControls
283
293
  };
284
294
 
285
- // Map stages to index safely, fallback to 0 if not found
286
- const operationModeStageMap = {
295
+ // Map status to index safely, fallback to 0 if not found
296
+ const operationModeStatusMap = {
287
297
  'manual': 0,
288
298
  'heat': 2,
289
299
  'dry': 1,
@@ -298,43 +308,43 @@ class MiElHvac extends EventEmitter {
298
308
  'auto_leader': 4
299
309
  };
300
310
 
301
- const stageIndex = operationModeStageMap[operationModeStage] ?? 0;
311
+ const statusIndex = operationModeStatusMap[operationModeStatus] ?? 0;
302
312
  switch (operationMode) {
303
313
  case 'heat':
304
- obj.currentOperationMode = [2, 1, 2, 3, 0][stageIndex]; // INACTIVE, IDLE, HEATING, COOLING
314
+ obj.currentOperationMode = [2, 1, 2, 3, 0][statusIndex]; // INACTIVE, IDLE, HEATING, COOLING
305
315
  obj.targetOperationMode = 1; // AUTO, HEAT, COOL
306
316
  break;
307
317
  case 'dry':
308
- obj.currentOperationMode = [1, 1, 2, 3, 0][stageIndex];
318
+ obj.currentOperationMode = [1, 1, 2, 3, 0][statusIndex];
309
319
  obj.targetOperationMode = this.autoDryFanMode === 2 ? 0 : this.heatDryFanMode === 2 ? 1 : this.coolDryFanMode === 2 ? 2 : obj.targetOperationMode;
310
320
  break;
311
321
  case 'cool':
312
- obj.currentOperationMode = [3, 1, 2, 3, 0][stageIndex];
322
+ obj.currentOperationMode = [3, 1, 2, 3, 0][statusIndex];
313
323
  obj.targetOperationMode = 2;
314
324
  break;
315
325
  case 'fan':
316
- obj.currentOperationMode = [1, 1, 2, 3, 0][stageIndex];
326
+ obj.currentOperationMode = [1, 1, 2, 3, 0][statusIndex];
317
327
  obj.targetOperationMode = this.autoDryFanMode === 3 ? 0 : this.heatDryFanMode === 3 ? 1 : this.coolDryFanMode === 3 ? 2 : obj.targetOperationMode;
318
328
  break;
319
329
  case 'auto':
320
- obj.currentOperationMode = [2, 1, 2, 3, 0][stageIndex];
330
+ obj.currentOperationMode = [2, 1, 2, 3, 0][statusIndex];
321
331
  obj.targetOperationMode = 0;
322
332
  break;
323
333
  case 'heat_isee':
324
- obj.currentOperationMode = [2, 1, 2, 3, 0][stageIndex];
334
+ obj.currentOperationMode = [2, 1, 2, 3, 0][statusIndex];
325
335
  obj.targetOperationMode = 1;
326
336
  break;
327
337
  case 'dry_isee':
328
- obj.currentOperationMode = [1, 1, 2, 3, 0][stageIndex];
338
+ obj.currentOperationMode = [1, 1, 2, 3, 0][statusIndex];
329
339
  obj.targetOperationMode = this.autoDryFanMode === 2 ? 0 : this.heatDryFanMode === 2 ? 1 : this.coolDryFanMode === 2 ? 2 : obj.targetOperationMode;
330
340
  break;
331
341
  case 'cool_isee':
332
- obj.currentOperationMode = [3, 1, 2, 3, 0][stageIndex];
342
+ obj.currentOperationMode = [3, 1, 2, 3, 0][statusIndex];
333
343
  obj.targetOperationMode = 2;
334
344
  break;
335
345
  default:
336
346
  this.emit('warn', `Unknown operating mode: ${operationMode}`);
337
- return;
347
+ return null;
338
348
  }
339
349
 
340
350
  // If power is off, force currentOperationMode to 0 (inactive)
@@ -347,60 +357,45 @@ class MiElHvac extends EventEmitter {
347
357
 
348
358
 
349
359
  if (modelSupportsFanSpeed) {
350
- // Map fan speed string to index
351
360
  const fanSpeedMap = {
352
361
  'auto': 0,
353
362
  'quiet': 1,
354
363
  '1': 2,
355
364
  '2': 3,
356
365
  '3': 4,
357
- '4': 5,
358
- '5': 6 // Added for completeness if needed
366
+ '4': 5
359
367
  };
360
368
 
361
- // Get mapped index, fallback to 0 if not found
362
- const fanSpeedIndex = fanSpeedMap[fanSpeed] ?? 0;
363
-
364
- // Function to generate speed arrays dynamically
365
- const generateSpeedArray = (count, hasAuto) => {
366
- // if hasAuto, first element is count+1 (offset), else 0
367
- // Then numbers 1 .. count-1 (except 0 and auto)
368
- // your original arrays always have [hasAuto ? count+1 : 0, 1, 2, ..., count-1]
369
- // So let's build that:
370
- const arr = [];
371
- if (hasAuto) {
372
- arr.push(count + 1); // e.g. 3+1=4 for 3 speeds
373
- } else {
374
- arr.push(0);
375
- }
376
- for (let i = 1; i < count; i++) {
377
- arr.push(i);
369
+ const fanIndex = fanSpeedMap[fanSpeed];
370
+ obj.fanSpeed = 0;
371
+ obj.fanSpeedSetPropsMaxValue = 0;
372
+
373
+ if (typeof fanIndex === 'number') {
374
+ switch (numberOfFanSpeeds) {
375
+ case 2:
376
+ obj.fanSpeed = hasAutomaticFanSpeed ? [3, 1, 2][fanIndex] ?? 1 : [0, 1, 2][fanIndex] ?? 1;
377
+ obj.fanSpeedSetPropsMaxValue = hasAutomaticFanSpeed ? 3 : 2;
378
+ break;
379
+ case 3:
380
+ obj.fanSpeed = hasAutomaticFanSpeed ? [4, 1, 2, 3][fanIndex] ?? 1 : [0, 1, 2, 3][fanIndex] ?? 1;
381
+ obj.fanSpeedSetPropsMaxValue = hasAutomaticFanSpeed ? 4 : 3;
382
+ break;
383
+ case 4:
384
+ obj.fanSpeed = hasAutomaticFanSpeed ? [5, 1, 2, 3, 4][fanIndex] ?? 1 : [0, 1, 2, 3, 4][fanIndex] ?? 1;
385
+ obj.fanSpeedSetPropsMaxValue = hasAutomaticFanSpeed ? 5 : 4;
386
+ break;
387
+ case 5:
388
+ obj.fanSpeed = hasAutomaticFanSpeed ? [6, 1, 2, 3, 4, 5][fanIndex] ?? 1 : [0, 1, 2, 3, 4, 5][fanIndex] ?? 1;
389
+ obj.fanSpeedSetPropsMaxValue = hasAutomaticFanSpeed ? 6 : 5;
390
+ break;
391
+ default:
392
+ this.emit('warn', `Unknown fan speeds: ${numberOfFanSpeeds}`);
378
393
  }
379
- return arr;
380
- };
381
394
 
382
- switch (numberOfFanSpeeds) {
383
- case 2:
384
- obj.fanSpeed = generateSpeedArray(3, hasAutomaticFanSpeed)[fanSpeedIndex];
385
- obj.fanSpeedSetPropsMaxValue = hasAutomaticFanSpeed ? 3 : 2;
386
- break;
387
- case 3:
388
- obj.fanSpeed = generateSpeedArray(4, hasAutomaticFanSpeed)[fanSpeedIndex];
389
- obj.fanSpeedSetPropsMaxValue = hasAutomaticFanSpeed ? 4 : 3;
390
- break;
391
- case 4:
392
- obj.fanSpeed = generateSpeedArray(5, hasAutomaticFanSpeed)[fanSpeedIndex];
393
- obj.fanSpeedSetPropsMaxValue = hasAutomaticFanSpeed ? 5 : 4;
394
- break;
395
- case 5:
396
- obj.fanSpeed = generateSpeedArray(6, hasAutomaticFanSpeed)[fanSpeedIndex];
397
- obj.fanSpeedSetPropsMaxValue = hasAutomaticFanSpeed ? 6 : 5;
398
- break;
399
- default:
400
- // Fallback for unexpected fan speed count
401
- obj.fanSpeed = 0;
402
- obj.fanSpeedSetPropsMaxValue = 0;
403
- break;
395
+ // Cap value to max
396
+ if (obj.fanSpeed > obj.fanSpeedSetPropsMaxValue) {
397
+ obj.fanSpeed = obj.fanSpeedSetPropsMaxValue;
398
+ }
404
399
  }
405
400
  }
406
401
 
@@ -482,17 +477,19 @@ class MiElHvac extends EventEmitter {
482
477
  3: () => power && ['cool', 'cool_isee'].includes(operationMode),
483
478
  4: () => power && operationMode === 'fan',
484
479
  5: () => power && operationMode === 'auto',
485
- 6: () => power && operationMode === 'purify',
486
480
  };
487
481
 
488
482
  const vaneHMap = {
489
- 11: 'left',
490
- 12: 'left_middle',
483
+ 10: 'left',
484
+ 11: 'left_middle',
485
+ 12: 'left_center',
491
486
  13: 'center',
492
- 14: 'right_middle',
493
- 15: 'right',
494
- 16: 'split',
495
- 17: 'swing',
487
+ 14: 'right_center',
488
+ 15: 'right_middle',
489
+ 16: 'right',
490
+ 17: 'split',
491
+ 18: 'swing',
492
+ 19: 'airdirection',
496
493
  };
497
494
 
498
495
  const vaneVMap = {
@@ -515,10 +512,9 @@ class MiElHvac extends EventEmitter {
515
512
  };
516
513
 
517
514
  const airDirMap = {
518
- 40: () => power && airDirection === 'indirect',
519
- 41: () => power && airDirection === 'direct',
520
- 42: () => power && airDirection === 'even',
521
- 43: () => power && !['indirect', 'direct', 'even'].includes(airDirection),
515
+ 40: 'indirect',
516
+ 41: 'direct',
517
+ 42: 'even',
522
518
  };
523
519
 
524
520
  const prohibitMap = {
@@ -528,11 +524,18 @@ class MiElHvac extends EventEmitter {
528
524
  53: 'temp',
529
525
  };
530
526
 
527
+ const stateMap = {
528
+ 60: 'on', //purify
529
+ 61: 'on', //econocool
530
+ 62: 'on', //powerfull
531
+ 63: 'on', //nightmode
532
+ };
533
+
531
534
  this.buttonsConfigured.forEach((button, index) => {
532
535
  const mode = button.mode;
533
536
  let state = false;
534
537
 
535
- if (modeMap[mode] !== undefined) {
538
+ if (modeMap[mode]) {
536
539
  state = modeMap[mode]();
537
540
  } else if (vaneHMap[mode]) {
538
541
  state = power && vaneHorizontalDirection === vaneHMap[mode];
@@ -541,9 +544,11 @@ class MiElHvac extends EventEmitter {
541
544
  } else if (fanSpeedMap[mode]) {
542
545
  state = power && fanSpeed === fanSpeedMap[mode];
543
546
  } else if (airDirMap[mode]) {
544
- state = airDirMap[mode]();
545
- } else if (prohibitMap[mode] !== undefined) {
546
- state = prohibit === prohibitMap[mode];
547
+ state = power && airDirection === airDirMap[mode];
548
+ } else if (prohibitMap[mode]) {
549
+ state = power && prohibit === prohibitMap[mode];
550
+ } else if (stateMap[mode]) {
551
+ state = power && purify === stateMap[mode];
547
552
  } else {
548
553
  this.emit('warn', `Unknown button mode: ${mode} detected`);
549
554
  }
@@ -575,15 +580,18 @@ class MiElHvac extends EventEmitter {
575
580
  3: isOneOf(operationMode, ['cool', 'cool_isee']),
576
581
  4: is(operationMode, 'fan'),
577
582
  5: is(operationMode, 'auto'),
578
- 6: is(operationMode, 'purify'),
583
+ 6: is(purify, 'on'),
579
584
 
580
- 11: is(vaneHorizontalDirection, 'left'),
581
- 12: is(vaneHorizontalDirection, 'left_middle'),
585
+ 10: is(vaneHorizontalDirection, 'left'),
586
+ 11: is(vaneHorizontalDirection, 'left_middle'),
587
+ 12: is(vaneHorizontalDirection, 'left_center'),
582
588
  13: is(vaneHorizontalDirection, 'center'),
583
- 14: is(vaneHorizontalDirection, 'right_middle'),
584
- 15: is(vaneHorizontalDirection, 'right'),
585
- 16: is(vaneHorizontalDirection, 'split'),
586
- 17: is(vaneHorizontalDirection, 'swing'),
589
+ 14: is(vaneHorizontalDirection, 'right_center'),
590
+ 15: is(vaneHorizontalDirection, 'right_middle'),
591
+ 16: is(vaneHorizontalDirection, 'right'),
592
+ 17: is(vaneHorizontalDirection, 'split'),
593
+ 18: is(vaneHorizontalDirection, 'swing'),
594
+ 19: is(vaneHorizontalDirection, 'airdirection'),
587
595
 
588
596
  20: is(vaneVerticalDirection, 'auto'),
589
597
  21: is(vaneVerticalDirection, 'up'),
@@ -605,7 +613,6 @@ class MiElHvac extends EventEmitter {
605
613
  40: is(airDirection, 'indirect'),
606
614
  41: is(airDirection, 'direct'),
607
615
  42: is(airDirection, 'even'),
608
- 43: powerOn && !['indirect', 'direct', 'even'].includes(airDirection),
609
616
 
610
617
  50: prohibit === 'all',
611
618
  51: prohibit === 'power',
@@ -614,24 +621,25 @@ class MiElHvac extends EventEmitter {
614
621
 
615
622
  60: remoteTemperatureSensorState,
616
623
 
617
- 70: operationStage === 'normal',
618
- 71: operationStage === 'defrost',
619
- 72: operationStage === 'preheat',
620
- 73: operationStage === 'standby',
624
+ 70: operationStatus === 'normal',
625
+ 71: operationStatus === 'filter',
626
+ 72: operationStatus === 'defrost',
627
+ 73: operationStatus === 'standby',
628
+ 74: operationStatus === 'preheat',
621
629
 
622
- 80: fanSpeedStage === 'off',
623
- 81: fanSpeedStage === 'quiet',
624
- 82: fanSpeedStage === '1',
625
- 83: fanSpeedStage === '2',
626
- 84: fanSpeedStage === '3',
627
- 85: fanSpeedStage === '4',
628
- 86: fanSpeedStage === '5',
630
+ 80: fanSpeedStatus === 'off',
631
+ 81: fanSpeedStatus === 'quiet',
632
+ 82: fanSpeedStatus === '1',
633
+ 83: fanSpeedStatus === '2',
634
+ 84: fanSpeedStatus === '3',
635
+ 85: fanSpeedStatus === '4',
636
+ 86: fanSpeedStatus === '5',
629
637
 
630
638
  90: operationMode !== 'auto',
631
- 91: operationModeStage === 'auto_fan',
632
- 92: operationModeStage === 'auto_heat',
633
- 93: operationModeStage === 'auto_cool',
634
- 94: operationModeStage === 'auto_leader',
639
+ 91: operationModeStatus === 'auto_fan',
640
+ 92: operationModeStatus === 'auto_heat',
641
+ 93: operationModeStatus === 'auto_cool',
642
+ 94: operationModeStatus === 'auto_leader',
635
643
  };
636
644
 
637
645
  if (mode in sensorStates) {
@@ -664,12 +672,12 @@ class MiElHvac extends EventEmitter {
664
672
  if (!this.disableLogInfo) {
665
673
  this.emit('info', `Power: ${power ? 'ON' : 'OFF'}`);
666
674
  const info = power ? this.emit('info', `Target operation mode: ${operationMode.toUpperCase()}`) : false;
667
- const info1 = power ? this.emit('info', `Current operation mode: ${operationModeStage.toUpperCase()}`) : false;
675
+ const info1 = power ? this.emit('info', `Current operation mode: ${operationModeStatus.toUpperCase()}`) : false;
668
676
  const info2 = power ? this.emit('info', `Target temperature: ${setTemperature}${temperatureUnit}`) : false;
669
677
  const info3 = power ? this.emit('info', `Current temperature: ${roomTemperature}${temperatureUnit}`) : false;
670
678
  const info4 = power && outdoorTemperature !== null ? this.emit('info', `Outdoor temperature: ${outdoorTemperature}${temperatureUnit}`) : false;
671
679
  const info5 = power && modelSupportsFanSpeed ? this.emit('info', `Target Fan speed: ${fanSpeed.toUpperCase()}`) : false;
672
- const info6 = power && modelSupportsFanSpeed ? this.emit('info', `Current Fan speed: ${fanSpeedStage.toUpperCase()}`) : false;
680
+ const info6 = power && modelSupportsFanSpeed ? this.emit('info', `Current Fan speed: ${fanSpeedStatus.toUpperCase()}`) : false;
673
681
  const info7 = power && vaneHorizontalDirection !== 'Unknown' ? this.emit('info', `Vane horizontal: ${MiElHVAC.HorizontalVane[vaneHorizontalDirection] ?? vaneHorizontalDirection}`) : false;
674
682
  const info8 = power && vaneVerticalDirection !== 'Unknown' ? this.emit('info', `Vane vertical: ${MiElHVAC.VerticalVane[vaneVerticalDirection] ?? vaneVerticalDirection}`) : false;
675
683
  const info9 = power ? this.emit('info', `Swing mode: ${MiElHVAC.SwingMode[swingMode]}`) : false;
@@ -1058,58 +1066,59 @@ class MiElHvac extends EventEmitter {
1058
1066
  0: () => state ? MiElHVAC.PowerOn : MiElHVAC.PowerOff,
1059
1067
 
1060
1068
  // Modes
1061
- 1: () => getModeCommand('heat'),
1062
- 2: () => getModeCommand('dry'),
1063
- 3: () => getModeCommand('cool'),
1064
- 4: () => getModeCommand('fan'),
1065
- 5: () => getModeCommand('auto'),
1066
- 6: () => getModeCommand('purify'),
1069
+ 1: () => getCommand('SetMode', 'heat'),
1070
+ 2: () => getCommand('SetMode', 'dry'),
1071
+ 3: () => getCommand('SetMode', 'cool'),
1072
+ 4: () => getCommand('SetMode', 'fan'),
1073
+ 5: () => getCommand('SetMode', 'auto'),
1067
1074
 
1068
1075
  // Horizontal Swing
1069
- 11: () => getSwingCommand('SetSwingH', 'left'),
1070
- 12: () => getSwingCommand('SetSwingH', 'left_middle'),
1071
- 13: () => getSwingCommand('SetSwingH', 'center'),
1072
- 14: () => getSwingCommand('SetSwingH', 'right_middle'),
1073
- 15: () => getSwingCommand('SetSwingH', 'right'),
1074
- 16: () => getSwingCommand('SetSwingH', 'split'),
1075
- 17: () => getSwingCommand('SetSwingH', 'swing'),
1076
+ 10: () => getCommand('SetSwingH', 'left'),
1077
+ 11: () => getCommand('SetSwingH', 'left_middle'),
1078
+ 12: () => getCommand('SetSwingH', 'left_center'),
1079
+ 13: () => getCommand('SetSwingH', 'center'),
1080
+ 14: () => getCommand('SetSwingH', 'right_center'),
1081
+ 15: () => getCommand('SetSwingH', 'right_middle'),
1082
+ 16: () => getCommand('SetSwingH', 'right'),
1083
+ 17: () => getCommand('SetSwingH', 'split'),
1084
+ 18: () => getCommand('SetSwingH', 'swing'),
1076
1085
 
1077
1086
  // Vertical Swing
1078
- 20: () => getSwingCommand('SetSwingV', 'auto'),
1079
- 21: () => getSwingCommand('SetSwingV', 'up'),
1080
- 22: () => getSwingCommand('SetSwingV', 'up_middle'),
1081
- 23: () => getSwingCommand('SetSwingV', 'center'),
1082
- 24: () => getSwingCommand('SetSwingV', 'down_middle'),
1083
- 25: () => getSwingCommand('SetSwingV', 'down'),
1084
- 26: () => getSwingCommand('SetSwingV', 'swing'),
1087
+ 20: () => getCommand('SetSwingV', 'auto'),
1088
+ 21: () => getCommand('SetSwingV', 'up'),
1089
+ 22: () => getCommand('SetSwingV', 'up_middle'),
1090
+ 23: () => getCommand('SetSwingV', 'center'),
1091
+ 24: () => getCommand('SetSwingV', 'down_middle'),
1092
+ 25: () => getCommand('SetSwingV', 'down'),
1093
+ 26: () => getCommand('SetSwingV', 'swing'),
1085
1094
 
1086
1095
  // Fan Speeds
1087
- 30: () => getSwingCommand('SetFanSpeed', 'auto'),
1088
- 31: () => getSwingCommand('SetFanSpeed', 'quiet'),
1089
- 32: () => getSwingCommand('SetFanSpeed', '1'),
1090
- 33: () => getSwingCommand('SetFanSpeed', '2'),
1091
- 34: () => getSwingCommand('SetFanSpeed', '3'),
1092
- 35: () => getSwingCommand('SetFanSpeed', '4'),
1096
+ 30: () => getCommand('SetFanSpeed', 'auto'),
1097
+ 31: () => getCommand('SetFanSpeed', 'quiet'),
1098
+ 32: () => getCommand('SetFanSpeed', '1'),
1099
+ 33: () => getCommand('SetFanSpeed', '2'),
1100
+ 34: () => getCommand('SetFanSpeed', '3'),
1101
+ 35: () => getCommand('SetFanSpeed', '4'),
1093
1102
 
1094
1103
  // Air Direction
1095
- 40: () => getSwingCommand('SetAirDirection', 'indirect'),
1096
- 41: () => getSwingCommand('SetAirDirection', 'direct'),
1097
- 42: () => getSwingCommand('SetAirDirection', 'even'),
1098
- 43: () => getSwingCommand('SetAirDirection', 'off'),
1104
+ 40: () => getCommand('SetAirDirection', 'indirect'),
1105
+ 41: () => getCommand('SetAirDirection', 'direct'),
1106
+ 42: () => getCommand('SetAirDirection', 'even'),
1099
1107
 
1100
1108
  // Prohibit
1101
- 50: () => getSwingCommand('SetProhibit', 'all'),
1102
- 51: () => getSwingCommand('SetProhibit', 'power'),
1103
- 52: () => getSwingCommand('SetProhibit', 'mode'),
1104
- 53: () => getSwingCommand('SetProhibit', 'temp')
1105
- };
1106
-
1107
- const getModeCommand = (target) => {
1108
- button.previousValue = state ? MiElHVAC.SetMode[this.mielHvac.operationMode] : button.previousValue;
1109
- return state ? MiElHVAC.SetMode[target] : button.previousValue;
1109
+ 50: () => getCommand('SetProhibit', 'all'),
1110
+ 51: () => getCommand('SetProhibit', 'power'),
1111
+ 52: () => getCommand('SetProhibit', 'mode'),
1112
+ 53: () => getCommand('SetProhibit', 'temp'),
1113
+
1114
+ // Purify
1115
+ 60: () => getCommand('SetPurify', 'purify'),
1116
+ 61: () => getCommand('SetEconoCool', 'econocool'),
1117
+ 62: () => getCommand('SetPowerFull', 'powerfull'),
1118
+ 63: () => getCommand('SetNightMode', 'nightmode'),
1110
1119
  };
1111
1120
 
1112
- const getSwingCommand = (type, target) => {
1121
+ const getCommand = (type, target) => {
1113
1122
  const current = this.mielHvac[getCurrentKey(type)];
1114
1123
  button.previousValue = state ? MiElHVAC[type][current] : button.previousValue;
1115
1124
  return state ? MiElHVAC[type][target] : button.previousValue;
@@ -1117,11 +1126,16 @@ class MiElHvac extends EventEmitter {
1117
1126
 
1118
1127
  const getCurrentKey = (type) => {
1119
1128
  switch (type) {
1129
+ case 'SetMode': return 'operationMode';
1120
1130
  case 'SetSwingH': return 'vaneHorizontalDirection';
1121
1131
  case 'SetSwingV': return 'vaneVerticalDirection';
1122
1132
  case 'SetFanSpeed': return 'fanSpeed';
1123
1133
  case 'SetAirDirection': return 'airDirection';
1124
1134
  case 'SetProhibit': return 'prohibit';
1135
+ case 'SetPurify': return 'purify';
1136
+ case 'SetEconoCool': return 'econoCool';
1137
+ case 'SetPowerFull': return 'powerFull';
1138
+ case 'SetNightMode': return 'nightMode';
1125
1139
  default: return '';
1126
1140
  }
1127
1141
  };
@@ -1132,7 +1146,7 @@ class MiElHvac extends EventEmitter {
1132
1146
  }
1133
1147
 
1134
1148
  data = mappings[mode]();
1135
- if (!this.mielHvac.power && state && mode > 0 && mode < 50) {
1149
+ if (!this.mielHvac.power && state && mode > 0 && mode <= 63) {
1136
1150
  await this.axiosInstance(MiElHVAC.PowerOn);
1137
1151
  }
1138
1152
 
@@ -1231,7 +1245,8 @@ class MiElHvac extends EventEmitter {
1231
1245
  async start() {
1232
1246
  try {
1233
1247
  //check device state
1234
- await this.checkDeviceState();
1248
+ const checkState = await this.checkDeviceState();
1249
+ if (!checkState) return null;
1235
1250
 
1236
1251
  //connect to deice success
1237
1252
  this.emit('success', `Connect Success`)