homebridge-midea-platform 1.1.2-beta.2 → 1.1.2-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/CHANGELOG.md +6 -1
- package/config.schema.json +20 -56
- package/dist/accessory/AccessoryFactory.d.ts +12 -12
- package/dist/accessory/AccessoryFactory.js +31 -31
- package/dist/accessory/AirConditionerAccessory.d.ts +86 -86
- package/dist/accessory/AirConditionerAccessory.js +560 -560
- 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.d.ts.map +1 -1
- package/dist/accessory/DehumidifierAccessory.js +345 -343
- package/dist/accessory/DehumidifierAccessory.js.map +1 -1
- 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 +60 -60
- 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 +49 -49
- package/dist/core/MideaConstants.js +57 -57
- 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 +242 -242
- package/dist/core/MideaUtils.d.ts +32 -32
- package/dist/core/MideaUtils.js +181 -181
- package/dist/devices/DeviceFactory.d.ts +12 -12
- package/dist/devices/DeviceFactory.js +33 -33
- package/dist/devices/a1/MideaA1Device.d.ts +76 -76
- package/dist/devices/a1/MideaA1Device.js +136 -136
- package/dist/devices/a1/MideaA1Message.d.ts +40 -40
- package/dist/devices/a1/MideaA1Message.js +198 -198
- package/dist/devices/ac/MideaACDevice.d.ts +100 -100
- package/dist/devices/ac/MideaACDevice.js +370 -370
- package/dist/devices/ac/MideaACMessage.d.ts +92 -92
- package/dist/devices/ac/MideaACMessage.js +589 -589
- package/dist/devices/db/MideaDBDevice.d.ts +29 -29
- package/dist/devices/db/MideaDBDevice.js +88 -88
- package/dist/devices/db/MideaDBMessage.d.ts +32 -32
- package/dist/devices/db/MideaDBMessage.js +101 -101
- package/dist/devices/e2/MideaE2Device.d.ts +44 -44
- package/dist/devices/e2/MideaE2Device.js +119 -119
- 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 +125 -125
- 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 +92 -92
- 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 +213 -213
- package/dist/platformUtils.d.ts +98 -97
- package/dist/platformUtils.d.ts.map +1 -1
- package/dist/platformUtils.js +96 -95
- package/dist/platformUtils.js.map +1 -1
- package/dist/settings.d.ts +8 -8
- package/dist/settings.js +11 -11
- package/docs/db.md +3 -0
- package/package.json +1 -1
|
@@ -1,590 +1,590 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MessageACResponse = exports.MessageNewProtocolSet = exports.MessageGeneralSet = exports.MessageSubProtocolSet = exports.MessageSubProtocolQuery = exports.MessageSubProtocol = exports.MessageNewProtocolQuery = exports.MessageSwitchDisplay = exports.MessagePowerQuery = exports.MessageQuery = void 0;
|
|
4
|
-
/***********************************************************************
|
|
5
|
-
* Midea Air Conditioner Device message handler class
|
|
6
|
-
*
|
|
7
|
-
* Copyright (c) 2023 Kovalovszky Patrik, https://github.com/kovapatrik
|
|
8
|
-
*
|
|
9
|
-
* With thanks to https://github.com/georgezhao2010/midea_ac_lan
|
|
10
|
-
*
|
|
11
|
-
*/
|
|
12
|
-
const MideaConstants_1 = require("../../core/MideaConstants");
|
|
13
|
-
const MideaMessage_1 = require("../../core/MideaMessage");
|
|
14
|
-
const MideaUtils_1 = require("../../core/MideaUtils");
|
|
15
|
-
var NewProtocolTags;
|
|
16
|
-
(function (NewProtocolTags) {
|
|
17
|
-
NewProtocolTags[NewProtocolTags["WIND_SWING_UD_ANGLE"] = 9] = "WIND_SWING_UD_ANGLE";
|
|
18
|
-
NewProtocolTags[NewProtocolTags["WIND_SWING_LR_ANGLE"] = 10] = "WIND_SWING_LR_ANGLE";
|
|
19
|
-
NewProtocolTags[NewProtocolTags["INDOOR_HUMIDITY"] = 21] = "INDOOR_HUMIDITY";
|
|
20
|
-
NewProtocolTags[NewProtocolTags["SCREEN_DISPLAY"] = 23] = "SCREEN_DISPLAY";
|
|
21
|
-
NewProtocolTags[NewProtocolTags["BREEZELESS"] = 24] = "BREEZELESS";
|
|
22
|
-
NewProtocolTags[NewProtocolTags["PROMPT_TONE"] = 26] = "PROMPT_TONE";
|
|
23
|
-
NewProtocolTags[NewProtocolTags["INDIRECT_WIND"] = 66] = "INDIRECT_WIND";
|
|
24
|
-
NewProtocolTags[NewProtocolTags["FRESH_AIR_1"] = 563] = "FRESH_AIR_1";
|
|
25
|
-
NewProtocolTags[NewProtocolTags["FRESH_AIR_2"] = 75] = "FRESH_AIR_2";
|
|
26
|
-
})(NewProtocolTags || (NewProtocolTags = {}));
|
|
27
|
-
const BB_AC_MODES = [0, 3, 1, 2, 4, 5];
|
|
28
|
-
class MessageACBase extends MideaMessage_1.MessageRequest {
|
|
29
|
-
constructor(device_protocol_version, message_type, body_type) {
|
|
30
|
-
super(MideaConstants_1.DeviceType.AIR_CONDITIONER, message_type, body_type, device_protocol_version);
|
|
31
|
-
MessageACBase.message_serial += 1;
|
|
32
|
-
if (MessageACBase.message_serial >= 254) {
|
|
33
|
-
MessageACBase.message_serial = 1;
|
|
34
|
-
}
|
|
35
|
-
this.message_id = MessageACBase.message_serial;
|
|
36
|
-
}
|
|
37
|
-
get body() {
|
|
38
|
-
let body = Buffer.concat([Buffer.from([this.body_type]), this._body, Buffer.from([this.message_id])]);
|
|
39
|
-
body = Buffer.concat([body, Buffer.from([(0, MideaUtils_1.calculate)(body)])]);
|
|
40
|
-
return body;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
MessageACBase.message_serial = 0;
|
|
44
|
-
class MessageQuery extends MessageACBase {
|
|
45
|
-
constructor(device_protocol_version) {
|
|
46
|
-
super(device_protocol_version, MideaMessage_1.MessageType.QUERY, 0x41);
|
|
47
|
-
}
|
|
48
|
-
get _body() {
|
|
49
|
-
return Buffer.from([0x81, 0x00, 0xff, 0x03, 0xff, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
exports.MessageQuery = MessageQuery;
|
|
53
|
-
class MessagePowerQuery extends MessageACBase {
|
|
54
|
-
constructor(device_protocol_version) {
|
|
55
|
-
super(device_protocol_version, MideaMessage_1.MessageType.QUERY, 0x41);
|
|
56
|
-
}
|
|
57
|
-
get _body() {
|
|
58
|
-
return Buffer.from([0x21, 0x01, 0x44, 0x00, 0x01]);
|
|
59
|
-
}
|
|
60
|
-
get body() {
|
|
61
|
-
let body = Buffer.concat([Buffer.from([this.body_type]), this._body]);
|
|
62
|
-
body = Buffer.concat([body, Buffer.from([(0, MideaUtils_1.calculate)(body)])]);
|
|
63
|
-
return body;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
exports.MessagePowerQuery = MessagePowerQuery;
|
|
67
|
-
class MessageSwitchDisplay extends MessageACBase {
|
|
68
|
-
constructor(device_protocol_version) {
|
|
69
|
-
super(device_protocol_version, MideaMessage_1.MessageType.QUERY, 0x41);
|
|
70
|
-
}
|
|
71
|
-
get _body() {
|
|
72
|
-
return Buffer.from([0x81, 0x00, 0xff, 0x02, 0xff, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
exports.MessageSwitchDisplay = MessageSwitchDisplay;
|
|
76
|
-
class MessageNewProtocolQuery extends MessageACBase {
|
|
77
|
-
constructor(device_protocol_version, alternate_display = false) {
|
|
78
|
-
super(device_protocol_version, MideaMessage_1.MessageType.QUERY, 0xb1);
|
|
79
|
-
this.alternate_display = alternate_display;
|
|
80
|
-
}
|
|
81
|
-
get _body() {
|
|
82
|
-
const query_params = [
|
|
83
|
-
NewProtocolTags.WIND_SWING_UD_ANGLE,
|
|
84
|
-
NewProtocolTags.WIND_SWING_LR_ANGLE,
|
|
85
|
-
NewProtocolTags.INDIRECT_WIND,
|
|
86
|
-
NewProtocolTags.BREEZELESS,
|
|
87
|
-
NewProtocolTags.INDOOR_HUMIDITY,
|
|
88
|
-
this.alternate_display ? NewProtocolTags.SCREEN_DISPLAY : undefined,
|
|
89
|
-
NewProtocolTags.FRESH_AIR_1,
|
|
90
|
-
NewProtocolTags.FRESH_AIR_2,
|
|
91
|
-
];
|
|
92
|
-
let body = Buffer.from([query_params.length]);
|
|
93
|
-
for (const param of query_params) {
|
|
94
|
-
if (param) {
|
|
95
|
-
body = Buffer.concat([body, Buffer.from([param & 0xff, param >> 8])]);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
return body;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
exports.MessageNewProtocolQuery = MessageNewProtocolQuery;
|
|
102
|
-
class MessageSubProtocol extends MessageACBase {
|
|
103
|
-
constructor(device_protocol_version, message_type, subprotocol_query_type) {
|
|
104
|
-
super(device_protocol_version, message_type, 0xaa);
|
|
105
|
-
this.subprotocol_query_type = subprotocol_query_type;
|
|
106
|
-
}
|
|
107
|
-
get body() {
|
|
108
|
-
let body = Buffer.concat([Buffer.from([this.body_type]), this._body]);
|
|
109
|
-
body = Buffer.concat([body, Buffer.from([(0, MideaUtils_1.calculate)(body)])]);
|
|
110
|
-
body = Buffer.concat([body, Buffer.from([this.checksum(body)])]);
|
|
111
|
-
return body;
|
|
112
|
-
}
|
|
113
|
-
get _body() {
|
|
114
|
-
let body = Buffer.from([
|
|
115
|
-
6 + 2 + (this.subprotocol_body ? this.subprotocol_body.length : 0),
|
|
116
|
-
0x00,
|
|
117
|
-
0xff,
|
|
118
|
-
0xff,
|
|
119
|
-
this.subprotocol_query_type,
|
|
120
|
-
]);
|
|
121
|
-
if (this.subprotocol_body) {
|
|
122
|
-
body = Buffer.concat([body, this.subprotocol_body]);
|
|
123
|
-
}
|
|
124
|
-
return body;
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
exports.MessageSubProtocol = MessageSubProtocol;
|
|
128
|
-
class MessageSubProtocolQuery extends MessageSubProtocol {
|
|
129
|
-
constructor(device_protocol_version, subprotocol_query_type) {
|
|
130
|
-
super(device_protocol_version, MideaMessage_1.MessageType.QUERY, subprotocol_query_type);
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
exports.MessageSubProtocolQuery = MessageSubProtocolQuery;
|
|
134
|
-
class MessageSubProtocolSet extends MessageSubProtocol {
|
|
135
|
-
constructor(device_protocol_version) {
|
|
136
|
-
super(device_protocol_version, MideaMessage_1.MessageType.SET, 0x20);
|
|
137
|
-
this.power = false;
|
|
138
|
-
this.mode = 0;
|
|
139
|
-
this.target_temperature = 20.0;
|
|
140
|
-
this.fan_speed = 102;
|
|
141
|
-
this.boost_mode = false;
|
|
142
|
-
this.aux_heating = false;
|
|
143
|
-
this.dry = false;
|
|
144
|
-
this.eco_mode = false;
|
|
145
|
-
this.sleep_mode = false;
|
|
146
|
-
this.sn8_flag = false;
|
|
147
|
-
this.timer = false;
|
|
148
|
-
this.prompt_tone = false;
|
|
149
|
-
}
|
|
150
|
-
get subprotocol_body() {
|
|
151
|
-
const power = this.power ? 0x01 : 0x00;
|
|
152
|
-
const dry = this.dry && this.power ? 0x10 : 0;
|
|
153
|
-
const boost_mode = this.boost_mode ? 0x20 : 0;
|
|
154
|
-
const aux_heating = this.aux_heating ? 0x40 : 0;
|
|
155
|
-
const sleep_mode = this.sleep_mode ? 0x80 : 0;
|
|
156
|
-
const mode = this.mode === 0 ? 0 : this.mode < BB_AC_MODES.length ? BB_AC_MODES[this.mode] - 1 : 2;
|
|
157
|
-
const target_temperature = (this.target_temperature * 2 + 30) | 0;
|
|
158
|
-
const water_model_temperature_set = ((this.target_temperature - 1) * 2 + 50) | 0;
|
|
159
|
-
const fan_speed = this.fan_speed;
|
|
160
|
-
const eco = this.eco_mode ? 0x40 : 0;
|
|
161
|
-
const prompt_tone = this.prompt_tone ? 0x01 : 0;
|
|
162
|
-
const timer = this.sn8_flag && this.timer ? 0x04 : 0;
|
|
163
|
-
return Buffer.from([
|
|
164
|
-
boost_mode | power | dry,
|
|
165
|
-
aux_heating,
|
|
166
|
-
sleep_mode,
|
|
167
|
-
0x00,
|
|
168
|
-
0x00,
|
|
169
|
-
mode,
|
|
170
|
-
target_temperature,
|
|
171
|
-
fan_speed,
|
|
172
|
-
0x32,
|
|
173
|
-
0x00,
|
|
174
|
-
0x00,
|
|
175
|
-
0x00,
|
|
176
|
-
0x00,
|
|
177
|
-
0x00,
|
|
178
|
-
0x00,
|
|
179
|
-
0x01,
|
|
180
|
-
0x01,
|
|
181
|
-
0x00,
|
|
182
|
-
0x01,
|
|
183
|
-
water_model_temperature_set,
|
|
184
|
-
prompt_tone,
|
|
185
|
-
target_temperature,
|
|
186
|
-
0x32,
|
|
187
|
-
0x66,
|
|
188
|
-
0x00,
|
|
189
|
-
eco | timer,
|
|
190
|
-
0x00,
|
|
191
|
-
0x00,
|
|
192
|
-
0x00,
|
|
193
|
-
0x00,
|
|
194
|
-
0x00,
|
|
195
|
-
0x00,
|
|
196
|
-
0x00,
|
|
197
|
-
0x00,
|
|
198
|
-
0x00,
|
|
199
|
-
0x00,
|
|
200
|
-
0x08,
|
|
201
|
-
]);
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
exports.MessageSubProtocolSet = MessageSubProtocolSet;
|
|
205
|
-
class MessageGeneralSet extends MessageACBase {
|
|
206
|
-
constructor(device_protocol_version) {
|
|
207
|
-
super(device_protocol_version, MideaMessage_1.MessageType.SET, 0x40);
|
|
208
|
-
this.power = false;
|
|
209
|
-
this.prompt_tone = true;
|
|
210
|
-
this.mode = 0;
|
|
211
|
-
this.target_temperature = 20.0;
|
|
212
|
-
this.fan_speed = 102;
|
|
213
|
-
this.swing_vertical = false;
|
|
214
|
-
this.swing_horizontal = false;
|
|
215
|
-
this.boost_mode = false;
|
|
216
|
-
this.smart_eye = false;
|
|
217
|
-
this.dry = false;
|
|
218
|
-
this.aux_heating = false;
|
|
219
|
-
this.eco_mode = false;
|
|
220
|
-
this.temp_fahrenheit = false;
|
|
221
|
-
this.sleep_mode = false;
|
|
222
|
-
this.natural_wind = false;
|
|
223
|
-
this.frost_protect = false;
|
|
224
|
-
this.comfort_mode = false;
|
|
225
|
-
}
|
|
226
|
-
get _body() {
|
|
227
|
-
// Byte1, Power, prompt_tone
|
|
228
|
-
const power = this.power ? 0x01 : 0x00;
|
|
229
|
-
const prompt_tone = this.prompt_tone ? 0x40 : 0x00;
|
|
230
|
-
// Byte2, mode target_temperature
|
|
231
|
-
const mode = (this.mode << 5) & 0xe0;
|
|
232
|
-
const target_temperature = ((this.target_temperature | 0) & 0xf) | ((Math.round(this.target_temperature * 2) | 0) % 2 !== 0 ? 0x10 : 0);
|
|
233
|
-
// Byte 3, fan_speed
|
|
234
|
-
const fan_speed = this.fan_speed & 0x7f;
|
|
235
|
-
// Byte 7, swing_mode
|
|
236
|
-
const swing_mode = 0x30 | (this.swing_vertical ? 0x0c : 0) | (this.swing_horizontal ? 0x03 : 0);
|
|
237
|
-
// Byte 8, turbo
|
|
238
|
-
const boost_mode = this.boost_mode ? 0x20 : 0;
|
|
239
|
-
// Byte 9 aux_heating eco_mode
|
|
240
|
-
const smart_eye = this.smart_eye ? 0x01 : 0;
|
|
241
|
-
const dry = this.dry ? 0x04 : 0;
|
|
242
|
-
const aux_heating = this.aux_heating ? 0x08 : 0;
|
|
243
|
-
const eco_mode = this.eco_mode ? 0x80 : 0;
|
|
244
|
-
// Byte 10 temp_fahrenheit
|
|
245
|
-
const temp_fahrenheit = this.temp_fahrenheit ? 0x04 : 0;
|
|
246
|
-
const sleep_mode = this.sleep_mode ? 0x01 : 0;
|
|
247
|
-
const boost_mode_1 = this.boost_mode ? 0x02 : 0;
|
|
248
|
-
// Byte 17 natural_wind
|
|
249
|
-
const natural_wind = this.natural_wind ? 0x40 : 0;
|
|
250
|
-
// Byte 21 frost_protect
|
|
251
|
-
const frost_protect = this.frost_protect ? 0x80 : 0;
|
|
252
|
-
// Byte 22 comfort_mode
|
|
253
|
-
const comfort_mode = this.comfort_mode ? 0x01 : 0;
|
|
254
|
-
return Buffer.from([
|
|
255
|
-
power | prompt_tone,
|
|
256
|
-
mode | target_temperature,
|
|
257
|
-
fan_speed,
|
|
258
|
-
0x00,
|
|
259
|
-
0x00,
|
|
260
|
-
0x00,
|
|
261
|
-
swing_mode,
|
|
262
|
-
boost_mode,
|
|
263
|
-
smart_eye | dry | aux_heating | eco_mode,
|
|
264
|
-
temp_fahrenheit | sleep_mode | boost_mode_1,
|
|
265
|
-
0x00,
|
|
266
|
-
0x00,
|
|
267
|
-
0x00,
|
|
268
|
-
0x00,
|
|
269
|
-
0x00,
|
|
270
|
-
0x00,
|
|
271
|
-
natural_wind,
|
|
272
|
-
0x00,
|
|
273
|
-
0x00,
|
|
274
|
-
0x00,
|
|
275
|
-
frost_protect,
|
|
276
|
-
comfort_mode,
|
|
277
|
-
]);
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
exports.MessageGeneralSet = MessageGeneralSet;
|
|
281
|
-
class MessageNewProtocolSet extends MessageACBase {
|
|
282
|
-
constructor(device_protocol_version) {
|
|
283
|
-
super(device_protocol_version, MideaMessage_1.MessageType.SET, 0xb0);
|
|
284
|
-
this.prompt_tone = false;
|
|
285
|
-
}
|
|
286
|
-
get _body() {
|
|
287
|
-
let pack_count = 0;
|
|
288
|
-
let payload = Buffer.from([0x00]);
|
|
289
|
-
if (this.wind_swing_ud_angle !== undefined) {
|
|
290
|
-
pack_count += 1;
|
|
291
|
-
payload = Buffer.concat([
|
|
292
|
-
payload,
|
|
293
|
-
MideaMessage_1.NewProtocolMessageBody.packet(NewProtocolTags.WIND_SWING_UD_ANGLE, Buffer.from([this.wind_swing_ud_angle])),
|
|
294
|
-
]);
|
|
295
|
-
}
|
|
296
|
-
if (this.wind_swing_lr_angle !== undefined) {
|
|
297
|
-
pack_count += 1;
|
|
298
|
-
payload = Buffer.concat([
|
|
299
|
-
payload,
|
|
300
|
-
MideaMessage_1.NewProtocolMessageBody.packet(NewProtocolTags.WIND_SWING_LR_ANGLE, Buffer.from([this.wind_swing_lr_angle])),
|
|
301
|
-
]);
|
|
302
|
-
}
|
|
303
|
-
if (this.breezeless !== undefined) {
|
|
304
|
-
pack_count += 1;
|
|
305
|
-
payload = Buffer.concat([
|
|
306
|
-
payload,
|
|
307
|
-
MideaMessage_1.NewProtocolMessageBody.packet(NewProtocolTags.BREEZELESS, Buffer.from([this.breezeless ? 0x01 : 0x00])),
|
|
308
|
-
]);
|
|
309
|
-
}
|
|
310
|
-
if (this.indirect_wind !== undefined) {
|
|
311
|
-
pack_count += 1;
|
|
312
|
-
payload = Buffer.concat([
|
|
313
|
-
payload,
|
|
314
|
-
MideaMessage_1.NewProtocolMessageBody.packet(NewProtocolTags.INDIRECT_WIND, Buffer.from([this.indirect_wind ? 0x02 : 0x01])),
|
|
315
|
-
]);
|
|
316
|
-
}
|
|
317
|
-
if (this.screen_display !== undefined) {
|
|
318
|
-
pack_count += 1;
|
|
319
|
-
payload = Buffer.concat([
|
|
320
|
-
payload,
|
|
321
|
-
MideaMessage_1.NewProtocolMessageBody.packet(NewProtocolTags.SCREEN_DISPLAY, Buffer.from([this.screen_display ? 0x64 : 0x00])),
|
|
322
|
-
]);
|
|
323
|
-
}
|
|
324
|
-
if (this.fresh_air_1 !== undefined && this.fresh_air_1.length === 2) {
|
|
325
|
-
pack_count += 1;
|
|
326
|
-
const fresh_air_power = this.fresh_air_1[0] > 0 ? 2 : 1;
|
|
327
|
-
const fresh_air_fan_speed = this.fresh_air_1[1];
|
|
328
|
-
payload = Buffer.concat([
|
|
329
|
-
payload,
|
|
330
|
-
MideaMessage_1.NewProtocolMessageBody.packet(NewProtocolTags.FRESH_AIR_1, Buffer.from([fresh_air_power, fresh_air_fan_speed, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00])),
|
|
331
|
-
]);
|
|
332
|
-
}
|
|
333
|
-
if (this.fresh_air_2 !== undefined && this.fresh_air_2.length === 2) {
|
|
334
|
-
pack_count += 1;
|
|
335
|
-
const fresh_air_power = this.fresh_air_2[0] > 0 ? 1 : 0;
|
|
336
|
-
const fresh_air_fan_speed = this.fresh_air_2[1];
|
|
337
|
-
payload = Buffer.concat([
|
|
338
|
-
payload,
|
|
339
|
-
MideaMessage_1.NewProtocolMessageBody.packet(NewProtocolTags.FRESH_AIR_2, Buffer.from([fresh_air_power, fresh_air_fan_speed, 0xff])),
|
|
340
|
-
]);
|
|
341
|
-
}
|
|
342
|
-
pack_count += 1;
|
|
343
|
-
payload = Buffer.concat([
|
|
344
|
-
payload,
|
|
345
|
-
MideaMessage_1.NewProtocolMessageBody.packet(NewProtocolTags.PROMPT_TONE, Buffer.from([this.prompt_tone ? 0x01 : 0x00])),
|
|
346
|
-
]);
|
|
347
|
-
payload[0] = pack_count;
|
|
348
|
-
return payload;
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
exports.MessageNewProtocolSet = MessageNewProtocolSet;
|
|
352
|
-
class XA0MessageBody extends MideaMessage_1.MessageBody {
|
|
353
|
-
constructor(body) {
|
|
354
|
-
super(body);
|
|
355
|
-
this.power = (body[1] & 0x1) > 0;
|
|
356
|
-
this.target_temperature = ((body[1] & 0x3e) >> 1) - 4 + 16.0 + ((body[1] & 0x40) > 0 ? 0.5 : 0.0);
|
|
357
|
-
this.mode = (body[2] & 0xe0) >> 5;
|
|
358
|
-
this.fan_speed = body[3] & 0x7f;
|
|
359
|
-
this.fan_auto = this.fan_speed > 100;
|
|
360
|
-
this.swing_vertical = (body[7] & 0xc) > 0;
|
|
361
|
-
this.swing_horizontal = (body[7] & 0x3) > 0;
|
|
362
|
-
this.boost_mode = (body[8] & 0x20) > 0 || (body[10] & 0x2) > 0;
|
|
363
|
-
this.smart_eye = (body[9] & 0x01) > 0;
|
|
364
|
-
this.dry = (body[9] & 0x04) > 0;
|
|
365
|
-
this.aux_heating = (body[9] & 0x08) > 0;
|
|
366
|
-
this.eco_mode = (body[9] & 0x10) > 0;
|
|
367
|
-
this.sleep_mode = (body[10] & 0x01) > 0;
|
|
368
|
-
this.natural_wind = (body[10] & 0x40) > 0;
|
|
369
|
-
this.full_dust = (body[13] & 0x20) > 0;
|
|
370
|
-
this.comfort_mode = body.length > 16 ? (body[14] & 0x1) > 0 : false;
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
|
-
class XA1MessageBody extends MideaMessage_1.MessageBody {
|
|
374
|
-
constructor(body) {
|
|
375
|
-
super(body);
|
|
376
|
-
if (body[13] !== 0xff) {
|
|
377
|
-
const temp_integer = ((body[13] - 50) / 2) | 0;
|
|
378
|
-
const temp_decimal = body.length > 20 ? (body[18] & 0xf) * 0.1 : 0;
|
|
379
|
-
if (body[13] > 49) {
|
|
380
|
-
this.indoor_temperature = temp_integer + temp_decimal;
|
|
381
|
-
}
|
|
382
|
-
else {
|
|
383
|
-
this.indoor_temperature = temp_integer - temp_decimal;
|
|
384
|
-
}
|
|
385
|
-
}
|
|
386
|
-
if (body[14] === 0xff) {
|
|
387
|
-
this.outdoor_temperature = undefined;
|
|
388
|
-
}
|
|
389
|
-
else {
|
|
390
|
-
const temp_integer = ((body[14] - 50) / 2) | 0;
|
|
391
|
-
const temp_decimal = body.length > 20 ? ((body[18] & 0xf0) >> 4) * 0.1 : 0;
|
|
392
|
-
if (body[14] > 49) {
|
|
393
|
-
this.outdoor_temperature = temp_integer + temp_decimal;
|
|
394
|
-
}
|
|
395
|
-
else {
|
|
396
|
-
this.outdoor_temperature = temp_integer - temp_decimal;
|
|
397
|
-
}
|
|
398
|
-
}
|
|
399
|
-
this.indoor_humidity = body[17];
|
|
400
|
-
}
|
|
401
|
-
}
|
|
402
|
-
class XBXMessageBody extends MideaMessage_1.NewProtocolMessageBody {
|
|
403
|
-
constructor(body, body_type) {
|
|
404
|
-
super(body, body_type);
|
|
405
|
-
const params = this.parse();
|
|
406
|
-
if (NewProtocolTags.WIND_SWING_LR_ANGLE in params) {
|
|
407
|
-
this.wind_swing_lr_angle = params[NewProtocolTags.WIND_SWING_LR_ANGLE][0];
|
|
408
|
-
}
|
|
409
|
-
if (NewProtocolTags.WIND_SWING_UD_ANGLE in params) {
|
|
410
|
-
this.wind_swing_ud_angle = params[NewProtocolTags.WIND_SWING_UD_ANGLE][0];
|
|
411
|
-
}
|
|
412
|
-
if (NewProtocolTags.INDIRECT_WIND in params) {
|
|
413
|
-
this.indirect_wind = params[NewProtocolTags.INDIRECT_WIND][0] === 0x02;
|
|
414
|
-
}
|
|
415
|
-
if (NewProtocolTags.INDOOR_HUMIDITY in params) {
|
|
416
|
-
this.indoor_humidity = params[NewProtocolTags.INDOOR_HUMIDITY][0];
|
|
417
|
-
}
|
|
418
|
-
if (NewProtocolTags.BREEZELESS in params) {
|
|
419
|
-
this.breezeless = params[NewProtocolTags.BREEZELESS][0] === 1;
|
|
420
|
-
}
|
|
421
|
-
if (NewProtocolTags.SCREEN_DISPLAY in params) {
|
|
422
|
-
this.screen_display = params[NewProtocolTags.SCREEN_DISPLAY][0] > 0;
|
|
423
|
-
this.screen_display_new = true;
|
|
424
|
-
}
|
|
425
|
-
if (NewProtocolTags.FRESH_AIR_1 in params) {
|
|
426
|
-
this.fresh_air_1 = true;
|
|
427
|
-
const data = params[NewProtocolTags.FRESH_AIR_1];
|
|
428
|
-
this.fresh_air_power = data[0] === 0x02;
|
|
429
|
-
this.fresh_air_fan_speed = data[1];
|
|
430
|
-
}
|
|
431
|
-
if (NewProtocolTags.FRESH_AIR_2 in params) {
|
|
432
|
-
this.fresh_air_2 = true;
|
|
433
|
-
const data = params[NewProtocolTags.FRESH_AIR_2];
|
|
434
|
-
this.fresh_air_power = data[0] > 0;
|
|
435
|
-
this.fresh_air_fan_speed = data[1];
|
|
436
|
-
}
|
|
437
|
-
}
|
|
438
|
-
}
|
|
439
|
-
class XC0MessageBody extends MideaMessage_1.MessageBody {
|
|
440
|
-
constructor(body) {
|
|
441
|
-
super(body);
|
|
442
|
-
this.power = (body[1] & 0x1) > 0;
|
|
443
|
-
this.mode = (body[2] & 0xe0) >> 5;
|
|
444
|
-
this.target_temperature = (body[2] & 0x0f) + 16.0 + ((body[2] & 0x10) > 0 ? 0.5 : 0.0);
|
|
445
|
-
this.fan_speed = body[3] & 0x7f;
|
|
446
|
-
this.fan_auto = this.fan_speed > 100;
|
|
447
|
-
this.swing_vertical = (body[7] & 0x0c) > 0;
|
|
448
|
-
this.swing_horizontal = (body[7] & 0x03) > 0;
|
|
449
|
-
this.boost_mode = (body[8] & 0x20) > 0 || (body[10] & 0x2) > 0;
|
|
450
|
-
this.smart_eye = (body[8] & 0x40) > 0;
|
|
451
|
-
this.natural_wind = (body[9] & 0x2) > 0;
|
|
452
|
-
this.dry = (body[9] & 0x4) > 0;
|
|
453
|
-
this.eco_mode = (body[9] & 0x10) > 0;
|
|
454
|
-
this.aux_heating = (body[9] & 0x08) > 0;
|
|
455
|
-
this.temp_fahrenheit = (body[10] & 0x04) > 0;
|
|
456
|
-
this.sleep_mode = (body[10] & 0x01) > 0;
|
|
457
|
-
if (body[11] !== 0xff) {
|
|
458
|
-
const temp_integer = ((body[11] - 50) / 2) | 0;
|
|
459
|
-
const temp_decimal = (body[15] & 0x0f) * 0.1;
|
|
460
|
-
if (body[11] > 49) {
|
|
461
|
-
this.indoor_temperature = temp_integer + temp_decimal;
|
|
462
|
-
}
|
|
463
|
-
else {
|
|
464
|
-
this.indoor_temperature = temp_integer - temp_decimal;
|
|
465
|
-
}
|
|
466
|
-
}
|
|
467
|
-
if (body[12] === 0xff) {
|
|
468
|
-
this.outdoor_temperature = undefined;
|
|
469
|
-
}
|
|
470
|
-
else {
|
|
471
|
-
const temp_integer = ((body[12] - 50) / 2) | 0;
|
|
472
|
-
const temp_decimal = ((body[15] & 0xf0) >> 4) * 0.1;
|
|
473
|
-
if (body[12] > 49) {
|
|
474
|
-
this.outdoor_temperature = temp_integer + temp_decimal;
|
|
475
|
-
}
|
|
476
|
-
else {
|
|
477
|
-
this.outdoor_temperature = temp_integer - temp_decimal;
|
|
478
|
-
}
|
|
479
|
-
}
|
|
480
|
-
this.full_dust = (body[13] & 0x20) > 0;
|
|
481
|
-
this.screen_display = ((body[14] >> 4) & 0x7) !== 0x07 && this.power;
|
|
482
|
-
this.frost_protect = body.length > 23 ? (body[21] & 0x80) > 0 : false;
|
|
483
|
-
this.comfort_mode = body.length > 24 ? (body[22] & 0x1) > 0 : false;
|
|
484
|
-
}
|
|
485
|
-
}
|
|
486
|
-
class XC1MessageBody extends MideaMessage_1.MessageBody {
|
|
487
|
-
constructor(body, analysis_method = 3) {
|
|
488
|
-
super(body);
|
|
489
|
-
if (body[3] === 0x44) {
|
|
490
|
-
this.total_energy_consumption = XC1MessageBody.parse_consumption(analysis_method, body[4], body[5], body[6], body[7]);
|
|
491
|
-
this.current_energy_consumption = XC1MessageBody.parse_consumption(analysis_method, body[12], body[13], body[14], body[15]);
|
|
492
|
-
this.realtime_power = XC1MessageBody.parse_power(analysis_method, body[16], body[17], body[18]);
|
|
493
|
-
}
|
|
494
|
-
}
|
|
495
|
-
static parse_power(analysis_method, byte1, byte2, byte3) {
|
|
496
|
-
if (analysis_method === 1) {
|
|
497
|
-
return byte1 + byte2 / 100 + byte3 / 10000;
|
|
498
|
-
}
|
|
499
|
-
else if (analysis_method === 2) {
|
|
500
|
-
return ((byte1 << 16) + (byte2 << 8) + byte3) / 1000;
|
|
501
|
-
}
|
|
502
|
-
else {
|
|
503
|
-
return (byte1 * 10000 + byte2 * 100 + byte3) / 10;
|
|
504
|
-
}
|
|
505
|
-
}
|
|
506
|
-
static parse_consumption(analysis_method, byte1, byte2, byte3, byte4) {
|
|
507
|
-
if (analysis_method === 1) {
|
|
508
|
-
return byte1 * 10000 + byte2 * 100 + byte3 + byte4 / 100;
|
|
509
|
-
}
|
|
510
|
-
else if (analysis_method === 2) {
|
|
511
|
-
return ((byte1 << 32) + (byte2 << 16) + (byte3 << 8) + byte4) / 1000;
|
|
512
|
-
}
|
|
513
|
-
else {
|
|
514
|
-
return (byte1 * 1000000 + byte2 * 10000 + byte3 * 100 + byte4) / 100;
|
|
515
|
-
}
|
|
516
|
-
}
|
|
517
|
-
}
|
|
518
|
-
class XBBMessageBody extends MideaMessage_1.MessageBody {
|
|
519
|
-
constructor(body) {
|
|
520
|
-
super(body);
|
|
521
|
-
const subprotocol_head = body.subarray(0, 6);
|
|
522
|
-
const subprotocol_body = body.subarray(6, body.length);
|
|
523
|
-
const data_type = subprotocol_head[subprotocol_head.length - 1];
|
|
524
|
-
const subprotocol_body_len = subprotocol_body.length;
|
|
525
|
-
if (data_type === 0x20 || data_type === 0x11) {
|
|
526
|
-
this.power = (subprotocol_body[0] & 0x1) > 0;
|
|
527
|
-
this.dry = (subprotocol_body[0] & 0x10) > 0;
|
|
528
|
-
this.boost_mode = (subprotocol_body[0] & 0x20) > 0;
|
|
529
|
-
this.aux_heating = (subprotocol_body[1] & 0x40) > 0;
|
|
530
|
-
this.sleep_mode = (subprotocol_body[2] & 0x80) > 0;
|
|
531
|
-
this.mode = BB_AC_MODES.indexOf(subprotocol_body[5] + 1);
|
|
532
|
-
if (this.mode === -1) {
|
|
533
|
-
this.mode = 0;
|
|
534
|
-
}
|
|
535
|
-
this.target_temperature = (subprotocol_body[6] - 30) / 2;
|
|
536
|
-
this.fan_speed = subprotocol_body[7];
|
|
537
|
-
this.fan_auto = this.fan_speed > 100;
|
|
538
|
-
this.timer = subprotocol_body_len > 27 ? (subprotocol_body[25] & 0x04) > 0 : false;
|
|
539
|
-
this.eco_mode = subprotocol_body_len > 27 ? (subprotocol_body[25] & 0x40) > 0 : false;
|
|
540
|
-
}
|
|
541
|
-
else if (data_type === 0x10) {
|
|
542
|
-
if ((subprotocol_body[8] & 0x80) === 0x80) {
|
|
543
|
-
this.indoor_temperature = ((0 - (~(subprotocol_body[7] + subprotocol_body[8] * 256) + 1)) & 0xffff) / 100;
|
|
544
|
-
}
|
|
545
|
-
else {
|
|
546
|
-
this.indoor_temperature = (subprotocol_body[7] + subprotocol_body[8] * 256) / 100;
|
|
547
|
-
}
|
|
548
|
-
this.indoor_humidity = subprotocol_body[30];
|
|
549
|
-
this.sn8_flag = subprotocol_body[80] === 0x31;
|
|
550
|
-
}
|
|
551
|
-
else if (data_type === 0x30) {
|
|
552
|
-
if ((subprotocol_body[6] & 0x80) === 0x80) {
|
|
553
|
-
this.outdoor_temperature = ((0 - (~(subprotocol_body[5] + subprotocol_body[6] * 256) + 1)) & 0xffff) / 100;
|
|
554
|
-
}
|
|
555
|
-
else {
|
|
556
|
-
this.outdoor_temperature = (subprotocol_body[5] + subprotocol_body[6] * 256) / 100;
|
|
557
|
-
}
|
|
558
|
-
}
|
|
559
|
-
}
|
|
560
|
-
}
|
|
561
|
-
class MessageACResponse extends MideaMessage_1.MessageResponse {
|
|
562
|
-
constructor(message, power_analysis_method = 3) {
|
|
563
|
-
super(message);
|
|
564
|
-
this.message = message;
|
|
565
|
-
if (this.message_type === MideaMessage_1.MessageType.NOTIFY2 && this.body_type === 0xa0) {
|
|
566
|
-
this.set_body(new XA0MessageBody(this.body));
|
|
567
|
-
}
|
|
568
|
-
else if (this.message_type === MideaMessage_1.MessageType.NOTIFY1 && this.body_type === 0xa1) {
|
|
569
|
-
this.set_body(new XA1MessageBody(this.body));
|
|
570
|
-
}
|
|
571
|
-
else if ([MideaMessage_1.MessageType.QUERY, MideaMessage_1.MessageType.SET, MideaMessage_1.MessageType.NOTIFY2].includes(this.message_type) &&
|
|
572
|
-
[0xb0, 0xb1, 0xb5].includes(this.body_type)) {
|
|
573
|
-
this.set_body(new XBXMessageBody(this.body, this.body_type));
|
|
574
|
-
}
|
|
575
|
-
else if ([MideaMessage_1.MessageType.QUERY, MideaMessage_1.MessageType.SET].includes(this.message_type) && this.body_type === 0xc0) {
|
|
576
|
-
this.set_body(new XC0MessageBody(this.body));
|
|
577
|
-
}
|
|
578
|
-
else if (this.message_type === MideaMessage_1.MessageType.QUERY && this.body_type === 0xc1) {
|
|
579
|
-
this.set_body(new XC1MessageBody(this.body, power_analysis_method));
|
|
580
|
-
}
|
|
581
|
-
else if ([MideaMessage_1.MessageType.QUERY, MideaMessage_1.MessageType.SET, MideaMessage_1.MessageType.NOTIFY2].includes(this.message_type) &&
|
|
582
|
-
this.body_type === 0xbb &&
|
|
583
|
-
this.body.length >= 21) {
|
|
584
|
-
this.used_subprotocol = true;
|
|
585
|
-
this.set_body(new XBBMessageBody(this.body));
|
|
586
|
-
}
|
|
587
|
-
}
|
|
588
|
-
}
|
|
589
|
-
exports.MessageACResponse = MessageACResponse;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MessageACResponse = exports.MessageNewProtocolSet = exports.MessageGeneralSet = exports.MessageSubProtocolSet = exports.MessageSubProtocolQuery = exports.MessageSubProtocol = exports.MessageNewProtocolQuery = exports.MessageSwitchDisplay = exports.MessagePowerQuery = exports.MessageQuery = void 0;
|
|
4
|
+
/***********************************************************************
|
|
5
|
+
* Midea Air Conditioner Device message handler class
|
|
6
|
+
*
|
|
7
|
+
* Copyright (c) 2023 Kovalovszky Patrik, https://github.com/kovapatrik
|
|
8
|
+
*
|
|
9
|
+
* With thanks to https://github.com/georgezhao2010/midea_ac_lan
|
|
10
|
+
*
|
|
11
|
+
*/
|
|
12
|
+
const MideaConstants_1 = require("../../core/MideaConstants");
|
|
13
|
+
const MideaMessage_1 = require("../../core/MideaMessage");
|
|
14
|
+
const MideaUtils_1 = require("../../core/MideaUtils");
|
|
15
|
+
var NewProtocolTags;
|
|
16
|
+
(function (NewProtocolTags) {
|
|
17
|
+
NewProtocolTags[NewProtocolTags["WIND_SWING_UD_ANGLE"] = 9] = "WIND_SWING_UD_ANGLE";
|
|
18
|
+
NewProtocolTags[NewProtocolTags["WIND_SWING_LR_ANGLE"] = 10] = "WIND_SWING_LR_ANGLE";
|
|
19
|
+
NewProtocolTags[NewProtocolTags["INDOOR_HUMIDITY"] = 21] = "INDOOR_HUMIDITY";
|
|
20
|
+
NewProtocolTags[NewProtocolTags["SCREEN_DISPLAY"] = 23] = "SCREEN_DISPLAY";
|
|
21
|
+
NewProtocolTags[NewProtocolTags["BREEZELESS"] = 24] = "BREEZELESS";
|
|
22
|
+
NewProtocolTags[NewProtocolTags["PROMPT_TONE"] = 26] = "PROMPT_TONE";
|
|
23
|
+
NewProtocolTags[NewProtocolTags["INDIRECT_WIND"] = 66] = "INDIRECT_WIND";
|
|
24
|
+
NewProtocolTags[NewProtocolTags["FRESH_AIR_1"] = 563] = "FRESH_AIR_1";
|
|
25
|
+
NewProtocolTags[NewProtocolTags["FRESH_AIR_2"] = 75] = "FRESH_AIR_2";
|
|
26
|
+
})(NewProtocolTags || (NewProtocolTags = {}));
|
|
27
|
+
const BB_AC_MODES = [0, 3, 1, 2, 4, 5];
|
|
28
|
+
class MessageACBase extends MideaMessage_1.MessageRequest {
|
|
29
|
+
constructor(device_protocol_version, message_type, body_type) {
|
|
30
|
+
super(MideaConstants_1.DeviceType.AIR_CONDITIONER, message_type, body_type, device_protocol_version);
|
|
31
|
+
MessageACBase.message_serial += 1;
|
|
32
|
+
if (MessageACBase.message_serial >= 254) {
|
|
33
|
+
MessageACBase.message_serial = 1;
|
|
34
|
+
}
|
|
35
|
+
this.message_id = MessageACBase.message_serial;
|
|
36
|
+
}
|
|
37
|
+
get body() {
|
|
38
|
+
let body = Buffer.concat([Buffer.from([this.body_type]), this._body, Buffer.from([this.message_id])]);
|
|
39
|
+
body = Buffer.concat([body, Buffer.from([(0, MideaUtils_1.calculate)(body)])]);
|
|
40
|
+
return body;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
MessageACBase.message_serial = 0;
|
|
44
|
+
class MessageQuery extends MessageACBase {
|
|
45
|
+
constructor(device_protocol_version) {
|
|
46
|
+
super(device_protocol_version, MideaMessage_1.MessageType.QUERY, 0x41);
|
|
47
|
+
}
|
|
48
|
+
get _body() {
|
|
49
|
+
return Buffer.from([0x81, 0x00, 0xff, 0x03, 0xff, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
exports.MessageQuery = MessageQuery;
|
|
53
|
+
class MessagePowerQuery extends MessageACBase {
|
|
54
|
+
constructor(device_protocol_version) {
|
|
55
|
+
super(device_protocol_version, MideaMessage_1.MessageType.QUERY, 0x41);
|
|
56
|
+
}
|
|
57
|
+
get _body() {
|
|
58
|
+
return Buffer.from([0x21, 0x01, 0x44, 0x00, 0x01]);
|
|
59
|
+
}
|
|
60
|
+
get body() {
|
|
61
|
+
let body = Buffer.concat([Buffer.from([this.body_type]), this._body]);
|
|
62
|
+
body = Buffer.concat([body, Buffer.from([(0, MideaUtils_1.calculate)(body)])]);
|
|
63
|
+
return body;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
exports.MessagePowerQuery = MessagePowerQuery;
|
|
67
|
+
class MessageSwitchDisplay extends MessageACBase {
|
|
68
|
+
constructor(device_protocol_version) {
|
|
69
|
+
super(device_protocol_version, MideaMessage_1.MessageType.QUERY, 0x41);
|
|
70
|
+
}
|
|
71
|
+
get _body() {
|
|
72
|
+
return Buffer.from([0x81, 0x00, 0xff, 0x02, 0xff, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
exports.MessageSwitchDisplay = MessageSwitchDisplay;
|
|
76
|
+
class MessageNewProtocolQuery extends MessageACBase {
|
|
77
|
+
constructor(device_protocol_version, alternate_display = false) {
|
|
78
|
+
super(device_protocol_version, MideaMessage_1.MessageType.QUERY, 0xb1);
|
|
79
|
+
this.alternate_display = alternate_display;
|
|
80
|
+
}
|
|
81
|
+
get _body() {
|
|
82
|
+
const query_params = [
|
|
83
|
+
NewProtocolTags.WIND_SWING_UD_ANGLE,
|
|
84
|
+
NewProtocolTags.WIND_SWING_LR_ANGLE,
|
|
85
|
+
NewProtocolTags.INDIRECT_WIND,
|
|
86
|
+
NewProtocolTags.BREEZELESS,
|
|
87
|
+
NewProtocolTags.INDOOR_HUMIDITY,
|
|
88
|
+
this.alternate_display ? NewProtocolTags.SCREEN_DISPLAY : undefined,
|
|
89
|
+
NewProtocolTags.FRESH_AIR_1,
|
|
90
|
+
NewProtocolTags.FRESH_AIR_2,
|
|
91
|
+
];
|
|
92
|
+
let body = Buffer.from([query_params.length]);
|
|
93
|
+
for (const param of query_params) {
|
|
94
|
+
if (param) {
|
|
95
|
+
body = Buffer.concat([body, Buffer.from([param & 0xff, param >> 8])]);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return body;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
exports.MessageNewProtocolQuery = MessageNewProtocolQuery;
|
|
102
|
+
class MessageSubProtocol extends MessageACBase {
|
|
103
|
+
constructor(device_protocol_version, message_type, subprotocol_query_type) {
|
|
104
|
+
super(device_protocol_version, message_type, 0xaa);
|
|
105
|
+
this.subprotocol_query_type = subprotocol_query_type;
|
|
106
|
+
}
|
|
107
|
+
get body() {
|
|
108
|
+
let body = Buffer.concat([Buffer.from([this.body_type]), this._body]);
|
|
109
|
+
body = Buffer.concat([body, Buffer.from([(0, MideaUtils_1.calculate)(body)])]);
|
|
110
|
+
body = Buffer.concat([body, Buffer.from([this.checksum(body)])]);
|
|
111
|
+
return body;
|
|
112
|
+
}
|
|
113
|
+
get _body() {
|
|
114
|
+
let body = Buffer.from([
|
|
115
|
+
6 + 2 + (this.subprotocol_body ? this.subprotocol_body.length : 0),
|
|
116
|
+
0x00,
|
|
117
|
+
0xff,
|
|
118
|
+
0xff,
|
|
119
|
+
this.subprotocol_query_type,
|
|
120
|
+
]);
|
|
121
|
+
if (this.subprotocol_body) {
|
|
122
|
+
body = Buffer.concat([body, this.subprotocol_body]);
|
|
123
|
+
}
|
|
124
|
+
return body;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
exports.MessageSubProtocol = MessageSubProtocol;
|
|
128
|
+
class MessageSubProtocolQuery extends MessageSubProtocol {
|
|
129
|
+
constructor(device_protocol_version, subprotocol_query_type) {
|
|
130
|
+
super(device_protocol_version, MideaMessage_1.MessageType.QUERY, subprotocol_query_type);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
exports.MessageSubProtocolQuery = MessageSubProtocolQuery;
|
|
134
|
+
class MessageSubProtocolSet extends MessageSubProtocol {
|
|
135
|
+
constructor(device_protocol_version) {
|
|
136
|
+
super(device_protocol_version, MideaMessage_1.MessageType.SET, 0x20);
|
|
137
|
+
this.power = false;
|
|
138
|
+
this.mode = 0;
|
|
139
|
+
this.target_temperature = 20.0;
|
|
140
|
+
this.fan_speed = 102;
|
|
141
|
+
this.boost_mode = false;
|
|
142
|
+
this.aux_heating = false;
|
|
143
|
+
this.dry = false;
|
|
144
|
+
this.eco_mode = false;
|
|
145
|
+
this.sleep_mode = false;
|
|
146
|
+
this.sn8_flag = false;
|
|
147
|
+
this.timer = false;
|
|
148
|
+
this.prompt_tone = false;
|
|
149
|
+
}
|
|
150
|
+
get subprotocol_body() {
|
|
151
|
+
const power = this.power ? 0x01 : 0x00;
|
|
152
|
+
const dry = this.dry && this.power ? 0x10 : 0;
|
|
153
|
+
const boost_mode = this.boost_mode ? 0x20 : 0;
|
|
154
|
+
const aux_heating = this.aux_heating ? 0x40 : 0;
|
|
155
|
+
const sleep_mode = this.sleep_mode ? 0x80 : 0;
|
|
156
|
+
const mode = this.mode === 0 ? 0 : this.mode < BB_AC_MODES.length ? BB_AC_MODES[this.mode] - 1 : 2;
|
|
157
|
+
const target_temperature = (this.target_temperature * 2 + 30) | 0;
|
|
158
|
+
const water_model_temperature_set = ((this.target_temperature - 1) * 2 + 50) | 0;
|
|
159
|
+
const fan_speed = this.fan_speed;
|
|
160
|
+
const eco = this.eco_mode ? 0x40 : 0;
|
|
161
|
+
const prompt_tone = this.prompt_tone ? 0x01 : 0;
|
|
162
|
+
const timer = this.sn8_flag && this.timer ? 0x04 : 0;
|
|
163
|
+
return Buffer.from([
|
|
164
|
+
boost_mode | power | dry,
|
|
165
|
+
aux_heating,
|
|
166
|
+
sleep_mode,
|
|
167
|
+
0x00,
|
|
168
|
+
0x00,
|
|
169
|
+
mode,
|
|
170
|
+
target_temperature,
|
|
171
|
+
fan_speed,
|
|
172
|
+
0x32,
|
|
173
|
+
0x00,
|
|
174
|
+
0x00,
|
|
175
|
+
0x00,
|
|
176
|
+
0x00,
|
|
177
|
+
0x00,
|
|
178
|
+
0x00,
|
|
179
|
+
0x01,
|
|
180
|
+
0x01,
|
|
181
|
+
0x00,
|
|
182
|
+
0x01,
|
|
183
|
+
water_model_temperature_set,
|
|
184
|
+
prompt_tone,
|
|
185
|
+
target_temperature,
|
|
186
|
+
0x32,
|
|
187
|
+
0x66,
|
|
188
|
+
0x00,
|
|
189
|
+
eco | timer,
|
|
190
|
+
0x00,
|
|
191
|
+
0x00,
|
|
192
|
+
0x00,
|
|
193
|
+
0x00,
|
|
194
|
+
0x00,
|
|
195
|
+
0x00,
|
|
196
|
+
0x00,
|
|
197
|
+
0x00,
|
|
198
|
+
0x00,
|
|
199
|
+
0x00,
|
|
200
|
+
0x08,
|
|
201
|
+
]);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
exports.MessageSubProtocolSet = MessageSubProtocolSet;
|
|
205
|
+
class MessageGeneralSet extends MessageACBase {
|
|
206
|
+
constructor(device_protocol_version) {
|
|
207
|
+
super(device_protocol_version, MideaMessage_1.MessageType.SET, 0x40);
|
|
208
|
+
this.power = false;
|
|
209
|
+
this.prompt_tone = true;
|
|
210
|
+
this.mode = 0;
|
|
211
|
+
this.target_temperature = 20.0;
|
|
212
|
+
this.fan_speed = 102;
|
|
213
|
+
this.swing_vertical = false;
|
|
214
|
+
this.swing_horizontal = false;
|
|
215
|
+
this.boost_mode = false;
|
|
216
|
+
this.smart_eye = false;
|
|
217
|
+
this.dry = false;
|
|
218
|
+
this.aux_heating = false;
|
|
219
|
+
this.eco_mode = false;
|
|
220
|
+
this.temp_fahrenheit = false;
|
|
221
|
+
this.sleep_mode = false;
|
|
222
|
+
this.natural_wind = false;
|
|
223
|
+
this.frost_protect = false;
|
|
224
|
+
this.comfort_mode = false;
|
|
225
|
+
}
|
|
226
|
+
get _body() {
|
|
227
|
+
// Byte1, Power, prompt_tone
|
|
228
|
+
const power = this.power ? 0x01 : 0x00;
|
|
229
|
+
const prompt_tone = this.prompt_tone ? 0x40 : 0x00;
|
|
230
|
+
// Byte2, mode target_temperature
|
|
231
|
+
const mode = (this.mode << 5) & 0xe0;
|
|
232
|
+
const target_temperature = ((this.target_temperature | 0) & 0xf) | ((Math.round(this.target_temperature * 2) | 0) % 2 !== 0 ? 0x10 : 0);
|
|
233
|
+
// Byte 3, fan_speed
|
|
234
|
+
const fan_speed = this.fan_speed & 0x7f;
|
|
235
|
+
// Byte 7, swing_mode
|
|
236
|
+
const swing_mode = 0x30 | (this.swing_vertical ? 0x0c : 0) | (this.swing_horizontal ? 0x03 : 0);
|
|
237
|
+
// Byte 8, turbo
|
|
238
|
+
const boost_mode = this.boost_mode ? 0x20 : 0;
|
|
239
|
+
// Byte 9 aux_heating eco_mode
|
|
240
|
+
const smart_eye = this.smart_eye ? 0x01 : 0;
|
|
241
|
+
const dry = this.dry ? 0x04 : 0;
|
|
242
|
+
const aux_heating = this.aux_heating ? 0x08 : 0;
|
|
243
|
+
const eco_mode = this.eco_mode ? 0x80 : 0;
|
|
244
|
+
// Byte 10 temp_fahrenheit
|
|
245
|
+
const temp_fahrenheit = this.temp_fahrenheit ? 0x04 : 0;
|
|
246
|
+
const sleep_mode = this.sleep_mode ? 0x01 : 0;
|
|
247
|
+
const boost_mode_1 = this.boost_mode ? 0x02 : 0;
|
|
248
|
+
// Byte 17 natural_wind
|
|
249
|
+
const natural_wind = this.natural_wind ? 0x40 : 0;
|
|
250
|
+
// Byte 21 frost_protect
|
|
251
|
+
const frost_protect = this.frost_protect ? 0x80 : 0;
|
|
252
|
+
// Byte 22 comfort_mode
|
|
253
|
+
const comfort_mode = this.comfort_mode ? 0x01 : 0;
|
|
254
|
+
return Buffer.from([
|
|
255
|
+
power | prompt_tone,
|
|
256
|
+
mode | target_temperature,
|
|
257
|
+
fan_speed,
|
|
258
|
+
0x00,
|
|
259
|
+
0x00,
|
|
260
|
+
0x00,
|
|
261
|
+
swing_mode,
|
|
262
|
+
boost_mode,
|
|
263
|
+
smart_eye | dry | aux_heating | eco_mode,
|
|
264
|
+
temp_fahrenheit | sleep_mode | boost_mode_1,
|
|
265
|
+
0x00,
|
|
266
|
+
0x00,
|
|
267
|
+
0x00,
|
|
268
|
+
0x00,
|
|
269
|
+
0x00,
|
|
270
|
+
0x00,
|
|
271
|
+
natural_wind,
|
|
272
|
+
0x00,
|
|
273
|
+
0x00,
|
|
274
|
+
0x00,
|
|
275
|
+
frost_protect,
|
|
276
|
+
comfort_mode,
|
|
277
|
+
]);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
exports.MessageGeneralSet = MessageGeneralSet;
|
|
281
|
+
class MessageNewProtocolSet extends MessageACBase {
|
|
282
|
+
constructor(device_protocol_version) {
|
|
283
|
+
super(device_protocol_version, MideaMessage_1.MessageType.SET, 0xb0);
|
|
284
|
+
this.prompt_tone = false;
|
|
285
|
+
}
|
|
286
|
+
get _body() {
|
|
287
|
+
let pack_count = 0;
|
|
288
|
+
let payload = Buffer.from([0x00]);
|
|
289
|
+
if (this.wind_swing_ud_angle !== undefined) {
|
|
290
|
+
pack_count += 1;
|
|
291
|
+
payload = Buffer.concat([
|
|
292
|
+
payload,
|
|
293
|
+
MideaMessage_1.NewProtocolMessageBody.packet(NewProtocolTags.WIND_SWING_UD_ANGLE, Buffer.from([this.wind_swing_ud_angle])),
|
|
294
|
+
]);
|
|
295
|
+
}
|
|
296
|
+
if (this.wind_swing_lr_angle !== undefined) {
|
|
297
|
+
pack_count += 1;
|
|
298
|
+
payload = Buffer.concat([
|
|
299
|
+
payload,
|
|
300
|
+
MideaMessage_1.NewProtocolMessageBody.packet(NewProtocolTags.WIND_SWING_LR_ANGLE, Buffer.from([this.wind_swing_lr_angle])),
|
|
301
|
+
]);
|
|
302
|
+
}
|
|
303
|
+
if (this.breezeless !== undefined) {
|
|
304
|
+
pack_count += 1;
|
|
305
|
+
payload = Buffer.concat([
|
|
306
|
+
payload,
|
|
307
|
+
MideaMessage_1.NewProtocolMessageBody.packet(NewProtocolTags.BREEZELESS, Buffer.from([this.breezeless ? 0x01 : 0x00])),
|
|
308
|
+
]);
|
|
309
|
+
}
|
|
310
|
+
if (this.indirect_wind !== undefined) {
|
|
311
|
+
pack_count += 1;
|
|
312
|
+
payload = Buffer.concat([
|
|
313
|
+
payload,
|
|
314
|
+
MideaMessage_1.NewProtocolMessageBody.packet(NewProtocolTags.INDIRECT_WIND, Buffer.from([this.indirect_wind ? 0x02 : 0x01])),
|
|
315
|
+
]);
|
|
316
|
+
}
|
|
317
|
+
if (this.screen_display !== undefined) {
|
|
318
|
+
pack_count += 1;
|
|
319
|
+
payload = Buffer.concat([
|
|
320
|
+
payload,
|
|
321
|
+
MideaMessage_1.NewProtocolMessageBody.packet(NewProtocolTags.SCREEN_DISPLAY, Buffer.from([this.screen_display ? 0x64 : 0x00])),
|
|
322
|
+
]);
|
|
323
|
+
}
|
|
324
|
+
if (this.fresh_air_1 !== undefined && this.fresh_air_1.length === 2) {
|
|
325
|
+
pack_count += 1;
|
|
326
|
+
const fresh_air_power = this.fresh_air_1[0] > 0 ? 2 : 1;
|
|
327
|
+
const fresh_air_fan_speed = this.fresh_air_1[1];
|
|
328
|
+
payload = Buffer.concat([
|
|
329
|
+
payload,
|
|
330
|
+
MideaMessage_1.NewProtocolMessageBody.packet(NewProtocolTags.FRESH_AIR_1, Buffer.from([fresh_air_power, fresh_air_fan_speed, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00])),
|
|
331
|
+
]);
|
|
332
|
+
}
|
|
333
|
+
if (this.fresh_air_2 !== undefined && this.fresh_air_2.length === 2) {
|
|
334
|
+
pack_count += 1;
|
|
335
|
+
const fresh_air_power = this.fresh_air_2[0] > 0 ? 1 : 0;
|
|
336
|
+
const fresh_air_fan_speed = this.fresh_air_2[1];
|
|
337
|
+
payload = Buffer.concat([
|
|
338
|
+
payload,
|
|
339
|
+
MideaMessage_1.NewProtocolMessageBody.packet(NewProtocolTags.FRESH_AIR_2, Buffer.from([fresh_air_power, fresh_air_fan_speed, 0xff])),
|
|
340
|
+
]);
|
|
341
|
+
}
|
|
342
|
+
pack_count += 1;
|
|
343
|
+
payload = Buffer.concat([
|
|
344
|
+
payload,
|
|
345
|
+
MideaMessage_1.NewProtocolMessageBody.packet(NewProtocolTags.PROMPT_TONE, Buffer.from([this.prompt_tone ? 0x01 : 0x00])),
|
|
346
|
+
]);
|
|
347
|
+
payload[0] = pack_count;
|
|
348
|
+
return payload;
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
exports.MessageNewProtocolSet = MessageNewProtocolSet;
|
|
352
|
+
class XA0MessageBody extends MideaMessage_1.MessageBody {
|
|
353
|
+
constructor(body) {
|
|
354
|
+
super(body);
|
|
355
|
+
this.power = (body[1] & 0x1) > 0;
|
|
356
|
+
this.target_temperature = ((body[1] & 0x3e) >> 1) - 4 + 16.0 + ((body[1] & 0x40) > 0 ? 0.5 : 0.0);
|
|
357
|
+
this.mode = (body[2] & 0xe0) >> 5;
|
|
358
|
+
this.fan_speed = body[3] & 0x7f;
|
|
359
|
+
this.fan_auto = this.fan_speed > 100;
|
|
360
|
+
this.swing_vertical = (body[7] & 0xc) > 0;
|
|
361
|
+
this.swing_horizontal = (body[7] & 0x3) > 0;
|
|
362
|
+
this.boost_mode = (body[8] & 0x20) > 0 || (body[10] & 0x2) > 0;
|
|
363
|
+
this.smart_eye = (body[9] & 0x01) > 0;
|
|
364
|
+
this.dry = (body[9] & 0x04) > 0;
|
|
365
|
+
this.aux_heating = (body[9] & 0x08) > 0;
|
|
366
|
+
this.eco_mode = (body[9] & 0x10) > 0;
|
|
367
|
+
this.sleep_mode = (body[10] & 0x01) > 0;
|
|
368
|
+
this.natural_wind = (body[10] & 0x40) > 0;
|
|
369
|
+
this.full_dust = (body[13] & 0x20) > 0;
|
|
370
|
+
this.comfort_mode = body.length > 16 ? (body[14] & 0x1) > 0 : false;
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
class XA1MessageBody extends MideaMessage_1.MessageBody {
|
|
374
|
+
constructor(body) {
|
|
375
|
+
super(body);
|
|
376
|
+
if (body[13] !== 0xff) {
|
|
377
|
+
const temp_integer = ((body[13] - 50) / 2) | 0;
|
|
378
|
+
const temp_decimal = body.length > 20 ? (body[18] & 0xf) * 0.1 : 0;
|
|
379
|
+
if (body[13] > 49) {
|
|
380
|
+
this.indoor_temperature = temp_integer + temp_decimal;
|
|
381
|
+
}
|
|
382
|
+
else {
|
|
383
|
+
this.indoor_temperature = temp_integer - temp_decimal;
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
if (body[14] === 0xff) {
|
|
387
|
+
this.outdoor_temperature = undefined;
|
|
388
|
+
}
|
|
389
|
+
else {
|
|
390
|
+
const temp_integer = ((body[14] - 50) / 2) | 0;
|
|
391
|
+
const temp_decimal = body.length > 20 ? ((body[18] & 0xf0) >> 4) * 0.1 : 0;
|
|
392
|
+
if (body[14] > 49) {
|
|
393
|
+
this.outdoor_temperature = temp_integer + temp_decimal;
|
|
394
|
+
}
|
|
395
|
+
else {
|
|
396
|
+
this.outdoor_temperature = temp_integer - temp_decimal;
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
this.indoor_humidity = body[17];
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
class XBXMessageBody extends MideaMessage_1.NewProtocolMessageBody {
|
|
403
|
+
constructor(body, body_type) {
|
|
404
|
+
super(body, body_type);
|
|
405
|
+
const params = this.parse();
|
|
406
|
+
if (NewProtocolTags.WIND_SWING_LR_ANGLE in params) {
|
|
407
|
+
this.wind_swing_lr_angle = params[NewProtocolTags.WIND_SWING_LR_ANGLE][0];
|
|
408
|
+
}
|
|
409
|
+
if (NewProtocolTags.WIND_SWING_UD_ANGLE in params) {
|
|
410
|
+
this.wind_swing_ud_angle = params[NewProtocolTags.WIND_SWING_UD_ANGLE][0];
|
|
411
|
+
}
|
|
412
|
+
if (NewProtocolTags.INDIRECT_WIND in params) {
|
|
413
|
+
this.indirect_wind = params[NewProtocolTags.INDIRECT_WIND][0] === 0x02;
|
|
414
|
+
}
|
|
415
|
+
if (NewProtocolTags.INDOOR_HUMIDITY in params) {
|
|
416
|
+
this.indoor_humidity = params[NewProtocolTags.INDOOR_HUMIDITY][0];
|
|
417
|
+
}
|
|
418
|
+
if (NewProtocolTags.BREEZELESS in params) {
|
|
419
|
+
this.breezeless = params[NewProtocolTags.BREEZELESS][0] === 1;
|
|
420
|
+
}
|
|
421
|
+
if (NewProtocolTags.SCREEN_DISPLAY in params) {
|
|
422
|
+
this.screen_display = params[NewProtocolTags.SCREEN_DISPLAY][0] > 0;
|
|
423
|
+
this.screen_display_new = true;
|
|
424
|
+
}
|
|
425
|
+
if (NewProtocolTags.FRESH_AIR_1 in params) {
|
|
426
|
+
this.fresh_air_1 = true;
|
|
427
|
+
const data = params[NewProtocolTags.FRESH_AIR_1];
|
|
428
|
+
this.fresh_air_power = data[0] === 0x02;
|
|
429
|
+
this.fresh_air_fan_speed = data[1];
|
|
430
|
+
}
|
|
431
|
+
if (NewProtocolTags.FRESH_AIR_2 in params) {
|
|
432
|
+
this.fresh_air_2 = true;
|
|
433
|
+
const data = params[NewProtocolTags.FRESH_AIR_2];
|
|
434
|
+
this.fresh_air_power = data[0] > 0;
|
|
435
|
+
this.fresh_air_fan_speed = data[1];
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
class XC0MessageBody extends MideaMessage_1.MessageBody {
|
|
440
|
+
constructor(body) {
|
|
441
|
+
super(body);
|
|
442
|
+
this.power = (body[1] & 0x1) > 0;
|
|
443
|
+
this.mode = (body[2] & 0xe0) >> 5;
|
|
444
|
+
this.target_temperature = (body[2] & 0x0f) + 16.0 + ((body[2] & 0x10) > 0 ? 0.5 : 0.0);
|
|
445
|
+
this.fan_speed = body[3] & 0x7f;
|
|
446
|
+
this.fan_auto = this.fan_speed > 100;
|
|
447
|
+
this.swing_vertical = (body[7] & 0x0c) > 0;
|
|
448
|
+
this.swing_horizontal = (body[7] & 0x03) > 0;
|
|
449
|
+
this.boost_mode = (body[8] & 0x20) > 0 || (body[10] & 0x2) > 0;
|
|
450
|
+
this.smart_eye = (body[8] & 0x40) > 0;
|
|
451
|
+
this.natural_wind = (body[9] & 0x2) > 0;
|
|
452
|
+
this.dry = (body[9] & 0x4) > 0;
|
|
453
|
+
this.eco_mode = (body[9] & 0x10) > 0;
|
|
454
|
+
this.aux_heating = (body[9] & 0x08) > 0;
|
|
455
|
+
this.temp_fahrenheit = (body[10] & 0x04) > 0;
|
|
456
|
+
this.sleep_mode = (body[10] & 0x01) > 0;
|
|
457
|
+
if (body[11] !== 0xff) {
|
|
458
|
+
const temp_integer = ((body[11] - 50) / 2) | 0;
|
|
459
|
+
const temp_decimal = (body[15] & 0x0f) * 0.1;
|
|
460
|
+
if (body[11] > 49) {
|
|
461
|
+
this.indoor_temperature = temp_integer + temp_decimal;
|
|
462
|
+
}
|
|
463
|
+
else {
|
|
464
|
+
this.indoor_temperature = temp_integer - temp_decimal;
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
if (body[12] === 0xff) {
|
|
468
|
+
this.outdoor_temperature = undefined;
|
|
469
|
+
}
|
|
470
|
+
else {
|
|
471
|
+
const temp_integer = ((body[12] - 50) / 2) | 0;
|
|
472
|
+
const temp_decimal = ((body[15] & 0xf0) >> 4) * 0.1;
|
|
473
|
+
if (body[12] > 49) {
|
|
474
|
+
this.outdoor_temperature = temp_integer + temp_decimal;
|
|
475
|
+
}
|
|
476
|
+
else {
|
|
477
|
+
this.outdoor_temperature = temp_integer - temp_decimal;
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
this.full_dust = (body[13] & 0x20) > 0;
|
|
481
|
+
this.screen_display = ((body[14] >> 4) & 0x7) !== 0x07 && this.power;
|
|
482
|
+
this.frost_protect = body.length > 23 ? (body[21] & 0x80) > 0 : false;
|
|
483
|
+
this.comfort_mode = body.length > 24 ? (body[22] & 0x1) > 0 : false;
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
class XC1MessageBody extends MideaMessage_1.MessageBody {
|
|
487
|
+
constructor(body, analysis_method = 3) {
|
|
488
|
+
super(body);
|
|
489
|
+
if (body[3] === 0x44) {
|
|
490
|
+
this.total_energy_consumption = XC1MessageBody.parse_consumption(analysis_method, body[4], body[5], body[6], body[7]);
|
|
491
|
+
this.current_energy_consumption = XC1MessageBody.parse_consumption(analysis_method, body[12], body[13], body[14], body[15]);
|
|
492
|
+
this.realtime_power = XC1MessageBody.parse_power(analysis_method, body[16], body[17], body[18]);
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
static parse_power(analysis_method, byte1, byte2, byte3) {
|
|
496
|
+
if (analysis_method === 1) {
|
|
497
|
+
return byte1 + byte2 / 100 + byte3 / 10000;
|
|
498
|
+
}
|
|
499
|
+
else if (analysis_method === 2) {
|
|
500
|
+
return ((byte1 << 16) + (byte2 << 8) + byte3) / 1000;
|
|
501
|
+
}
|
|
502
|
+
else {
|
|
503
|
+
return (byte1 * 10000 + byte2 * 100 + byte3) / 10;
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
static parse_consumption(analysis_method, byte1, byte2, byte3, byte4) {
|
|
507
|
+
if (analysis_method === 1) {
|
|
508
|
+
return byte1 * 10000 + byte2 * 100 + byte3 + byte4 / 100;
|
|
509
|
+
}
|
|
510
|
+
else if (analysis_method === 2) {
|
|
511
|
+
return ((byte1 << 32) + (byte2 << 16) + (byte3 << 8) + byte4) / 1000;
|
|
512
|
+
}
|
|
513
|
+
else {
|
|
514
|
+
return (byte1 * 1000000 + byte2 * 10000 + byte3 * 100 + byte4) / 100;
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
class XBBMessageBody extends MideaMessage_1.MessageBody {
|
|
519
|
+
constructor(body) {
|
|
520
|
+
super(body);
|
|
521
|
+
const subprotocol_head = body.subarray(0, 6);
|
|
522
|
+
const subprotocol_body = body.subarray(6, body.length);
|
|
523
|
+
const data_type = subprotocol_head[subprotocol_head.length - 1];
|
|
524
|
+
const subprotocol_body_len = subprotocol_body.length;
|
|
525
|
+
if (data_type === 0x20 || data_type === 0x11) {
|
|
526
|
+
this.power = (subprotocol_body[0] & 0x1) > 0;
|
|
527
|
+
this.dry = (subprotocol_body[0] & 0x10) > 0;
|
|
528
|
+
this.boost_mode = (subprotocol_body[0] & 0x20) > 0;
|
|
529
|
+
this.aux_heating = (subprotocol_body[1] & 0x40) > 0;
|
|
530
|
+
this.sleep_mode = (subprotocol_body[2] & 0x80) > 0;
|
|
531
|
+
this.mode = BB_AC_MODES.indexOf(subprotocol_body[5] + 1);
|
|
532
|
+
if (this.mode === -1) {
|
|
533
|
+
this.mode = 0;
|
|
534
|
+
}
|
|
535
|
+
this.target_temperature = (subprotocol_body[6] - 30) / 2;
|
|
536
|
+
this.fan_speed = subprotocol_body[7];
|
|
537
|
+
this.fan_auto = this.fan_speed > 100;
|
|
538
|
+
this.timer = subprotocol_body_len > 27 ? (subprotocol_body[25] & 0x04) > 0 : false;
|
|
539
|
+
this.eco_mode = subprotocol_body_len > 27 ? (subprotocol_body[25] & 0x40) > 0 : false;
|
|
540
|
+
}
|
|
541
|
+
else if (data_type === 0x10) {
|
|
542
|
+
if ((subprotocol_body[8] & 0x80) === 0x80) {
|
|
543
|
+
this.indoor_temperature = ((0 - (~(subprotocol_body[7] + subprotocol_body[8] * 256) + 1)) & 0xffff) / 100;
|
|
544
|
+
}
|
|
545
|
+
else {
|
|
546
|
+
this.indoor_temperature = (subprotocol_body[7] + subprotocol_body[8] * 256) / 100;
|
|
547
|
+
}
|
|
548
|
+
this.indoor_humidity = subprotocol_body[30];
|
|
549
|
+
this.sn8_flag = subprotocol_body[80] === 0x31;
|
|
550
|
+
}
|
|
551
|
+
else if (data_type === 0x30) {
|
|
552
|
+
if ((subprotocol_body[6] & 0x80) === 0x80) {
|
|
553
|
+
this.outdoor_temperature = ((0 - (~(subprotocol_body[5] + subprotocol_body[6] * 256) + 1)) & 0xffff) / 100;
|
|
554
|
+
}
|
|
555
|
+
else {
|
|
556
|
+
this.outdoor_temperature = (subprotocol_body[5] + subprotocol_body[6] * 256) / 100;
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
class MessageACResponse extends MideaMessage_1.MessageResponse {
|
|
562
|
+
constructor(message, power_analysis_method = 3) {
|
|
563
|
+
super(message);
|
|
564
|
+
this.message = message;
|
|
565
|
+
if (this.message_type === MideaMessage_1.MessageType.NOTIFY2 && this.body_type === 0xa0) {
|
|
566
|
+
this.set_body(new XA0MessageBody(this.body));
|
|
567
|
+
}
|
|
568
|
+
else if (this.message_type === MideaMessage_1.MessageType.NOTIFY1 && this.body_type === 0xa1) {
|
|
569
|
+
this.set_body(new XA1MessageBody(this.body));
|
|
570
|
+
}
|
|
571
|
+
else if ([MideaMessage_1.MessageType.QUERY, MideaMessage_1.MessageType.SET, MideaMessage_1.MessageType.NOTIFY2].includes(this.message_type) &&
|
|
572
|
+
[0xb0, 0xb1, 0xb5].includes(this.body_type)) {
|
|
573
|
+
this.set_body(new XBXMessageBody(this.body, this.body_type));
|
|
574
|
+
}
|
|
575
|
+
else if ([MideaMessage_1.MessageType.QUERY, MideaMessage_1.MessageType.SET].includes(this.message_type) && this.body_type === 0xc0) {
|
|
576
|
+
this.set_body(new XC0MessageBody(this.body));
|
|
577
|
+
}
|
|
578
|
+
else if (this.message_type === MideaMessage_1.MessageType.QUERY && this.body_type === 0xc1) {
|
|
579
|
+
this.set_body(new XC1MessageBody(this.body, power_analysis_method));
|
|
580
|
+
}
|
|
581
|
+
else if ([MideaMessage_1.MessageType.QUERY, MideaMessage_1.MessageType.SET, MideaMessage_1.MessageType.NOTIFY2].includes(this.message_type) &&
|
|
582
|
+
this.body_type === 0xbb &&
|
|
583
|
+
this.body.length >= 21) {
|
|
584
|
+
this.used_subprotocol = true;
|
|
585
|
+
this.set_body(new XBBMessageBody(this.body));
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
exports.MessageACResponse = MessageACResponse;
|
|
590
590
|
//# sourceMappingURL=MideaACMessage.js.map
|