homebridge-melcloud-control 3.8.3 → 3.8.4-beta.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/index.js +27 -3
- package/package.json +1 -1
- package/src/deviceata.js +12 -12
- package/src/deviceatw.js +12 -11
- package/src/deviceerv.js +12 -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.1",
|
|
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,8 +252,12 @@ class DeviceAta extends EventEmitter {
|
|
|
257
252
|
}
|
|
258
253
|
|
|
259
254
|
//prepare accessory
|
|
260
|
-
async prepareAccessory(
|
|
255
|
+
async prepareAccessory(deviceData) {
|
|
261
256
|
try {
|
|
257
|
+
const deviceId = this.deviceId;
|
|
258
|
+
const deviceTypeText = this.deviceTypeText;
|
|
259
|
+
const deviceName = this.deviceName;
|
|
260
|
+
const accountName = this.accountName;
|
|
262
261
|
const presetsOnServer = this.accessory.presets;
|
|
263
262
|
const modelSupportsHeat = this.accessory.modelSupportsHeat;
|
|
264
263
|
const modelSupportsDry = this.accessory.modelSupportsDry;
|
|
@@ -483,9 +482,9 @@ class DeviceAta extends EventEmitter {
|
|
|
483
482
|
})
|
|
484
483
|
.onSet(async (value) => {
|
|
485
484
|
try {
|
|
486
|
-
|
|
487
|
-
await this.melCloud.send(accountInfo);
|
|
485
|
+
value = [false, true][value];
|
|
488
486
|
this.accessory.useFahrenheit = value;
|
|
487
|
+
this.emit('melCloud', 'UseFahrenheit', value);
|
|
489
488
|
const info = this.disableLogInfo ? false : this.emit('info', `Set temperature display unit: ${TemperatureDisplayUnits[value]}`);
|
|
490
489
|
} catch (error) {
|
|
491
490
|
this.emit('warn', `Set temperature display unit error: ${error}`);
|
|
@@ -575,9 +574,9 @@ class DeviceAta extends EventEmitter {
|
|
|
575
574
|
})
|
|
576
575
|
.onSet(async (value) => {
|
|
577
576
|
try {
|
|
578
|
-
|
|
579
|
-
await this.melCloud.send(accountInfo);
|
|
577
|
+
value = [false, true][value];
|
|
580
578
|
this.accessory.useFahrenheit = value;
|
|
579
|
+
this.emit('melCloud', 'UseFahrenheit', value);
|
|
581
580
|
const info = this.disableLogInfo ? false : this.emit('info', `Set temperature display unit: ${TemperatureDisplayUnits[value]}`);
|
|
582
581
|
} catch (error) {
|
|
583
582
|
this.emit('warn', `Set temperature display unit error: ${error}`);
|
|
@@ -1044,6 +1043,7 @@ class DeviceAta extends EventEmitter {
|
|
|
1044
1043
|
this.accessory.swingMode = swingFunction && vaneHorizontalDirection === 12 && vaneVerticalDirection === 7 ? 1 : 0;
|
|
1045
1044
|
this.accessory.lockPhysicalControl = prohibitSetTemperature && prohibitOperationMode && prohibitPower ? 1 : 0;
|
|
1046
1045
|
this.accessory.temperatureIncrement = temperatureIncrement;
|
|
1046
|
+
this.accessory.temperatureUnit = TemperatureDisplayUnits[this.accessory.useFahrenheit];
|
|
1047
1047
|
|
|
1048
1048
|
//operating mode 0, HEAT, DRY, COOL, 4, 5, 6, FAN, AUTO, ISEE HEAT, ISEE DRY, ISEE COOL
|
|
1049
1049
|
switch (this.displayMode) {
|
|
@@ -1362,7 +1362,7 @@ class DeviceAta extends EventEmitter {
|
|
|
1362
1362
|
|
|
1363
1363
|
//prepare accessory
|
|
1364
1364
|
if (this.startPrepareAccessory) {
|
|
1365
|
-
const accessory = await this.prepareAccessory(
|
|
1365
|
+
const accessory = await this.prepareAccessory(deviceData);
|
|
1366
1366
|
this.emit('publishAccessory', accessory);
|
|
1367
1367
|
this.startPrepareAccessory = false;
|
|
1368
1368
|
}
|
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,8 +282,12 @@ class DeviceAtw extends EventEmitter {
|
|
|
286
282
|
}
|
|
287
283
|
|
|
288
284
|
//prepare accessory
|
|
289
|
-
async prepareAccessory(
|
|
285
|
+
async prepareAccessory(deviceData) {
|
|
290
286
|
try {
|
|
287
|
+
const deviceId = this.deviceId;
|
|
288
|
+
const deviceTypeText = this.deviceTypeText;
|
|
289
|
+
const deviceName = this.deviceName;
|
|
290
|
+
const accountName = this.accountName;
|
|
291
291
|
const presetsOnServer = this.accessory.presets;
|
|
292
292
|
const zonesCount = this.accessory.zonesCount;
|
|
293
293
|
const caseHeatPump = this.accessory.caseHeatPump;
|
|
@@ -625,9 +625,9 @@ class DeviceAtw extends EventEmitter {
|
|
|
625
625
|
})
|
|
626
626
|
.onSet(async (value) => {
|
|
627
627
|
try {
|
|
628
|
-
|
|
629
|
-
await this.melCloud.send(accountInfo);
|
|
628
|
+
value = [false, true][value];
|
|
630
629
|
this.accessory.useFahrenheit = value;
|
|
630
|
+
this.emit('melCloud', 'UseFahrenheit', value);
|
|
631
631
|
const info = this.disableLogInfo ? false : this.emit('info', `Set temperature display unit: ${TemperatureDisplayUnits[value]}`);
|
|
632
632
|
} catch (error) {
|
|
633
633
|
this.emit('warn', `Set temperature display unit error: ${error}`);
|
|
@@ -807,9 +807,9 @@ class DeviceAtw extends EventEmitter {
|
|
|
807
807
|
})
|
|
808
808
|
.onSet(async (value) => {
|
|
809
809
|
try {
|
|
810
|
-
|
|
811
|
-
await this.melCloud.send(accountInfo);
|
|
810
|
+
value = [false, true][value];
|
|
812
811
|
this.accessory.useFahrenheit = value;
|
|
812
|
+
this.emit('melCloud', 'UseFahrenheit', value);
|
|
813
813
|
const info = this.disableLogInfo ? false : this.emit('info', `Set temperature display unit: ${TemperatureDisplayUnits[value]}`);
|
|
814
814
|
} catch (error) {
|
|
815
815
|
this.emit('warn', `Set temperature display unit error: ${error}`);
|
|
@@ -1438,6 +1438,7 @@ class DeviceAtw extends EventEmitter {
|
|
|
1438
1438
|
this.accessory.caseHotWaterSensor = caseHotWaterSensor;
|
|
1439
1439
|
this.accessory.caseZone2Sensor = caseZone2Sensor;
|
|
1440
1440
|
this.accessory.sensorsCount = zonesSensorsCount;
|
|
1441
|
+
this.accessory.temperatureUnit = TemperatureDisplayUnits[this.accessory.useFahrenheit];
|
|
1441
1442
|
|
|
1442
1443
|
//default values
|
|
1443
1444
|
let name = 'Heat Pump'
|
|
@@ -1970,7 +1971,7 @@ class DeviceAtw extends EventEmitter {
|
|
|
1970
1971
|
|
|
1971
1972
|
//prepare accessory
|
|
1972
1973
|
if (this.startPrepareAccessory) {
|
|
1973
|
-
const accessory = await this.prepareAccessory(
|
|
1974
|
+
const accessory = await this.prepareAccessory(deviceData);
|
|
1974
1975
|
this.emit('publishAccessory', accessory);
|
|
1975
1976
|
this.startPrepareAccessory = false;
|
|
1976
1977
|
}
|
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,8 +241,12 @@ class DeviceErv extends EventEmitter {
|
|
|
245
241
|
}
|
|
246
242
|
|
|
247
243
|
//prepare accessory
|
|
248
|
-
async prepareAccessory(
|
|
244
|
+
async prepareAccessory(deviceData) {
|
|
249
245
|
try {
|
|
246
|
+
const deviceId = this.deviceId;
|
|
247
|
+
const deviceTypeText = this.deviceTypeText;
|
|
248
|
+
const deviceName = this.deviceName;
|
|
249
|
+
const accountName = this.accountName;
|
|
250
250
|
const presetsOnServer = this.accessory.presets;
|
|
251
251
|
const hasRoomTemperature = this.accessory.hasRoomTemperature;
|
|
252
252
|
const hasSupplyTemperature = this.accessory.hasSupplyTemperature;
|
|
@@ -448,9 +448,9 @@ class DeviceErv extends EventEmitter {
|
|
|
448
448
|
})
|
|
449
449
|
.onSet(async (value) => {
|
|
450
450
|
try {
|
|
451
|
-
|
|
452
|
-
await this.melCloud.send(accountInfo);
|
|
451
|
+
value = [false, true][value];
|
|
453
452
|
this.accessory.useFahrenheit = value;
|
|
453
|
+
this.emit('melCloud', 'UseFahrenheit', value);
|
|
454
454
|
const info = this.disableLogInfo ? false : this.emit('info', `Set temperature display unit: ${TemperatureDisplayUnits[value]}`);
|
|
455
455
|
} catch (error) {
|
|
456
456
|
this.emit('warn', `Set temperature display unit error: ${error}`);
|
|
@@ -540,9 +540,9 @@ class DeviceErv extends EventEmitter {
|
|
|
540
540
|
})
|
|
541
541
|
.onSet(async (value) => {
|
|
542
542
|
try {
|
|
543
|
-
|
|
544
|
-
await this.melCloud.send(accountInfo);
|
|
543
|
+
value = [false, true][value];
|
|
545
544
|
this.accessory.useFahrenheit = value;
|
|
545
|
+
this.emit('melCloud', 'UseFahrenheit', value);
|
|
546
546
|
const info = this.disableLogInfo ? false : this.emit('info', `Set temperature display unit: ${TemperatureDisplayUnits[value]}`);
|
|
547
547
|
} catch (error) {
|
|
548
548
|
this.emit('warn', `Set temperature display unit error: ${error}`);
|
|
@@ -971,6 +971,7 @@ class DeviceErv extends EventEmitter {
|
|
|
971
971
|
this.accessory.temperatureIncrement = maxTempHeat;
|
|
972
972
|
this.accessory.minTempCoolDry = minTempCoolDry;
|
|
973
973
|
this.accessory.maxTempCoolDry = maxTempCoolDry;
|
|
974
|
+
this.accessory.temperatureUnit = TemperatureDisplayUnits[this.accessory.useFahrenheit];
|
|
974
975
|
|
|
975
976
|
//ventilation mode - 0, HEAT, 2, COOL, 4, 5, 6, FAN, AUTO
|
|
976
977
|
switch (this.displayMode) {
|
|
@@ -1230,7 +1231,7 @@ class DeviceErv extends EventEmitter {
|
|
|
1230
1231
|
|
|
1231
1232
|
//prepare accessory
|
|
1232
1233
|
if (this.startPrepareAccessory) {
|
|
1233
|
-
const accessory = await this.prepareAccessory(
|
|
1234
|
+
const accessory = await this.prepareAccessory(deviceData);
|
|
1234
1235
|
this.emit('publishAccessory', accessory);
|
|
1235
1236
|
this.startPrepareAccessory = false;
|
|
1236
1237
|
}
|