homebridge-tasmota-control 1.6.15-beta.9 → 1.7.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 +8 -0
- package/config.schema.json +86 -38
- package/index.js +69 -87
- package/package.json +3 -3
- package/src/constants.js +18 -8
- package/src/deviceinfo.js +4 -5
- package/src/fans.js +71 -92
- package/src/functions.js +31 -0
- package/src/impulsegenerator.js +12 -10
- package/src/lights.js +54 -82
- package/src/mielhvac.js +185 -186
- package/src/sensors.js +69 -92
- package/src/switches.js +40 -63
package/src/mielhvac.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { promises as fsPromises } from 'fs';
|
|
2
1
|
import axios from 'axios';
|
|
3
2
|
import EventEmitter from 'events';
|
|
4
3
|
import ImpulseGenerator from './impulsegenerator.js';
|
|
4
|
+
import Functions from './functions.js';
|
|
5
5
|
import { ApiCommands, MiElHVAC, TemperatureDisplayUnits } from './constants.js';
|
|
6
6
|
let Accessory, Characteristic, Service, Categories, AccessoryUUID;
|
|
7
7
|
|
|
@@ -40,8 +40,8 @@ class MiElHvac extends EventEmitter {
|
|
|
40
40
|
const presets = miElHvac.presets || [];
|
|
41
41
|
this.presetsConfigured = [];
|
|
42
42
|
for (const preset of presets) {
|
|
43
|
-
const displayType = preset.displayType
|
|
44
|
-
if (displayType
|
|
43
|
+
const displayType = preset.displayType;
|
|
44
|
+
if (!displayType) {
|
|
45
45
|
continue;
|
|
46
46
|
}
|
|
47
47
|
|
|
@@ -60,8 +60,8 @@ class MiElHvac extends EventEmitter {
|
|
|
60
60
|
const buttons = miElHvac.buttons || [];
|
|
61
61
|
this.buttonsConfigured = [];
|
|
62
62
|
for (const button of buttons) {
|
|
63
|
-
const displayType = button.displayType
|
|
64
|
-
if (displayType
|
|
63
|
+
const displayType = button.displayType;
|
|
64
|
+
if (!displayType) {
|
|
65
65
|
continue;
|
|
66
66
|
}
|
|
67
67
|
|
|
@@ -80,8 +80,8 @@ class MiElHvac extends EventEmitter {
|
|
|
80
80
|
const sensors = miElHvac.sensors || [];
|
|
81
81
|
this.sensorsConfigured = [];
|
|
82
82
|
for (const sensor of sensors) {
|
|
83
|
-
const displayType = sensor.displayType
|
|
84
|
-
if (displayType
|
|
83
|
+
const displayType = sensor.displayType;
|
|
84
|
+
if (!displayType) {
|
|
85
85
|
continue;
|
|
86
86
|
}
|
|
87
87
|
|
|
@@ -114,20 +114,17 @@ class MiElHvac extends EventEmitter {
|
|
|
114
114
|
this.disableLogDeviceInfo = config.disableLogDeviceInfo || false;
|
|
115
115
|
this.refreshInterval = refreshInterval;
|
|
116
116
|
|
|
117
|
-
//variable
|
|
118
|
-
this.startPrepareAccessory = true;
|
|
119
|
-
|
|
120
117
|
//mielhvac
|
|
121
118
|
this.mielHvac = {};
|
|
122
119
|
this.previousStateSwingV = 'auto';
|
|
123
120
|
this.previousStateSwingH = 'center';
|
|
121
|
+
this.functions = new Functions();
|
|
124
122
|
|
|
125
123
|
//axios instance
|
|
126
124
|
const url = `http://${config.host}/cm?cmnd=`;
|
|
127
125
|
this.axiosInstance = axios.create({
|
|
128
|
-
method: 'GET',
|
|
129
126
|
baseURL: url,
|
|
130
|
-
timeout:
|
|
127
|
+
timeout: 15000,
|
|
131
128
|
withCredentials: config.auth,
|
|
132
129
|
auth: {
|
|
133
130
|
username: config.user,
|
|
@@ -137,11 +134,9 @@ class MiElHvac extends EventEmitter {
|
|
|
137
134
|
|
|
138
135
|
//axios instance remote temp
|
|
139
136
|
if (remoteTemperatureSensorEnable) {
|
|
140
|
-
const path = remoteTemperatureSensorPath;
|
|
141
137
|
this.axiosInstanceRemoteTemp = axios.create({
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
timeout: remoteTemperatureSensorRefreshInterval > 10000 ? 10000 : remoteTemperatureSensorRefreshInterval,
|
|
138
|
+
baseURL: remoteTemperatureSensorPath,
|
|
139
|
+
timeout: 10000,
|
|
145
140
|
withCredentials: remoteTemperatureSensorAuth,
|
|
146
141
|
auth: {
|
|
147
142
|
username: remoteTemperatureSensorUser,
|
|
@@ -150,48 +145,48 @@ class MiElHvac extends EventEmitter {
|
|
|
150
145
|
});
|
|
151
146
|
}
|
|
152
147
|
|
|
153
|
-
//
|
|
154
|
-
this.
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
this.
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
this.emit('
|
|
167
|
-
};
|
|
168
|
-
}).on('updateRemoteTemp', async () => {
|
|
169
|
-
if (this.call1) return;
|
|
170
|
-
|
|
171
|
-
try {
|
|
172
|
-
this.call1 = true;
|
|
173
|
-
await this.updateRemoteTemp();
|
|
174
|
-
} catch (error) {
|
|
175
|
-
this.call1 = false;
|
|
176
|
-
this.emit('error', `Impulse generator error: ${error}`);
|
|
177
|
-
}
|
|
178
|
-
}).on('state', (state) => {
|
|
179
|
-
const emitState = state ? this.emit('success', `Impulse generator started`) : this.emit('warn', `Impulse generator stopped`);
|
|
180
|
-
});
|
|
148
|
+
//lock flags
|
|
149
|
+
this.locks = {
|
|
150
|
+
checkState: false,
|
|
151
|
+
updateRemoteTemp: false,
|
|
152
|
+
};
|
|
153
|
+
this.impulseGenerator = new ImpulseGenerator()
|
|
154
|
+
.on('checkState', () => this.handleWithLock('checkState', async () => {
|
|
155
|
+
await this.checkState();
|
|
156
|
+
}))
|
|
157
|
+
.on('updateRemoteTemp', () => this.handleWithLock('updateRemoteTemp', async () => {
|
|
158
|
+
await this.checkState();
|
|
159
|
+
}))
|
|
160
|
+
.on('state', (state) => {
|
|
161
|
+
this.emit('success', `Impulse generator ${state ? 'started' : 'stopped'}.`);
|
|
162
|
+
});
|
|
181
163
|
}
|
|
182
164
|
|
|
183
|
-
async
|
|
184
|
-
|
|
165
|
+
async handleWithLock(lockKey, fn) {
|
|
166
|
+
if (this.locks[lockKey]) return;
|
|
167
|
+
|
|
168
|
+
this.locks[lockKey] = true;
|
|
169
|
+
try {
|
|
170
|
+
await fn();
|
|
171
|
+
} catch (error) {
|
|
172
|
+
this.emit('error', `Inpulse generator error: ${error}`);
|
|
173
|
+
} finally {
|
|
174
|
+
this.locks[lockKey] = false;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
async checkState() {
|
|
179
|
+
if (this.enableDebugMode) this.emit('debug', `Requesting status`);
|
|
185
180
|
try {
|
|
186
181
|
//power status
|
|
187
|
-
const powerStatusData = await this.axiosInstance(ApiCommands.PowerStatus);
|
|
182
|
+
const powerStatusData = await this.axiosInstance.get(ApiCommands.PowerStatus);
|
|
188
183
|
const powerStatus = powerStatusData.data ?? {};
|
|
189
|
-
|
|
184
|
+
if (this.enableDebugMode) this.emit('debug', `Power status: ${JSON.stringify(powerStatus, null, 2)}`);
|
|
190
185
|
|
|
191
186
|
//sensor status
|
|
192
|
-
const sensorStatusData = await this.axiosInstance(ApiCommands.Status);
|
|
187
|
+
const sensorStatusData = await this.axiosInstance.get(ApiCommands.Status);
|
|
193
188
|
const sensorStatus = sensorStatusData.data ?? {};
|
|
194
|
-
|
|
189
|
+
if (this.enableDebugMode) this.emit('debug', `Sensors status: ${JSON.stringify(sensorStatus, null, 2)}`);
|
|
195
190
|
|
|
196
191
|
//sensor status keys
|
|
197
192
|
const sensorStatusKeys = Object.keys(sensorStatus);
|
|
@@ -205,34 +200,39 @@ class MiElHvac extends EventEmitter {
|
|
|
205
200
|
const temperatureUnit = statusSns.TempUnit === 'C' ? '°C' : 'F';
|
|
206
201
|
|
|
207
202
|
//mielhvac
|
|
208
|
-
const miElHvac = statusSns.MiElHVAC
|
|
203
|
+
const miElHvac = statusSns.MiElHVAC;
|
|
209
204
|
|
|
210
|
-
if (!miElHvac) {
|
|
205
|
+
if (!miElHvac || Object.keys(miElHvac).length === 0) {
|
|
211
206
|
this.emit('warn', "Empty data received");
|
|
212
|
-
return;
|
|
207
|
+
return null;
|
|
213
208
|
}
|
|
214
|
-
|
|
209
|
+
|
|
215
210
|
const power = miElHvac.Power === 'on' ? 1 : 0;
|
|
216
211
|
const roomTemperature = miElHvac.Temperature ?? null;
|
|
212
|
+
if (!roomTemperature) return null;
|
|
213
|
+
|
|
217
214
|
const outdoorTemperature = miElHvac.OutdoorTemperature ?? null;
|
|
218
215
|
const setTemperature = miElHvac.SetTemperature;
|
|
219
216
|
const operationMode = miElHvac.Mode ?? 'Unknown';
|
|
220
|
-
const
|
|
217
|
+
const operationModeStatus = miElHvac.ModeStatus ?? 'Unknown';
|
|
221
218
|
const fanSpeed = miElHvac.FanSpeed ?? 'Unknown';
|
|
222
|
-
const
|
|
219
|
+
const fanSpeedStatus = miElHvac.FanStatus ?? 'Unknown';
|
|
223
220
|
const vaneVerticalDirection = miElHvac.SwingV ?? 'Unknown';
|
|
224
221
|
const vaneHorizontalDirection = miElHvac.SwingH ?? 'Unknown';
|
|
225
222
|
const prohibit = miElHvac.Prohibit ?? 'Unknown';
|
|
226
223
|
const purify = miElHvac.Purify ?? 'Unknown';
|
|
224
|
+
const econoCool = miElHvac.EonoCool ?? 'Unknown';
|
|
225
|
+
const powerFull = miElHvac.PowerFull ?? 'Unknown';
|
|
226
|
+
const nightMode = miElHvac.NightMode ?? 'Unknown';
|
|
227
227
|
const airDirection = miElHvac.AirDirection ?? 'Unknown';
|
|
228
228
|
const compressor = miElHvac.Compressor ?? 'Unknown';
|
|
229
229
|
const compressorFrequency = miElHvac.CompressorFrequency ?? 0;
|
|
230
230
|
const operationPower = miElHvac.OperationPower ?? 0;
|
|
231
231
|
const operationEnergy = miElHvac.OperationEnergy ?? 0;
|
|
232
|
-
const
|
|
232
|
+
const operationStatus = miElHvac.OperationStatus ?? 'Unknown';
|
|
233
233
|
const swingMode = vaneVerticalDirection === 'swing' && vaneHorizontalDirection === 'swing' ? 1 : 0;
|
|
234
|
-
const defaultCoolingSetTemperature = parseFloat(await this.readData(this.info.defaultCoolingSetTemperatureFile));
|
|
235
|
-
const defaultHeatingSetTemperature = parseFloat(await this.readData(this.info.defaultHeatingSetTemperatureFile));
|
|
234
|
+
const defaultCoolingSetTemperature = parseFloat(await this.functions.readData(this.info.defaultCoolingSetTemperatureFile));
|
|
235
|
+
const defaultHeatingSetTemperature = parseFloat(await this.functions.readData(this.info.defaultHeatingSetTemperatureFile));
|
|
236
236
|
const remoteTemperatureSensorState = miElHvac.RemoteTemperatureSensorState ?? false; //ON, OFF
|
|
237
237
|
const remoteTemperatureSensorAutoClearTime = miElHvac.RemoteTemperatureSensorAutoClearTime ?? 0; //time in ms
|
|
238
238
|
|
|
@@ -257,20 +257,23 @@ class MiElHvac extends EventEmitter {
|
|
|
257
257
|
outdoorTemperature: outdoorTemperature,
|
|
258
258
|
setTemperature: setTemperature,
|
|
259
259
|
operationMode: operationMode,
|
|
260
|
-
|
|
260
|
+
operationModeStatus: operationModeStatus,
|
|
261
261
|
currentOperationMode: 0,
|
|
262
262
|
targetOperationMode: 0,
|
|
263
263
|
vaneVerticalDirection: vaneVerticalDirection,
|
|
264
264
|
vaneHorizontalDirection: vaneHorizontalDirection,
|
|
265
265
|
prohibit: prohibit,
|
|
266
266
|
purify: purify,
|
|
267
|
+
econoCool: econoCool,
|
|
268
|
+
powerFull: powerFull,
|
|
269
|
+
nightMode: nightMode,
|
|
267
270
|
airDirection: airDirection,
|
|
268
271
|
swingMode: swingMode,
|
|
269
272
|
compressor: compressor,
|
|
270
273
|
compressorFrequency: compressorFrequency,
|
|
271
274
|
operationPower: operationPower,
|
|
272
275
|
operationEnergy: operationEnergy,
|
|
273
|
-
|
|
276
|
+
operationStatus: operationStatus,
|
|
274
277
|
defaultCoolingSetTemperature: defaultCoolingSetTemperature,
|
|
275
278
|
defaultHeatingSetTemperature: defaultHeatingSetTemperature,
|
|
276
279
|
remoteTemperatureSensorState: remoteTemperatureSensorState,
|
|
@@ -290,8 +293,8 @@ class MiElHvac extends EventEmitter {
|
|
|
290
293
|
hideVaneControls: hideVaneControls
|
|
291
294
|
};
|
|
292
295
|
|
|
293
|
-
// Map
|
|
294
|
-
const
|
|
296
|
+
// Map status to index safely, fallback to 0 if not found
|
|
297
|
+
const operationModeStatusMap = {
|
|
295
298
|
'manual': 0,
|
|
296
299
|
'heat': 2,
|
|
297
300
|
'dry': 1,
|
|
@@ -306,43 +309,43 @@ class MiElHvac extends EventEmitter {
|
|
|
306
309
|
'auto_leader': 4
|
|
307
310
|
};
|
|
308
311
|
|
|
309
|
-
const
|
|
312
|
+
const statusIndex = operationModeStatusMap[operationModeStatus] ?? 0;
|
|
310
313
|
switch (operationMode) {
|
|
311
314
|
case 'heat':
|
|
312
|
-
obj.currentOperationMode = [2, 1, 2, 3, 0][
|
|
315
|
+
obj.currentOperationMode = [2, 1, 2, 3, 0][statusIndex]; // INACTIVE, IDLE, HEATING, COOLING
|
|
313
316
|
obj.targetOperationMode = 1; // AUTO, HEAT, COOL
|
|
314
317
|
break;
|
|
315
318
|
case 'dry':
|
|
316
|
-
obj.currentOperationMode = [1, 1, 2, 3, 0][
|
|
319
|
+
obj.currentOperationMode = [1, 1, 2, 3, 0][statusIndex];
|
|
317
320
|
obj.targetOperationMode = this.autoDryFanMode === 2 ? 0 : this.heatDryFanMode === 2 ? 1 : this.coolDryFanMode === 2 ? 2 : obj.targetOperationMode;
|
|
318
321
|
break;
|
|
319
322
|
case 'cool':
|
|
320
|
-
obj.currentOperationMode = [3, 1, 2, 3, 0][
|
|
323
|
+
obj.currentOperationMode = [3, 1, 2, 3, 0][statusIndex];
|
|
321
324
|
obj.targetOperationMode = 2;
|
|
322
325
|
break;
|
|
323
326
|
case 'fan':
|
|
324
|
-
obj.currentOperationMode = [1, 1, 2, 3, 0][
|
|
327
|
+
obj.currentOperationMode = [1, 1, 2, 3, 0][statusIndex];
|
|
325
328
|
obj.targetOperationMode = this.autoDryFanMode === 3 ? 0 : this.heatDryFanMode === 3 ? 1 : this.coolDryFanMode === 3 ? 2 : obj.targetOperationMode;
|
|
326
329
|
break;
|
|
327
330
|
case 'auto':
|
|
328
|
-
obj.currentOperationMode = [2, 1, 2, 3, 0][
|
|
331
|
+
obj.currentOperationMode = [2, 1, 2, 3, 0][statusIndex];
|
|
329
332
|
obj.targetOperationMode = 0;
|
|
330
333
|
break;
|
|
331
334
|
case 'heat_isee':
|
|
332
|
-
obj.currentOperationMode = [2, 1, 2, 3, 0][
|
|
335
|
+
obj.currentOperationMode = [2, 1, 2, 3, 0][statusIndex];
|
|
333
336
|
obj.targetOperationMode = 1;
|
|
334
337
|
break;
|
|
335
338
|
case 'dry_isee':
|
|
336
|
-
obj.currentOperationMode = [1, 1, 2, 3, 0][
|
|
339
|
+
obj.currentOperationMode = [1, 1, 2, 3, 0][statusIndex];
|
|
337
340
|
obj.targetOperationMode = this.autoDryFanMode === 2 ? 0 : this.heatDryFanMode === 2 ? 1 : this.coolDryFanMode === 2 ? 2 : obj.targetOperationMode;
|
|
338
341
|
break;
|
|
339
342
|
case 'cool_isee':
|
|
340
|
-
obj.currentOperationMode = [3, 1, 2, 3, 0][
|
|
343
|
+
obj.currentOperationMode = [3, 1, 2, 3, 0][statusIndex];
|
|
341
344
|
obj.targetOperationMode = 2;
|
|
342
345
|
break;
|
|
343
346
|
default:
|
|
344
347
|
this.emit('warn', `Unknown operating mode: ${operationMode}`);
|
|
345
|
-
return;
|
|
348
|
+
return null;
|
|
346
349
|
}
|
|
347
350
|
|
|
348
351
|
// If power is off, force currentOperationMode to 0 (inactive)
|
|
@@ -386,6 +389,8 @@ class MiElHvac extends EventEmitter {
|
|
|
386
389
|
obj.fanSpeed = hasAutomaticFanSpeed ? [6, 1, 2, 3, 4, 5][fanIndex] ?? 1 : [0, 1, 2, 3, 4, 5][fanIndex] ?? 1;
|
|
387
390
|
obj.fanSpeedSetPropsMaxValue = hasAutomaticFanSpeed ? 6 : 5;
|
|
388
391
|
break;
|
|
392
|
+
default:
|
|
393
|
+
this.emit('warn', `Unknown fan speeds: ${numberOfFanSpeeds}`);
|
|
389
394
|
}
|
|
390
395
|
|
|
391
396
|
// Cap value to max
|
|
@@ -480,11 +485,12 @@ class MiElHvac extends EventEmitter {
|
|
|
480
485
|
11: 'left_middle',
|
|
481
486
|
12: 'left_center',
|
|
482
487
|
13: 'center',
|
|
483
|
-
14: '
|
|
488
|
+
14: 'right_center',
|
|
484
489
|
15: 'right_middle',
|
|
485
|
-
16: '
|
|
490
|
+
16: 'right',
|
|
486
491
|
17: 'split',
|
|
487
492
|
18: 'swing',
|
|
493
|
+
19: 'airdirection',
|
|
488
494
|
};
|
|
489
495
|
|
|
490
496
|
const vaneVMap = {
|
|
@@ -507,10 +513,9 @@ class MiElHvac extends EventEmitter {
|
|
|
507
513
|
};
|
|
508
514
|
|
|
509
515
|
const airDirMap = {
|
|
510
|
-
40:
|
|
511
|
-
41:
|
|
512
|
-
42:
|
|
513
|
-
43: () => power && !['indirect', 'direct', 'even'].includes(airDirection),
|
|
516
|
+
40: 'indirect',
|
|
517
|
+
41: 'direct',
|
|
518
|
+
42: 'even',
|
|
514
519
|
};
|
|
515
520
|
|
|
516
521
|
const prohibitMap = {
|
|
@@ -520,15 +525,25 @@ class MiElHvac extends EventEmitter {
|
|
|
520
525
|
53: 'temp',
|
|
521
526
|
};
|
|
522
527
|
|
|
523
|
-
const
|
|
524
|
-
60:
|
|
528
|
+
const functionsMap = {
|
|
529
|
+
60: 'purify', //purify
|
|
530
|
+
61: 'econoCool', //econocool
|
|
531
|
+
62: 'powerFull', //powerfull
|
|
532
|
+
63: 'noghtMode', //nightmode
|
|
533
|
+
};
|
|
534
|
+
|
|
535
|
+
const functionsStateMap = {
|
|
536
|
+
60: 'on', //purify
|
|
537
|
+
61: 'on', //econocool
|
|
538
|
+
62: 'on', //powerfull
|
|
539
|
+
63: 'on', //nightmode
|
|
525
540
|
};
|
|
526
541
|
|
|
527
542
|
this.buttonsConfigured.forEach((button, index) => {
|
|
528
543
|
const mode = button.mode;
|
|
529
544
|
let state = false;
|
|
530
545
|
|
|
531
|
-
if (modeMap[mode]
|
|
546
|
+
if (modeMap[mode]) {
|
|
532
547
|
state = modeMap[mode]();
|
|
533
548
|
} else if (vaneHMap[mode]) {
|
|
534
549
|
state = power && vaneHorizontalDirection === vaneHMap[mode];
|
|
@@ -537,11 +552,11 @@ class MiElHvac extends EventEmitter {
|
|
|
537
552
|
} else if (fanSpeedMap[mode]) {
|
|
538
553
|
state = power && fanSpeed === fanSpeedMap[mode];
|
|
539
554
|
} else if (airDirMap[mode]) {
|
|
540
|
-
state = airDirMap[mode]
|
|
541
|
-
} else if (prohibitMap[mode]
|
|
542
|
-
state = prohibit === prohibitMap[mode];
|
|
543
|
-
} else if (
|
|
544
|
-
state =
|
|
555
|
+
state = power && airDirection === airDirMap[mode];
|
|
556
|
+
} else if (prohibitMap[mode]) {
|
|
557
|
+
state = power && prohibit === prohibitMap[mode];
|
|
558
|
+
} else if (functionsStateMap[mode]) {
|
|
559
|
+
state = power && functionsMap[mode] === functionsStateMap[mode];
|
|
545
560
|
} else {
|
|
546
561
|
this.emit('warn', `Unknown button mode: ${mode} detected`);
|
|
547
562
|
}
|
|
@@ -573,15 +588,18 @@ class MiElHvac extends EventEmitter {
|
|
|
573
588
|
3: isOneOf(operationMode, ['cool', 'cool_isee']),
|
|
574
589
|
4: is(operationMode, 'fan'),
|
|
575
590
|
5: is(operationMode, 'auto'),
|
|
576
|
-
6: is(
|
|
591
|
+
6: is(purify, 'on'),
|
|
577
592
|
|
|
578
|
-
|
|
579
|
-
|
|
593
|
+
10: is(vaneHorizontalDirection, 'left'),
|
|
594
|
+
11: is(vaneHorizontalDirection, 'left_middle'),
|
|
595
|
+
12: is(vaneHorizontalDirection, 'left_center'),
|
|
580
596
|
13: is(vaneHorizontalDirection, 'center'),
|
|
581
|
-
14: is(vaneHorizontalDirection, '
|
|
582
|
-
15: is(vaneHorizontalDirection, '
|
|
583
|
-
16: is(vaneHorizontalDirection, '
|
|
584
|
-
17: is(vaneHorizontalDirection, '
|
|
597
|
+
14: is(vaneHorizontalDirection, 'right_center'),
|
|
598
|
+
15: is(vaneHorizontalDirection, 'right_middle'),
|
|
599
|
+
16: is(vaneHorizontalDirection, 'right'),
|
|
600
|
+
17: is(vaneHorizontalDirection, 'split'),
|
|
601
|
+
18: is(vaneHorizontalDirection, 'swing'),
|
|
602
|
+
19: is(vaneHorizontalDirection, 'airdirection'),
|
|
585
603
|
|
|
586
604
|
20: is(vaneVerticalDirection, 'auto'),
|
|
587
605
|
21: is(vaneVerticalDirection, 'up'),
|
|
@@ -603,7 +621,6 @@ class MiElHvac extends EventEmitter {
|
|
|
603
621
|
40: is(airDirection, 'indirect'),
|
|
604
622
|
41: is(airDirection, 'direct'),
|
|
605
623
|
42: is(airDirection, 'even'),
|
|
606
|
-
43: powerOn && !['indirect', 'direct', 'even'].includes(airDirection),
|
|
607
624
|
|
|
608
625
|
50: prohibit === 'all',
|
|
609
626
|
51: prohibit === 'power',
|
|
@@ -612,24 +629,25 @@ class MiElHvac extends EventEmitter {
|
|
|
612
629
|
|
|
613
630
|
60: remoteTemperatureSensorState,
|
|
614
631
|
|
|
615
|
-
70:
|
|
616
|
-
71:
|
|
617
|
-
72:
|
|
618
|
-
73:
|
|
632
|
+
70: operationStatus === 'normal',
|
|
633
|
+
71: operationStatus === 'filter',
|
|
634
|
+
72: operationStatus === 'defrost',
|
|
635
|
+
73: operationStatus === 'standby',
|
|
636
|
+
74: operationStatus === 'preheat',
|
|
619
637
|
|
|
620
|
-
80:
|
|
621
|
-
81:
|
|
622
|
-
82:
|
|
623
|
-
83:
|
|
624
|
-
84:
|
|
625
|
-
85:
|
|
626
|
-
86:
|
|
638
|
+
80: fanSpeedStatus === 'off',
|
|
639
|
+
81: fanSpeedStatus === 'quiet',
|
|
640
|
+
82: fanSpeedStatus === '1',
|
|
641
|
+
83: fanSpeedStatus === '2',
|
|
642
|
+
84: fanSpeedStatus === '3',
|
|
643
|
+
85: fanSpeedStatus === '4',
|
|
644
|
+
86: fanSpeedStatus === '5',
|
|
627
645
|
|
|
628
646
|
90: operationMode !== 'auto',
|
|
629
|
-
91:
|
|
630
|
-
92:
|
|
631
|
-
93:
|
|
632
|
-
94:
|
|
647
|
+
91: operationModeStatus === 'auto_fan',
|
|
648
|
+
92: operationModeStatus === 'auto_heat',
|
|
649
|
+
93: operationModeStatus === 'auto_cool',
|
|
650
|
+
94: operationModeStatus === 'auto_leader',
|
|
633
651
|
};
|
|
634
652
|
|
|
635
653
|
if (mode in sensorStates) {
|
|
@@ -662,12 +680,12 @@ class MiElHvac extends EventEmitter {
|
|
|
662
680
|
if (!this.disableLogInfo) {
|
|
663
681
|
this.emit('info', `Power: ${power ? 'ON' : 'OFF'}`);
|
|
664
682
|
const info = power ? this.emit('info', `Target operation mode: ${operationMode.toUpperCase()}`) : false;
|
|
665
|
-
const info1 = power ? this.emit('info', `Current operation mode: ${
|
|
683
|
+
const info1 = power ? this.emit('info', `Current operation mode: ${operationModeStatus.toUpperCase()}`) : false;
|
|
666
684
|
const info2 = power ? this.emit('info', `Target temperature: ${setTemperature}${temperatureUnit}`) : false;
|
|
667
685
|
const info3 = power ? this.emit('info', `Current temperature: ${roomTemperature}${temperatureUnit}`) : false;
|
|
668
686
|
const info4 = power && outdoorTemperature !== null ? this.emit('info', `Outdoor temperature: ${outdoorTemperature}${temperatureUnit}`) : false;
|
|
669
687
|
const info5 = power && modelSupportsFanSpeed ? this.emit('info', `Target Fan speed: ${fanSpeed.toUpperCase()}`) : false;
|
|
670
|
-
const info6 = power && modelSupportsFanSpeed ? this.emit('info', `Current Fan speed: ${
|
|
688
|
+
const info6 = power && modelSupportsFanSpeed ? this.emit('info', `Current Fan speed: ${fanSpeedStatus.toUpperCase()}`) : false;
|
|
671
689
|
const info7 = power && vaneHorizontalDirection !== 'Unknown' ? this.emit('info', `Vane horizontal: ${MiElHVAC.HorizontalVane[vaneHorizontalDirection] ?? vaneHorizontalDirection}`) : false;
|
|
672
690
|
const info8 = power && vaneVerticalDirection !== 'Unknown' ? this.emit('info', `Vane vertical: ${MiElHVAC.VerticalVane[vaneVerticalDirection] ?? vaneVerticalDirection}`) : false;
|
|
673
691
|
const info9 = power ? this.emit('info', `Swing mode: ${MiElHVAC.SwingMode[swingMode]}`) : false;
|
|
@@ -688,13 +706,13 @@ class MiElHvac extends EventEmitter {
|
|
|
688
706
|
async updateRemoteTemp() {
|
|
689
707
|
try {
|
|
690
708
|
//get remote temp
|
|
691
|
-
const rmoteTempData = await this.axiosInstanceRemoteTemp();
|
|
709
|
+
const rmoteTempData = await this.axiosInstanceRemoteTemp.get();
|
|
692
710
|
const remoteTemp = rmoteTempData.data ?? false;
|
|
693
|
-
|
|
711
|
+
if (this.enableDebugMode) this.emit('debug', `Remote temp: ${JSON.stringify(remoteTemp, null, 2)}`);
|
|
694
712
|
|
|
695
713
|
//set remote temp
|
|
696
|
-
const temp = `${MiElHVAC.
|
|
697
|
-
await this.axiosInstance(temp);
|
|
714
|
+
const temp = `${MiElHVAC.SetRemoteTemp}${remoteTemp}`
|
|
715
|
+
await this.axiosInstance.get(temp);
|
|
698
716
|
|
|
699
717
|
return true
|
|
700
718
|
} catch (error) {
|
|
@@ -702,31 +720,11 @@ class MiElHvac extends EventEmitter {
|
|
|
702
720
|
}
|
|
703
721
|
}
|
|
704
722
|
|
|
705
|
-
async saveData(path, data) {
|
|
706
|
-
try {
|
|
707
|
-
data = JSON.stringify(data, null, 2);
|
|
708
|
-
await fsPromises.writeFile(path, data);
|
|
709
|
-
const debug = !this.enableDebugMode ? false : this.emit('debug', `Saved data: ${data}`);
|
|
710
|
-
return true;
|
|
711
|
-
} catch (error) {
|
|
712
|
-
throw new Error(`Save data error: ${error}`);
|
|
713
|
-
}
|
|
714
|
-
}
|
|
715
|
-
|
|
716
|
-
async readData(path) {
|
|
717
|
-
try {
|
|
718
|
-
const data = await fsPromises.readFile(path);
|
|
719
|
-
return data;
|
|
720
|
-
} catch (error) {
|
|
721
|
-
throw new Error(`Read data error: ${error}`);
|
|
722
|
-
}
|
|
723
|
-
}
|
|
724
|
-
|
|
725
723
|
async startImpulseGenerator() {
|
|
726
724
|
try {
|
|
727
725
|
//start impulse generator
|
|
728
|
-
const timers = [{ name: '
|
|
729
|
-
|
|
726
|
+
const timers = [{ name: 'checkState', sampling: this.refreshInterval }];
|
|
727
|
+
if (this.remoteTemperatureSensorEnable) timers.push({ name: 'updateRemoteTemp', sampling: this.remoteTemperatureSensorRefreshInterval });
|
|
730
728
|
await this.impulseGenerator.start(timers);
|
|
731
729
|
return true;
|
|
732
730
|
} catch (error) {
|
|
@@ -747,7 +745,7 @@ class MiElHvac extends EventEmitter {
|
|
|
747
745
|
|
|
748
746
|
//prepare accessory
|
|
749
747
|
async prepareAccessory() {
|
|
750
|
-
|
|
748
|
+
if (this.enableDebugMode) this.emit('debug', `Prepare Accessory`);
|
|
751
749
|
|
|
752
750
|
try {
|
|
753
751
|
//accessory
|
|
@@ -757,7 +755,7 @@ class MiElHvac extends EventEmitter {
|
|
|
757
755
|
const accessory = new Accessory(accessoryName, accessoryUUID, accessoryCategory);
|
|
758
756
|
|
|
759
757
|
//Prepare information service
|
|
760
|
-
|
|
758
|
+
if (this.enableDebugMode) this.emit('debug', `Prepare Information Service`);
|
|
761
759
|
accessory.getService(Service.AccessoryInformation)
|
|
762
760
|
.setCharacteristic(Characteristic.Manufacturer, 'Tasmota')
|
|
763
761
|
.setCharacteristic(Characteristic.Model, this.info.modelName ?? 'Model Name')
|
|
@@ -766,8 +764,8 @@ class MiElHvac extends EventEmitter {
|
|
|
766
764
|
.setCharacteristic(Characteristic.ConfiguredName, accessoryName);
|
|
767
765
|
|
|
768
766
|
//Prepare services
|
|
769
|
-
|
|
770
|
-
|
|
767
|
+
if (this.enableDebugMode) this.emit('debug', `Prepare Services`);
|
|
768
|
+
if (this.enableDebugMode) this.emit('debug', `Prepare mitsubishi hvac service`);
|
|
771
769
|
const autoDryFanMode = [MiElHVAC.SetMode.auto, MiElHVAC.SetMode.auto, MiElHVAC.SetMode.dry, MiElHVAC.SetMode.fan][this.autoDryFanMode]; //NONE, AUTO, DRY, FAN
|
|
772
770
|
const heatDryFanMode = [MiElHVAC.SetMode.heat, MiElHVAC.SetMode.heat, MiElHVAC.SetMode.dry, MiElHVAC.SetMode.fan][this.heatDryFanMode]; //NONE, HEAT, DRY, FAN
|
|
773
771
|
const coolDryFanMode = [MiElHVAC.SetMode.cool, MiElHVAC.SetMode.cool, MiElHVAC.SetMode.dry, MiElHVAC.SetMode.fan][this.coolDryFanMode]; //NONE, COOL, DRY, FAN
|
|
@@ -785,8 +783,8 @@ class MiElHvac extends EventEmitter {
|
|
|
785
783
|
.onSet(async (state) => {
|
|
786
784
|
try {
|
|
787
785
|
const power = [MiElHVAC.PowerOff, MiElHVAC.PowerOn][state];
|
|
788
|
-
await this.axiosInstance(power);
|
|
789
|
-
|
|
786
|
+
await this.axiosInstance.get(power);
|
|
787
|
+
if (!this.disableLogInfo) this.emit('info', `Set power: ${state ? 'ON' : 'OFF'}`);
|
|
790
788
|
} catch (error) {
|
|
791
789
|
this.emit('warn', `Set power error: ${error}`);
|
|
792
790
|
}
|
|
@@ -810,17 +808,17 @@ class MiElHvac extends EventEmitter {
|
|
|
810
808
|
try {
|
|
811
809
|
switch (value) {
|
|
812
810
|
case 0: //AUTO
|
|
813
|
-
await this.axiosInstance(autoDryFanMode);
|
|
811
|
+
await this.axiosInstance.get(autoDryFanMode);
|
|
814
812
|
break;
|
|
815
813
|
case 1: //HEAT
|
|
816
|
-
await this.axiosInstance(heatDryFanMode);
|
|
814
|
+
await this.axiosInstance.get(heatDryFanMode);
|
|
817
815
|
break;
|
|
818
816
|
case 2: //COOL
|
|
819
|
-
await this.axiosInstance(coolDryFanMode);
|
|
817
|
+
await this.axiosInstance.get(coolDryFanMode);
|
|
820
818
|
break;
|
|
821
819
|
};
|
|
822
820
|
|
|
823
|
-
|
|
821
|
+
if (!this.disableLogInfo) this.emit('info', `Set operation mode: ${MiElHVAC.OperationMode[value]}`);
|
|
824
822
|
} catch (error) {
|
|
825
823
|
this.emit('warn', `Set operation mode error: ${error}`);
|
|
826
824
|
}
|
|
@@ -866,8 +864,8 @@ class MiElHvac extends EventEmitter {
|
|
|
866
864
|
|
|
867
865
|
//fan speed mode
|
|
868
866
|
const fanSpeedMap = ['auto', 'quiet', '1', '2', '3', '4'][fanSpeed];
|
|
869
|
-
await this.axiosInstance(MiElHVAC.SetFanSpeed[fanSpeedMap]);
|
|
870
|
-
|
|
867
|
+
await this.axiosInstance.get(MiElHVAC.SetFanSpeed[fanSpeedMap]);
|
|
868
|
+
if (!this.disableLogInfo) this.emit('info', `Set fan speed mode: ${MiElHVAC.FanSpeed[fanSpeedModeText]}`);
|
|
871
869
|
} catch (error) {
|
|
872
870
|
this.emit('warn', `Set fan speed mode error: ${error}`);
|
|
873
871
|
}
|
|
@@ -883,20 +881,20 @@ class MiElHvac extends EventEmitter {
|
|
|
883
881
|
try {
|
|
884
882
|
switch (value) {
|
|
885
883
|
case 0:
|
|
886
|
-
await this.axiosInstance(MiElHVAC.SetSwingV[this.previousStateSwingV]);
|
|
887
|
-
await this.axiosInstance(MiElHVAC.SetSwingH[this.previousStateSwingH]);
|
|
884
|
+
await this.axiosInstance.get(MiElHVAC.SetSwingV[this.previousStateSwingV]);
|
|
885
|
+
await this.axiosInstance.get(MiElHVAC.SetSwingH[this.previousStateSwingH]);
|
|
888
886
|
break;
|
|
889
887
|
case 1:
|
|
890
888
|
//set vane v
|
|
891
889
|
this.previousStateSwingV = this.mielHvac.vaneVerticalDirection;
|
|
892
|
-
await this.axiosInstance(MiElHVAC.SetSwingV.swing);
|
|
890
|
+
await this.axiosInstance.get(MiElHVAC.SetSwingV.swing);
|
|
893
891
|
|
|
894
892
|
//set vane h
|
|
895
893
|
this.previousStateSwingH = this.mielHvac.vaneHorizontalDirection;
|
|
896
|
-
await this.axiosInstance(MiElHVAC.SetSwingH.swing);
|
|
894
|
+
await this.axiosInstance.get(MiElHVAC.SetSwingH.swing);
|
|
897
895
|
break;
|
|
898
896
|
}
|
|
899
|
-
|
|
897
|
+
if (!this.disableLogInfo) this.emit('info', `Set air direction mode: ${MiElHVAC.SwingMode[value]}`);
|
|
900
898
|
} catch (error) {
|
|
901
899
|
this.emit('warn', `Set vane swing mode error: ${error}`);
|
|
902
900
|
}
|
|
@@ -915,13 +913,13 @@ class MiElHvac extends EventEmitter {
|
|
|
915
913
|
.onSet(async (value) => {
|
|
916
914
|
try {
|
|
917
915
|
if (this.mielHvac.targetOperationMode === 0) {
|
|
918
|
-
await this.saveData(this.info.defaultCoolingSetTemperatureFile, value);
|
|
916
|
+
await this.functions.saveData(this.info.defaultCoolingSetTemperatureFile, value);
|
|
919
917
|
value = (value + this.info.mielHvac.defaultHeatingSetTemperature) / 2;
|
|
920
918
|
}
|
|
921
919
|
|
|
922
920
|
const temp = `${MiElHVAC.SetTemp}${value}`
|
|
923
|
-
await this.axiosInstance(temp);
|
|
924
|
-
|
|
921
|
+
await this.axiosInstance.get(temp);
|
|
922
|
+
if (!this.disableLogInfo) this.emit('info', `Set ${this.mielHvac.targetOperationMode === 2 ? 'temperature' : 'cooling threshold temperature'}: ${value}${this.mielHvac.temperatureUnit}`);
|
|
925
923
|
} catch (error) {
|
|
926
924
|
this.emit('warn', `Set cooling threshold temperature error: ${error}`);
|
|
927
925
|
}
|
|
@@ -940,13 +938,13 @@ class MiElHvac extends EventEmitter {
|
|
|
940
938
|
.onSet(async (value) => {
|
|
941
939
|
try {
|
|
942
940
|
if (this.mielHvac.targetOperationMode === 0) {
|
|
943
|
-
await this.saveData(this.info.defaultHeatingSetTemperatureFile, value);
|
|
941
|
+
await this.functions.saveData(this.info.defaultHeatingSetTemperatureFile, value);
|
|
944
942
|
value = (value + this.info.mielHvac.defaultCoolingSetTemperature) / 2;
|
|
945
943
|
}
|
|
946
944
|
|
|
947
945
|
const temp = `${MiElHVAC.SetTemp}${value}`
|
|
948
|
-
await this.axiosInstance(temp);
|
|
949
|
-
|
|
946
|
+
await this.axiosInstance.get(temp);
|
|
947
|
+
if (!this.disableLogInfo) this.emit('info', `Set ${this.mielHvac.targetOperationMode === 1 ? 'temperature' : 'heating threshold temperature'}: ${value}${this.mielHvac.temperatureUnit}`);
|
|
950
948
|
} catch (error) {
|
|
951
949
|
this.emit('warn', `Set heating threshold temperature error: ${error}`);
|
|
952
950
|
}
|
|
@@ -960,8 +958,8 @@ class MiElHvac extends EventEmitter {
|
|
|
960
958
|
.onSet(async (value) => {
|
|
961
959
|
try {
|
|
962
960
|
const lock = [MiElHVAC.SetProhibit.off, MiElHVAC.SetProhibit.all][value];
|
|
963
|
-
await this.axiosInstance(lock);
|
|
964
|
-
|
|
961
|
+
await this.axiosInstance.get(lock);
|
|
962
|
+
if (!this.disableLogInfo) this.emit('info', `Set local physical controls: ${value ? 'LOCK' : 'UNLOCK'}`);
|
|
965
963
|
} catch (error) {
|
|
966
964
|
this.emit('warn', `Set lock physical controls error: ${error}`);
|
|
967
965
|
}
|
|
@@ -974,8 +972,8 @@ class MiElHvac extends EventEmitter {
|
|
|
974
972
|
.onSet(async (value) => {
|
|
975
973
|
try {
|
|
976
974
|
const unit = [MiElHVAC.SetDisplayUnit.c, MiElHVAC.SetDisplayUnit.f][value];
|
|
977
|
-
//await this.axiosInstance(unit);
|
|
978
|
-
|
|
975
|
+
//await this.axiosInstance.get(unit);
|
|
976
|
+
if (!this.disableLogInfo) this.emit('info', `Set temperature display unit: ${TemperatureDisplayUnits[value]}`);
|
|
979
977
|
} catch (error) {
|
|
980
978
|
this.emit('warn', `Set temperature display unit error: ${error}`);
|
|
981
979
|
}
|
|
@@ -1002,7 +1000,7 @@ class MiElHvac extends EventEmitter {
|
|
|
1002
1000
|
if (state) {
|
|
1003
1001
|
// Power on if needed
|
|
1004
1002
|
if (!this.mielHvac.power) {
|
|
1005
|
-
await this.axiosInstance(MiElHVAC.PowerOn);
|
|
1003
|
+
await this.axiosInstance.get(MiElHVAC.PowerOn);
|
|
1006
1004
|
}
|
|
1007
1005
|
|
|
1008
1006
|
// Apply preset commands in sequence
|
|
@@ -1015,7 +1013,7 @@ class MiElHvac extends EventEmitter {
|
|
|
1015
1013
|
];
|
|
1016
1014
|
|
|
1017
1015
|
for (const cmd of commands) {
|
|
1018
|
-
await this.axiosInstance(cmd);
|
|
1016
|
+
await this.axiosInstance.get(cmd);
|
|
1019
1017
|
}
|
|
1020
1018
|
|
|
1021
1019
|
if (!this.disableLogInfo) {
|
|
@@ -1067,9 +1065,9 @@ class MiElHvac extends EventEmitter {
|
|
|
1067
1065
|
11: () => getCommand('SetSwingH', 'left_middle'),
|
|
1068
1066
|
12: () => getCommand('SetSwingH', 'left_center'),
|
|
1069
1067
|
13: () => getCommand('SetSwingH', 'center'),
|
|
1070
|
-
14: () => getCommand('SetSwingH', '
|
|
1071
|
-
15: () => getCommand('SetSwingH', '
|
|
1072
|
-
16: () => getCommand('SetSwingH', '
|
|
1068
|
+
14: () => getCommand('SetSwingH', 'right_center'),
|
|
1069
|
+
15: () => getCommand('SetSwingH', 'right_middle'),
|
|
1070
|
+
16: () => getCommand('SetSwingH', 'right'),
|
|
1073
1071
|
17: () => getCommand('SetSwingH', 'split'),
|
|
1074
1072
|
18: () => getCommand('SetSwingH', 'swing'),
|
|
1075
1073
|
|
|
@@ -1094,7 +1092,6 @@ class MiElHvac extends EventEmitter {
|
|
|
1094
1092
|
40: () => getCommand('SetAirDirection', 'indirect'),
|
|
1095
1093
|
41: () => getCommand('SetAirDirection', 'direct'),
|
|
1096
1094
|
42: () => getCommand('SetAirDirection', 'even'),
|
|
1097
|
-
43: () => getCommand('SetAirDirection', 'off'),
|
|
1098
1095
|
|
|
1099
1096
|
// Prohibit
|
|
1100
1097
|
50: () => getCommand('SetProhibit', 'all'),
|
|
@@ -1104,6 +1101,9 @@ class MiElHvac extends EventEmitter {
|
|
|
1104
1101
|
|
|
1105
1102
|
// Purify
|
|
1106
1103
|
60: () => getCommand('SetPurify', 'purify'),
|
|
1104
|
+
61: () => getCommand('SetEconoCool', 'econocool'),
|
|
1105
|
+
62: () => getCommand('SetPowerFull', 'powerfull'),
|
|
1106
|
+
63: () => getCommand('SetNightMode', 'nightmode'),
|
|
1107
1107
|
};
|
|
1108
1108
|
|
|
1109
1109
|
const getCommand = (type, target) => {
|
|
@@ -1121,6 +1121,9 @@ class MiElHvac extends EventEmitter {
|
|
|
1121
1121
|
case 'SetAirDirection': return 'airDirection';
|
|
1122
1122
|
case 'SetProhibit': return 'prohibit';
|
|
1123
1123
|
case 'SetPurify': return 'purify';
|
|
1124
|
+
case 'SetEconoCool': return 'econoCool';
|
|
1125
|
+
case 'SetPowerFull': return 'powerFull';
|
|
1126
|
+
case 'SetNightMode': return 'nightMode';
|
|
1124
1127
|
default: return '';
|
|
1125
1128
|
}
|
|
1126
1129
|
};
|
|
@@ -1131,11 +1134,11 @@ class MiElHvac extends EventEmitter {
|
|
|
1131
1134
|
}
|
|
1132
1135
|
|
|
1133
1136
|
data = mappings[mode]();
|
|
1134
|
-
if (!this.mielHvac.power && state && mode > 0 && mode <=
|
|
1135
|
-
await this.axiosInstance(MiElHVAC.PowerOn);
|
|
1137
|
+
if (!this.mielHvac.power && state && mode > 0 && mode <= 63) {
|
|
1138
|
+
await this.axiosInstance.get(MiElHVAC.PowerOn);
|
|
1136
1139
|
}
|
|
1137
1140
|
|
|
1138
|
-
await this.axiosInstance(data);
|
|
1141
|
+
await this.axiosInstance.get(data);
|
|
1139
1142
|
|
|
1140
1143
|
if (!this.disableLogInfo) {
|
|
1141
1144
|
const action = state ? `Set: ${buttonName}` : `Unset: ${buttonName}, Set: ${button.previousValue}`;
|
|
@@ -1156,7 +1159,7 @@ class MiElHvac extends EventEmitter {
|
|
|
1156
1159
|
|
|
1157
1160
|
//sensors services
|
|
1158
1161
|
if (this.sensorsConfiguredCount > 0) {
|
|
1159
|
-
|
|
1162
|
+
if (this.enableDebugMode) this.emit('debug', `Prepare sensors services`);
|
|
1160
1163
|
this.sensorsServices = [];
|
|
1161
1164
|
|
|
1162
1165
|
this.sensorsConfigured.forEach((sensor, index) => {
|
|
@@ -1184,7 +1187,7 @@ class MiElHvac extends EventEmitter {
|
|
|
1184
1187
|
|
|
1185
1188
|
//room temperature sensor service
|
|
1186
1189
|
if (this.temperatureSensor && this.mielHvac.roomTemperature !== null) {
|
|
1187
|
-
|
|
1190
|
+
if (this.enableDebugMode) this.emit('debug', `Prepare room temperature sensor service`);
|
|
1188
1191
|
this.roomTemperatureSensorService = new Service.TemperatureSensor(`${serviceName} Room`, `Room Temperature Sensor`);
|
|
1189
1192
|
this.roomTemperatureSensorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
|
|
1190
1193
|
this.roomTemperatureSensorService.setCharacteristic(Characteristic.ConfiguredName, `${accessoryName} Room`);
|
|
@@ -1203,7 +1206,7 @@ class MiElHvac extends EventEmitter {
|
|
|
1203
1206
|
|
|
1204
1207
|
//outdoor temperature sensor service
|
|
1205
1208
|
if (this.temperatureSensorOutdoor && this.mielHvac.hasOutdoorTemperature && this.mielHvac.outdoorTemperature !== null) {
|
|
1206
|
-
|
|
1209
|
+
if (this.enableDebugMode) this.emit('debug', `Prepare outdoor temperature sensor service`);
|
|
1207
1210
|
this.outdoorTemperatureSensorService = new Service.TemperatureSensor(`${serviceName} Outdoor`, `Outdoor Temperature Sensor`);
|
|
1208
1211
|
this.outdoorTemperatureSensorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
|
|
1209
1212
|
this.outdoorTemperatureSensorService.setCharacteristic(Characteristic.ConfiguredName, `${accessoryName} Outdoor`);
|
|
@@ -1230,22 +1233,18 @@ class MiElHvac extends EventEmitter {
|
|
|
1230
1233
|
async start() {
|
|
1231
1234
|
try {
|
|
1232
1235
|
//check device state
|
|
1233
|
-
await this.
|
|
1236
|
+
const checkState = await this.checkState();
|
|
1237
|
+
if (!checkState) return null;
|
|
1234
1238
|
|
|
1235
1239
|
//connect to deice success
|
|
1236
1240
|
this.emit('success', `Connect Success`)
|
|
1237
1241
|
|
|
1238
1242
|
//check device info
|
|
1239
|
-
|
|
1243
|
+
if (!this.disableLogDeviceInfo) await this.deviceInfo();
|
|
1240
1244
|
|
|
1241
1245
|
//start prepare accessory
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
const publishAccessory = this.emit('publishAccessory', accessory);
|
|
1245
|
-
this.startPrepareAccessory = false;
|
|
1246
|
-
}
|
|
1247
|
-
|
|
1248
|
-
return true;
|
|
1246
|
+
const accessory = await this.prepareAccessory();
|
|
1247
|
+
return accessory;
|
|
1249
1248
|
} catch (error) {
|
|
1250
1249
|
throw new Error(`Start error: ${error}`);
|
|
1251
1250
|
}
|