homebridge-melcloud-control 3.8.3 → 3.8.4-beta.0
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/index.js +27 -3
- package/package.json +1 -1
- package/src/deviceata.js +8 -12
- package/src/deviceatw.js +8 -11
- package/src/deviceerv.js +8 -11
package/index.js
CHANGED
|
@@ -135,13 +135,21 @@ class MelCloudPlatform {
|
|
|
135
135
|
const deviceName = device.name;
|
|
136
136
|
const deviceTypeText = device.typeString;
|
|
137
137
|
const deviceRefreshInterval = device.refreshInterval * 1000 || 5000;
|
|
138
|
-
const airConditioner = new DeviceAta(api, account, device,
|
|
138
|
+
const airConditioner = new DeviceAta(api, account, device, contextKey, accountName, deviceId, deviceName, deviceTypeText, devicesFile, deviceRefreshInterval, useFahrenheit, restFul, mqtt)
|
|
139
139
|
airConditioner.on('publishAccessory', (accessory) => {
|
|
140
140
|
|
|
141
141
|
//publish device
|
|
142
142
|
api.publishExternalAccessories(PluginName, [accessory]);
|
|
143
143
|
const emitLog = disableLogSuccess ? false : log.success(`${accountName}, ${deviceTypeText} ${deviceName}, published as external accessory.`);
|
|
144
144
|
})
|
|
145
|
+
.on('melCloud', async (key, value) => {
|
|
146
|
+
try {
|
|
147
|
+
accountInfo[key] = value;
|
|
148
|
+
await melCloud.send(accountInfo);
|
|
149
|
+
} catch (error) {
|
|
150
|
+
const emitLog = disableLogError ? false : log.error(`${accountName}, ${deviceTypeText}, ${deviceName}, ${error}.`);
|
|
151
|
+
};
|
|
152
|
+
})
|
|
145
153
|
.on('devInfo', (devInfo) => {
|
|
146
154
|
const emitLog = disableLogDeviceInfo ? false : log.info(devInfo);
|
|
147
155
|
})
|
|
@@ -201,13 +209,21 @@ class MelCloudPlatform {
|
|
|
201
209
|
const deviceName = device.name;
|
|
202
210
|
const deviceTypeText = device.typeString;
|
|
203
211
|
const deviceRefreshInterval = device.refreshInterval * 1000 || 5000;
|
|
204
|
-
const heatPump = new DeviceAtw(api, account, device,
|
|
212
|
+
const heatPump = new DeviceAtw(api, account, device, contextKey, accountName, deviceId, deviceName, deviceTypeText, devicesFile, deviceRefreshInterval, useFahrenheit, restFul, mqtt)
|
|
205
213
|
heatPump.on('publishAccessory', (accessory) => {
|
|
206
214
|
|
|
207
215
|
//publish device
|
|
208
216
|
api.publishExternalAccessories(PluginName, [accessory]);
|
|
209
217
|
const emitLog = disableLogSuccess ? false : log.success(`${accountName}, ${deviceTypeText} ${deviceName}, published as external accessory.`);
|
|
210
218
|
})
|
|
219
|
+
.on('melCloud', async (key, value) => {
|
|
220
|
+
try {
|
|
221
|
+
accountInfo[key] = value;
|
|
222
|
+
await melCloud.send(accountInfo);
|
|
223
|
+
} catch (error) {
|
|
224
|
+
const emitLog = disableLogError ? false : log.error(`${accountName}, ${deviceTypeText}, ${deviceName}, ${error}.`);
|
|
225
|
+
};
|
|
226
|
+
})
|
|
211
227
|
.on('devInfo', (devInfo) => {
|
|
212
228
|
const emitLog = disableLogDeviceInfo ? false : log.info(devInfo);
|
|
213
229
|
})
|
|
@@ -267,13 +283,21 @@ class MelCloudPlatform {
|
|
|
267
283
|
const deviceName = device.name;
|
|
268
284
|
const deviceTypeText = device.typeString;
|
|
269
285
|
const deviceRefreshInterval = device.refreshInterval * 1000 || 5000;
|
|
270
|
-
const energyRecoveryVentilation = new DeviceErv(api, account, device,
|
|
286
|
+
const energyRecoveryVentilation = new DeviceErv(api, account, device, contextKey, accountName, deviceId, deviceName, deviceTypeText, devicesFile, deviceRefreshInterval, useFahrenheit, restFul, mqtt)
|
|
271
287
|
energyRecoveryVentilation.on('publishAccessory', (accessory) => {
|
|
272
288
|
|
|
273
289
|
//publish device
|
|
274
290
|
api.publishExternalAccessories(PluginName, [accessory]);
|
|
275
291
|
const emitLog = disableLogSuccess ? false : log.success(`${accountName}, ${deviceTypeText} ${deviceName}, published as external accessory.`);
|
|
276
292
|
})
|
|
293
|
+
.on('melCloud', async (key, value) => {
|
|
294
|
+
try {
|
|
295
|
+
accountInfo[key] = value;
|
|
296
|
+
await melCloud.send(accountInfo);
|
|
297
|
+
} catch (error) {
|
|
298
|
+
const emitLog = disableLogError ? false : log.error(`${accountName}, ${deviceTypeText}, ${deviceName}, ${error}.`);
|
|
299
|
+
};
|
|
300
|
+
})
|
|
277
301
|
.on('devInfo', (devInfo) => {
|
|
278
302
|
const emitLog = disableLogDeviceInfo ? false : log.info(devInfo);
|
|
279
303
|
})
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"displayName": "MELCloud Control",
|
|
3
3
|
"name": "homebridge-melcloud-control",
|
|
4
|
-
"version": "3.8.
|
|
4
|
+
"version": "3.8.4-beta.0",
|
|
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
|
@@ -6,7 +6,7 @@ import { TemperatureDisplayUnits, AirConditioner } from './constants.js';
|
|
|
6
6
|
let Accessory, Characteristic, Service, Categories, AccessoryUUID;
|
|
7
7
|
|
|
8
8
|
class DeviceAta extends EventEmitter {
|
|
9
|
-
constructor(api, account, device,
|
|
9
|
+
constructor(api, account, device, contextKey, accountName, deviceId, deviceName, deviceTypeText, devicesFile, refreshInterval, useFahrenheit, restFul, mqtt) {
|
|
10
10
|
super();
|
|
11
11
|
|
|
12
12
|
Accessory = api.platformAccessory;
|
|
@@ -27,7 +27,6 @@ class DeviceAta extends EventEmitter {
|
|
|
27
27
|
this.disableLogInfo = account.disableLogInfo || false;
|
|
28
28
|
this.disableLogDeviceInfo = account.disableLogDeviceInfo || false;
|
|
29
29
|
this.enableDebugMode = account.enableDebugMode || false;
|
|
30
|
-
this.accountInfo = accountInfo;
|
|
31
30
|
this.contextKey = contextKey;
|
|
32
31
|
this.accountName = accountName;
|
|
33
32
|
this.deviceId = deviceId;
|
|
@@ -44,9 +43,6 @@ class DeviceAta extends EventEmitter {
|
|
|
44
43
|
this.mqtt = mqtt;
|
|
45
44
|
this.mqttConnected = false;
|
|
46
45
|
|
|
47
|
-
//function
|
|
48
|
-
this.melCloud = melCloud; //function
|
|
49
|
-
|
|
50
46
|
//presets configured
|
|
51
47
|
this.presetsConfigured = [];
|
|
52
48
|
for (const preset of this.presets) {
|
|
@@ -91,7 +87,6 @@ class DeviceAta extends EventEmitter {
|
|
|
91
87
|
//accessory
|
|
92
88
|
this.accessory = {};
|
|
93
89
|
this.accessory.useFahrenheit = useFahrenheit ? 1 : 0;
|
|
94
|
-
this.accessory.temperatureUnit = TemperatureDisplayUnits[this.accessory.useFahrenheit];
|
|
95
90
|
};
|
|
96
91
|
|
|
97
92
|
async externalIntegrations() {
|
|
@@ -257,7 +252,7 @@ class DeviceAta extends EventEmitter {
|
|
|
257
252
|
}
|
|
258
253
|
|
|
259
254
|
//prepare accessory
|
|
260
|
-
async prepareAccessory(
|
|
255
|
+
async prepareAccessory(deviceData, deviceId, deviceTypeText, deviceName, accountName) {
|
|
261
256
|
try {
|
|
262
257
|
const presetsOnServer = this.accessory.presets;
|
|
263
258
|
const modelSupportsHeat = this.accessory.modelSupportsHeat;
|
|
@@ -483,9 +478,9 @@ class DeviceAta extends EventEmitter {
|
|
|
483
478
|
})
|
|
484
479
|
.onSet(async (value) => {
|
|
485
480
|
try {
|
|
486
|
-
|
|
487
|
-
await this.melCloud.send(accountInfo);
|
|
481
|
+
value = [false, true][value];
|
|
488
482
|
this.accessory.useFahrenheit = value;
|
|
483
|
+
this.emit('melCloud', 'UseFahrenheit', value);
|
|
489
484
|
const info = this.disableLogInfo ? false : this.emit('info', `Set temperature display unit: ${TemperatureDisplayUnits[value]}`);
|
|
490
485
|
} catch (error) {
|
|
491
486
|
this.emit('warn', `Set temperature display unit error: ${error}`);
|
|
@@ -575,9 +570,9 @@ class DeviceAta extends EventEmitter {
|
|
|
575
570
|
})
|
|
576
571
|
.onSet(async (value) => {
|
|
577
572
|
try {
|
|
578
|
-
|
|
579
|
-
await this.melCloud.send(accountInfo);
|
|
573
|
+
value = [false, true][value];
|
|
580
574
|
this.accessory.useFahrenheit = value;
|
|
575
|
+
this.emit('melCloud', 'UseFahrenheit', value);
|
|
581
576
|
const info = this.disableLogInfo ? false : this.emit('info', `Set temperature display unit: ${TemperatureDisplayUnits[value]}`);
|
|
582
577
|
} catch (error) {
|
|
583
578
|
this.emit('warn', `Set temperature display unit error: ${error}`);
|
|
@@ -1044,6 +1039,7 @@ class DeviceAta extends EventEmitter {
|
|
|
1044
1039
|
this.accessory.swingMode = swingFunction && vaneHorizontalDirection === 12 && vaneVerticalDirection === 7 ? 1 : 0;
|
|
1045
1040
|
this.accessory.lockPhysicalControl = prohibitSetTemperature && prohibitOperationMode && prohibitPower ? 1 : 0;
|
|
1046
1041
|
this.accessory.temperatureIncrement = temperatureIncrement;
|
|
1042
|
+
this.accessory.temperatureUnit = TemperatureDisplayUnits[this.accessory.useFahrenheit];
|
|
1047
1043
|
|
|
1048
1044
|
//operating mode 0, HEAT, DRY, COOL, 4, 5, 6, FAN, AUTO, ISEE HEAT, ISEE DRY, ISEE COOL
|
|
1049
1045
|
switch (this.displayMode) {
|
|
@@ -1362,7 +1358,7 @@ class DeviceAta extends EventEmitter {
|
|
|
1362
1358
|
|
|
1363
1359
|
//prepare accessory
|
|
1364
1360
|
if (this.startPrepareAccessory) {
|
|
1365
|
-
const accessory = await this.prepareAccessory(
|
|
1361
|
+
const accessory = await this.prepareAccessory(deviceData, this.deviceId, this.deviceTypeText, this.deviceName, this.accountName);
|
|
1366
1362
|
this.emit('publishAccessory', accessory);
|
|
1367
1363
|
this.startPrepareAccessory = false;
|
|
1368
1364
|
}
|
package/src/deviceatw.js
CHANGED
|
@@ -6,7 +6,7 @@ import { TemperatureDisplayUnits, HeatPump } from './constants.js';
|
|
|
6
6
|
let Accessory, Characteristic, Service, Categories, AccessoryUUID;
|
|
7
7
|
|
|
8
8
|
class DeviceAtw extends EventEmitter {
|
|
9
|
-
constructor(api, account, device,
|
|
9
|
+
constructor(api, account, device, contextKey, accountName, deviceId, deviceName, deviceTypeText, devicesFile, refreshInterval, useFahrenheit, restFul, mqtt) {
|
|
10
10
|
super();
|
|
11
11
|
|
|
12
12
|
Accessory = api.platformAccessory;
|
|
@@ -49,9 +49,6 @@ class DeviceAtw extends EventEmitter {
|
|
|
49
49
|
this.mqtt = mqtt;
|
|
50
50
|
this.mqttConnected = false;
|
|
51
51
|
|
|
52
|
-
//function
|
|
53
|
-
this.melCloud = melCloud; //function
|
|
54
|
-
|
|
55
52
|
//presets configured
|
|
56
53
|
this.presetsConfigured = [];
|
|
57
54
|
for (const preset of this.presets) {
|
|
@@ -99,7 +96,6 @@ class DeviceAtw extends EventEmitter {
|
|
|
99
96
|
zonesSensors: [{}, {}, {}, {}]
|
|
100
97
|
};
|
|
101
98
|
this.accessory.useFahrenheit = useFahrenheit ? 1 : 0;
|
|
102
|
-
this.accessory.temperatureUnit = TemperatureDisplayUnits[this.accessory.useFahrenheit];
|
|
103
99
|
};
|
|
104
100
|
|
|
105
101
|
async externalIntegrations() {
|
|
@@ -286,7 +282,7 @@ class DeviceAtw extends EventEmitter {
|
|
|
286
282
|
}
|
|
287
283
|
|
|
288
284
|
//prepare accessory
|
|
289
|
-
async prepareAccessory(
|
|
285
|
+
async prepareAccessory(deviceData, deviceId, deviceTypeText, deviceName, accountName) {
|
|
290
286
|
try {
|
|
291
287
|
const presetsOnServer = this.accessory.presets;
|
|
292
288
|
const zonesCount = this.accessory.zonesCount;
|
|
@@ -625,9 +621,9 @@ class DeviceAtw extends EventEmitter {
|
|
|
625
621
|
})
|
|
626
622
|
.onSet(async (value) => {
|
|
627
623
|
try {
|
|
628
|
-
|
|
629
|
-
await this.melCloud.send(accountInfo);
|
|
624
|
+
value = [false, true][value];
|
|
630
625
|
this.accessory.useFahrenheit = value;
|
|
626
|
+
this.emit('melCloud', 'UseFahrenheit', value);
|
|
631
627
|
const info = this.disableLogInfo ? false : this.emit('info', `Set temperature display unit: ${TemperatureDisplayUnits[value]}`);
|
|
632
628
|
} catch (error) {
|
|
633
629
|
this.emit('warn', `Set temperature display unit error: ${error}`);
|
|
@@ -807,9 +803,9 @@ class DeviceAtw extends EventEmitter {
|
|
|
807
803
|
})
|
|
808
804
|
.onSet(async (value) => {
|
|
809
805
|
try {
|
|
810
|
-
|
|
811
|
-
await this.melCloud.send(accountInfo);
|
|
806
|
+
value = [false, true][value];
|
|
812
807
|
this.accessory.useFahrenheit = value;
|
|
808
|
+
this.emit('melCloud', 'UseFahrenheit', value);
|
|
813
809
|
const info = this.disableLogInfo ? false : this.emit('info', `Set temperature display unit: ${TemperatureDisplayUnits[value]}`);
|
|
814
810
|
} catch (error) {
|
|
815
811
|
this.emit('warn', `Set temperature display unit error: ${error}`);
|
|
@@ -1438,6 +1434,7 @@ class DeviceAtw extends EventEmitter {
|
|
|
1438
1434
|
this.accessory.caseHotWaterSensor = caseHotWaterSensor;
|
|
1439
1435
|
this.accessory.caseZone2Sensor = caseZone2Sensor;
|
|
1440
1436
|
this.accessory.sensorsCount = zonesSensorsCount;
|
|
1437
|
+
this.accessory.temperatureUnit = TemperatureDisplayUnits[this.accessory.useFahrenheit];
|
|
1441
1438
|
|
|
1442
1439
|
//default values
|
|
1443
1440
|
let name = 'Heat Pump'
|
|
@@ -1970,7 +1967,7 @@ class DeviceAtw extends EventEmitter {
|
|
|
1970
1967
|
|
|
1971
1968
|
//prepare accessory
|
|
1972
1969
|
if (this.startPrepareAccessory) {
|
|
1973
|
-
const accessory = await this.prepareAccessory(
|
|
1970
|
+
const accessory = await this.prepareAccessory(deviceData, this.deviceId, this.deviceTypeText, this.deviceName, this.accountName);
|
|
1974
1971
|
this.emit('publishAccessory', accessory);
|
|
1975
1972
|
this.startPrepareAccessory = false;
|
|
1976
1973
|
}
|
package/src/deviceerv.js
CHANGED
|
@@ -6,7 +6,7 @@ import { TemperatureDisplayUnits, Ventilation } from './constants.js';
|
|
|
6
6
|
let Accessory, Characteristic, Service, Categories, AccessoryUUID;
|
|
7
7
|
|
|
8
8
|
class DeviceErv extends EventEmitter {
|
|
9
|
-
constructor(api, account, device,
|
|
9
|
+
constructor(api, account, device, contextKey, accountName, deviceId, deviceName, deviceTypeText, devicesFile, refreshInterval, useFahrenheit, restFul, mqtt) {
|
|
10
10
|
super();
|
|
11
11
|
|
|
12
12
|
Accessory = api.platformAccessory;
|
|
@@ -42,9 +42,6 @@ class DeviceErv extends EventEmitter {
|
|
|
42
42
|
this.mqtt = mqtt;
|
|
43
43
|
this.mqttConnected = false;
|
|
44
44
|
|
|
45
|
-
//function
|
|
46
|
-
this.melCloud = melCloud; //function
|
|
47
|
-
|
|
48
45
|
//presets configured
|
|
49
46
|
this.presetsConfigured = [];
|
|
50
47
|
for (const preset of this.presets) {
|
|
@@ -89,7 +86,6 @@ class DeviceErv extends EventEmitter {
|
|
|
89
86
|
//accessory
|
|
90
87
|
this.accessory = {};
|
|
91
88
|
this.accessory.useFahrenheit = useFahrenheit ? 1 : 0;
|
|
92
|
-
this.accessory.temperatureUnit = TemperatureDisplayUnits[this.accessory.useFahrenheit];
|
|
93
89
|
};
|
|
94
90
|
|
|
95
91
|
async externalIntegrations() {
|
|
@@ -245,7 +241,7 @@ class DeviceErv extends EventEmitter {
|
|
|
245
241
|
}
|
|
246
242
|
|
|
247
243
|
//prepare accessory
|
|
248
|
-
async prepareAccessory(
|
|
244
|
+
async prepareAccessory(deviceData, deviceId, deviceTypeText, deviceName, accountName) {
|
|
249
245
|
try {
|
|
250
246
|
const presetsOnServer = this.accessory.presets;
|
|
251
247
|
const hasRoomTemperature = this.accessory.hasRoomTemperature;
|
|
@@ -448,9 +444,9 @@ class DeviceErv extends EventEmitter {
|
|
|
448
444
|
})
|
|
449
445
|
.onSet(async (value) => {
|
|
450
446
|
try {
|
|
451
|
-
|
|
452
|
-
await this.melCloud.send(accountInfo);
|
|
447
|
+
value = [false, true][value];
|
|
453
448
|
this.accessory.useFahrenheit = value;
|
|
449
|
+
this.emit('melCloud', 'UseFahrenheit', value);
|
|
454
450
|
const info = this.disableLogInfo ? false : this.emit('info', `Set temperature display unit: ${TemperatureDisplayUnits[value]}`);
|
|
455
451
|
} catch (error) {
|
|
456
452
|
this.emit('warn', `Set temperature display unit error: ${error}`);
|
|
@@ -540,9 +536,9 @@ class DeviceErv extends EventEmitter {
|
|
|
540
536
|
})
|
|
541
537
|
.onSet(async (value) => {
|
|
542
538
|
try {
|
|
543
|
-
|
|
544
|
-
await this.melCloud.send(accountInfo);
|
|
539
|
+
value = [false, true][value];
|
|
545
540
|
this.accessory.useFahrenheit = value;
|
|
541
|
+
this.emit('melCloud', 'UseFahrenheit', value);
|
|
546
542
|
const info = this.disableLogInfo ? false : this.emit('info', `Set temperature display unit: ${TemperatureDisplayUnits[value]}`);
|
|
547
543
|
} catch (error) {
|
|
548
544
|
this.emit('warn', `Set temperature display unit error: ${error}`);
|
|
@@ -971,6 +967,7 @@ class DeviceErv extends EventEmitter {
|
|
|
971
967
|
this.accessory.temperatureIncrement = maxTempHeat;
|
|
972
968
|
this.accessory.minTempCoolDry = minTempCoolDry;
|
|
973
969
|
this.accessory.maxTempCoolDry = maxTempCoolDry;
|
|
970
|
+
this.accessory.temperatureUnit = TemperatureDisplayUnits[this.accessory.useFahrenheit];
|
|
974
971
|
|
|
975
972
|
//ventilation mode - 0, HEAT, 2, COOL, 4, 5, 6, FAN, AUTO
|
|
976
973
|
switch (this.displayMode) {
|
|
@@ -1230,7 +1227,7 @@ class DeviceErv extends EventEmitter {
|
|
|
1230
1227
|
|
|
1231
1228
|
//prepare accessory
|
|
1232
1229
|
if (this.startPrepareAccessory) {
|
|
1233
|
-
const accessory = await this.prepareAccessory(
|
|
1230
|
+
const accessory = await this.prepareAccessory(deviceData, this.deviceId, this.deviceTypeText, this.deviceName, this.accountName);
|
|
1234
1231
|
this.emit('publishAccessory', accessory);
|
|
1235
1232
|
this.startPrepareAccessory = false;
|
|
1236
1233
|
}
|