homebridge-midea-platform 1.2.0-beta.2 → 1.2.0-beta.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.
- package/.husky/pre-commit +0 -0
- package/AC_ori.lua +5140 -0
- package/config.schema.json +14 -2
- package/dist/accessory/AccessoryFactory.d.ts +13 -12
- package/dist/accessory/AccessoryFactory.d.ts.map +1 -1
- package/dist/accessory/AccessoryFactory.js +37 -31
- package/dist/accessory/AccessoryFactory.js.map +1 -1
- package/dist/accessory/AirConditionerAccessory.d.ts +98 -92
- package/dist/accessory/AirConditionerAccessory.d.ts.map +1 -1
- package/dist/accessory/AirConditionerAccessory.js +662 -607
- package/dist/accessory/AirConditionerAccessory.js.map +1 -1
- package/dist/accessory/BaseAccessory.d.ts +11 -11
- package/dist/accessory/BaseAccessory.js +21 -21
- package/dist/accessory/DehumidifierAccessory.d.ts +45 -45
- package/dist/accessory/DehumidifierAccessory.js +344 -344
- package/dist/accessory/DishwasherAccessory.d.ts +30 -30
- package/dist/accessory/DishwasherAccessory.js +63 -63
- package/dist/accessory/ElectricWaterHeaterAccessory.d.ts +44 -44
- package/dist/accessory/ElectricWaterHeaterAccessory.js +176 -176
- package/dist/accessory/FanAccessory.d.ts +39 -39
- package/dist/accessory/FanAccessory.js +123 -123
- package/dist/accessory/FrontLoadWasherAccessory.d.ts +30 -30
- package/dist/accessory/FrontLoadWasherAccessory.js +66 -66
- package/dist/accessory/GasWaterHeaterAccessory.d.ts +51 -51
- package/dist/accessory/GasWaterHeaterAccessory.js +216 -216
- package/dist/core/MideaCloud.d.ts +35 -35
- package/dist/core/MideaCloud.js +350 -350
- package/dist/core/MideaConstants.d.ts +50 -50
- package/dist/core/MideaConstants.js +58 -58
- package/dist/core/MideaDevice.d.ts +76 -76
- package/dist/core/MideaDevice.js +409 -409
- package/dist/core/MideaDiscover.d.ts +35 -35
- package/dist/core/MideaDiscover.js +212 -212
- package/dist/core/MideaMessage.d.ts +75 -75
- package/dist/core/MideaMessage.js +184 -184
- package/dist/core/MideaPacketBuilder.d.ts +10 -10
- package/dist/core/MideaPacketBuilder.js +60 -60
- package/dist/core/MideaSecurity.d.ts +63 -63
- package/dist/core/MideaSecurity.js +251 -251
- package/dist/core/MideaUtils.d.ts +32 -32
- package/dist/core/MideaUtils.js +181 -181
- package/dist/devices/DeviceFactory.d.ts +13 -13
- package/dist/devices/DeviceFactory.d.ts.map +1 -1
- package/dist/devices/DeviceFactory.js +37 -36
- package/dist/devices/DeviceFactory.js.map +1 -1
- package/dist/devices/a1/MideaA1Device.d.ts +76 -76
- package/dist/devices/a1/MideaA1Device.js +145 -145
- package/dist/devices/a1/MideaA1Message.d.ts +40 -40
- package/dist/devices/a1/MideaA1Message.js +198 -198
- package/dist/devices/ac/MideaACDevice.d.ts +106 -104
- package/dist/devices/ac/MideaACDevice.d.ts.map +1 -1
- package/dist/devices/ac/MideaACDevice.js +400 -384
- package/dist/devices/ac/MideaACDevice.js.map +1 -1
- package/dist/devices/ac/MideaACMessage.d.ts +95 -94
- package/dist/devices/ac/MideaACMessage.d.ts.map +1 -1
- package/dist/devices/ac/MideaACMessage.js +619 -611
- package/dist/devices/ac/MideaACMessage.js.map +1 -1
- package/dist/devices/db/MideaDBDevice.d.ts +29 -29
- package/dist/devices/db/MideaDBDevice.js +100 -100
- package/dist/devices/db/MideaDBMessage.d.ts +32 -32
- package/dist/devices/db/MideaDBMessage.js +101 -101
- package/dist/devices/e1/MideaE1Device.d.ts +56 -56
- package/dist/devices/e1/MideaE1Device.js +128 -128
- package/dist/devices/e1/MideaE1Message.d.ts +28 -28
- package/dist/devices/e1/MideaE1Message.js +107 -107
- package/dist/devices/e2/MideaE2Device.d.ts +44 -44
- package/dist/devices/e2/MideaE2Device.js +129 -129
- package/dist/devices/e2/MideaE2Message.d.ts +33 -33
- package/dist/devices/e2/MideaE2Message.js +132 -132
- package/dist/devices/e3/MideaE3Device.d.ts +43 -43
- package/dist/devices/e3/MideaE3Device.js +137 -137
- package/dist/devices/e3/MideaE3Message.d.ts +51 -51
- package/dist/devices/e3/MideaE3Message.js +136 -136
- package/dist/devices/fa/MideaFADevice.d.ts +36 -36
- package/dist/devices/fa/MideaFADevice.js +106 -106
- package/dist/devices/fa/MideaFAMessage.d.ts +38 -38
- package/dist/devices/fa/MideaFAMessage.js +98 -98
- package/dist/index.d.ts +6 -6
- package/dist/index.js +6 -6
- package/dist/platform.d.ts +60 -60
- package/dist/platform.js +212 -212
- package/dist/platformUtils.d.ts +108 -106
- package/dist/platformUtils.d.ts.map +1 -1
- package/dist/platformUtils.js +103 -101
- package/dist/platformUtils.js.map +1 -1
- package/dist/settings.d.ts +8 -8
- package/dist/settings.js +11 -11
- package/docs/ac.md +6 -0
- package/package.json +1 -1
|
@@ -1,385 +1,401 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const MideaDevice_1 = __importDefault(require("../../core/MideaDevice"));
|
|
7
|
-
const MideaACMessage_1 = require("./MideaACMessage");
|
|
8
|
-
const platformUtils_1 = require("../../platformUtils");
|
|
9
|
-
class MideaACDevice extends MideaDevice_1.default {
|
|
10
|
-
/*********************************************************************
|
|
11
|
-
* Constructor initializes all the attributes. We set some to invalid
|
|
12
|
-
* values so that they are detected as "changed" on the first status
|
|
13
|
-
* refresh... and passed back to the Homebridge/HomeKit accessory callback
|
|
14
|
-
* function to set their initial values.
|
|
15
|
-
*/
|
|
16
|
-
constructor(logger, device_info, config, deviceConfig) {
|
|
17
|
-
super(logger, device_info, config, deviceConfig);
|
|
18
|
-
this.FRESH_AIR_FAN_SPEEDS = {
|
|
19
|
-
0: 'Off',
|
|
20
|
-
20: 'Silent',
|
|
21
|
-
40: 'Low',
|
|
22
|
-
60: 'Medium',
|
|
23
|
-
80: 'High',
|
|
24
|
-
100: 'Full',
|
|
25
|
-
};
|
|
26
|
-
this.FRESH_AIR_FAN_SPEEDS_REVERSE = {
|
|
27
|
-
100: 'Full',
|
|
28
|
-
80: 'High',
|
|
29
|
-
60: 'Medium',
|
|
30
|
-
40: 'Low',
|
|
31
|
-
20: 'Silent',
|
|
32
|
-
0: 'Off',
|
|
33
|
-
};
|
|
34
|
-
this.used_subprotocol = false;
|
|
35
|
-
this.bb_sn8_flag = false;
|
|
36
|
-
this.bb_timer = false;
|
|
37
|
-
this.DEFAULT_POWER_ANALYSIS_METHOD = 2;
|
|
38
|
-
this.alternate_switch_display = false;
|
|
39
|
-
this.last_fan_speed = 0;
|
|
40
|
-
this.attributes = {
|
|
41
|
-
PROMPT_TONE: false,
|
|
42
|
-
POWER: undefined,
|
|
43
|
-
MODE: 0,
|
|
44
|
-
TARGET_TEMPERATURE: 0,
|
|
45
|
-
FAN_SPEED: 0,
|
|
46
|
-
FAN_AUTO: false,
|
|
47
|
-
SWING_VERTICAL: undefined,
|
|
48
|
-
WIND_SWING_UD_ANGLE: 0,
|
|
49
|
-
SWING_HORIZONTAL: undefined,
|
|
50
|
-
WIND_SWING_LR_ANGLE: 0,
|
|
51
|
-
SMART_EYE: false,
|
|
52
|
-
DRY: false,
|
|
53
|
-
AUX_HEATING: false,
|
|
54
|
-
BOOST_MODE: false,
|
|
55
|
-
SLEEP_MODE: false,
|
|
56
|
-
FROST_PROTECT: false,
|
|
57
|
-
COMFORT_MODE: false,
|
|
58
|
-
ECO_MODE: false,
|
|
59
|
-
NATURAL_WIND: false,
|
|
60
|
-
TEMP_FAHRENHEIT: false,
|
|
61
|
-
SCREEN_DISPLAY: undefined,
|
|
62
|
-
SCREEN_DISPLAY_NEW: false,
|
|
63
|
-
FULL_DUST: false,
|
|
64
|
-
INDOOR_TEMPERATURE: undefined,
|
|
65
|
-
OUTDOOR_TEMPERATURE: undefined,
|
|
66
|
-
INDIRECT_WIND: false,
|
|
67
|
-
INDOOR_HUMIDITY: undefined,
|
|
68
|
-
BREEZELESS: false,
|
|
69
|
-
TOTAL_ENERGY_CONSUMPTION: undefined,
|
|
70
|
-
CURRENT_ENERGY_CONSUMPTION: undefined,
|
|
71
|
-
REALTIME_POWER: 0,
|
|
72
|
-
FRESH_AIR_POWER: false,
|
|
73
|
-
FRESH_AIR_FAN_SPEED: 0,
|
|
74
|
-
FRESH_AIR_MODE: undefined,
|
|
75
|
-
FRESH_AIR_1: false,
|
|
76
|
-
FRESH_AIR_2: false,
|
|
77
|
-
SELF_CLEAN: undefined,
|
|
78
|
-
RATE_SELECT: undefined,
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
this.
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
new MideaACMessage_1.MessageSubProtocolQuery(this.device_protocol_version,
|
|
88
|
-
new MideaACMessage_1.MessageSubProtocolQuery(this.device_protocol_version,
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
new MideaACMessage_1.
|
|
94
|
-
new MideaACMessage_1.
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
//
|
|
119
|
-
//
|
|
120
|
-
|
|
121
|
-
changed[status]
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
//
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
message
|
|
169
|
-
message.
|
|
170
|
-
message.
|
|
171
|
-
message.
|
|
172
|
-
message.
|
|
173
|
-
message.
|
|
174
|
-
message.
|
|
175
|
-
message.
|
|
176
|
-
message.
|
|
177
|
-
message.
|
|
178
|
-
message.
|
|
179
|
-
message.
|
|
180
|
-
message.
|
|
181
|
-
message.
|
|
182
|
-
message.
|
|
183
|
-
message.
|
|
184
|
-
message.
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
message
|
|
190
|
-
message.
|
|
191
|
-
message.
|
|
192
|
-
message.
|
|
193
|
-
message.
|
|
194
|
-
message.
|
|
195
|
-
message.
|
|
196
|
-
message.
|
|
197
|
-
message.
|
|
198
|
-
message.
|
|
199
|
-
message.
|
|
200
|
-
message.
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
'
|
|
219
|
-
'
|
|
220
|
-
'
|
|
221
|
-
'
|
|
222
|
-
'
|
|
223
|
-
'
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
this.
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
if (this.
|
|
237
|
-
|
|
238
|
-
messageToSend.NEW_PROTOCOL.
|
|
239
|
-
messageToSend.NEW_PROTOCOL.
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
messageToSend.NEW_PROTOCOL
|
|
248
|
-
messageToSend.NEW_PROTOCOL.
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
messageToSend.NEW_PROTOCOL
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
const
|
|
258
|
-
|
|
259
|
-
messageToSend.NEW_PROTOCOL
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
messageToSend.NEW_PROTOCOL
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
const
|
|
269
|
-
|
|
270
|
-
messageToSend.NEW_PROTOCOL
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
messageToSend.GENERAL
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
messageToSend.GENERAL.
|
|
278
|
-
messageToSend.GENERAL.
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
messageToSend.GENERAL.
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
message
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
message.
|
|
317
|
-
|
|
318
|
-
this.attributes.
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
message
|
|
326
|
-
message.
|
|
327
|
-
|
|
328
|
-
this.attributes.
|
|
329
|
-
this.attributes.
|
|
330
|
-
this.attributes.
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
this.attributes.
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
this.attributes.
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
message
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const MideaDevice_1 = __importDefault(require("../../core/MideaDevice"));
|
|
7
|
+
const MideaACMessage_1 = require("./MideaACMessage");
|
|
8
|
+
const platformUtils_1 = require("../../platformUtils");
|
|
9
|
+
class MideaACDevice extends MideaDevice_1.default {
|
|
10
|
+
/*********************************************************************
|
|
11
|
+
* Constructor initializes all the attributes. We set some to invalid
|
|
12
|
+
* values so that they are detected as "changed" on the first status
|
|
13
|
+
* refresh... and passed back to the Homebridge/HomeKit accessory callback
|
|
14
|
+
* function to set their initial values.
|
|
15
|
+
*/
|
|
16
|
+
constructor(logger, device_info, config, deviceConfig) {
|
|
17
|
+
super(logger, device_info, config, deviceConfig);
|
|
18
|
+
this.FRESH_AIR_FAN_SPEEDS = {
|
|
19
|
+
0: 'Off',
|
|
20
|
+
20: 'Silent',
|
|
21
|
+
40: 'Low',
|
|
22
|
+
60: 'Medium',
|
|
23
|
+
80: 'High',
|
|
24
|
+
100: 'Full',
|
|
25
|
+
};
|
|
26
|
+
this.FRESH_AIR_FAN_SPEEDS_REVERSE = {
|
|
27
|
+
100: 'Full',
|
|
28
|
+
80: 'High',
|
|
29
|
+
60: 'Medium',
|
|
30
|
+
40: 'Low',
|
|
31
|
+
20: 'Silent',
|
|
32
|
+
0: 'Off',
|
|
33
|
+
};
|
|
34
|
+
this.used_subprotocol = false;
|
|
35
|
+
this.bb_sn8_flag = false;
|
|
36
|
+
this.bb_timer = false;
|
|
37
|
+
this.DEFAULT_POWER_ANALYSIS_METHOD = 2;
|
|
38
|
+
this.alternate_switch_display = false;
|
|
39
|
+
this.last_fan_speed = 0;
|
|
40
|
+
this.attributes = {
|
|
41
|
+
PROMPT_TONE: false,
|
|
42
|
+
POWER: undefined,
|
|
43
|
+
MODE: 0,
|
|
44
|
+
TARGET_TEMPERATURE: 0,
|
|
45
|
+
FAN_SPEED: 0,
|
|
46
|
+
FAN_AUTO: false,
|
|
47
|
+
SWING_VERTICAL: undefined,
|
|
48
|
+
WIND_SWING_UD_ANGLE: 0,
|
|
49
|
+
SWING_HORIZONTAL: undefined,
|
|
50
|
+
WIND_SWING_LR_ANGLE: 0,
|
|
51
|
+
SMART_EYE: false,
|
|
52
|
+
DRY: false,
|
|
53
|
+
AUX_HEATING: false,
|
|
54
|
+
BOOST_MODE: false,
|
|
55
|
+
SLEEP_MODE: false,
|
|
56
|
+
FROST_PROTECT: false,
|
|
57
|
+
COMFORT_MODE: false,
|
|
58
|
+
ECO_MODE: false,
|
|
59
|
+
NATURAL_WIND: false,
|
|
60
|
+
TEMP_FAHRENHEIT: false,
|
|
61
|
+
SCREEN_DISPLAY: undefined,
|
|
62
|
+
SCREEN_DISPLAY_NEW: false,
|
|
63
|
+
FULL_DUST: false,
|
|
64
|
+
INDOOR_TEMPERATURE: undefined,
|
|
65
|
+
OUTDOOR_TEMPERATURE: undefined,
|
|
66
|
+
INDIRECT_WIND: false,
|
|
67
|
+
INDOOR_HUMIDITY: undefined,
|
|
68
|
+
BREEZELESS: false,
|
|
69
|
+
TOTAL_ENERGY_CONSUMPTION: undefined,
|
|
70
|
+
CURRENT_ENERGY_CONSUMPTION: undefined,
|
|
71
|
+
REALTIME_POWER: 0,
|
|
72
|
+
FRESH_AIR_POWER: false,
|
|
73
|
+
FRESH_AIR_FAN_SPEED: 0,
|
|
74
|
+
FRESH_AIR_MODE: undefined,
|
|
75
|
+
FRESH_AIR_1: false,
|
|
76
|
+
FRESH_AIR_2: false,
|
|
77
|
+
SELF_CLEAN: undefined,
|
|
78
|
+
RATE_SELECT: undefined,
|
|
79
|
+
ION: undefined,
|
|
80
|
+
};
|
|
81
|
+
this.defaultFahrenheit = deviceConfig.AC_options.fahrenheit;
|
|
82
|
+
this.defaultScreenOff = deviceConfig.AC_options.screenOff;
|
|
83
|
+
}
|
|
84
|
+
build_query() {
|
|
85
|
+
if (this.used_subprotocol) {
|
|
86
|
+
return [
|
|
87
|
+
new MideaACMessage_1.MessageSubProtocolQuery(this.device_protocol_version, 0x10),
|
|
88
|
+
new MideaACMessage_1.MessageSubProtocolQuery(this.device_protocol_version, 0x11),
|
|
89
|
+
new MideaACMessage_1.MessageSubProtocolQuery(this.device_protocol_version, 0x30),
|
|
90
|
+
];
|
|
91
|
+
}
|
|
92
|
+
return [
|
|
93
|
+
new MideaACMessage_1.MessageQuery(this.device_protocol_version),
|
|
94
|
+
new MideaACMessage_1.MessageNewProtocolQuery(this.device_protocol_version, this.alternate_switch_display),
|
|
95
|
+
new MideaACMessage_1.MessagePowerQuery(this.device_protocol_version),
|
|
96
|
+
];
|
|
97
|
+
}
|
|
98
|
+
process_message(msg) {
|
|
99
|
+
const message = new MideaACMessage_1.MessageACResponse(msg, this.power_analysis_method);
|
|
100
|
+
if (this.verbose) {
|
|
101
|
+
this.logger.debug(`[${this.name}] Body:\n${JSON.stringify(message.body)}`);
|
|
102
|
+
}
|
|
103
|
+
const changed = {};
|
|
104
|
+
let has_fresh_air = false;
|
|
105
|
+
if (message.used_subprotocol) {
|
|
106
|
+
this.used_subprotocol = true;
|
|
107
|
+
if (message.get_body_attribute('sn8_flag')) {
|
|
108
|
+
this.bb_sn8_flag = message.get_body_attribute('sn8_flag');
|
|
109
|
+
}
|
|
110
|
+
if (message.get_body_attribute('timer')) {
|
|
111
|
+
this.bb_timer = message.get_body_attribute('timer');
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
for (const status of Object.keys(this.attributes)) {
|
|
115
|
+
const value = message.get_body_attribute(status.toLowerCase());
|
|
116
|
+
if (value !== undefined) {
|
|
117
|
+
if (this.attributes[status] !== value) {
|
|
118
|
+
// Track only those attributes that change value. So when we send to the Homebridge /
|
|
119
|
+
// HomeKit accessory we only update values that change. First time through this
|
|
120
|
+
// should be most/all attributes having initialized them to invalid values.
|
|
121
|
+
this.logger.debug(`[${this.name}] Value for ${status} changed from '${this.attributes[status]}' to '${value}'`);
|
|
122
|
+
changed[status] = value;
|
|
123
|
+
}
|
|
124
|
+
this.attributes[status] = value;
|
|
125
|
+
if (status === 'FRESH_AIR_POWER') {
|
|
126
|
+
has_fresh_air = true;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
// Following attributes do not have equivalents in Homebridge / Homekit accessory so
|
|
131
|
+
// there is no need to track whether anything has changed.
|
|
132
|
+
if (has_fresh_air) {
|
|
133
|
+
if (this.attributes.FRESH_AIR_POWER) {
|
|
134
|
+
for (const [k, v] of Object.entries(this.FRESH_AIR_FAN_SPEEDS_REVERSE)) {
|
|
135
|
+
if (this.attributes.FRESH_AIR_FAN_SPEED > Number.parseInt(k)) {
|
|
136
|
+
break;
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
this.attributes.FRESH_AIR_MODE = v;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
this.attributes.FRESH_AIR_MODE = 'Off';
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
if (!this.attributes.POWER || this.attributes.SWING_VERTICAL) {
|
|
148
|
+
this.attributes.INDIRECT_WIND = false;
|
|
149
|
+
}
|
|
150
|
+
if (!this.attributes.POWER) {
|
|
151
|
+
this.attributes.SCREEN_DISPLAY = false;
|
|
152
|
+
}
|
|
153
|
+
if (this.attributes.FRESH_AIR_1) {
|
|
154
|
+
this.fresh_air_version = 1;
|
|
155
|
+
}
|
|
156
|
+
else if (this.attributes.FRESH_AIR_2) {
|
|
157
|
+
this.fresh_air_version = 2;
|
|
158
|
+
}
|
|
159
|
+
// Now we update Homebridge / Homekit accessory
|
|
160
|
+
if (Object.keys(changed).length > 0) {
|
|
161
|
+
this.update(changed);
|
|
162
|
+
}
|
|
163
|
+
else {
|
|
164
|
+
this.logger.debug(`[${this.name}] Status unchanged`);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
make_message_set() {
|
|
168
|
+
const message = new MideaACMessage_1.MessageGeneralSet(this.device_protocol_version);
|
|
169
|
+
message.power = !!this.attributes.POWER; // force to boolean
|
|
170
|
+
message.prompt_tone = this.attributes.PROMPT_TONE;
|
|
171
|
+
message.mode = this.attributes.MODE;
|
|
172
|
+
message.target_temperature = this.attributes.TARGET_TEMPERATURE;
|
|
173
|
+
message.fan_speed = this.attributes.FAN_SPEED;
|
|
174
|
+
message.swing_vertical = !!this.attributes.SWING_VERTICAL; // force to boolean
|
|
175
|
+
message.swing_horizontal = !!this.attributes.SWING_HORIZONTAL; // force to boolean
|
|
176
|
+
message.boost_mode = this.attributes.BOOST_MODE;
|
|
177
|
+
message.smart_eye = this.attributes.SMART_EYE;
|
|
178
|
+
message.dry = this.attributes.DRY;
|
|
179
|
+
message.eco_mode = this.attributes.ECO_MODE;
|
|
180
|
+
message.aux_heating = this.attributes.AUX_HEATING;
|
|
181
|
+
message.sleep_mode = this.attributes.SLEEP_MODE;
|
|
182
|
+
message.frost_protect = this.attributes.FROST_PROTECT;
|
|
183
|
+
message.comfort_mode = this.attributes.COMFORT_MODE;
|
|
184
|
+
message.natural_wind = this.attributes.NATURAL_WIND;
|
|
185
|
+
message.temp_fahrenheit = this.attributes.TEMP_FAHRENHEIT;
|
|
186
|
+
return message;
|
|
187
|
+
}
|
|
188
|
+
make_subprotocol_message_set() {
|
|
189
|
+
const message = new MideaACMessage_1.MessageSubProtocolSet(this.device_protocol_version);
|
|
190
|
+
message.power = !!this.attributes.POWER; // force to boolean
|
|
191
|
+
message.prompt_tone = this.attributes.PROMPT_TONE;
|
|
192
|
+
message.aux_heating = this.attributes.AUX_HEATING;
|
|
193
|
+
message.mode = this.attributes.MODE;
|
|
194
|
+
message.target_temperature = this.attributes.TARGET_TEMPERATURE;
|
|
195
|
+
message.fan_speed = this.attributes.FAN_SPEED;
|
|
196
|
+
message.boost_mode = this.attributes.BOOST_MODE;
|
|
197
|
+
message.dry = this.attributes.DRY;
|
|
198
|
+
message.eco_mode = this.attributes.ECO_MODE;
|
|
199
|
+
message.sleep_mode = this.attributes.SLEEP_MODE;
|
|
200
|
+
message.sn8_flag = this.bb_sn8_flag;
|
|
201
|
+
message.timer = this.bb_timer;
|
|
202
|
+
return message;
|
|
203
|
+
}
|
|
204
|
+
make_message_unique_set() {
|
|
205
|
+
return this.used_subprotocol ? this.make_subprotocol_message_set() : this.make_message_set();
|
|
206
|
+
}
|
|
207
|
+
async set_attribute(attributes) {
|
|
208
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
209
|
+
const messageToSend = {
|
|
210
|
+
GENERAL: undefined,
|
|
211
|
+
NEW_PROTOCOL: undefined,
|
|
212
|
+
SWITCH_DISPLAY: undefined,
|
|
213
|
+
};
|
|
214
|
+
try {
|
|
215
|
+
for (const [k, v] of Object.entries(attributes)) {
|
|
216
|
+
// not sensor data
|
|
217
|
+
if (![
|
|
218
|
+
'INDOOR_TEMPERATURE',
|
|
219
|
+
'OUTDOOR_TEMPERATURE',
|
|
220
|
+
'INDOOR_HUMIDITY',
|
|
221
|
+
'FULL_DUST',
|
|
222
|
+
'TOTAL_ENERGY_CONSUMPTION',
|
|
223
|
+
'CURRENT_ENERGY_CONSUMPTION',
|
|
224
|
+
'REALTIME_POWER',
|
|
225
|
+
].includes(k)) {
|
|
226
|
+
if (v === this.attributes[k]) {
|
|
227
|
+
this.logger.info(`[${this.name}] Attribute ${k} already set to ${v}`);
|
|
228
|
+
continue;
|
|
229
|
+
}
|
|
230
|
+
this.logger.info(`[${this.name}] Set device attribute ${k} to: ${v}`);
|
|
231
|
+
this.attributes[k] = v;
|
|
232
|
+
if (k === 'PROMPT_TONE') {
|
|
233
|
+
this.attributes.PROMPT_TONE = !!v;
|
|
234
|
+
}
|
|
235
|
+
else if (k === 'SCREEN_DISPLAY') {
|
|
236
|
+
// if (this.attributes.SCREEN_DISPLAY_NEW)
|
|
237
|
+
if (this.alternate_switch_display) {
|
|
238
|
+
(_a = messageToSend.NEW_PROTOCOL) !== null && _a !== void 0 ? _a : (messageToSend.NEW_PROTOCOL = new MideaACMessage_1.MessageNewProtocolSet(this.device_protocol_version));
|
|
239
|
+
messageToSend.NEW_PROTOCOL.screen_display = !!v;
|
|
240
|
+
messageToSend.NEW_PROTOCOL.prompt_tone = this.attributes.PROMPT_TONE;
|
|
241
|
+
}
|
|
242
|
+
else {
|
|
243
|
+
(_b = messageToSend.SWITCH_DISPLAY) !== null && _b !== void 0 ? _b : (messageToSend.SWITCH_DISPLAY = new MideaACMessage_1.MessageSwitchDisplay(this.device_protocol_version));
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
else if (['INDIRECT_WIND', 'BREEZELESS'].includes(k)) {
|
|
247
|
+
(_c = messageToSend.NEW_PROTOCOL) !== null && _c !== void 0 ? _c : (messageToSend.NEW_PROTOCOL = new MideaACMessage_1.MessageNewProtocolSet(this.device_protocol_version));
|
|
248
|
+
messageToSend.NEW_PROTOCOL[k.toLowerCase()] = !!v;
|
|
249
|
+
messageToSend.NEW_PROTOCOL.prompt_tone = this.attributes.PROMPT_TONE;
|
|
250
|
+
}
|
|
251
|
+
else if (k === 'FRESH_AIR_POWER' && this.fresh_air_version !== undefined) {
|
|
252
|
+
(_d = messageToSend.NEW_PROTOCOL) !== null && _d !== void 0 ? _d : (messageToSend.NEW_PROTOCOL = new MideaACMessage_1.MessageNewProtocolSet(this.device_protocol_version));
|
|
253
|
+
messageToSend.NEW_PROTOCOL[this.fresh_air_version] = [!!v, this.attributes.FRESH_AIR_FAN_SPEED];
|
|
254
|
+
}
|
|
255
|
+
else if (k === 'FRESH_AIR_MODE' && this.fresh_air_version !== undefined) {
|
|
256
|
+
if (Object.values(this.FRESH_AIR_FAN_SPEEDS).includes(v)) {
|
|
257
|
+
const speed = Number.parseInt(Object.keys(this.FRESH_AIR_FAN_SPEEDS).find((key) => this.FRESH_AIR_FAN_SPEEDS[key] === v));
|
|
258
|
+
const fresh_air = speed > 0 ? [true, speed] : [false, this.attributes.FRESH_AIR_FAN_SPEED];
|
|
259
|
+
(_e = messageToSend.NEW_PROTOCOL) !== null && _e !== void 0 ? _e : (messageToSend.NEW_PROTOCOL = new MideaACMessage_1.MessageNewProtocolSet(this.device_protocol_version));
|
|
260
|
+
messageToSend.NEW_PROTOCOL[this.fresh_air_version] = fresh_air;
|
|
261
|
+
}
|
|
262
|
+
else if (!v) {
|
|
263
|
+
(_f = messageToSend.NEW_PROTOCOL) !== null && _f !== void 0 ? _f : (messageToSend.NEW_PROTOCOL = new MideaACMessage_1.MessageNewProtocolSet(this.device_protocol_version));
|
|
264
|
+
messageToSend.NEW_PROTOCOL[this.fresh_air_version] = [false, this.attributes.FRESH_AIR_FAN_SPEED];
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
else if (k === 'FRESH_AIR_FAN_SPEED' && this.fresh_air_version !== undefined) {
|
|
268
|
+
const value = v;
|
|
269
|
+
const fresh_air = value > 0 ? [true, value] : [false, this.attributes.FRESH_AIR_FAN_SPEED];
|
|
270
|
+
(_g = messageToSend.NEW_PROTOCOL) !== null && _g !== void 0 ? _g : (messageToSend.NEW_PROTOCOL = new MideaACMessage_1.MessageNewProtocolSet(this.device_protocol_version));
|
|
271
|
+
messageToSend.NEW_PROTOCOL[this.fresh_air_version] = fresh_air;
|
|
272
|
+
}
|
|
273
|
+
else {
|
|
274
|
+
(_h = messageToSend.GENERAL) !== null && _h !== void 0 ? _h : (messageToSend.GENERAL = this.make_message_unique_set());
|
|
275
|
+
messageToSend.GENERAL[k.toLowerCase()] = v;
|
|
276
|
+
if (['BOOST_MODE', 'SLEEP_MODE', 'FROST_PROTECT', 'COMFORT_MODE', 'ECO_MODE'].includes(k)) {
|
|
277
|
+
messageToSend.GENERAL.sleep_mode = false;
|
|
278
|
+
messageToSend.GENERAL.boost_mode = false;
|
|
279
|
+
messageToSend.GENERAL.eco_mode = false;
|
|
280
|
+
if (messageToSend.GENERAL instanceof MideaACMessage_1.MessageGeneralSet) {
|
|
281
|
+
messageToSend.GENERAL.frost_protect = false;
|
|
282
|
+
messageToSend.GENERAL.comfort_mode = false;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
if (k === 'POWER' && v === true && messageToSend.GENERAL instanceof MideaACMessage_1.MessageGeneralSet) {
|
|
286
|
+
messageToSend.GENERAL.temp_fahrenheit = this.defaultFahrenheit;
|
|
287
|
+
this.attributes.TEMP_FAHRENHEIT = this.defaultFahrenheit;
|
|
288
|
+
if (this.defaultScreenOff) {
|
|
289
|
+
(_j = messageToSend.SWITCH_DISPLAY) !== null && _j !== void 0 ? _j : (messageToSend.SWITCH_DISPLAY = new MideaACMessage_1.MessageSwitchDisplay(this.device_protocol_version));
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
for (const [k, v] of Object.entries(messageToSend)) {
|
|
296
|
+
if (v !== undefined) {
|
|
297
|
+
this.logger.debug(`[${this.name}] Set message ${k}:\n${JSON.stringify(v)}`);
|
|
298
|
+
await this.build_send(v);
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
catch (err) {
|
|
303
|
+
const msg = err instanceof Error ? err.stack : err;
|
|
304
|
+
this.logger.debug(`[${this.name}] Error in set_attribute (${this.ip}:${this.port}):\n${msg}`);
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
set_alternate_switch_display(value) {
|
|
308
|
+
this.alternate_switch_display = value;
|
|
309
|
+
}
|
|
310
|
+
async set_target_temperature(target_temperature, mode) {
|
|
311
|
+
this.logger.info(`[${this.name}] Set target temperature to: ${target_temperature}`);
|
|
312
|
+
const message = this.make_message_unique_set();
|
|
313
|
+
message.target_temperature = target_temperature;
|
|
314
|
+
this.attributes.TARGET_TEMPERATURE = target_temperature;
|
|
315
|
+
if (mode) {
|
|
316
|
+
message.mode = mode;
|
|
317
|
+
message.power = true;
|
|
318
|
+
this.attributes.MODE = mode;
|
|
319
|
+
this.attributes.POWER = true;
|
|
320
|
+
}
|
|
321
|
+
await this.build_send(message);
|
|
322
|
+
}
|
|
323
|
+
async set_swing(swing_horizontal, swing_vertical) {
|
|
324
|
+
this.logger.info(`[${this.name}] Set swing horizontal to: ${swing_horizontal}, vertical to: ${swing_vertical}`);
|
|
325
|
+
const message = this.make_message_set();
|
|
326
|
+
message.swing_horizontal = swing_horizontal;
|
|
327
|
+
message.swing_vertical = swing_vertical;
|
|
328
|
+
this.attributes.SWING_HORIZONTAL = swing_horizontal;
|
|
329
|
+
this.attributes.SWING_VERTICAL = swing_vertical;
|
|
330
|
+
this.attributes.WIND_SWING_LR_ANGLE = 0;
|
|
331
|
+
this.attributes.WIND_SWING_UD_ANGLE = 0;
|
|
332
|
+
await this.build_send(message);
|
|
333
|
+
}
|
|
334
|
+
async set_fan_auto(fan_auto) {
|
|
335
|
+
this.logger.info(`[${this.name}] Set fan auto to: ${fan_auto}`);
|
|
336
|
+
const message = this.make_message_unique_set();
|
|
337
|
+
if (fan_auto) {
|
|
338
|
+
// Save last fan speed before setting to auto
|
|
339
|
+
this.last_fan_speed = this.attributes.FAN_SPEED;
|
|
340
|
+
}
|
|
341
|
+
const fan_speed = fan_auto ? 102 : this.last_fan_speed;
|
|
342
|
+
message.fan_speed = fan_speed;
|
|
343
|
+
this.attributes.FAN_SPEED = fan_speed;
|
|
344
|
+
this.attributes.FAN_AUTO = fan_auto;
|
|
345
|
+
await this.build_send(message);
|
|
346
|
+
}
|
|
347
|
+
async set_swing_angle(swing_direction, swing_angle) {
|
|
348
|
+
this.logger.info(`[${this.name}] Set swing ${swing_direction} angle to: ${swing_angle}`);
|
|
349
|
+
const message = new MideaACMessage_1.MessageNewProtocolSet(this.device_protocol_version);
|
|
350
|
+
this.attributes.SWING_HORIZONTAL = false;
|
|
351
|
+
this.attributes.SWING_VERTICAL = false;
|
|
352
|
+
switch (swing_direction) {
|
|
353
|
+
case platformUtils_1.SwingAngle.HORIZONTAL:
|
|
354
|
+
message.wind_swing_lr_angle = swing_angle;
|
|
355
|
+
this.attributes.WIND_SWING_LR_ANGLE = swing_angle;
|
|
356
|
+
break;
|
|
357
|
+
case platformUtils_1.SwingAngle.VERTICAL:
|
|
358
|
+
message.wind_swing_ud_angle = swing_angle;
|
|
359
|
+
this.attributes.WIND_SWING_UD_ANGLE = swing_angle;
|
|
360
|
+
break;
|
|
361
|
+
}
|
|
362
|
+
message.prompt_tone = this.attributes.PROMPT_TONE;
|
|
363
|
+
await this.build_send(message);
|
|
364
|
+
}
|
|
365
|
+
async set_self_clean(self_clean) {
|
|
366
|
+
this.logger.info(`[${this.name}] Set self clean to: ${self_clean}`);
|
|
367
|
+
const message = new MideaACMessage_1.MessageNewProtocolSet(this.device_protocol_version);
|
|
368
|
+
message.self_clean = self_clean;
|
|
369
|
+
this.attributes.SELF_CLEAN = self_clean;
|
|
370
|
+
message.prompt_tone = this.attributes.PROMPT_TONE;
|
|
371
|
+
await this.build_send(message);
|
|
372
|
+
}
|
|
373
|
+
async set_ion(ion) {
|
|
374
|
+
this.logger.info(`[${this.name}] Set ion to: ${ion}`);
|
|
375
|
+
// If ion is enabled, we need to turn on the device first
|
|
376
|
+
if (ion === true) {
|
|
377
|
+
this.logger.info(`[${this.name}] Powering on device to enable ion`);
|
|
378
|
+
this.attributes.POWER = true;
|
|
379
|
+
const message = this.make_message_unique_set();
|
|
380
|
+
await this.build_send(message);
|
|
381
|
+
}
|
|
382
|
+
const message = new MideaACMessage_1.MessageNewProtocolSet(this.device_protocol_version);
|
|
383
|
+
message.ion = ion;
|
|
384
|
+
this.attributes.ION = ion;
|
|
385
|
+
message.prompt_tone = this.attributes.PROMPT_TONE;
|
|
386
|
+
await this.build_send(message);
|
|
387
|
+
}
|
|
388
|
+
async set_rate_select(rate_select) {
|
|
389
|
+
this.logger.info(`[${this.name}] Set rate select to: ${rate_select}`);
|
|
390
|
+
const message = new MideaACMessage_1.MessageNewProtocolSet(this.device_protocol_version);
|
|
391
|
+
message.rate_select = rate_select;
|
|
392
|
+
this.attributes.RATE_SELECT = rate_select;
|
|
393
|
+
message.prompt_tone = this.attributes.PROMPT_TONE;
|
|
394
|
+
await this.build_send(message);
|
|
395
|
+
}
|
|
396
|
+
set_subtype() {
|
|
397
|
+
this.logger.debug('No subtype for AC device');
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
exports.default = MideaACDevice;
|
|
385
401
|
//# sourceMappingURL=MideaACDevice.js.map
|