homebridge-melcloud-control 4.7.6-beta.3 → 4.7.6-beta.5
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/homebridge-ui/public/index.html +5 -5
- package/homebridge-ui/server.js +5 -8
- package/index.js +30 -33
- package/package.json +1 -1
- package/src/deviceata.js +48 -45
- package/src/deviceatw.js +46 -42
- package/src/deviceerv.js +31 -28
- package/src/melcloud.js +24 -36
- package/src/melcloudata.js +5 -7
- package/src/melcloudatw.js +5 -7
- package/src/melclouderv.js +5 -7
- package/src/melcloudhome.js +34 -41
|
@@ -255,10 +255,10 @@
|
|
|
255
255
|
|
|
256
256
|
try {
|
|
257
257
|
const account = this.account;
|
|
258
|
-
const
|
|
258
|
+
const melCloudDevicesData = await homebridge.request('/connect', account);
|
|
259
259
|
|
|
260
|
-
if (!
|
|
261
|
-
updateInfo('info',
|
|
260
|
+
if (!melCloudDevicesData.State) {
|
|
261
|
+
updateInfo('info', melCloudDevicesData.Status, 'red');
|
|
262
262
|
document.getElementById('logIn').disabled = false;
|
|
263
263
|
homebridge.hideSpinner();
|
|
264
264
|
return;
|
|
@@ -272,10 +272,10 @@
|
|
|
272
272
|
// Prepare MELCloud data
|
|
273
273
|
const newInMelCloud = { ata: [], ataPresets: [], ataSchedules: [], ataScenes: [], atw: [], atwPresets: [], atwSchedules: [], atwScenes: [], erv: [], ervPresets: [], ervSchedules: [], ervScenes: [] };
|
|
274
274
|
const devicesInMelCloudByType = { ata: [], atw: [], erv: [] };
|
|
275
|
-
const scenesInMelCloud =
|
|
275
|
+
const scenesInMelCloud = melCloudDevicesData.Scenes ?? [];
|
|
276
276
|
|
|
277
277
|
// Split devices by type
|
|
278
|
-
const devices =
|
|
278
|
+
const devices = melCloudDevicesData.Devices;
|
|
279
279
|
for (const device of devices) {
|
|
280
280
|
if (device.Type === 0) devicesInMelCloudByType.ata.push(device);
|
|
281
281
|
if (device.Type === 1) devicesInMelCloudByType.atw.push(device);
|
package/homebridge-ui/server.js
CHANGED
|
@@ -14,17 +14,14 @@ class PluginUiServer extends HomebridgePluginUiServer {
|
|
|
14
14
|
};
|
|
15
15
|
|
|
16
16
|
async start(account) {
|
|
17
|
-
const
|
|
18
|
-
const accountFile = `${this.homebridgeStoragePath}/melcloud/${accountName}_Account`;
|
|
19
|
-
const buildingsFile = `${this.homebridgeStoragePath}/melcloud/${accountName}_Buildings`;
|
|
20
|
-
const melCloud = account.type === 'melcloud' ? new MelCloud(account, accountFile, buildingsFile) : new MelCloudHome(account, accountFile, buildingsFile);
|
|
17
|
+
const melCloudClass = account.type === 'melcloud' ? new MelCloud(account) : new MelCloudHome(account);
|
|
21
18
|
|
|
22
19
|
try {
|
|
23
|
-
const
|
|
24
|
-
if (!
|
|
20
|
+
const melCloudAccountData = await melCloudClass.connect();
|
|
21
|
+
if (!melCloudAccountData.State) return melCloudAccountData;
|
|
25
22
|
|
|
26
|
-
const
|
|
27
|
-
return
|
|
23
|
+
const melCloudDevicesData = await melCloudClass.checkDevicesList();
|
|
24
|
+
return melCloudDevicesData;
|
|
28
25
|
} catch (error) {
|
|
29
26
|
throw new Error(error);
|
|
30
27
|
}
|
package/index.js
CHANGED
|
@@ -37,7 +37,8 @@ class MelCloudPlatform {
|
|
|
37
37
|
continue;
|
|
38
38
|
}
|
|
39
39
|
accountsName.push(name);
|
|
40
|
-
const accountRefreshInterval = (account.refreshInterval ?? 120) * 1000
|
|
40
|
+
const accountRefreshInterval = (account.refreshInterval ?? 120) * 1000;
|
|
41
|
+
const accountMelcloud = account.type === 'melcloud';
|
|
41
42
|
|
|
42
43
|
//log config
|
|
43
44
|
const logLevel = {
|
|
@@ -64,59 +65,55 @@ class MelCloudPlatform {
|
|
|
64
65
|
log.info(`${name}, Config: ${JSON.stringify(safeConfig, null, 2)}`);
|
|
65
66
|
}
|
|
66
67
|
|
|
67
|
-
//define directory and file paths
|
|
68
|
-
const accountFile = `${prefDir}/${name}_Account`;
|
|
69
|
-
const buildingsFile = `${prefDir}/${name}_Buildings`;
|
|
70
|
-
|
|
71
68
|
try {
|
|
72
69
|
//create impulse generator
|
|
73
70
|
const impulseGenerator = new ImpulseGenerator()
|
|
74
71
|
.on('start', async () => {
|
|
75
72
|
try {
|
|
76
73
|
//melcloud account
|
|
77
|
-
let
|
|
74
|
+
let melCloudClass;
|
|
78
75
|
let timmers = []
|
|
79
76
|
switch (account.type) {
|
|
80
77
|
case 'melcloud':
|
|
81
78
|
timmers = [{ name: 'checkDevicesList', sampling: accountRefreshInterval }];
|
|
82
|
-
|
|
79
|
+
melCloudClass = new MelCloud(account, true);
|
|
83
80
|
break;
|
|
84
81
|
case 'melcloudhome':
|
|
85
82
|
timmers = [{ name: 'connect', sampling: 3300000 }, { name: 'checkDevicesList', sampling: 5000 }];
|
|
86
|
-
|
|
83
|
+
melCloudClass = new MelCloudHome(account, true);
|
|
87
84
|
break;
|
|
88
85
|
default:
|
|
89
86
|
if (logLevel.warn) log.warn(`Unknown account type: ${account.type}.`);
|
|
90
87
|
return;
|
|
91
88
|
}
|
|
92
|
-
|
|
89
|
+
melCloudClass.on('success', (msg) => logLevel.success && log.success(`${name}, ${msg}`))
|
|
93
90
|
.on('info', (msg) => log.info(`${name}, ${msg}`))
|
|
94
91
|
.on('debug', (msg) => log.info(`${name}, debug: ${msg}`))
|
|
95
92
|
.on('warn', (msg) => log.warn(`${name}, ${msg}`))
|
|
96
93
|
.on('error', (msg) => log.error(`${name}, ${msg}`));
|
|
97
94
|
|
|
98
95
|
//connect
|
|
99
|
-
const
|
|
100
|
-
if (!
|
|
101
|
-
if (logLevel.warn) log.warn(`${name}, ${
|
|
96
|
+
const melCloudAccountData = await melCloudClass.connect();
|
|
97
|
+
if (!melCloudAccountData?.State) {
|
|
98
|
+
if (logLevel.warn) log.warn(`${name}, ${melCloudAccountData.Status}`);
|
|
102
99
|
return;
|
|
103
100
|
}
|
|
104
|
-
if (logLevel.success) log.success(`${name}, ${
|
|
101
|
+
if (logLevel.success) log.success(`${name}, ${melCloudAccountData.Status}`);
|
|
105
102
|
|
|
106
103
|
//check devices list
|
|
107
|
-
const
|
|
108
|
-
if (!
|
|
109
|
-
if (logLevel.warn) log.warn(`${name}, ${
|
|
104
|
+
const melCloudDevicesData = await melCloudClass.checkDevicesList();
|
|
105
|
+
if (!melCloudDevicesData.State) {
|
|
106
|
+
if (logLevel.warn) log.warn(`${name}, ${melCloudDevicesData.Status}`);
|
|
110
107
|
return;
|
|
111
108
|
}
|
|
112
|
-
if (logLevel.debug) log.info(
|
|
109
|
+
if (logLevel.debug) log.info(melCloudDevicesData.Status);
|
|
113
110
|
await new Promise(r => setTimeout(r, 1000));
|
|
114
111
|
|
|
115
112
|
//start account impulse generator
|
|
116
|
-
await
|
|
113
|
+
await melCloudClass.impulseGenerator.state(true, timmers, false);
|
|
117
114
|
|
|
118
115
|
//filter configured devices
|
|
119
|
-
const devicesIds = (
|
|
116
|
+
const devicesIds = (melCloudDevicesData.Devices ?? []).map(d => String(d.DeviceID));
|
|
120
117
|
const ataDevices = (account.ataDevices || []).filter(d => (d.displayType ?? 0) > 0 && devicesIds.includes(d.id));
|
|
121
118
|
const atwDevices = (account.atwDevices || []).filter(d => (d.displayType ?? 0) > 0 && devicesIds.includes(d.id));
|
|
122
119
|
const ervDevices = (account.ervDevices || []).filter(d => (d.displayType ?? 0) > 0 && devicesIds.includes(d.id));
|
|
@@ -132,20 +129,20 @@ class MelCloudPlatform {
|
|
|
132
129
|
const defaultTempsFile = `${prefDir}/${name}_${device.id}_Temps`;
|
|
133
130
|
|
|
134
131
|
//device in melcloud
|
|
135
|
-
const
|
|
136
|
-
|
|
132
|
+
const melCloudDeviceData = melCloudDevicesData.Devices.find(d => d.DeviceID === device.id);
|
|
133
|
+
melCloudDeviceData.Scenes = melCloudDevicesData.Scenes ?? [];
|
|
137
134
|
|
|
138
135
|
//presets
|
|
139
|
-
const presetIds = (
|
|
140
|
-
const presets =
|
|
136
|
+
const presetIds = (melCloudDeviceData.Presets ?? []).map(p => String(p.ID));
|
|
137
|
+
const presets = accountMelcloud ? (device.presets || []).filter(p => (p.displayType ?? 0) > 0 && presetIds.includes(p.id)) : [];
|
|
141
138
|
|
|
142
139
|
//schedules
|
|
143
|
-
const schedulesIds = (
|
|
144
|
-
const schedules =
|
|
140
|
+
const schedulesIds = (melCloudDeviceData.Schedule ?? []).map(s => String(s.Id));
|
|
141
|
+
const schedules = !accountMelcloud ? (device.schedules || []).filter(s => (s.displayType ?? 0) > 0 && schedulesIds.includes(s.id)) : [];
|
|
145
142
|
|
|
146
143
|
//scenes
|
|
147
|
-
const scenesIds = (
|
|
148
|
-
const scenes =
|
|
144
|
+
const scenesIds = (melCloudDevicesData.Scenes ?? []).map(s => String(s.Id));
|
|
145
|
+
const scenes = !accountMelcloud ? (device.scenes || []).filter(s => (s.displayType ?? 0) > 0 && scenesIds.includes(s.id)) : [];
|
|
149
146
|
|
|
150
147
|
//buttons
|
|
151
148
|
const buttons = (device.buttonsSensors || []).filter(b => (b.displayType ?? 0) > 0);
|
|
@@ -172,32 +169,32 @@ class MelCloudPlatform {
|
|
|
172
169
|
}
|
|
173
170
|
}
|
|
174
171
|
|
|
175
|
-
let
|
|
172
|
+
let deviceClass;
|
|
176
173
|
switch (deviceType) {
|
|
177
174
|
case 0: //ATA
|
|
178
|
-
|
|
175
|
+
deviceClass = new DeviceAta(api, account, device, presets, schedules, scenes, buttons, defaultTempsFile, melCloudClass, melCloudAccountData, melCloudDeviceData);
|
|
179
176
|
break;
|
|
180
177
|
case 1: //ATW
|
|
181
|
-
|
|
178
|
+
deviceClass = new DeviceAtw(api, account, device, presets, schedules, scenes, buttons, defaultTempsFile, melCloudClass, melCloudAccountData, melCloudDeviceData);
|
|
182
179
|
break;
|
|
183
180
|
case 2:
|
|
184
181
|
break;
|
|
185
182
|
case 3: //ERV
|
|
186
|
-
|
|
183
|
+
deviceClass = new DeviceErv(api, account, device, presets, schedules, scenes, buttons, defaultTempsFile, melCloudClass, melCloudAccountData, melCloudDeviceData);
|
|
187
184
|
break;
|
|
188
185
|
default:
|
|
189
186
|
if (logLevel.warn) log.warn(`${name}, ${deviceTypeString}, ${deviceName}, unknown device: ${deviceType}.`);
|
|
190
187
|
return;
|
|
191
188
|
}
|
|
192
189
|
|
|
193
|
-
|
|
190
|
+
deviceClass.on('devInfo', (info) => logLevel.devInfo && log.info(info))
|
|
194
191
|
.on('success', (msg) => logLevel.success && log.success(`${name}, ${deviceTypeString}, ${deviceName}, ${msg}`))
|
|
195
192
|
.on('info', (msg) => log.info(`${name}, ${deviceTypeString}, ${deviceName}, ${msg}`))
|
|
196
193
|
.on('debug', (msg) => log.info(`${name}, ${deviceTypeString}, ${deviceName}, debug: ${msg}`))
|
|
197
194
|
.on('warn', (msg) => log.warn(`${name}, ${deviceTypeString}, ${deviceName}, ${msg}`))
|
|
198
195
|
.on('error', (msg) => log.error(`${name}, ${deviceTypeString}, ${deviceName}, ${msg}`));
|
|
199
196
|
|
|
200
|
-
const accessory = await
|
|
197
|
+
const accessory = await deviceClass.start();
|
|
201
198
|
if (accessory) {
|
|
202
199
|
api.publishExternalAccessories(PluginName, [accessory]);
|
|
203
200
|
if (logLevel.success) log.success(`${name}, ${deviceTypeString}, ${deviceName}, Published as external accessory.`);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"displayName": "MELCloud Control",
|
|
3
3
|
"name": "homebridge-melcloud-control",
|
|
4
|
-
"version": "4.7.6-beta.
|
|
4
|
+
"version": "4.7.6-beta.5",
|
|
5
5
|
"description": "Homebridge plugin to control Mitsubishi Air Conditioner, Heat Pump and Energy Recovery Ventilation.",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": "grzegorz914",
|
package/src/deviceata.js
CHANGED
|
@@ -7,7 +7,7 @@ import { TemperatureDisplayUnits, AirConditioner, DeviceType } from './constants
|
|
|
7
7
|
let Accessory, Characteristic, Service, Categories, AccessoryUUID;
|
|
8
8
|
|
|
9
9
|
class DeviceAta extends EventEmitter {
|
|
10
|
-
constructor(api, account, device, presets, schedules, scenes, buttons, defaultTempsFile,
|
|
10
|
+
constructor(api, account, device, presets, schedules, scenes, buttons, defaultTempsFile, melCloudClass, melCloudAccountData, melCloudDeviceData) {
|
|
11
11
|
super();
|
|
12
12
|
|
|
13
13
|
Accessory = api.platformAccessory;
|
|
@@ -17,11 +17,10 @@ class DeviceAta extends EventEmitter {
|
|
|
17
17
|
AccessoryUUID = api.hap.uuid;
|
|
18
18
|
|
|
19
19
|
//account config
|
|
20
|
-
this.melcloud = melcloud;
|
|
21
|
-
this.melcloudDevice = deviceInMelCloud;
|
|
22
20
|
this.account = account;
|
|
23
21
|
this.accountType = account.type;
|
|
24
22
|
this.accountName = account.name;
|
|
23
|
+
this.accountTypeMelCloud = account.type === 'melcloud';
|
|
25
24
|
this.logDeviceInfo = account.log?.deviceInfo || false;
|
|
26
25
|
this.logInfo = account.log?.info || false;
|
|
27
26
|
this.logWarn = account.log?.warn || false;
|
|
@@ -51,8 +50,11 @@ class DeviceAta extends EventEmitter {
|
|
|
51
50
|
|
|
52
51
|
//files
|
|
53
52
|
this.defaultTempsFile = defaultTempsFile;
|
|
54
|
-
|
|
55
|
-
|
|
53
|
+
|
|
54
|
+
//melcloud
|
|
55
|
+
this.melCloudClass = melCloudClass;
|
|
56
|
+
this.melCloudDeviceData = melCloudDeviceData;
|
|
57
|
+
this.melCloudAccountData = melCloudAccountData;
|
|
56
58
|
|
|
57
59
|
//external integrations
|
|
58
60
|
this.restFul = account.restFul ?? {};
|
|
@@ -186,6 +188,7 @@ class DeviceAta extends EventEmitter {
|
|
|
186
188
|
|
|
187
189
|
async setOverExternalIntegration(integration, deviceData, key, value) {
|
|
188
190
|
try {
|
|
191
|
+
const accountTypeMelCloud = this.accountTypeMelCloud;
|
|
189
192
|
let set = false
|
|
190
193
|
let flag = null;
|
|
191
194
|
switch (key) {
|
|
@@ -210,7 +213,7 @@ class DeviceAta extends EventEmitter {
|
|
|
210
213
|
flag = AirConditioner.EffectiveFlags.SetTemperature;
|
|
211
214
|
break;
|
|
212
215
|
case 'FanSpeed':
|
|
213
|
-
key =
|
|
216
|
+
key = accountTypeMelCloud ? key : 'SetFanSpeed';
|
|
214
217
|
deviceData.Device[key] = value;
|
|
215
218
|
flag = AirConditioner.EffectiveFlags.SetFanSpeed;
|
|
216
219
|
break;
|
|
@@ -223,55 +226,55 @@ class DeviceAta extends EventEmitter {
|
|
|
223
226
|
flag = AirConditioner.EffectiveFlags.VaneVerticalDirection;
|
|
224
227
|
break;
|
|
225
228
|
case 'HideVaneControls':
|
|
226
|
-
if (
|
|
229
|
+
if (!accountTypeMelCloud) return;
|
|
227
230
|
|
|
228
231
|
deviceData[key] = value;
|
|
229
232
|
flag = AirConditioner.EffectiveFlags.Prohibit;
|
|
230
233
|
break;
|
|
231
234
|
case 'HideDryModeControl':
|
|
232
|
-
if (
|
|
235
|
+
if (!accountTypeMelCloud) return;
|
|
233
236
|
|
|
234
237
|
deviceData[key] = value;
|
|
235
238
|
flag = AirConditioner.EffectiveFlags.Prohibit;
|
|
236
239
|
break;
|
|
237
240
|
case 'ProhibitSetTemperature':
|
|
238
|
-
if (
|
|
241
|
+
if (!accountTypeMelCloud) return;
|
|
239
242
|
|
|
240
243
|
deviceData.Device[key] = value;
|
|
241
244
|
flag = AirConditioner.EffectiveFlags.Prohibit;
|
|
242
245
|
break;
|
|
243
246
|
case 'ProhibitOperationMode':
|
|
244
|
-
if (
|
|
247
|
+
if (!accountTypeMelCloud) return;
|
|
245
248
|
|
|
246
249
|
deviceData.Device[key] = value;
|
|
247
250
|
flag = AirConditioner.EffectiveFlags.Prohibit;
|
|
248
251
|
break;
|
|
249
252
|
case 'ProhibitPower':
|
|
250
|
-
if (
|
|
253
|
+
if (!accountTypeMelCloud) return;
|
|
251
254
|
|
|
252
255
|
deviceData.Device[key] = value;
|
|
253
256
|
flag = AirConditioner.EffectiveFlags.Prohibit;
|
|
254
257
|
break;
|
|
255
258
|
case 'FrostProtection':
|
|
256
|
-
if (
|
|
259
|
+
if (accountTypeMelCloud) return;
|
|
257
260
|
|
|
258
261
|
deviceData.Device[key].Enabled = value;
|
|
259
262
|
flag = 'frostprotection';
|
|
260
263
|
break;
|
|
261
264
|
case 'OverheatProtection':
|
|
262
|
-
if (
|
|
265
|
+
if (accountTypeMelCloud) return;
|
|
263
266
|
|
|
264
267
|
deviceData.Device[key].Enabled = value;
|
|
265
268
|
flag = 'overheatprotection';
|
|
266
269
|
break;
|
|
267
270
|
case 'Schedules':
|
|
268
|
-
if (
|
|
271
|
+
if (accountTypeMelCloud) return;
|
|
269
272
|
|
|
270
273
|
deviceData.Device[key].Enabled = value;
|
|
271
274
|
flag = 'schedule';
|
|
272
275
|
break;
|
|
273
276
|
case 'HolidayMode':
|
|
274
|
-
if (
|
|
277
|
+
if (accountTypeMelCloud) return;
|
|
275
278
|
|
|
276
279
|
deviceData.Device[key].Enabled = value;
|
|
277
280
|
flag = 'holidaymode';
|
|
@@ -404,7 +407,7 @@ class DeviceAta extends EventEmitter {
|
|
|
404
407
|
})
|
|
405
408
|
.onSet(async (value) => {
|
|
406
409
|
try {
|
|
407
|
-
const fanKey = this.
|
|
410
|
+
const fanKey = this.accountTypeMelCloud ? 'FanSpeed' : 'SetFanSpeed';
|
|
408
411
|
switch (numberOfFanSpeeds) {
|
|
409
412
|
case 2: //Fan speed mode 2
|
|
410
413
|
value = supportsAutomaticFanSpeed ? [0, 1, 2, 0][value] : [1, 1, 2][value];
|
|
@@ -495,7 +498,7 @@ class DeviceAta extends EventEmitter {
|
|
|
495
498
|
return value;
|
|
496
499
|
})
|
|
497
500
|
.onSet(async (value) => {
|
|
498
|
-
if (this.
|
|
501
|
+
if (!this.accountTypeMelCloud) return;
|
|
499
502
|
|
|
500
503
|
try {
|
|
501
504
|
value = value ? true : false;
|
|
@@ -514,13 +517,13 @@ class DeviceAta extends EventEmitter {
|
|
|
514
517
|
return value;
|
|
515
518
|
})
|
|
516
519
|
.onSet(async (value) => {
|
|
517
|
-
if (this.
|
|
520
|
+
if (!this.accountTypeMelCloud) return;
|
|
518
521
|
|
|
519
522
|
try {
|
|
520
523
|
this.accessory.useFahrenheit = value ? true : false;
|
|
521
|
-
this.
|
|
524
|
+
this.melCloudAccountData.UseFahrenheit = value ? true : false;
|
|
522
525
|
if (this.logInfo) this.emit('info', `Set temperature display unit: ${TemperatureDisplayUnits[value]}`);
|
|
523
|
-
await this.melCloudAta.send(this.accountType, this.displayType, deviceData, 'account', this.
|
|
526
|
+
await this.melCloudAta.send(this.accountType, this.displayType, deviceData, 'account', this.melCloudAccountData);
|
|
524
527
|
} catch (error) {
|
|
525
528
|
if (this.logWarn) this.emit('warn', `Set temperature display unit error: ${error}`);
|
|
526
529
|
};
|
|
@@ -613,13 +616,13 @@ class DeviceAta extends EventEmitter {
|
|
|
613
616
|
return value;
|
|
614
617
|
})
|
|
615
618
|
.onSet(async (value) => {
|
|
616
|
-
if (this.
|
|
619
|
+
if (!this.accountTypeMelCloud) return;
|
|
617
620
|
|
|
618
621
|
try {
|
|
619
622
|
this.accessory.useFahrenheit = value ? true : false;
|
|
620
|
-
this.
|
|
623
|
+
this.melCloudAccountData.UseFahrenheit = value ? true : false;
|
|
621
624
|
if (this.logInfo) this.emit('info', `Set temperature display unit: ${TemperatureDisplayUnits[value]}`);
|
|
622
|
-
await this.melCloudAta.send(this.accountType, this.displayType, deviceData, 'account', this.
|
|
625
|
+
await this.melCloudAta.send(this.accountType, this.displayType, deviceData, 'account', this.melCloudAccountData);
|
|
623
626
|
} catch (error) {
|
|
624
627
|
if (this.logWarn) this.emit('warn', `Set temperature display unit error: ${error}`);
|
|
625
628
|
};
|
|
@@ -1226,7 +1229,7 @@ class DeviceAta extends EventEmitter {
|
|
|
1226
1229
|
})
|
|
1227
1230
|
.onSet(async (state) => {
|
|
1228
1231
|
try {
|
|
1229
|
-
const fanKey = this.
|
|
1232
|
+
const fanKey = this.accountTypeMelCloud ? 'FanSpeed' : 'SetFanSpeed';
|
|
1230
1233
|
let flag = null;
|
|
1231
1234
|
switch (mode) {
|
|
1232
1235
|
case 0: //POWER ON,OFF
|
|
@@ -1467,7 +1470,7 @@ class DeviceAta extends EventEmitter {
|
|
|
1467
1470
|
async start() {
|
|
1468
1471
|
try {
|
|
1469
1472
|
//melcloud device
|
|
1470
|
-
this.melCloudAta = new MelCloudAta(this.account, this.device, this.defaultTempsFile, this.
|
|
1473
|
+
this.melCloudAta = new MelCloudAta(this.account, this.device, this.defaultTempsFile, this.melCloudClass)
|
|
1471
1474
|
.on('deviceInfo', (modelIndoor, modelOutdoor, serialNumber, firmwareAppVersion) => {
|
|
1472
1475
|
if (this.logDeviceInfo && this.displayDeviceInfo) {
|
|
1473
1476
|
this.emit('devInfo', `---- ${this.deviceTypeString}: ${this.deviceName} ----`);
|
|
@@ -1493,19 +1496,19 @@ class DeviceAta extends EventEmitter {
|
|
|
1493
1496
|
this.deviceData = deviceData;
|
|
1494
1497
|
|
|
1495
1498
|
//keys
|
|
1496
|
-
const
|
|
1497
|
-
const fanKey =
|
|
1498
|
-
const tempStepKey =
|
|
1499
|
-
const connectKey =
|
|
1500
|
-
const errorKey =
|
|
1501
|
-
const supportAirDirectionKey =
|
|
1502
|
-
const supportSwingKey =
|
|
1503
|
-
const supportVideWaneKey =
|
|
1504
|
-
const supportAutoKey =
|
|
1505
|
-
const supportHeatKey =
|
|
1506
|
-
const supportDryKey =
|
|
1507
|
-
const supportCoolKey =
|
|
1508
|
-
const supportStandbyKey =
|
|
1499
|
+
const accountTypeMelCloud = this.accountTypeMelCloud;
|
|
1500
|
+
const fanKey = accountTypeMelCloud ? 'FanSpeed' : 'SetFanSpeed';
|
|
1501
|
+
const tempStepKey = accountTypeMelCloud ? 'TemperatureIncrement' : 'HasHalfDegreeIncrements';
|
|
1502
|
+
const connectKey = accountTypeMelCloud ? 'Offline' : 'IsConnected';
|
|
1503
|
+
const errorKey = accountTypeMelCloud ? 'HasError' : 'IsInError';
|
|
1504
|
+
const supportAirDirectionKey = accountTypeMelCloud ? 'AirDirectionFunction' : 'HasAirDirectionFunction';
|
|
1505
|
+
const supportSwingKey = accountTypeMelCloud ? 'SwingFunction' : 'HasSwing';
|
|
1506
|
+
const supportVideWaneKey = accountTypeMelCloud ? 'ModelSupportsWideVane' : 'SupportsWideVane';
|
|
1507
|
+
const supportAutoKey = accountTypeMelCloud ? 'ModelSupportsAuto' : 'HasAutoOperationMode';
|
|
1508
|
+
const supportHeatKey = accountTypeMelCloud ? 'ModelSupportsHeat' : 'HasHeatOperationMode';
|
|
1509
|
+
const supportDryKey = accountTypeMelCloud ? 'ModelSupportsDry' : 'HasDryOperationMode';
|
|
1510
|
+
const supportCoolKey = accountTypeMelCloud ? 'ModelSupportsCool' : 'HasCoolOperationMode';
|
|
1511
|
+
const supportStandbyKey = accountTypeMelCloud ? 'ModelSupportsStandbyMode' : 'HasStandby';
|
|
1509
1512
|
|
|
1510
1513
|
//presets schedules
|
|
1511
1514
|
const presetsOnServer = deviceData.Presets ?? [];
|
|
@@ -1529,7 +1532,7 @@ class DeviceAta extends EventEmitter {
|
|
|
1529
1532
|
const supportsSwingFunction = deviceData.Device[supportSwingKey];
|
|
1530
1533
|
const supportsWideVane = deviceData.Device[supportVideWaneKey];
|
|
1531
1534
|
const supportsOutdoorTemperature = deviceData.Device.HasOutdoorTemperature;
|
|
1532
|
-
const supportsFanSpeed =
|
|
1535
|
+
const supportsFanSpeed = accountTypeMelCloud ? deviceData.Device.ModelSupportsFanSpeed : deviceData.Device.NumberOfFanSpeeds > 0;
|
|
1533
1536
|
const supportsAuto1 = deviceData.Device[supportAutoKey];
|
|
1534
1537
|
const supportsAuto = this.autoDryFanMode >= 1 && supportsAuto1
|
|
1535
1538
|
const supportsHeat1 = deviceData.Device[supportHeatKey];
|
|
@@ -1540,7 +1543,7 @@ class DeviceAta extends EventEmitter {
|
|
|
1540
1543
|
const numberOfFanSpeeds = deviceData.Device.NumberOfFanSpeeds;
|
|
1541
1544
|
const minSetHeatRoomTemperature = 10;
|
|
1542
1545
|
const maxSetHeatCoolDryAutoRoomTemperature = 31;
|
|
1543
|
-
const minSetCoolDryAutoRoomTemperature =
|
|
1546
|
+
const minSetCoolDryAutoRoomTemperature = accountTypeMelCloud ? 4 : deviceData.Device.MinTempAutomatic ?? 16;
|
|
1544
1547
|
|
|
1545
1548
|
//device state
|
|
1546
1549
|
const power = deviceData.Device.Power ?? false;
|
|
@@ -1562,7 +1565,7 @@ class DeviceAta extends EventEmitter {
|
|
|
1562
1565
|
const prohibitPower = deviceData.Device.ProhibitPower ?? false;
|
|
1563
1566
|
const temperatureStep = deviceData.Device[tempStepKey] ? 0.5 : 1;
|
|
1564
1567
|
const outdoorTemperature = deviceData.Device.OutdoorTemperature;
|
|
1565
|
-
const isConnected =
|
|
1568
|
+
const isConnected = accountTypeMelCloud ? !deviceData.Device[connectKey] : deviceData.Device[connectKey];
|
|
1566
1569
|
const isInError = deviceData.Device[errorKey];
|
|
1567
1570
|
const currentSwingMode = supportsSwingFunction ? (supportsWideVane ? vaneHorizontalDirection === 12 && vaneVerticalDirection === 7 ? 1 : 0 : vaneVerticalDirection === 7 ? 1 : 0) : 0;
|
|
1568
1571
|
|
|
@@ -1607,8 +1610,8 @@ class DeviceAta extends EventEmitter {
|
|
|
1607
1610
|
currentSwingMode: currentSwingMode,
|
|
1608
1611
|
lockPhysicalControl: prohibitSetTemperature && prohibitOperationMode && prohibitPower ? 1 : 0,
|
|
1609
1612
|
temperatureStep: temperatureStep,
|
|
1610
|
-
useFahrenheit: this.
|
|
1611
|
-
temperatureUnit: TemperatureDisplayUnits[this.
|
|
1613
|
+
useFahrenheit: this.melCloudAccountData.useFahrenheit ? 1 : 0,
|
|
1614
|
+
temperatureUnit: TemperatureDisplayUnits[this.melCloudAccountData.useFahrenheit ? 1 : 0],
|
|
1612
1615
|
isConnected: isConnected,
|
|
1613
1616
|
isInError: isInError
|
|
1614
1617
|
};
|
|
@@ -2016,7 +2019,7 @@ class DeviceAta extends EventEmitter {
|
|
|
2016
2019
|
if (supportsSwingFunction) this.emit('info', `Air direction: ${AirConditioner.AirDirectionMapEnumToString[currentSwingMode]}`);
|
|
2017
2020
|
this.emit('info', `Temperature display unit: ${obj.temperatureUnit}`);
|
|
2018
2021
|
this.emit('info', `Lock physical controls: ${obj.lockPhysicalControl ? 'Locked' : 'Unlocked'}`);
|
|
2019
|
-
if (this.
|
|
2022
|
+
if (!this.accountTypeMelCloud) this.emit('info', `Signal strength: ${deviceData.Rssi}dBm`);
|
|
2020
2023
|
}
|
|
2021
2024
|
})
|
|
2022
2025
|
.on('success', (success) => this.emit('success', success))
|
|
@@ -2035,7 +2038,7 @@ class DeviceAta extends EventEmitter {
|
|
|
2035
2038
|
if (this.restFul.enable || this.mqtt.enable) await this.externalIntegrations();
|
|
2036
2039
|
|
|
2037
2040
|
//check state
|
|
2038
|
-
await this.melCloudAta.updateState('request', this.
|
|
2041
|
+
await this.melCloudAta.updateState('request', this.melCloudDeviceData);
|
|
2039
2042
|
|
|
2040
2043
|
//prepare accessory
|
|
2041
2044
|
const accessory = await this.prepareAccessory();
|