homebridge-midea-platform 1.2.0-beta.8 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +5 -2
- package/README.md +2 -2
- package/dist/accessory/AccessoryFactory.d.ts +14 -15
- package/dist/accessory/AccessoryFactory.js +34 -40
- package/dist/accessory/AccessoryFactory.js.map +1 -1
- package/dist/accessory/AirConditionerAccessory.d.ts +98 -99
- package/dist/accessory/AirConditionerAccessory.js +666 -662
- package/dist/accessory/AirConditionerAccessory.js.map +1 -1
- package/dist/accessory/BaseAccessory.d.ts +11 -12
- package/dist/accessory/BaseAccessory.js +21 -21
- package/dist/accessory/BaseAccessory.js.map +1 -1
- package/dist/accessory/DehumidifierAccessory.d.ts +45 -46
- package/dist/accessory/DehumidifierAccessory.js +343 -344
- package/dist/accessory/DehumidifierAccessory.js.map +1 -1
- package/dist/accessory/DishwasherAccessory.d.ts +30 -31
- package/dist/accessory/DishwasherAccessory.js +59 -63
- package/dist/accessory/DishwasherAccessory.js.map +1 -1
- package/dist/accessory/ElectricWaterHeaterAccessory.d.ts +44 -45
- package/dist/accessory/ElectricWaterHeaterAccessory.js +172 -176
- package/dist/accessory/ElectricWaterHeaterAccessory.js.map +1 -1
- package/dist/accessory/FanAccessory.d.ts +39 -40
- package/dist/accessory/FanAccessory.js +120 -123
- package/dist/accessory/FanAccessory.js.map +1 -1
- package/dist/accessory/FrontLoadWasherAccessory.d.ts +30 -31
- package/dist/accessory/FrontLoadWasherAccessory.js +63 -66
- package/dist/accessory/FrontLoadWasherAccessory.js.map +1 -1
- package/dist/accessory/GasWaterHeaterAccessory.d.ts +51 -52
- package/dist/accessory/GasWaterHeaterAccessory.js +217 -216
- package/dist/accessory/GasWaterHeaterAccessory.js.map +1 -1
- package/dist/accessory/{HeatPumpWifiControllerAccessory.d.ts → HeatPumpWiFiControllerAccessory.d.ts} +34 -35
- package/dist/accessory/{HeatPumpWifiControllerAccessory.js → HeatPumpWiFiControllerAccessory.js} +55 -36
- package/dist/accessory/HeatPumpWiFiControllerAccessory.js.map +1 -0
- package/dist/core/MideaCloud.d.ts +34 -36
- package/dist/core/MideaCloud.js +349 -350
- package/dist/core/MideaCloud.js.map +1 -1
- package/dist/core/MideaConstants.d.ts +51 -52
- package/dist/core/MideaConstants.js +56 -59
- package/dist/core/MideaConstants.js.map +1 -1
- package/dist/core/MideaDevice.d.ts +75 -78
- package/dist/core/MideaDevice.js +430 -420
- package/dist/core/MideaDevice.js.map +1 -1
- package/dist/core/MideaDiscover.d.ts +34 -36
- package/dist/core/MideaDiscover.js +208 -212
- package/dist/core/MideaDiscover.js.map +1 -1
- package/dist/core/MideaMessage.d.ts +75 -76
- package/dist/core/MideaMessage.js +185 -184
- package/dist/core/MideaMessage.js.map +1 -1
- package/dist/core/MideaPacketBuilder.d.ts +9 -11
- package/dist/core/MideaPacketBuilder.js +60 -60
- package/dist/core/MideaPacketBuilder.js.map +1 -1
- package/dist/core/MideaSecurity.d.ts +62 -64
- package/dist/core/MideaSecurity.js +241 -251
- package/dist/core/MideaSecurity.js.map +1 -1
- package/dist/core/MideaUtils.d.ts +31 -33
- package/dist/core/MideaUtils.js +178 -181
- package/dist/core/MideaUtils.js.map +1 -1
- package/dist/devices/DeviceFactory.d.ts +14 -15
- package/dist/devices/DeviceFactory.js +34 -40
- package/dist/devices/DeviceFactory.js.map +1 -1
- package/dist/devices/a1/MideaA1Device.d.ts +75 -77
- package/dist/devices/a1/MideaA1Device.js +142 -145
- package/dist/devices/a1/MideaA1Device.js.map +1 -1
- package/dist/devices/a1/MideaA1Message.d.ts +39 -41
- package/dist/devices/a1/MideaA1Message.js +219 -198
- package/dist/devices/a1/MideaA1Message.js.map +1 -1
- package/dist/devices/ac/MideaACDevice.d.ts +105 -107
- package/dist/devices/ac/MideaACDevice.js +417 -400
- package/dist/devices/ac/MideaACDevice.js.map +1 -1
- package/dist/devices/ac/MideaACMessage.d.ts +97 -96
- package/dist/devices/ac/MideaACMessage.js +724 -621
- package/dist/devices/ac/MideaACMessage.js.map +1 -1
- package/dist/devices/c3/MideaC3Device.d.ts +73 -75
- package/dist/devices/c3/MideaC3Device.js +249 -255
- package/dist/devices/c3/MideaC3Device.js.map +1 -1
- package/dist/devices/c3/MideaC3Message.d.ts +81 -80
- package/dist/devices/c3/MideaC3Message.js +190 -152
- package/dist/devices/c3/MideaC3Message.js.map +1 -1
- package/dist/devices/db/MideaDBDevice.d.ts +28 -30
- package/dist/devices/db/MideaDBDevice.js +94 -100
- package/dist/devices/db/MideaDBDevice.js.map +1 -1
- package/dist/devices/db/MideaDBMessage.d.ts +31 -33
- package/dist/devices/db/MideaDBMessage.js +101 -101
- package/dist/devices/db/MideaDBMessage.js.map +1 -1
- package/dist/devices/e1/MideaE1Device.d.ts +55 -57
- package/dist/devices/e1/MideaE1Device.js +122 -128
- package/dist/devices/e1/MideaE1Device.js.map +1 -1
- package/dist/devices/e1/MideaE1Message.d.ts +27 -29
- package/dist/devices/e1/MideaE1Message.js +128 -107
- package/dist/devices/e1/MideaE1Message.js.map +1 -1
- package/dist/devices/e2/MideaE2Device.d.ts +43 -45
- package/dist/devices/e2/MideaE2Device.js +124 -129
- package/dist/devices/e2/MideaE2Device.js.map +1 -1
- package/dist/devices/e2/MideaE2Message.d.ts +34 -34
- package/dist/devices/e2/MideaE2Message.js +143 -132
- package/dist/devices/e2/MideaE2Message.js.map +1 -1
- package/dist/devices/e3/MideaE3Device.d.ts +42 -44
- package/dist/devices/e3/MideaE3Device.js +132 -137
- package/dist/devices/e3/MideaE3Device.js.map +1 -1
- package/dist/devices/e3/MideaE3Message.d.ts +51 -52
- package/dist/devices/e3/MideaE3Message.js +144 -136
- package/dist/devices/e3/MideaE3Message.js.map +1 -1
- package/dist/devices/fa/MideaFADevice.d.ts +35 -37
- package/dist/devices/fa/MideaFADevice.js +102 -106
- package/dist/devices/fa/MideaFADevice.js.map +1 -1
- package/dist/devices/fa/MideaFAMessage.d.ts +38 -39
- package/dist/devices/fa/MideaFAMessage.js +108 -98
- package/dist/devices/fa/MideaFAMessage.js.map +1 -1
- package/dist/index.d.ts +6 -7
- package/dist/index.js +8 -6
- package/dist/index.js.map +1 -1
- package/dist/platform.d.ts +61 -61
- package/dist/platform.js +232 -212
- package/dist/platform.js.map +1 -1
- package/dist/platformUtils.d.ts +116 -117
- package/dist/platformUtils.js +107 -110
- package/dist/platformUtils.js.map +1 -1
- package/dist/settings.d.ts +8 -9
- package/dist/settings.js +8 -11
- package/dist/settings.js.map +1 -1
- package/docs/download_lua.md +9 -0
- package/eslint.config.js +43 -0
- package/homebridge-ui/public/js/bootstrap.min.js +1179 -1
- package/homebridge-ui/{server.js → server.cjs} +30 -30
- package/package.json +21 -31
- package/.eslintignore +0 -3
- package/.husky/pre-commit +0 -5
- package/.prettierrc +0 -19
- package/dist/accessory/AccessoryFactory.d.ts.map +0 -1
- package/dist/accessory/AirConditionerAccessory.d.ts.map +0 -1
- package/dist/accessory/BaseAccessory.d.ts.map +0 -1
- package/dist/accessory/DehumidifierAccessory.d.ts.map +0 -1
- package/dist/accessory/DishwasherAccessory.d.ts.map +0 -1
- package/dist/accessory/ElectricWaterHeaterAccessory.d.ts.map +0 -1
- package/dist/accessory/FanAccessory.d.ts.map +0 -1
- package/dist/accessory/FrontLoadWasherAccessory.d.ts.map +0 -1
- package/dist/accessory/GasWaterHeaterAccessory.d.ts.map +0 -1
- package/dist/accessory/HeatPumpWifiControllerAccessory.d.ts.map +0 -1
- package/dist/accessory/HeatPumpWifiControllerAccessory.js.map +0 -1
- package/dist/core/MideaCloud.d.ts.map +0 -1
- package/dist/core/MideaConstants.d.ts.map +0 -1
- package/dist/core/MideaDevice.d.ts.map +0 -1
- package/dist/core/MideaDiscover.d.ts.map +0 -1
- package/dist/core/MideaMessage.d.ts.map +0 -1
- package/dist/core/MideaPacketBuilder.d.ts.map +0 -1
- package/dist/core/MideaSecurity.d.ts.map +0 -1
- package/dist/core/MideaUtils.d.ts.map +0 -1
- package/dist/devices/DeviceFactory.d.ts.map +0 -1
- package/dist/devices/a1/MideaA1Device.d.ts.map +0 -1
- package/dist/devices/a1/MideaA1Message.d.ts.map +0 -1
- package/dist/devices/ac/MideaACDevice.d.ts.map +0 -1
- package/dist/devices/ac/MideaACMessage.d.ts.map +0 -1
- package/dist/devices/c3/MideaC3Device.d.ts.map +0 -1
- package/dist/devices/c3/MideaC3Message.d.ts.map +0 -1
- package/dist/devices/db/MideaDBDevice.d.ts.map +0 -1
- package/dist/devices/db/MideaDBMessage.d.ts.map +0 -1
- package/dist/devices/e1/MideaE1Device.d.ts.map +0 -1
- package/dist/devices/e1/MideaE1Message.d.ts.map +0 -1
- package/dist/devices/e2/MideaE2Device.d.ts.map +0 -1
- package/dist/devices/e2/MideaE2Message.d.ts.map +0 -1
- package/dist/devices/e3/MideaE3Device.d.ts.map +0 -1
- package/dist/devices/e3/MideaE3Message.d.ts.map +0 -1
- package/dist/devices/fa/MideaFADevice.d.ts.map +0 -1
- package/dist/devices/fa/MideaFAMessage.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/platform.d.ts.map +0 -1
- package/dist/platformUtils.d.ts.map +0 -1
- package/dist/settings.d.ts.map +0 -1
|
@@ -1,401 +1,418 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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
|
|
88
|
-
new
|
|
89
|
-
new
|
|
90
|
-
];
|
|
91
|
-
}
|
|
92
|
-
return [
|
|
93
|
-
new
|
|
94
|
-
new
|
|
95
|
-
new
|
|
96
|
-
];
|
|
97
|
-
}
|
|
98
|
-
process_message(msg) {
|
|
99
|
-
const message = new
|
|
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
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
messageToSend.NEW_PROTOCOL.
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
messageToSend.NEW_PROTOCOL
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
messageToSend.
|
|
278
|
-
messageToSend.
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
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
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
this.
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
this.
|
|
349
|
-
|
|
350
|
-
this.
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
await this.build_send(message);
|
|
364
|
-
}
|
|
365
|
-
async
|
|
366
|
-
this.logger.info(`[${this.name}] Set
|
|
367
|
-
const message = new
|
|
368
|
-
|
|
369
|
-
this.attributes.
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
this.
|
|
385
|
-
message
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
this.
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
this.
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
}
|
|
400
|
-
|
|
1
|
+
import MideaDevice from '../../core/MideaDevice.js';
|
|
2
|
+
import { MessageACResponse, MessageGeneralSet, MessageNewProtocolQuery, MessageNewProtocolSet, MessagePowerQuery, MessageQuery, MessageSubProtocolQuery, MessageSubProtocolSet, MessageSwitchDisplay, } from './MideaACMessage.js';
|
|
3
|
+
import { SwingAngle } from '../../platformUtils.js';
|
|
4
|
+
export default class MideaACDevice extends MideaDevice {
|
|
5
|
+
FRESH_AIR_FAN_SPEEDS = {
|
|
6
|
+
0: 'Off',
|
|
7
|
+
20: 'Silent',
|
|
8
|
+
40: 'Low',
|
|
9
|
+
60: 'Medium',
|
|
10
|
+
80: 'High',
|
|
11
|
+
100: 'Full',
|
|
12
|
+
};
|
|
13
|
+
FRESH_AIR_FAN_SPEEDS_REVERSE = {
|
|
14
|
+
100: 'Full',
|
|
15
|
+
80: 'High',
|
|
16
|
+
60: 'Medium',
|
|
17
|
+
40: 'Low',
|
|
18
|
+
20: 'Silent',
|
|
19
|
+
0: 'Off',
|
|
20
|
+
};
|
|
21
|
+
attributes;
|
|
22
|
+
fresh_air_version;
|
|
23
|
+
used_subprotocol = false;
|
|
24
|
+
bb_sn8_flag = false;
|
|
25
|
+
bb_timer = false;
|
|
26
|
+
DEFAULT_POWER_ANALYSIS_METHOD = 2;
|
|
27
|
+
power_analysis_method;
|
|
28
|
+
alternate_switch_display = false;
|
|
29
|
+
last_fan_speed = 0;
|
|
30
|
+
defaultFahrenheit;
|
|
31
|
+
defaultScreenOff;
|
|
32
|
+
/*********************************************************************
|
|
33
|
+
* Constructor initializes all the attributes. We set some to invalid
|
|
34
|
+
* values so that they are detected as "changed" on the first status
|
|
35
|
+
* refresh... and passed back to the Homebridge/HomeKit accessory callback
|
|
36
|
+
* function to set their initial values.
|
|
37
|
+
*/
|
|
38
|
+
constructor(logger, device_info, config, deviceConfig) {
|
|
39
|
+
super(logger, device_info, config, deviceConfig);
|
|
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, // invalid
|
|
48
|
+
WIND_SWING_UD_ANGLE: 0,
|
|
49
|
+
SWING_HORIZONTAL: undefined, // invalid
|
|
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, // invalid
|
|
62
|
+
SCREEN_DISPLAY_NEW: false,
|
|
63
|
+
FULL_DUST: false,
|
|
64
|
+
INDOOR_TEMPERATURE: undefined, // invalid
|
|
65
|
+
OUTDOOR_TEMPERATURE: undefined, // invalid
|
|
66
|
+
INDIRECT_WIND: false,
|
|
67
|
+
INDOOR_HUMIDITY: undefined, // invalid
|
|
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, // invalid
|
|
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 MessageSubProtocolQuery(this.device_protocol_version, 0x10),
|
|
88
|
+
new MessageSubProtocolQuery(this.device_protocol_version, 0x11),
|
|
89
|
+
new MessageSubProtocolQuery(this.device_protocol_version, 0x30),
|
|
90
|
+
];
|
|
91
|
+
}
|
|
92
|
+
return [
|
|
93
|
+
new MessageQuery(this.device_protocol_version),
|
|
94
|
+
new MessageNewProtocolQuery(this.device_protocol_version, this.alternate_switch_display),
|
|
95
|
+
new MessagePowerQuery(this.device_protocol_version),
|
|
96
|
+
];
|
|
97
|
+
}
|
|
98
|
+
process_message(msg) {
|
|
99
|
+
const message = new 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 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 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
|
+
const messageToSend = {
|
|
209
|
+
GENERAL: undefined,
|
|
210
|
+
NEW_PROTOCOL: undefined,
|
|
211
|
+
SWITCH_DISPLAY: undefined,
|
|
212
|
+
};
|
|
213
|
+
try {
|
|
214
|
+
for (const [k, v] of Object.entries(attributes)) {
|
|
215
|
+
// not sensor data
|
|
216
|
+
if (![
|
|
217
|
+
'INDOOR_TEMPERATURE',
|
|
218
|
+
'OUTDOOR_TEMPERATURE',
|
|
219
|
+
'INDOOR_HUMIDITY',
|
|
220
|
+
'FULL_DUST',
|
|
221
|
+
'TOTAL_ENERGY_CONSUMPTION',
|
|
222
|
+
'CURRENT_ENERGY_CONSUMPTION',
|
|
223
|
+
'REALTIME_POWER',
|
|
224
|
+
].includes(k)) {
|
|
225
|
+
if (v === this.attributes[k]) {
|
|
226
|
+
this.logger.info(`[${this.name}] Attribute ${k} already set to ${v}`);
|
|
227
|
+
continue;
|
|
228
|
+
}
|
|
229
|
+
this.logger.info(`[${this.name}] Set device attribute ${k} to: ${v}`);
|
|
230
|
+
this.attributes[k] = v;
|
|
231
|
+
if (k === 'PROMPT_TONE') {
|
|
232
|
+
this.attributes.PROMPT_TONE = !!v;
|
|
233
|
+
}
|
|
234
|
+
else if (k === 'SCREEN_DISPLAY') {
|
|
235
|
+
// if (this.attributes.SCREEN_DISPLAY_NEW)
|
|
236
|
+
if (this.alternate_switch_display) {
|
|
237
|
+
messageToSend.NEW_PROTOCOL ??= new MessageNewProtocolSet(this.device_protocol_version);
|
|
238
|
+
messageToSend.NEW_PROTOCOL.screen_display = !!v;
|
|
239
|
+
messageToSend.NEW_PROTOCOL.prompt_tone = this.attributes.PROMPT_TONE;
|
|
240
|
+
}
|
|
241
|
+
else {
|
|
242
|
+
messageToSend.SWITCH_DISPLAY ??= new MessageSwitchDisplay(this.device_protocol_version);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
else if (['INDIRECT_WIND', 'BREEZELESS'].includes(k)) {
|
|
246
|
+
messageToSend.NEW_PROTOCOL ??= new MessageNewProtocolSet(this.device_protocol_version);
|
|
247
|
+
messageToSend.NEW_PROTOCOL[k.toLowerCase()] = !!v;
|
|
248
|
+
messageToSend.NEW_PROTOCOL.prompt_tone = this.attributes.PROMPT_TONE;
|
|
249
|
+
}
|
|
250
|
+
else if (k === 'FRESH_AIR_POWER' && this.fresh_air_version !== undefined) {
|
|
251
|
+
messageToSend.NEW_PROTOCOL ??= new MessageNewProtocolSet(this.device_protocol_version);
|
|
252
|
+
messageToSend.NEW_PROTOCOL[this.fresh_air_version] = [!!v, this.attributes.FRESH_AIR_FAN_SPEED];
|
|
253
|
+
}
|
|
254
|
+
else if (k === 'FRESH_AIR_MODE' && this.fresh_air_version !== undefined) {
|
|
255
|
+
if (Object.values(this.FRESH_AIR_FAN_SPEEDS).includes(v)) {
|
|
256
|
+
let speed;
|
|
257
|
+
switch (v) {
|
|
258
|
+
case 'Silent':
|
|
259
|
+
speed = 20;
|
|
260
|
+
break;
|
|
261
|
+
case 'Low':
|
|
262
|
+
speed = 40;
|
|
263
|
+
break;
|
|
264
|
+
case 'Medium':
|
|
265
|
+
speed = 60;
|
|
266
|
+
break;
|
|
267
|
+
case 'High':
|
|
268
|
+
speed = 80;
|
|
269
|
+
break;
|
|
270
|
+
case 'Full':
|
|
271
|
+
speed = 100;
|
|
272
|
+
break;
|
|
273
|
+
default:
|
|
274
|
+
speed = 0;
|
|
275
|
+
}
|
|
276
|
+
const fresh_air = speed > 0 ? [true, speed] : [false, this.attributes.FRESH_AIR_FAN_SPEED];
|
|
277
|
+
messageToSend.NEW_PROTOCOL ??= new MessageNewProtocolSet(this.device_protocol_version);
|
|
278
|
+
messageToSend.NEW_PROTOCOL[this.fresh_air_version] = fresh_air;
|
|
279
|
+
}
|
|
280
|
+
else if (!v) {
|
|
281
|
+
messageToSend.NEW_PROTOCOL ??= new MessageNewProtocolSet(this.device_protocol_version);
|
|
282
|
+
messageToSend.NEW_PROTOCOL[this.fresh_air_version] = [false, this.attributes.FRESH_AIR_FAN_SPEED];
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
else if (k === 'FRESH_AIR_FAN_SPEED' && this.fresh_air_version !== undefined) {
|
|
286
|
+
const value = v;
|
|
287
|
+
const fresh_air = value > 0 ? [true, value] : [false, this.attributes.FRESH_AIR_FAN_SPEED];
|
|
288
|
+
messageToSend.NEW_PROTOCOL ??= new MessageNewProtocolSet(this.device_protocol_version);
|
|
289
|
+
messageToSend.NEW_PROTOCOL[this.fresh_air_version] = fresh_air;
|
|
290
|
+
}
|
|
291
|
+
else {
|
|
292
|
+
messageToSend.GENERAL ??= this.make_message_unique_set();
|
|
293
|
+
messageToSend.GENERAL[k.toLowerCase()] = v;
|
|
294
|
+
if (['BOOST_MODE', 'SLEEP_MODE', 'FROST_PROTECT', 'COMFORT_MODE', 'ECO_MODE'].includes(k)) {
|
|
295
|
+
messageToSend.GENERAL.sleep_mode = false;
|
|
296
|
+
messageToSend.GENERAL.boost_mode = false;
|
|
297
|
+
messageToSend.GENERAL.eco_mode = false;
|
|
298
|
+
if (messageToSend.GENERAL instanceof MessageGeneralSet) {
|
|
299
|
+
messageToSend.GENERAL.frost_protect = false;
|
|
300
|
+
messageToSend.GENERAL.comfort_mode = false;
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
if (k === 'POWER' && v === true && messageToSend.GENERAL instanceof MessageGeneralSet) {
|
|
304
|
+
messageToSend.GENERAL.temp_fahrenheit = this.defaultFahrenheit;
|
|
305
|
+
this.attributes.TEMP_FAHRENHEIT = this.defaultFahrenheit;
|
|
306
|
+
if (this.defaultScreenOff) {
|
|
307
|
+
messageToSend.SWITCH_DISPLAY ??= new MessageSwitchDisplay(this.device_protocol_version);
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
for (const [k, v] of Object.entries(messageToSend)) {
|
|
314
|
+
if (v !== undefined) {
|
|
315
|
+
this.logger.debug(`[${this.name}] Set message ${k}:\n${JSON.stringify(v)}`);
|
|
316
|
+
await this.build_send(v);
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
catch (err) {
|
|
321
|
+
const msg = err instanceof Error ? err.stack : err;
|
|
322
|
+
this.logger.debug(`[${this.name}] Error in set_attribute (${this.ip}:${this.port}):\n${msg}`);
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
set_alternate_switch_display(value) {
|
|
326
|
+
this.alternate_switch_display = value;
|
|
327
|
+
}
|
|
328
|
+
async set_target_temperature(target_temperature, mode) {
|
|
329
|
+
this.logger.info(`[${this.name}] Set target temperature to: ${target_temperature}`);
|
|
330
|
+
const message = this.make_message_unique_set();
|
|
331
|
+
message.target_temperature = target_temperature;
|
|
332
|
+
this.attributes.TARGET_TEMPERATURE = target_temperature;
|
|
333
|
+
if (mode) {
|
|
334
|
+
message.mode = mode;
|
|
335
|
+
message.power = true;
|
|
336
|
+
this.attributes.MODE = mode;
|
|
337
|
+
this.attributes.POWER = true;
|
|
338
|
+
}
|
|
339
|
+
await this.build_send(message);
|
|
340
|
+
}
|
|
341
|
+
async set_swing(swing_horizontal, swing_vertical) {
|
|
342
|
+
this.logger.info(`[${this.name}] Set swing horizontal to: ${swing_horizontal}, vertical to: ${swing_vertical}`);
|
|
343
|
+
const message = this.make_message_set();
|
|
344
|
+
message.swing_horizontal = swing_horizontal;
|
|
345
|
+
message.swing_vertical = swing_vertical;
|
|
346
|
+
this.attributes.SWING_HORIZONTAL = swing_horizontal;
|
|
347
|
+
this.attributes.SWING_VERTICAL = swing_vertical;
|
|
348
|
+
this.attributes.WIND_SWING_LR_ANGLE = 0;
|
|
349
|
+
this.attributes.WIND_SWING_UD_ANGLE = 0;
|
|
350
|
+
await this.build_send(message);
|
|
351
|
+
}
|
|
352
|
+
async set_fan_auto(fan_auto) {
|
|
353
|
+
this.logger.info(`[${this.name}] Set fan auto to: ${fan_auto}`);
|
|
354
|
+
const message = this.make_message_unique_set();
|
|
355
|
+
if (fan_auto) {
|
|
356
|
+
// Save last fan speed before setting to auto
|
|
357
|
+
this.last_fan_speed = this.attributes.FAN_SPEED;
|
|
358
|
+
}
|
|
359
|
+
const fan_speed = fan_auto ? 102 : this.last_fan_speed;
|
|
360
|
+
message.fan_speed = fan_speed;
|
|
361
|
+
this.attributes.FAN_SPEED = fan_speed;
|
|
362
|
+
this.attributes.FAN_AUTO = fan_auto;
|
|
363
|
+
await this.build_send(message);
|
|
364
|
+
}
|
|
365
|
+
async set_swing_angle(swing_direction, swing_angle) {
|
|
366
|
+
this.logger.info(`[${this.name}] Set swing ${swing_direction} angle to: ${swing_angle}`);
|
|
367
|
+
const message = new MessageNewProtocolSet(this.device_protocol_version);
|
|
368
|
+
this.attributes.SWING_HORIZONTAL = false;
|
|
369
|
+
this.attributes.SWING_VERTICAL = false;
|
|
370
|
+
switch (swing_direction) {
|
|
371
|
+
case SwingAngle.HORIZONTAL:
|
|
372
|
+
message.wind_swing_lr_angle = swing_angle;
|
|
373
|
+
this.attributes.WIND_SWING_LR_ANGLE = swing_angle;
|
|
374
|
+
break;
|
|
375
|
+
case SwingAngle.VERTICAL:
|
|
376
|
+
message.wind_swing_ud_angle = swing_angle;
|
|
377
|
+
this.attributes.WIND_SWING_UD_ANGLE = swing_angle;
|
|
378
|
+
break;
|
|
379
|
+
}
|
|
380
|
+
message.prompt_tone = this.attributes.PROMPT_TONE;
|
|
381
|
+
await this.build_send(message);
|
|
382
|
+
}
|
|
383
|
+
async set_self_clean(self_clean) {
|
|
384
|
+
this.logger.info(`[${this.name}] Set self clean to: ${self_clean}`);
|
|
385
|
+
const message = new MessageNewProtocolSet(this.device_protocol_version);
|
|
386
|
+
message.self_clean = self_clean;
|
|
387
|
+
this.attributes.SELF_CLEAN = self_clean;
|
|
388
|
+
message.prompt_tone = this.attributes.PROMPT_TONE;
|
|
389
|
+
await this.build_send(message);
|
|
390
|
+
}
|
|
391
|
+
async set_ion(ion) {
|
|
392
|
+
this.logger.info(`[${this.name}] Set ion to: ${ion}`);
|
|
393
|
+
// If ion is enabled, we need to turn on the device first
|
|
394
|
+
if (ion === true) {
|
|
395
|
+
this.logger.info(`[${this.name}] Powering on device to enable ion`);
|
|
396
|
+
this.attributes.POWER = true;
|
|
397
|
+
const message = this.make_message_unique_set();
|
|
398
|
+
await this.build_send(message);
|
|
399
|
+
}
|
|
400
|
+
const message = new MessageNewProtocolSet(this.device_protocol_version);
|
|
401
|
+
message.ion = ion;
|
|
402
|
+
this.attributes.ION = ion;
|
|
403
|
+
message.prompt_tone = this.attributes.PROMPT_TONE;
|
|
404
|
+
await this.build_send(message);
|
|
405
|
+
}
|
|
406
|
+
async set_rate_select(rate_select) {
|
|
407
|
+
this.logger.info(`[${this.name}] Set rate select to: ${rate_select}`);
|
|
408
|
+
const message = new MessageNewProtocolSet(this.device_protocol_version);
|
|
409
|
+
message.rate_select = rate_select;
|
|
410
|
+
this.attributes.RATE_SELECT = rate_select;
|
|
411
|
+
message.prompt_tone = this.attributes.PROMPT_TONE;
|
|
412
|
+
await this.build_send(message);
|
|
413
|
+
}
|
|
414
|
+
set_subtype() {
|
|
415
|
+
this.logger.debug('No subtype for AC device');
|
|
416
|
+
}
|
|
417
|
+
}
|
|
401
418
|
//# sourceMappingURL=MideaACDevice.js.map
|