homebridge-melcloud-control 4.1.3-beta.2 → 4.1.3-beta.3
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/README.md +0 -1
- package/config.schema.json +4 -26
- package/package.json +1 -1
- package/src/deviceata.js +46 -31
package/README.md
CHANGED
|
@@ -230,7 +230,6 @@ Homebridge plugin for Air Conditioner, Heat Pump and Energy Recovery Ventilation
|
|
|
230
230
|
| `ataDevices[].frostProtectionSensor` | This enable extra `Frost Protectio` sensor to use with automations in HomeKit app. |
|
|
231
231
|
| `ataDevices[].overHeatProtectionSensor` | This enable extra `Overheat Protection` sensor to use with automations in HomeKit app. |
|
|
232
232
|
| `ataDevices[].holidayModeSensor` | This enable extra `Holiday Mode` sensor to use with automations in HomeKit app. |
|
|
233
|
-
| `ataDevices[].scheduleSensor` | This enable extra `Shedule` sensor to use with automations in HomeKit app. |
|
|
234
233
|
| `ataDevices[].errorSensor` | This enable `Error` sensor to use with automations in HomeKit app. |
|
|
235
234
|
| `ataDevices[].refreshInterval` | Here set the background devices state refresh time in (sec), default `5s`. |
|
|
236
235
|
| `ataDevices[].presets[]` | Array of ATA device `Presets` created automatically after login to MELCloud from plugin config UI. |
|
package/config.schema.json
CHANGED
|
@@ -422,15 +422,6 @@
|
|
|
422
422
|
"functionBody": "return model.accounts[arrayIndices[0]].type === 'melcloudhome';"
|
|
423
423
|
}
|
|
424
424
|
},
|
|
425
|
-
"scheduleSensor": {
|
|
426
|
-
"title": "Schedule Enabled",
|
|
427
|
-
"type": "boolean",
|
|
428
|
-
"default": false,
|
|
429
|
-
"description": "This enable extra schedule sensor to use with automations in HomeKit app.",
|
|
430
|
-
"condition": {
|
|
431
|
-
"functionBody": "return model.accounts[arrayIndices[0]].type === 'melcloudhome';"
|
|
432
|
-
}
|
|
433
|
-
},
|
|
434
425
|
"errorSensor": {
|
|
435
426
|
"title": "Error",
|
|
436
427
|
"type": "boolean",
|
|
@@ -541,7 +532,7 @@
|
|
|
541
532
|
"title": "Display Type",
|
|
542
533
|
"type": "integer",
|
|
543
534
|
"minimum": 0,
|
|
544
|
-
"maximum":
|
|
535
|
+
"maximum": 3,
|
|
545
536
|
"default": 0,
|
|
546
537
|
"description": "Select the characteristic type to be displayed in HomeKit app.",
|
|
547
538
|
"anyOf": [
|
|
@@ -551,34 +542,22 @@
|
|
|
551
542
|
0
|
|
552
543
|
]
|
|
553
544
|
},
|
|
554
|
-
{
|
|
555
|
-
"title": "Outlet",
|
|
556
|
-
"enum": [
|
|
557
|
-
1
|
|
558
|
-
]
|
|
559
|
-
},
|
|
560
|
-
{
|
|
561
|
-
"title": "Switch",
|
|
562
|
-
"enum": [
|
|
563
|
-
2
|
|
564
|
-
]
|
|
565
|
-
},
|
|
566
545
|
{
|
|
567
546
|
"title": "Motion Sensor",
|
|
568
547
|
"enum": [
|
|
569
|
-
|
|
548
|
+
1
|
|
570
549
|
]
|
|
571
550
|
},
|
|
572
551
|
{
|
|
573
552
|
"title": "Occupancy Sensor",
|
|
574
553
|
"enum": [
|
|
575
|
-
|
|
554
|
+
2
|
|
576
555
|
]
|
|
577
556
|
},
|
|
578
557
|
{
|
|
579
558
|
"title": "Contact Sensor",
|
|
580
559
|
"enum": [
|
|
581
|
-
|
|
560
|
+
3
|
|
582
561
|
]
|
|
583
562
|
}
|
|
584
563
|
]
|
|
@@ -2281,7 +2260,6 @@
|
|
|
2281
2260
|
"accounts[].ataDevices[].frostProtectionSensor",
|
|
2282
2261
|
"accounts[].ataDevices[].overheatProtectionSensor",
|
|
2283
2262
|
"accounts[].ataDevices[].holidayModeSensor",
|
|
2284
|
-
"accounts[].ataDevices[].scheduleSensor",
|
|
2285
2263
|
"accounts[].ataDevices[].errorSensor"
|
|
2286
2264
|
]
|
|
2287
2265
|
},
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"displayName": "MELCloud Control",
|
|
3
3
|
"name": "homebridge-melcloud-control",
|
|
4
|
-
"version": "4.1.3-beta.
|
|
4
|
+
"version": "4.1.3-beta.3",
|
|
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
|
@@ -32,7 +32,6 @@ class DeviceAta extends EventEmitter {
|
|
|
32
32
|
this.frostProtectionSensor = device.frostProtectionSensor || false;
|
|
33
33
|
this.overheatProtectionSensor = device.overheatProtectionSensor || false;
|
|
34
34
|
this.holidayModeSensor = device.holidayModeSensor || false;
|
|
35
|
-
this.scheduleSensor = device.scheduleSensor || false;
|
|
36
35
|
this.errorSensor = device.errorSensor || false;
|
|
37
36
|
this.heatDryFanMode = device.heatDryFanMode || 1; //NONE, HEAT, DRY, FAN
|
|
38
37
|
this.coolDryFanMode = device.coolDryFanMode || 1; //NONE, COOL, DRY, FAN
|
|
@@ -65,8 +64,8 @@ class DeviceAta extends EventEmitter {
|
|
|
65
64
|
//schedules configured
|
|
66
65
|
for (const schedule of this.schedules) {
|
|
67
66
|
schedule.name = schedule.name || 'Schedule'
|
|
68
|
-
schedule.serviceType = [null, Service.
|
|
69
|
-
schedule.characteristicType = [null, Characteristic.
|
|
67
|
+
schedule.serviceType = [null, Service.MotionSensor, Service.OccupancySensor, Service.ContactSensor][schedule.displayType];
|
|
68
|
+
schedule.characteristicType = [null, Characteristic.MotionDetected, Characteristic.OccupancyDetected, Characteristic.ContactSensorState][schedule.displayType];
|
|
70
69
|
schedule.state = false;
|
|
71
70
|
}
|
|
72
71
|
|
|
@@ -661,20 +660,6 @@ class DeviceAta extends EventEmitter {
|
|
|
661
660
|
accessory.addService(this.holidayModeSensorService);
|
|
662
661
|
}
|
|
663
662
|
|
|
664
|
-
//schedule sensor
|
|
665
|
-
if (this.scheduleSensor && this.accessory.scheduleEnabled !== null) {
|
|
666
|
-
if (this.logDebug) this.emit('debug', `Prepare schedule service`);
|
|
667
|
-
this.scheduleSensorService = new Service.ContactSensor(`${serviceName} Schedule`, `Schedule Sensor ${deviceId}`);
|
|
668
|
-
this.scheduleSensorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
|
|
669
|
-
this.scheduleSensorService.setCharacteristic(Characteristic.ConfiguredName, `${accessoryName} Schedule`);
|
|
670
|
-
this.scheduleSensorService.getCharacteristic(Characteristic.ContactSensorState)
|
|
671
|
-
.onGet(async () => {
|
|
672
|
-
const state = this.accessory.scheduleEnabled;
|
|
673
|
-
return state;
|
|
674
|
-
})
|
|
675
|
-
accessory.addService(this.scheduleSensorService);
|
|
676
|
-
}
|
|
677
|
-
|
|
678
663
|
//error sensor
|
|
679
664
|
if (this.errorSensor && this.accessory.isInError !== null) {
|
|
680
665
|
if (this.logDebug) this.emit('debug', `Prepare error service`);
|
|
@@ -747,7 +732,7 @@ class DeviceAta extends EventEmitter {
|
|
|
747
732
|
};
|
|
748
733
|
|
|
749
734
|
//schedules services
|
|
750
|
-
if (this.schedules.length > 0) {
|
|
735
|
+
if (this.schedules.length > 0 && this.accessory.scheduleEnabled !== null) {
|
|
751
736
|
if (this.logDebug) this.emit('debug', `Prepare schedules services`);
|
|
752
737
|
this.schedulesServices = [];
|
|
753
738
|
this.schedules.forEach((schedule, i) => {
|
|
@@ -757,25 +742,52 @@ class DeviceAta extends EventEmitter {
|
|
|
757
742
|
//get preset name prefix
|
|
758
743
|
const namePrefix = schedule.namePrefix;
|
|
759
744
|
|
|
745
|
+
//control
|
|
746
|
+
if (i === 0) {
|
|
747
|
+
if (this.logDebug) this.emit('debug', `Prepare schedule control service`);
|
|
748
|
+
const serviceNameSchedule = namePrefix ? `${accessoryName} Schedule Control` : `Schedule Control`;
|
|
749
|
+
this.schedulesControlService = new Service.Switch(serviceNameSchedule, `Schedule Control ${deviceId} ${i}`);
|
|
750
|
+
this.schedulesControlService.addOptionalCharacteristic(Characteristic.ConfiguredName);
|
|
751
|
+
this.schedulesControlService.setCharacteristic(Characteristic.ConfiguredName, serviceNameSchedule);
|
|
752
|
+
this.schedulesControlService.getCharacteristic(Characteristic.On)
|
|
753
|
+
.onGet(async () => {
|
|
754
|
+
const state = this.accessory.scheduleEnabled;
|
|
755
|
+
return state;
|
|
756
|
+
})
|
|
757
|
+
.onSet(async (state) => {
|
|
758
|
+
try {
|
|
759
|
+
deviceData.ScheduleEnabled = state;
|
|
760
|
+
await this.melCloudAta.send(this.accountType, this.displayType, deviceData, 'scheduleenabled');
|
|
761
|
+
if (this.logInfo) this.emit('info', `Schedule: ${state ? 'Enabled' : 'Disabled'}`);
|
|
762
|
+
} catch (error) {
|
|
763
|
+
if (this.logWarn) this.emit('warn', `Set schedule error: ${error}`);
|
|
764
|
+
};
|
|
765
|
+
});
|
|
766
|
+
accessory.addService(this.schedulesControlService);
|
|
767
|
+
|
|
768
|
+
if (this.logDebug) this.emit('debug', `Prepare schedule control sensor service`);
|
|
769
|
+
this.scheduleSensorService = new Service.ContactSensor(serviceNameSchedule, `Schedule Control Sensor ${deviceId}`);
|
|
770
|
+
this.scheduleSensorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
|
|
771
|
+
this.scheduleSensorService.setCharacteristic(Characteristic.ConfiguredName, serviceNameSchedule);
|
|
772
|
+
this.scheduleSensorService.getCharacteristic(Characteristic.ContactSensorState)
|
|
773
|
+
.onGet(async () => {
|
|
774
|
+
const state = this.accessory.scheduleEnabled;
|
|
775
|
+
return state;
|
|
776
|
+
})
|
|
777
|
+
accessory.addService(this.scheduleSensorService);
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
//sensors
|
|
760
781
|
const serviceName = namePrefix ? `${accessoryName} ${name}` : name;
|
|
761
782
|
const serviceType = schedule.serviceType;
|
|
762
783
|
const characteristicType = schedule.characteristicType;
|
|
763
|
-
const scheduleService = new serviceType(serviceName, `Schedule ${deviceId} ${i}`);
|
|
784
|
+
const scheduleService = new serviceType(serviceName, `Schedule Sensor ${deviceId} ${i}`);
|
|
764
785
|
scheduleService.addOptionalCharacteristic(Characteristic.ConfiguredName);
|
|
765
786
|
scheduleService.setCharacteristic(Characteristic.ConfiguredName, serviceName);
|
|
766
787
|
scheduleService.getCharacteristic(characteristicType)
|
|
767
788
|
.onGet(async () => {
|
|
768
789
|
const state = schedule.state;
|
|
769
790
|
return state;
|
|
770
|
-
})
|
|
771
|
-
.onSet(async (state) => {
|
|
772
|
-
try {
|
|
773
|
-
deviceData.ScheduleEnabled = state;
|
|
774
|
-
await this.melCloudAta.send(this.accountType, this.displayType, deviceData, 'scheduleenabled');
|
|
775
|
-
if (this.logInfo) this.emit('info', `${state ? 'Set:' : 'Unset:'} ${name}`);
|
|
776
|
-
} catch (error) {
|
|
777
|
-
if (this.logWarn) this.emit('warn', `Set schedule error: ${error}`);
|
|
778
|
-
};
|
|
779
791
|
});
|
|
780
792
|
this.schedulesServices.push(scheduleService);
|
|
781
793
|
accessory.addService(scheduleService);
|
|
@@ -1324,7 +1336,6 @@ class DeviceAta extends EventEmitter {
|
|
|
1324
1336
|
this.frostProtectionSensorService?.updateCharacteristic(Characteristic.ContactSensorState, frostProtectionActive);
|
|
1325
1337
|
this.overheatProtectionSensorService?.updateCharacteristic(Characteristic.ContactSensorState, overheatProtectionActive);
|
|
1326
1338
|
this.holidayModeSensorService?.updateCharacteristic(Characteristic.ContactSensorState, holidayModeActive);
|
|
1327
|
-
this.scheduleSensorService?.updateCharacteristic(Characteristic.ContactSensorState, scheduleEnabled);
|
|
1328
1339
|
this.errorService?.updateCharacteristic(Characteristic.ContactSensorState, isInError);
|
|
1329
1340
|
|
|
1330
1341
|
//update presets state
|
|
@@ -1345,10 +1356,14 @@ class DeviceAta extends EventEmitter {
|
|
|
1345
1356
|
};
|
|
1346
1357
|
|
|
1347
1358
|
//update schedules state
|
|
1348
|
-
if (this.schedules.length > 0) {
|
|
1359
|
+
if (this.schedules.length > 0 && scheduleEnabled !== null) {
|
|
1349
1360
|
this.schedules.forEach((schedule, i) => {
|
|
1361
|
+
//control
|
|
1362
|
+
if (i === 0) this.schedulesControlService?.updateCharacteristic(characteristicType, scheduleEnabled);
|
|
1363
|
+
|
|
1364
|
+
//sensors
|
|
1350
1365
|
const scheduleData = schedulesOnServer.find(s => s[presetsIdKey] === schedule.id);
|
|
1351
|
-
schedule.state = scheduleEnabled
|
|
1366
|
+
schedule.state = scheduleEnabled ? scheduleData.Enabled ?? false : false;
|
|
1352
1367
|
|
|
1353
1368
|
const characteristicType = schedule.characteristicType;
|
|
1354
1369
|
this.schedulesServices?.[i]?.updateCharacteristic(characteristicType, schedule.state);
|