homebridge-melcloud-control 4.2.6 → 4.2.8-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/CHANGELOG.md +6 -0
- package/README.md +12 -12
- package/config.schema.json +84 -12
- package/index.js +8 -8
- package/package.json +1 -1
- package/src/deviceata.js +99 -99
- package/src/deviceatw.js +103 -99
- package/src/deviceerv.js +100 -97
package/src/deviceata.js
CHANGED
|
@@ -29,7 +29,7 @@ class DeviceAta extends EventEmitter {
|
|
|
29
29
|
this.device = device;
|
|
30
30
|
this.deviceId = device.id;
|
|
31
31
|
this.deviceName = device.name;
|
|
32
|
-
this.
|
|
32
|
+
this.deviceTypeString = device.typeString;
|
|
33
33
|
this.displayType = device.displayType;
|
|
34
34
|
this.heatDryFanMode = device.heatDryFanMode || 1; //NONE, HEAT, DRY, FAN
|
|
35
35
|
this.coolDryFanMode = device.coolDryFanMode || 1; //NONE, COOL, DRY, FAN
|
|
@@ -45,14 +45,13 @@ class DeviceAta extends EventEmitter {
|
|
|
45
45
|
this.presets = this.accountType === 'melcloud' ? (device.presets || []).filter(preset => (preset.displayType ?? 0) > 0 && preset.id !== '0') : [];
|
|
46
46
|
this.schedules = this.accountType === 'melcloudhome' ? (device.schedules || []).filter(schedule => (schedule.displayType ?? 0) > 0 && schedule.id !== '0') : [];
|
|
47
47
|
this.scenes = this.accountType === 'melcloudhome' ? (device.scenes || []).filter(scene => (scene.displayType ?? 0) > 0 && scene.id !== '0') : [];
|
|
48
|
-
this.buttons = (device.buttonsSensors || []).filter(
|
|
48
|
+
this.buttons = (device.buttonsSensors || []).filter(button => (button.displayType ?? 0) > 0);
|
|
49
49
|
|
|
50
50
|
//files
|
|
51
51
|
this.devicesFile = devicesFile;
|
|
52
52
|
this.defaultTempsFile = defaultTempsFile;
|
|
53
53
|
this.accountInfo = accountInfo;
|
|
54
54
|
this.accountFile = accountFile;
|
|
55
|
-
this.displayDeviceInfo = true;
|
|
56
55
|
|
|
57
56
|
//external integrations
|
|
58
57
|
this.restFul = account.restFul ?? {};
|
|
@@ -60,8 +59,8 @@ class DeviceAta extends EventEmitter {
|
|
|
60
59
|
this.mqtt = account.mqtt ?? {};
|
|
61
60
|
this.mqttConnected = false;
|
|
62
61
|
|
|
63
|
-
const serviceType = [null, Service.MotionSensor, Service.OccupancySensor, Service.ContactSensor, Service.MotionSensor, Service.OccupancySensor, Service.ContactSensor];
|
|
64
|
-
const characteristicType = [null, Characteristic.MotionDetected, Characteristic.OccupancyDetected, Characteristic.ContactSensorState, Characteristic.MotionDetected, Characteristic.OccupancyDetected, Characteristic.ContactSensorState];
|
|
62
|
+
const serviceType = [null, Service.MotionSensor, Service.OccupancySensor, Service.ContactSensor, Service.MotionSensor, Service.OccupancySensor, Service.ContactSensor, null];
|
|
63
|
+
const characteristicType = [null, Characteristic.MotionDetected, Characteristic.OccupancyDetected, Characteristic.ContactSensorState, Characteristic.MotionDetected, Characteristic.OccupancyDetected, Characteristic.ContactSensorState, null];
|
|
65
64
|
|
|
66
65
|
//presets configured
|
|
67
66
|
for (const preset of this.presets) {
|
|
@@ -102,13 +101,22 @@ class DeviceAta extends EventEmitter {
|
|
|
102
101
|
.on('error', error => this.emit('error', error))
|
|
103
102
|
.on('debug', debug => this.emit('debug', debug));
|
|
104
103
|
|
|
105
|
-
//
|
|
104
|
+
//other variables
|
|
105
|
+
this.displayDeviceInfo = true;
|
|
106
106
|
this.deviceData = {};
|
|
107
|
-
|
|
108
|
-
//accessory
|
|
109
107
|
this.accessory = {};
|
|
110
108
|
};
|
|
111
109
|
|
|
110
|
+
async startStopImpulseGenerator(state, timers = []) {
|
|
111
|
+
try {
|
|
112
|
+
//start impulse generator
|
|
113
|
+
await this.melCloudAta.impulseGenerator.state(state, timers)
|
|
114
|
+
return true;
|
|
115
|
+
} catch (error) {
|
|
116
|
+
throw new Error(`Impulse generator start error: ${error}`);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
112
120
|
async externalIntegrations() {
|
|
113
121
|
//RESTFul server
|
|
114
122
|
const restFulEnabled = this.restFul.enable || false;
|
|
@@ -156,7 +164,7 @@ class DeviceAta extends EventEmitter {
|
|
|
156
164
|
host: this.mqtt.host,
|
|
157
165
|
port: this.mqtt.port || 1883,
|
|
158
166
|
clientId: this.mqtt.clientId ? `melcloud_${this.mqtt.clientId}_${Math.random().toString(16).slice(3)}` : `melcloud_${Math.random().toString(16).slice(3)}`,
|
|
159
|
-
prefix: this.mqtt.prefix ? `melcloud/${this.mqtt.prefix}/${this.
|
|
167
|
+
prefix: this.mqtt.prefix ? `melcloud/${this.mqtt.prefix}/${this.deviceTypeString}/${this.deviceName}` : `melcloud/${this.deviceTypeString}/${this.deviceName}`,
|
|
160
168
|
user: this.mqtt.auth?.user,
|
|
161
169
|
passwd: this.mqtt.auth?.passwd,
|
|
162
170
|
logWarn: this.logWarn,
|
|
@@ -296,22 +304,12 @@ class DeviceAta extends EventEmitter {
|
|
|
296
304
|
};
|
|
297
305
|
}
|
|
298
306
|
|
|
299
|
-
async startStopImpulseGenerator(state, timers = []) {
|
|
300
|
-
try {
|
|
301
|
-
//start impulse generator
|
|
302
|
-
await this.melCloudAta.impulseGenerator.state(state, timers)
|
|
303
|
-
return true;
|
|
304
|
-
} catch (error) {
|
|
305
|
-
throw new Error(`Impulse generator start error: ${error}`);
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
|
|
309
307
|
//prepare accessory
|
|
310
308
|
async prepareAccessory() {
|
|
311
309
|
try {
|
|
312
310
|
const deviceData = this.deviceData;
|
|
313
311
|
const deviceId = this.deviceId;
|
|
314
|
-
const
|
|
312
|
+
const deviceTypeString = this.deviceTypeString;
|
|
315
313
|
const deviceName = this.deviceName;
|
|
316
314
|
const accountName = this.accountName;
|
|
317
315
|
const presetsOnServer = this.accessory.presets;
|
|
@@ -347,7 +345,7 @@ class DeviceAta extends EventEmitter {
|
|
|
347
345
|
.setCharacteristic(Characteristic.ConfiguredName, accessoryName);
|
|
348
346
|
|
|
349
347
|
//melcloud services
|
|
350
|
-
const serviceName = `${
|
|
348
|
+
const serviceName = `${deviceTypeString} ${accessoryName}`;
|
|
351
349
|
switch (this.displayType) {
|
|
352
350
|
case 1: //Heater Cooler
|
|
353
351
|
if (this.logDebug) this.emit('debug', `Prepare heater/cooler service`);
|
|
@@ -910,17 +908,19 @@ class DeviceAta extends EventEmitter {
|
|
|
910
908
|
}
|
|
911
909
|
|
|
912
910
|
//sensor
|
|
913
|
-
if (
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
.
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
911
|
+
if (preset.displayType < 7) {
|
|
912
|
+
if (this.logDebug) this.emit('debug', `Prepare preset control sensor s${name} ervice`);
|
|
913
|
+
const presetControlSensorService = new serviceType(serviceName1, `presetControlSensorService${deviceId} ${i}`);
|
|
914
|
+
presetControlSensorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
|
|
915
|
+
presetControlSensorService.setCharacteristic(Characteristic.ConfiguredName, `${serviceName1} Control`);
|
|
916
|
+
presetControlSensorService.getCharacteristic(characteristicType)
|
|
917
|
+
.onGet(async () => {
|
|
918
|
+
const state = this.accessory.scheduleEnabled;
|
|
919
|
+
return state;
|
|
920
|
+
})
|
|
921
|
+
this.presetControlSensorServices.push(presetControlSensorService);
|
|
922
|
+
accessory.addService(presetControlSensorService);
|
|
923
|
+
}
|
|
924
924
|
});
|
|
925
925
|
};
|
|
926
926
|
|
|
@@ -967,30 +967,34 @@ class DeviceAta extends EventEmitter {
|
|
|
967
967
|
}
|
|
968
968
|
|
|
969
969
|
//sensor
|
|
970
|
-
if (
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
.
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
970
|
+
if (schedule.displayType < 7) {
|
|
971
|
+
if (this.logDebug) this.emit('debug', `Prepare schedule control sensor ${name} service`);
|
|
972
|
+
this.scheduleControlSensorService = new serviceType(`${serviceName2} Control`, `scheduleControlSensorService${deviceId} ${i}`);
|
|
973
|
+
this.scheduleControlSensorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
|
|
974
|
+
this.scheduleControlSensorService.setCharacteristic(Characteristic.ConfiguredName, `${serviceName2} Control`);
|
|
975
|
+
this.scheduleControlSensorService.getCharacteristic(characteristicType)
|
|
976
|
+
.onGet(async () => {
|
|
977
|
+
const state = this.accessory.scheduleEnabled;
|
|
978
|
+
return state;
|
|
979
|
+
})
|
|
980
|
+
accessory.addService(this.scheduleControlSensorService);
|
|
981
|
+
}
|
|
980
982
|
}
|
|
981
983
|
|
|
982
984
|
//sensors
|
|
983
|
-
if (
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
.
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
985
|
+
if (schedule.displayType < 7) {
|
|
986
|
+
if (this.logDebug) this.emit('debug', `Prepare schedule sensor ${name} service`);
|
|
987
|
+
const scheduleSensorService = new serviceType(serviceName1, `scheduleSensorService${deviceId} ${i}`);
|
|
988
|
+
scheduleSensorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
|
|
989
|
+
scheduleSensorService.setCharacteristic(Characteristic.ConfiguredName, serviceName1);
|
|
990
|
+
scheduleSensorService.getCharacteristic(characteristicType)
|
|
991
|
+
.onGet(async () => {
|
|
992
|
+
const state = schedule.state;
|
|
993
|
+
return state;
|
|
994
|
+
});
|
|
995
|
+
this.scheduleSensorServices.push(scheduleSensorService);
|
|
996
|
+
accessory.addService(scheduleSensorService);
|
|
997
|
+
}
|
|
994
998
|
});
|
|
995
999
|
};
|
|
996
1000
|
|
|
@@ -1037,17 +1041,19 @@ class DeviceAta extends EventEmitter {
|
|
|
1037
1041
|
}
|
|
1038
1042
|
|
|
1039
1043
|
//sensor
|
|
1040
|
-
if (
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
.
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1044
|
+
if (scene.displayType < 7) {
|
|
1045
|
+
if (this.logDebug) this.emit('debug', `Prepare scene control sensor ${name} service`);
|
|
1046
|
+
const sceneControlSensorService = new serviceType(`${serviceName1} Control`, `sceneControlSensorService${deviceId} ${i}`);
|
|
1047
|
+
sceneControlSensorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
|
|
1048
|
+
sceneControlSensorService.setCharacteristic(Characteristic.ConfiguredName, `${serviceName1} Control`);
|
|
1049
|
+
sceneControlSensorService.getCharacteristic(characteristicType)
|
|
1050
|
+
.onGet(async () => {
|
|
1051
|
+
const state = scene.state;
|
|
1052
|
+
return state;
|
|
1053
|
+
})
|
|
1054
|
+
this.sceneControlSensorServices.push(sceneControlSensorService);
|
|
1055
|
+
accessory.addService(sceneControlSensorService);
|
|
1056
|
+
}
|
|
1051
1057
|
});
|
|
1052
1058
|
};
|
|
1053
1059
|
|
|
@@ -1298,17 +1304,19 @@ class DeviceAta extends EventEmitter {
|
|
|
1298
1304
|
}
|
|
1299
1305
|
|
|
1300
1306
|
//sensor
|
|
1301
|
-
if (
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
.
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1307
|
+
if (button.displayType < 7) {
|
|
1308
|
+
if (this.logDebug) this.emit('debug', `Prepare scene control sensor ${name} service`);
|
|
1309
|
+
const buttonControlSensorService = new serviceType(serviceName, `buttonControlSensorService${deviceId} ${i}`);
|
|
1310
|
+
buttonControlSensorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
|
|
1311
|
+
buttonControlSensorService.setCharacteristic(Characteristic.ConfiguredName, serviceName);
|
|
1312
|
+
buttonControlSensorService.getCharacteristic(characteristicType)
|
|
1313
|
+
.onGet(async () => {
|
|
1314
|
+
const state = button.state;
|
|
1315
|
+
return state;
|
|
1316
|
+
})
|
|
1317
|
+
this.buttonControlSensorServices.push(buttonControlSensorService);
|
|
1318
|
+
accessory.addService(buttonControlSensorService);
|
|
1319
|
+
}
|
|
1312
1320
|
});
|
|
1313
1321
|
};
|
|
1314
1322
|
|
|
@@ -1325,7 +1333,7 @@ class DeviceAta extends EventEmitter {
|
|
|
1325
1333
|
this.melCloudAta = new MelCloudAta(this.account, this.device, this.devicesFile, this.defaultTempsFile, this.accountFile)
|
|
1326
1334
|
.on('deviceInfo', (modelIndoor, modelOutdoor, serialNumber, firmwareAppVersion) => {
|
|
1327
1335
|
if (this.logDeviceInfo && this.displayDeviceInfo) {
|
|
1328
|
-
this.emit('devInfo', `---- ${this.
|
|
1336
|
+
this.emit('devInfo', `---- ${this.deviceTypeString}: ${this.deviceName} ----`);
|
|
1329
1337
|
this.emit('devInfo', `Account: ${this.accountName}`);
|
|
1330
1338
|
if (modelIndoor) this.emit('devInfo', `Indoor: ${modelIndoor}`);
|
|
1331
1339
|
if (modelOutdoor) this.emit('devInfo', `Outdoor: ${modelOutdoor}`);
|
|
@@ -1338,7 +1346,7 @@ class DeviceAta extends EventEmitter {
|
|
|
1338
1346
|
|
|
1339
1347
|
//accessory info
|
|
1340
1348
|
this.manufacturer = 'Mitsubishi';
|
|
1341
|
-
this.model = modelIndoor ? modelIndoor : modelOutdoor ? modelOutdoor : `${this.
|
|
1349
|
+
this.model = modelIndoor ? modelIndoor : modelOutdoor ? modelOutdoor : `${this.deviceTypeString}`;
|
|
1342
1350
|
this.serialNumber = serialNumber.toString();
|
|
1343
1351
|
this.firmwareRevision = firmwareAppVersion.toString();
|
|
1344
1352
|
|
|
@@ -1675,16 +1683,14 @@ class DeviceAta extends EventEmitter {
|
|
|
1675
1683
|
&& presetData.FanSpeed === setFanSpeed) : false;
|
|
1676
1684
|
|
|
1677
1685
|
//control
|
|
1678
|
-
if (preset.displayType > 3)
|
|
1679
|
-
this.presetControlServices?.[i]?.updateCharacteristic(Characteristic.On, preset.state);
|
|
1680
|
-
}
|
|
1686
|
+
if (preset.displayType > 3) this.presetControlServices?.[i]?.updateCharacteristic(Characteristic.On, preset.state);
|
|
1681
1687
|
|
|
1682
1688
|
//sencor
|
|
1683
|
-
this.presetControlSensorServices?.[i]?.updateCharacteristic(characteristicType, preset.state);
|
|
1689
|
+
if (preset.displayType < 7) this.presetControlSensorServices?.[i]?.updateCharacteristic(characteristicType, preset.state);
|
|
1684
1690
|
});
|
|
1685
1691
|
};
|
|
1686
1692
|
|
|
1687
|
-
|
|
1693
|
+
///schedules
|
|
1688
1694
|
if (this.schedules.length > 0 && scheduleEnabled !== null) {
|
|
1689
1695
|
this.schedules.forEach((schedule, i) => {
|
|
1690
1696
|
const scheduleData = schedulesOnServer.find(s => s.Id === schedule.id);
|
|
@@ -1693,37 +1699,34 @@ class DeviceAta extends EventEmitter {
|
|
|
1693
1699
|
|
|
1694
1700
|
//control
|
|
1695
1701
|
if (i === 0) {
|
|
1696
|
-
if (schedule.displayType > 3)
|
|
1697
|
-
|
|
1698
|
-
}
|
|
1699
|
-
this.scheduleControlSensorService?.updateCharacteristic(characteristicType, scheduleEnabled);
|
|
1702
|
+
if (schedule.displayType > 3) this.scheduleControlService?.updateCharacteristic(Characteristic.On, scheduleEnabled);
|
|
1703
|
+
if (schedule.displayType < 7) this.scheduleControlSensorService?.updateCharacteristic(characteristicType, scheduleEnabled);
|
|
1700
1704
|
}
|
|
1701
1705
|
|
|
1702
1706
|
//sensor
|
|
1703
|
-
this.scheduleSensorServices?.[i]?.updateCharacteristic(characteristicType, schedule.state);
|
|
1707
|
+
if (schedule.displayType < 7) this.scheduleSensorServices?.[i]?.updateCharacteristic(characteristicType, schedule.state);
|
|
1704
1708
|
});
|
|
1705
1709
|
};
|
|
1706
1710
|
|
|
1707
|
-
//
|
|
1711
|
+
//scenes
|
|
1708
1712
|
if (this.scenes.length > 0) {
|
|
1709
1713
|
this.scenes.forEach((scene, i) => {
|
|
1710
1714
|
const sceneData = scenesOnServer.find(s => s.Id === scene.id);
|
|
1711
|
-
|
|
1715
|
+
const characteristicType = scene.characteristicType;
|
|
1716
|
+
scene.state = sceneData.Enabled;
|
|
1712
1717
|
|
|
1713
1718
|
//control
|
|
1714
|
-
if (scene.displayType > 3)
|
|
1715
|
-
this.sceneControlServices?.[i]?.updateCharacteristic(Characteristic.On, scene.state);
|
|
1716
|
-
}
|
|
1719
|
+
if (scene.displayType > 3) this.sceneControlServices?.[i]?.updateCharacteristic(Characteristic.On, scene.state);
|
|
1717
1720
|
|
|
1718
1721
|
//sensor
|
|
1719
|
-
|
|
1720
|
-
this.sceneControlSensorServices?.[i]?.updateCharacteristic(characteristicType, scene.state);
|
|
1722
|
+
if (scene.displayType < 7) this.sceneControlSensorServices?.[i]?.updateCharacteristic(characteristicType, scene.state);
|
|
1721
1723
|
});
|
|
1722
1724
|
};
|
|
1723
1725
|
|
|
1724
1726
|
//buttons
|
|
1725
1727
|
if (this.buttons.length > 0) {
|
|
1726
1728
|
this.buttons.forEach((button, i) => {
|
|
1729
|
+
const characteristicType = button.characteristicType;
|
|
1727
1730
|
const mode = button.mode;
|
|
1728
1731
|
switch (mode) {
|
|
1729
1732
|
case 0: //POWER ON,OFF
|
|
@@ -1837,13 +1840,10 @@ class DeviceAta extends EventEmitter {
|
|
|
1837
1840
|
};
|
|
1838
1841
|
|
|
1839
1842
|
//control
|
|
1840
|
-
if (button.displayType > 3)
|
|
1841
|
-
this.buttonControlServices?.[i]?.updateCharacteristic(Characteristic.On, button.state);
|
|
1842
|
-
}
|
|
1843
|
+
if (button.displayType > 3) this.buttonControlServices?.[i]?.updateCharacteristic(Characteristic.On, button.state);
|
|
1843
1844
|
|
|
1844
1845
|
//sensor
|
|
1845
|
-
|
|
1846
|
-
this.buttonControlSensorServices?.[i]?.updateCharacteristic(characteristicType, button.state);
|
|
1846
|
+
if (button.displayType < 7) this.buttonControlSensorServices?.[i]?.updateCharacteristic(characteristicType, button.state);
|
|
1847
1847
|
});
|
|
1848
1848
|
};
|
|
1849
1849
|
|