homebridge-melcloud-control 4.1.3-beta.3 → 4.1.3-beta.5

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 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
- * Schedules `ON/OFF`.
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
@@ -261,6 +268,7 @@ Homebridge plugin for Air Conditioner, Heat Pump and Energy Recovery Ventilation
261
268
  | `atwDevices[].temperatureReturnWaterTankSensor` | This enable extra `Return Water Tank` temperature sensor to use with automations in HomeKit app. |
262
269
  | `atwDevices[].temperatureFlowZone2Sensor` | This enable extra `Flow Zone 2` temperature sensor to use with automations in HomeKit app. |
263
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. |
264
272
  | `atwDevices[].errorSensor` | This enable `Error` sensors to use with automations in HomeKit app. |
265
273
  | `atwDevices[].refreshInterval` | Here set the background devices state refresh time in (sec), default `5s`. |
266
274
  | `atwDevices[].presets[]` | Array of ATW device `Presets` created automatically after login to MELCloud from plugin config UI. |
@@ -285,6 +293,7 @@ Homebridge plugin for Air Conditioner, Heat Pump and Energy Recovery Ventilation
285
293
  | `ervDevices[].temperatureSensor` | This enable extra `Room` temperature sensor to use with automations in HomeKit app. |
286
294
  | `ervDevices[].temperatureOutdoorSensor` | This enable extra `Outdoor` temperature sensor to use with automations in HomeKit app. |
287
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. |
288
297
  | `ervDevices[].errorSensor` | This enable `Error` sensors to use with automations in HomeKit app. |
289
298
  | `ervDevices[].refreshInterval` | Here set the background devices state refresh time in (sec), default `5s`. |
290
299
  | `ervDevices[].presets[]` | Array of ERV device `Presets` created automatically after login to MELCloud from plugin config UI. |
@@ -1116,15 +1116,6 @@
1116
1116
  "functionBody": "return model.accounts[arrayIndices[0]].type === 'melcloudhome';"
1117
1117
  }
1118
1118
  },
1119
- "scheduleSensor": {
1120
- "title": "Schedule Enabled",
1121
- "type": "boolean",
1122
- "default": false,
1123
- "description": "This enable extra schedule sensor to use with automations in HomeKit app.",
1124
- "condition": {
1125
- "functionBody": "return model.accounts[arrayIndices[0]].type === 'melcloudhome';"
1126
- }
1127
- },
1128
1119
  "errorSensor": {
1129
1120
  "title": "Error",
1130
1121
  "type": "boolean",
@@ -1609,15 +1600,6 @@
1609
1600
  "functionBody": "return model.accounts[arrayIndices[0]].type === 'melcloudhome';"
1610
1601
  }
1611
1602
  },
1612
- "scheduleSensor": {
1613
- "title": "Schedule Enabled",
1614
- "type": "boolean",
1615
- "default": false,
1616
- "description": "This enable extra schedule sensor to use with automations in HomeKit app.",
1617
- "condition": {
1618
- "functionBody": "return model.accounts[arrayIndices[0]].type === 'melcloudhome';"
1619
- }
1620
- },
1621
1603
  "errorSensor": {
1622
1604
  "title": "Error",
1623
1605
  "type": "boolean",
@@ -2411,7 +2393,6 @@
2411
2393
  "title": "System",
2412
2394
  "items": [
2413
2395
  "accounts[].atwDevices[].holidayModeSensor",
2414
- "accounts[].atwDevices[].scheduleSensor",
2415
2396
  "accounts[].atwDevices[].errorSensor"
2416
2397
  ]
2417
2398
  },
@@ -2556,7 +2537,6 @@
2556
2537
  "title": "System",
2557
2538
  "items": [
2558
2539
  "accounts[].ervDevices[].holidayModeSensor",
2559
- "accounts[].ervDevices[].scheduleSensor",
2560
2540
  "accounts[].ervDevices[].errorSensor"
2561
2541
  ]
2562
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.3",
4
+ "version": "4.1.3-beta.5",
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/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; //scheduleData.Enabled : false;
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; //scheduleData.Enabled : false;
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);
@@ -237,11 +237,7 @@ class MelCloudAta extends EventEmitter {
237
237
  return;
238
238
  }
239
239
  } catch (error) {
240
- // Return 500 for schedule hovewer working correct
241
- if (error?.response?.status === 500) {
242
- return true;
243
- }
244
-
240
+ if (error.response?.status === 500) return true; // Return 500 for schedule hovewer working correct
245
241
  throw new Error(`Send data error: ${error.message}`);
246
242
  }
247
243
  }
@@ -236,11 +236,7 @@ class MelCloudAtw extends EventEmitter {
236
236
  return;
237
237
  }
238
238
  } catch (error) {
239
- // Return 500 for schedule hovewer working correct
240
- if (error?.response?.status === 500) {
241
- return true;
242
- }
243
-
239
+ if (error.response?.status === 500) return true; // Return 500 for schedule hovewer working correct
244
240
  throw new Error(`Send data error: ${error.message}`);
245
241
  }
246
242
  }
@@ -244,11 +244,7 @@ class MelCloudErv extends EventEmitter {
244
244
  return;
245
245
  }
246
246
  } catch (error) {
247
- // Return 500 for schedule hovewer working correct
248
- if (error?.response?.status === 500) {
249
- return true;
250
- }
251
-
247
+ if (error.response?.status === 500) return true; // Return 500 for schedule hovewer working correct
252
248
  throw new Error(`Send data error: ${error.message}`);
253
249
  }
254
250
  }