homebridge-melcloud-control 4.1.3-beta.2 → 4.1.3-beta.4
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 +11 -3
- package/config.schema.json +4 -46
- package/package.json +1 -1
- package/src/deviceata.js +46 -31
- package/src/deviceatw.js +44 -29
- package/src/deviceerv.js +44 -29
package/README.md
CHANGED
|
@@ -65,7 +65,7 @@ Homebridge plugin for Air Conditioner, Heat Pump and Energy Recovery Ventilation
|
|
|
65
65
|
* Vane V mode `AUTO/1/2/3/4/5/SWING`.
|
|
66
66
|
* Fan speed mode `AUTO/1/2/3/4/5`.
|
|
67
67
|
* Presets `SET/UNSET`.
|
|
68
|
-
*
|
|
68
|
+
* Schedule `ON/OFF`.
|
|
69
69
|
* Sensors:
|
|
70
70
|
* For automation and notifications.
|
|
71
71
|
* Power `ON/OFF`.
|
|
@@ -80,7 +80,8 @@ Homebridge plugin for Air Conditioner, Heat Pump and Energy Recovery Ventilation
|
|
|
80
80
|
* Frost protection.
|
|
81
81
|
* Overheat protection.
|
|
82
82
|
* Holiday mode.
|
|
83
|
-
* Shedule.
|
|
83
|
+
* Shedule control.
|
|
84
|
+
* Shedule active
|
|
84
85
|
* Error
|
|
85
86
|
* Heat Pump:
|
|
86
87
|
* Heater Cooler:
|
|
@@ -118,6 +119,7 @@ Homebridge plugin for Air Conditioner, Heat Pump and Energy Recovery Ventilation
|
|
|
118
119
|
* Operating mode `HEAT/COOL/CURVE/HOLIDAY/AUTO HOT WATER/ECO HOT WATER/FORCE HOT WATER`.
|
|
119
120
|
* Physical lock controls `LOCK/UNLOCK`.
|
|
120
121
|
* Presets `SET/UNSET`.
|
|
122
|
+
* Schedule `ON/OFF`.
|
|
121
123
|
* Sensors:
|
|
122
124
|
* For automation and notifications.
|
|
123
125
|
* Power `ON/OFF`.
|
|
@@ -130,6 +132,8 @@ Homebridge plugin for Air Conditioner, Heat Pump and Energy Recovery Ventilation
|
|
|
130
132
|
* Water tank temperature.
|
|
131
133
|
* Flow Temperature Zone 1, 2, Hot Water.
|
|
132
134
|
* Return Temperature Zone 1, 2, Hot Water.
|
|
135
|
+
* Shedule control.
|
|
136
|
+
* Shedule active
|
|
133
137
|
* Error
|
|
134
138
|
* Energy Recovery Ventilation Lossnay:
|
|
135
139
|
* Heater Cooler:
|
|
@@ -147,6 +151,7 @@ Homebridge plugin for Air Conditioner, Heat Pump and Energy Recovery Ventilation
|
|
|
147
151
|
* Operating mode `LOSSNAY/BYPASS/AUTO/NIGHT PURGE`.
|
|
148
152
|
* Fan speed mode `AUTO/1/2/3/4`.
|
|
149
153
|
* Presets `SET/UNSET`.
|
|
154
|
+
* Schedule `ON/OFF`.
|
|
150
155
|
* Sensors:
|
|
151
156
|
* For automation and notifications.
|
|
152
157
|
* Power `ON/OFF`.
|
|
@@ -160,6 +165,8 @@ Homebridge plugin for Air Conditioner, Heat Pump and Energy Recovery Ventilation
|
|
|
160
165
|
* Filter maintenance.
|
|
161
166
|
* CO2 detected and level.
|
|
162
167
|
* PM2.5 air quality and level.
|
|
168
|
+
* Shedule control.
|
|
169
|
+
* Shedule active
|
|
163
170
|
* Error
|
|
164
171
|
|
|
165
172
|
### HOME app current device mode display
|
|
@@ -230,7 +237,6 @@ Homebridge plugin for Air Conditioner, Heat Pump and Energy Recovery Ventilation
|
|
|
230
237
|
| `ataDevices[].frostProtectionSensor` | This enable extra `Frost Protectio` sensor to use with automations in HomeKit app. |
|
|
231
238
|
| `ataDevices[].overHeatProtectionSensor` | This enable extra `Overheat Protection` sensor to use with automations in HomeKit app. |
|
|
232
239
|
| `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
240
|
| `ataDevices[].errorSensor` | This enable `Error` sensor to use with automations in HomeKit app. |
|
|
235
241
|
| `ataDevices[].refreshInterval` | Here set the background devices state refresh time in (sec), default `5s`. |
|
|
236
242
|
| `ataDevices[].presets[]` | Array of ATA device `Presets` created automatically after login to MELCloud from plugin config UI. |
|
|
@@ -262,6 +268,7 @@ Homebridge plugin for Air Conditioner, Heat Pump and Energy Recovery Ventilation
|
|
|
262
268
|
| `atwDevices[].temperatureReturnWaterTankSensor` | This enable extra `Return Water Tank` temperature sensor to use with automations in HomeKit app. |
|
|
263
269
|
| `atwDevices[].temperatureFlowZone2Sensor` | This enable extra `Flow Zone 2` temperature sensor to use with automations in HomeKit app. |
|
|
264
270
|
| `atwDevices[].temperatureReturnZone2Sensor` | This enable extra `Return Zone 2` temperature sensor to use with automations in HomeKit app. |
|
|
271
|
+
| `atwDevices[].holidayModeSensor` | This enable extra `Holiday Mode` sensor to use with automations in HomeKit app. |
|
|
265
272
|
| `atwDevices[].errorSensor` | This enable `Error` sensors to use with automations in HomeKit app. |
|
|
266
273
|
| `atwDevices[].refreshInterval` | Here set the background devices state refresh time in (sec), default `5s`. |
|
|
267
274
|
| `atwDevices[].presets[]` | Array of ATW device `Presets` created automatically after login to MELCloud from plugin config UI. |
|
|
@@ -286,6 +293,7 @@ Homebridge plugin for Air Conditioner, Heat Pump and Energy Recovery Ventilation
|
|
|
286
293
|
| `ervDevices[].temperatureSensor` | This enable extra `Room` temperature sensor to use with automations in HomeKit app. |
|
|
287
294
|
| `ervDevices[].temperatureOutdoorSensor` | This enable extra `Outdoor` temperature sensor to use with automations in HomeKit app. |
|
|
288
295
|
| `ervDevices[].temperatureSupplySensor` | This enable extra `Supply` temperature sensor to use with automations in HomeKit app. |
|
|
296
|
+
| `ervDevices[].holidayModeSensor` | This enable extra `Holiday Mode` sensor to use with automations in HomeKit app. |
|
|
289
297
|
| `ervDevices[].errorSensor` | This enable `Error` sensors to use with automations in HomeKit app. |
|
|
290
298
|
| `ervDevices[].refreshInterval` | Here set the background devices state refresh time in (sec), default `5s`. |
|
|
291
299
|
| `ervDevices[].presets[]` | Array of ERV 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
|
]
|
|
@@ -1137,15 +1116,6 @@
|
|
|
1137
1116
|
"functionBody": "return model.accounts[arrayIndices[0]].type === 'melcloudhome';"
|
|
1138
1117
|
}
|
|
1139
1118
|
},
|
|
1140
|
-
"scheduleSensor": {
|
|
1141
|
-
"title": "Schedule Enabled",
|
|
1142
|
-
"type": "boolean",
|
|
1143
|
-
"default": false,
|
|
1144
|
-
"description": "This enable extra schedule sensor to use with automations in HomeKit app.",
|
|
1145
|
-
"condition": {
|
|
1146
|
-
"functionBody": "return model.accounts[arrayIndices[0]].type === 'melcloudhome';"
|
|
1147
|
-
}
|
|
1148
|
-
},
|
|
1149
1119
|
"errorSensor": {
|
|
1150
1120
|
"title": "Error",
|
|
1151
1121
|
"type": "boolean",
|
|
@@ -1630,15 +1600,6 @@
|
|
|
1630
1600
|
"functionBody": "return model.accounts[arrayIndices[0]].type === 'melcloudhome';"
|
|
1631
1601
|
}
|
|
1632
1602
|
},
|
|
1633
|
-
"scheduleSensor": {
|
|
1634
|
-
"title": "Schedule Enabled",
|
|
1635
|
-
"type": "boolean",
|
|
1636
|
-
"default": false,
|
|
1637
|
-
"description": "This enable extra schedule sensor to use with automations in HomeKit app.",
|
|
1638
|
-
"condition": {
|
|
1639
|
-
"functionBody": "return model.accounts[arrayIndices[0]].type === 'melcloudhome';"
|
|
1640
|
-
}
|
|
1641
|
-
},
|
|
1642
1603
|
"errorSensor": {
|
|
1643
1604
|
"title": "Error",
|
|
1644
1605
|
"type": "boolean",
|
|
@@ -2281,7 +2242,6 @@
|
|
|
2281
2242
|
"accounts[].ataDevices[].frostProtectionSensor",
|
|
2282
2243
|
"accounts[].ataDevices[].overheatProtectionSensor",
|
|
2283
2244
|
"accounts[].ataDevices[].holidayModeSensor",
|
|
2284
|
-
"accounts[].ataDevices[].scheduleSensor",
|
|
2285
2245
|
"accounts[].ataDevices[].errorSensor"
|
|
2286
2246
|
]
|
|
2287
2247
|
},
|
|
@@ -2433,7 +2393,6 @@
|
|
|
2433
2393
|
"title": "System",
|
|
2434
2394
|
"items": [
|
|
2435
2395
|
"accounts[].atwDevices[].holidayModeSensor",
|
|
2436
|
-
"accounts[].atwDevices[].scheduleSensor",
|
|
2437
2396
|
"accounts[].atwDevices[].errorSensor"
|
|
2438
2397
|
]
|
|
2439
2398
|
},
|
|
@@ -2578,7 +2537,6 @@
|
|
|
2578
2537
|
"title": "System",
|
|
2579
2538
|
"items": [
|
|
2580
2539
|
"accounts[].ervDevices[].holidayModeSensor",
|
|
2581
|
-
"accounts[].ervDevices[].scheduleSensor",
|
|
2582
2540
|
"accounts[].ervDevices[].errorSensor"
|
|
2583
2541
|
]
|
|
2584
2542
|
},
|
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.4",
|
|
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);
|
package/src/deviceatw.js
CHANGED
|
@@ -38,7 +38,6 @@ class DeviceAtw extends EventEmitter {
|
|
|
38
38
|
this.temperatureFlowZone2Sensor = device.temperatureFlowZone2Sensor || false;
|
|
39
39
|
this.temperatureReturnZone2Sensor = device.temperatureReturnZone2Sensor || false;
|
|
40
40
|
this.holidayModeSensor = device.holidayModeSensor || false;
|
|
41
|
-
this.scheduleSensor = device.scheduleSensor || false;
|
|
42
41
|
this.errorSensor = device.errorSensor || false;
|
|
43
42
|
this.presets = this.accountType === 'melcloud' ? (device.presets || []).filter(preset => (preset.displayType ?? 0) > 0 && preset.id !== '0') : [];
|
|
44
43
|
this.schedules = this.accountType === 'melcloudhome' ? (device.schedules || []).filter(schedule => (schedule.displayType ?? 0) > 0 && schedule.id !== '0') : [];
|
|
@@ -1063,20 +1062,6 @@ class DeviceAtw extends EventEmitter {
|
|
|
1063
1062
|
accessory.addService(this.holidayModeSensorService);
|
|
1064
1063
|
}
|
|
1065
1064
|
|
|
1066
|
-
//schedule sensor
|
|
1067
|
-
if (this.scheduleSensor && this.accessory.scheduleEnabled !== null) {
|
|
1068
|
-
if (this.logDebug) this.emit('debug', `Prepare schedule service`);
|
|
1069
|
-
this.scheduleSensorService = new Service.ContactSensor(`${serviceName} Schedule`, `Schedule Sensor ${deviceId}`);
|
|
1070
|
-
this.scheduleSensorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
|
|
1071
|
-
this.scheduleSensorService.setCharacteristic(Characteristic.ConfiguredName, `${accessoryName} Schedule`);
|
|
1072
|
-
this.scheduleSensorService.getCharacteristic(Characteristic.ContactSensorState)
|
|
1073
|
-
.onGet(async () => {
|
|
1074
|
-
const state = this.accessory.scheduleEnabled;
|
|
1075
|
-
return state;
|
|
1076
|
-
})
|
|
1077
|
-
accessory.addService(this.scheduleSensorService);
|
|
1078
|
-
}
|
|
1079
|
-
|
|
1080
1065
|
//error sensor
|
|
1081
1066
|
if (this.errorSensor && this.accessory.isInError !== null) {
|
|
1082
1067
|
if (this.logDebug) this.emit('debug', `Prepare error service`);
|
|
@@ -1162,7 +1147,7 @@ class DeviceAtw extends EventEmitter {
|
|
|
1162
1147
|
};
|
|
1163
1148
|
|
|
1164
1149
|
//schedules services
|
|
1165
|
-
if (this.schedules.length > 0) {
|
|
1150
|
+
if (this.schedules.length > 0 && this.accessory.scheduleEnabled !== null) {
|
|
1166
1151
|
if (this.logDebug) this.emit('debug', `Prepare schedules services`);
|
|
1167
1152
|
this.schedulesServices = [];
|
|
1168
1153
|
this.schedules.forEach((schedule, i) => {
|
|
@@ -1172,25 +1157,52 @@ class DeviceAtw extends EventEmitter {
|
|
|
1172
1157
|
//get preset name prefix
|
|
1173
1158
|
const namePrefix = schedule.namePrefix;
|
|
1174
1159
|
|
|
1160
|
+
//control
|
|
1161
|
+
if (i === 0) {
|
|
1162
|
+
if (this.logDebug) this.emit('debug', `Prepare schedule control service`);
|
|
1163
|
+
const serviceNameSchedule = namePrefix ? `${accessoryName} Schedule Control` : `Schedule Control`;
|
|
1164
|
+
this.schedulesControlService = new Service.Switch(serviceNameSchedule, `Schedule Control ${deviceId} ${i}`);
|
|
1165
|
+
this.schedulesControlService.addOptionalCharacteristic(Characteristic.ConfiguredName);
|
|
1166
|
+
this.schedulesControlService.setCharacteristic(Characteristic.ConfiguredName, serviceNameSchedule);
|
|
1167
|
+
this.schedulesControlService.getCharacteristic(Characteristic.On)
|
|
1168
|
+
.onGet(async () => {
|
|
1169
|
+
const state = this.accessory.scheduleEnabled;
|
|
1170
|
+
return state;
|
|
1171
|
+
})
|
|
1172
|
+
.onSet(async (state) => {
|
|
1173
|
+
try {
|
|
1174
|
+
deviceData.ScheduleEnabled = state;
|
|
1175
|
+
await this.melCloudAta.send(this.accountType, this.displayType, deviceData, 'scheduleenabled');
|
|
1176
|
+
if (this.logInfo) this.emit('info', `Schedule: ${state ? 'Enabled' : 'Disabled'}`);
|
|
1177
|
+
} catch (error) {
|
|
1178
|
+
if (this.logWarn) this.emit('warn', `Set schedule error: ${error}`);
|
|
1179
|
+
};
|
|
1180
|
+
});
|
|
1181
|
+
accessory.addService(this.schedulesControlService);
|
|
1182
|
+
|
|
1183
|
+
if (this.logDebug) this.emit('debug', `Prepare schedule control sensor service`);
|
|
1184
|
+
this.scheduleSensorService = new Service.ContactSensor(serviceNameSchedule, `Schedule Control Sensor ${deviceId}`);
|
|
1185
|
+
this.scheduleSensorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
|
|
1186
|
+
this.scheduleSensorService.setCharacteristic(Characteristic.ConfiguredName, serviceNameSchedule);
|
|
1187
|
+
this.scheduleSensorService.getCharacteristic(Characteristic.ContactSensorState)
|
|
1188
|
+
.onGet(async () => {
|
|
1189
|
+
const state = this.accessory.scheduleEnabled;
|
|
1190
|
+
return state;
|
|
1191
|
+
})
|
|
1192
|
+
accessory.addService(this.scheduleSensorService);
|
|
1193
|
+
}
|
|
1194
|
+
|
|
1195
|
+
//sensors
|
|
1175
1196
|
const serviceName = namePrefix ? `${accessoryName} ${name}` : name;
|
|
1176
1197
|
const serviceType = schedule.serviceType;
|
|
1177
1198
|
const characteristicType = schedule.characteristicType;
|
|
1178
|
-
const scheduleService = new serviceType(serviceName, `Schedule ${deviceId} ${i}`);
|
|
1199
|
+
const scheduleService = new serviceType(serviceName, `Schedule Sensor ${deviceId} ${i}`);
|
|
1179
1200
|
scheduleService.addOptionalCharacteristic(Characteristic.ConfiguredName);
|
|
1180
1201
|
scheduleService.setCharacteristic(Characteristic.ConfiguredName, serviceName);
|
|
1181
1202
|
scheduleService.getCharacteristic(characteristicType)
|
|
1182
1203
|
.onGet(async () => {
|
|
1183
1204
|
const state = schedule.state;
|
|
1184
1205
|
return state;
|
|
1185
|
-
})
|
|
1186
|
-
.onSet(async (state) => {
|
|
1187
|
-
try {
|
|
1188
|
-
deviceData.ScheduleEnabled = state;
|
|
1189
|
-
await this.melCloudAta.send(this.accountType, this.displayType, deviceData, 'scheduleenabled');
|
|
1190
|
-
if (this.logInfo) this.emit('info', `${state ? 'Set:' : 'Unset:'} ${name}`);
|
|
1191
|
-
} catch (error) {
|
|
1192
|
-
if (this.logWarn) this.emit('warn', `Set schedule error: ${error}`);
|
|
1193
|
-
};
|
|
1194
1206
|
});
|
|
1195
1207
|
this.schedulesServices.push(scheduleService);
|
|
1196
1208
|
accessory.addService(scheduleService);
|
|
@@ -1901,7 +1913,6 @@ class DeviceAtw extends EventEmitter {
|
|
|
1901
1913
|
|
|
1902
1914
|
//update sensors state
|
|
1903
1915
|
this.holidayModeSensorService?.updateCharacteristic(Characteristic.ContactSensorState, holidayModeActive);
|
|
1904
|
-
this.scheduleSensorService?.updateCharacteristic(Characteristic.ContactSensorState, scheduleEnabled);
|
|
1905
1916
|
this.errorService?.updateCharacteristic(Characteristic.ContactSensorState, isInError);
|
|
1906
1917
|
|
|
1907
1918
|
//update presets state
|
|
@@ -1928,10 +1939,14 @@ class DeviceAtw extends EventEmitter {
|
|
|
1928
1939
|
};
|
|
1929
1940
|
|
|
1930
1941
|
//update schedules state
|
|
1931
|
-
if (this.schedules.length > 0) {
|
|
1942
|
+
if (this.schedules.length > 0 && scheduleEnabled !== null) {
|
|
1932
1943
|
this.schedules.forEach((schedule, i) => {
|
|
1944
|
+
//control
|
|
1945
|
+
if (i === 0) this.schedulesControlService?.updateCharacteristic(characteristicType, scheduleEnabled);
|
|
1946
|
+
|
|
1947
|
+
//sensors
|
|
1933
1948
|
const scheduleData = schedulesOnServer.find(s => s[presetsIdKey] === schedule.id);
|
|
1934
|
-
schedule.state = scheduleEnabled
|
|
1949
|
+
schedule.state = scheduleEnabled ? scheduleData.Enabled ?? false : false;
|
|
1935
1950
|
|
|
1936
1951
|
const characteristicType = schedule.characteristicType;
|
|
1937
1952
|
this.schedulesServices?.[i]?.updateCharacteristic(characteristicType, schedule.state);
|
package/src/deviceerv.js
CHANGED
|
@@ -31,7 +31,6 @@ class DeviceErv extends EventEmitter {
|
|
|
31
31
|
this.temperatureOutdoorSensor = device.temperatureOutdoorSensor || false;
|
|
32
32
|
this.temperatureSupplySensor = device.temperatureSupplySensor || false;
|
|
33
33
|
this.holidayModeSensor = device.holidayModeSensor || false;
|
|
34
|
-
this.scheduleSensor = device.scheduleSensor || false;
|
|
35
34
|
this.errorSensor = device.errorSensor || false;
|
|
36
35
|
this.presets = this.accountType === 'melcloud' ? (device.presets || []).filter(preset => (preset.displayType ?? 0) > 0 && preset.id !== '0') : [];
|
|
37
36
|
this.schedules = this.accountType === 'melcloudhome' ? (device.schedules || []).filter(schedule => (schedule.displayType ?? 0) > 0 && schedule.id !== '0') : [];
|
|
@@ -682,20 +681,6 @@ class DeviceErv extends EventEmitter {
|
|
|
682
681
|
accessory.addService(this.holidayModeSensorService);
|
|
683
682
|
}
|
|
684
683
|
|
|
685
|
-
//schedule sensor
|
|
686
|
-
if (this.scheduleSensor && this.accessory.scheduleEnabled !== null) {
|
|
687
|
-
if (this.logDebug) this.emit('debug', `Prepare schedule service`);
|
|
688
|
-
this.scheduleSensorService = new Service.ContactSensor(`${serviceName} Schedule`, `Schedule Sensor ${deviceId}`);
|
|
689
|
-
this.scheduleSensorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
|
|
690
|
-
this.scheduleSensorService.setCharacteristic(Characteristic.ConfiguredName, `${accessoryName} Schedule`);
|
|
691
|
-
this.scheduleSensorService.getCharacteristic(Characteristic.ContactSensorState)
|
|
692
|
-
.onGet(async () => {
|
|
693
|
-
const state = this.accessory.scheduleEnabled;
|
|
694
|
-
return state;
|
|
695
|
-
})
|
|
696
|
-
accessory.addService(this.scheduleSensorService);
|
|
697
|
-
}
|
|
698
|
-
|
|
699
684
|
//error sensor
|
|
700
685
|
if (this.errorSensor && this.accessory.isInError !== null) {
|
|
701
686
|
if (this.logDebug) this.emit('debug', `Prepare error service`);
|
|
@@ -766,7 +751,7 @@ class DeviceErv extends EventEmitter {
|
|
|
766
751
|
};
|
|
767
752
|
|
|
768
753
|
//schedules services
|
|
769
|
-
if (this.schedules.length > 0) {
|
|
754
|
+
if (this.schedules.length > 0 && this.accessory.scheduleEnabled !== null) {
|
|
770
755
|
if (this.logDebug) this.emit('debug', `Prepare schedules services`);
|
|
771
756
|
this.schedulesServices = [];
|
|
772
757
|
this.schedules.forEach((schedule, i) => {
|
|
@@ -776,25 +761,52 @@ class DeviceErv extends EventEmitter {
|
|
|
776
761
|
//get preset name prefix
|
|
777
762
|
const namePrefix = schedule.namePrefix;
|
|
778
763
|
|
|
764
|
+
//control
|
|
765
|
+
if (i === 0) {
|
|
766
|
+
if (this.logDebug) this.emit('debug', `Prepare schedule control service`);
|
|
767
|
+
const serviceNameSchedule = namePrefix ? `${accessoryName} Schedule Control` : `Schedule Control`;
|
|
768
|
+
this.schedulesControlService = new Service.Switch(serviceNameSchedule, `Schedule Control ${deviceId} ${i}`);
|
|
769
|
+
this.schedulesControlService.addOptionalCharacteristic(Characteristic.ConfiguredName);
|
|
770
|
+
this.schedulesControlService.setCharacteristic(Characteristic.ConfiguredName, serviceNameSchedule);
|
|
771
|
+
this.schedulesControlService.getCharacteristic(Characteristic.On)
|
|
772
|
+
.onGet(async () => {
|
|
773
|
+
const state = this.accessory.scheduleEnabled;
|
|
774
|
+
return state;
|
|
775
|
+
})
|
|
776
|
+
.onSet(async (state) => {
|
|
777
|
+
try {
|
|
778
|
+
deviceData.ScheduleEnabled = state;
|
|
779
|
+
await this.melCloudAta.send(this.accountType, this.displayType, deviceData, 'scheduleenabled');
|
|
780
|
+
if (this.logInfo) this.emit('info', `Schedule: ${state ? 'Enabled' : 'Disabled'}`);
|
|
781
|
+
} catch (error) {
|
|
782
|
+
if (this.logWarn) this.emit('warn', `Set schedule error: ${error}`);
|
|
783
|
+
};
|
|
784
|
+
});
|
|
785
|
+
accessory.addService(this.schedulesControlService);
|
|
786
|
+
|
|
787
|
+
if (this.logDebug) this.emit('debug', `Prepare schedule control sensor service`);
|
|
788
|
+
this.scheduleSensorService = new Service.ContactSensor(serviceNameSchedule, `Schedule Control Sensor ${deviceId}`);
|
|
789
|
+
this.scheduleSensorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
|
|
790
|
+
this.scheduleSensorService.setCharacteristic(Characteristic.ConfiguredName, serviceNameSchedule);
|
|
791
|
+
this.scheduleSensorService.getCharacteristic(Characteristic.ContactSensorState)
|
|
792
|
+
.onGet(async () => {
|
|
793
|
+
const state = this.accessory.scheduleEnabled;
|
|
794
|
+
return state;
|
|
795
|
+
})
|
|
796
|
+
accessory.addService(this.scheduleSensorService);
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
//sensors
|
|
779
800
|
const serviceName = namePrefix ? `${accessoryName} ${name}` : name;
|
|
780
801
|
const serviceType = schedule.serviceType;
|
|
781
802
|
const characteristicType = schedule.characteristicType;
|
|
782
|
-
const scheduleService = new serviceType(serviceName, `Schedule ${deviceId} ${i}`);
|
|
803
|
+
const scheduleService = new serviceType(serviceName, `Schedule Sensor ${deviceId} ${i}`);
|
|
783
804
|
scheduleService.addOptionalCharacteristic(Characteristic.ConfiguredName);
|
|
784
805
|
scheduleService.setCharacteristic(Characteristic.ConfiguredName, serviceName);
|
|
785
806
|
scheduleService.getCharacteristic(characteristicType)
|
|
786
807
|
.onGet(async () => {
|
|
787
808
|
const state = schedule.state;
|
|
788
809
|
return state;
|
|
789
|
-
})
|
|
790
|
-
.onSet(async (state) => {
|
|
791
|
-
try {
|
|
792
|
-
deviceData.ScheduleEnabled = state;
|
|
793
|
-
await this.melCloudAta.send(this.accountType, this.displayType, deviceData, 'scheduleenabled');
|
|
794
|
-
if (this.logInfo) this.emit('info', `${state ? 'Set:' : 'Unset:'} ${name}`);
|
|
795
|
-
} catch (error) {
|
|
796
|
-
if (this.logWarn) this.emit('warn', `Set schedule error: ${error}`);
|
|
797
|
-
};
|
|
798
810
|
});
|
|
799
811
|
this.schedulesServices.push(scheduleService);
|
|
800
812
|
accessory.addService(scheduleService);
|
|
@@ -1195,7 +1207,6 @@ class DeviceErv extends EventEmitter {
|
|
|
1195
1207
|
|
|
1196
1208
|
//error sensor
|
|
1197
1209
|
this.holidayModeSensorService?.updateCharacteristic(Characteristic.ContactSensorState, holidayModeActive);
|
|
1198
|
-
this.scheduleSensorService?.updateCharacteristic(Characteristic.ContactSensorState, scheduleEnabled);
|
|
1199
1210
|
this.errorService?.updateCharacteristic(Characteristic.ContactSensorState, isInError);
|
|
1200
1211
|
|
|
1201
1212
|
//update presets state
|
|
@@ -1215,10 +1226,14 @@ class DeviceErv extends EventEmitter {
|
|
|
1215
1226
|
};
|
|
1216
1227
|
|
|
1217
1228
|
//update schedules state
|
|
1218
|
-
if (this.schedules.length > 0) {
|
|
1229
|
+
if (this.schedules.length > 0 && scheduleEnabled !== null) {
|
|
1219
1230
|
this.schedules.forEach((schedule, i) => {
|
|
1231
|
+
//control
|
|
1232
|
+
if (i === 0) this.schedulesControlService?.updateCharacteristic(characteristicType, scheduleEnabled);
|
|
1233
|
+
|
|
1234
|
+
//sensors
|
|
1220
1235
|
const scheduleData = schedulesOnServer.find(s => s[presetsIdKey] === schedule.id);
|
|
1221
|
-
schedule.state = scheduleEnabled
|
|
1236
|
+
schedule.state = scheduleEnabled ? scheduleData.Enabled ?? false : false;
|
|
1222
1237
|
|
|
1223
1238
|
const characteristicType = schedule.characteristicType;
|
|
1224
1239
|
this.schedulesServices?.[i]?.updateCharacteristic(characteristicType, schedule.state);
|