homebridge-melcloud-control 2.3.0-beta.3 → 2.3.0-beta.31

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 CHANGED
@@ -26,7 +26,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
26
26
  ## Changes
27
27
 
28
28
  - removed from config.json `ataDisableAutoMode`, `ataDisableHeatMode`, `ataAutoHeatMode`
29
- - added to config.json `ataHeatDryFanMode`, `ataDisableAutoMode`
29
+ - added to config.json `ataHeatDryFanMode`, `ataCoolDryFanMode`, `ataAutoDryFanMode`
30
30
  - added [#132](https://github.com/grzegorz914/homebridge-melcloud-control/issues/132)
31
31
  - cleanup
32
32
  - config schema updated
package/README.md CHANGED
@@ -48,7 +48,7 @@ Homebridge plugin for Air Conditioner, Heat Pump and Energy Recovery Ventilation
48
48
  * Swing mode `AUTO/SWING`.
49
49
  * Physical lock controls `LOCK/UNLOCK`.
50
50
  * Temperature display unit `°F/°C`.
51
- * Assign operating mode for `HEAT/AUTO`.
51
+ * Assign operation mode for `HEAT/COOL/AUTO`.
52
52
  * Thermostat:
53
53
  * Power `ON/OFF`.
54
54
  * Operating mode `POWER OFF/HEAT/COOL/AUTO`.
@@ -176,11 +176,12 @@ Homebridge plugin for Air Conditioner, Heat Pump and Energy Recovery Ventilation
176
176
  | `user` | Here set the MELCloud username. |
177
177
  | `passwd` | Here set the MELCloud password. |
178
178
  | `language` | Here select the MELCloud language. |
179
- | `ataDisplayMode` | Here select main control mode `Heater/Cooler`, `Thermostat`. |
179
+ | `ataDisplayMode` | Here select device control mode `Heater/Cooler`, `Thermostat`. |
180
+ | `ataHeatDryFanMode` | Here select the operatiing mode for `Heat`, if this mode is not supported, it will be disabled. |
181
+ | `ataCoolDryFanMode` | Here select the operatiing mode for `Cool`, if this mode is not supported, it will be disabled. |
182
+ | `ataAutoDryFanMode` | Here select the operatiing mode for `Auto`, if this mode is not supported, it will be disabled.. |
180
183
  | `ataTemperatureSensor` | This enable extra `Room` temperature sensors to use with automations in HomeKit app. |
181
184
  | `ataTemperatureSensorOutdoor` | This enable extra `Outdoor` temperature sensors to use with automations in HomeKit app. |
182
- | `ataHeatDryFanMode` | Here select operation mode for `Heat`, if selected `Heat` and the mode is not supported by device then will be disabled, in other cases will use selected mode. |
183
- | `ataAutoDryFanMode` | Here select operation mode for `Auto`, if selected `Auto` and the mode is not supported by device then will be disabled, in other cases will use selected mode. |
184
185
  | `ataPresets` | This enable extra buttons for configured presets and display it in HomeKit app. |
185
186
  | `ataButtons.name` | Here set `Button Name` which You want expose to the `Homebridge/HomeKit`. |
186
187
  | `ataButtons.mode` | Here select button mode, VH - Vane Horizontal, VV - Vane Horizontal. |
@@ -205,7 +205,7 @@
205
205
  "required": true
206
206
  },
207
207
  "ataDisplayMode": {
208
- "title": "Control Mode",
208
+ "title": "Control",
209
209
  "type": "integer",
210
210
  "minimum": 0,
211
211
  "maximum": 1,
@@ -224,32 +224,11 @@
224
224
  ]
225
225
  }
226
226
  ],
227
- "description": "Select main control mode.",
227
+ "description": "Select device control mode displayed in HomeKit app.",
228
228
  "required": true
229
229
  },
230
- "ataTemperatureSensor": {
231
- "title": "Temperature Sensor Room",
232
- "type": "boolean",
233
- "default": false,
234
- "description": "This enable extra room temperature sensor to use with automations in HomeKit app.",
235
- "required": false
236
- },
237
- "ataTemperatureSensorOutdoor": {
238
- "title": "Temperature Sensor Outdoor",
239
- "type": "boolean",
240
- "default": false,
241
- "description": "This enable extra outdoor temperature sensor to use with automations in HomeKit app.",
242
- "required": false
243
- },
244
- "ataPresets": {
245
- "title": "Presets",
246
- "type": "boolean",
247
- "default": false,
248
- "description": "This enable extra buttons for configured presets and display it in HomeKit app.",
249
- "required": false
250
- },
251
230
  "ataHeatDryFanMode": {
252
- "title": "Heat Mode",
231
+ "title": "Heat",
253
232
  "type": "integer",
254
233
  "minimum": 0,
255
234
  "maximum": 3,
@@ -280,11 +259,46 @@
280
259
  ]
281
260
  }
282
261
  ],
283
- "description": "Operation mode for Heat, if selected Heat and the mode is not supported by device then will be disabled, in other cases will use selected mode.",
262
+ "description": "Select the operatiing mode for Heat, if this mode is not supported, it will be disabled.",
263
+ "required": true
264
+ },
265
+ "ataCoolDryFanMode": {
266
+ "title": "Cool",
267
+ "type": "integer",
268
+ "minimum": 0,
269
+ "maximum": 3,
270
+ "default": 1,
271
+ "oneOf": [
272
+ {
273
+ "title": "None/Disabled",
274
+ "enum": [
275
+ 0
276
+ ]
277
+ },
278
+ {
279
+ "title": "Cool",
280
+ "enum": [
281
+ 1
282
+ ]
283
+ },
284
+ {
285
+ "title": "Dry",
286
+ "enum": [
287
+ 2
288
+ ]
289
+ },
290
+ {
291
+ "title": "Fan",
292
+ "enum": [
293
+ 3
294
+ ]
295
+ }
296
+ ],
297
+ "description": "Select the operatiing mode for Cool, if this mode is not supported, it will be disabled.",
284
298
  "required": true
285
299
  },
286
300
  "ataAutoDryFanMode": {
287
- "title": "Auto Mode",
301
+ "title": "Auto",
288
302
  "type": "integer",
289
303
  "minimum": 0,
290
304
  "maximum": 3,
@@ -315,9 +329,30 @@
315
329
  ]
316
330
  }
317
331
  ],
318
- "description": "Operation mode for Auto, if selected Auto and the mode is not supported by device then will be disabled, in other cases will use selected mode.",
332
+ "description": "Select the operatiing mode for Auto, if this mode is not supported, it will be disabled.",
319
333
  "required": true
320
334
  },
335
+ "ataPresets": {
336
+ "title": "Presets",
337
+ "type": "boolean",
338
+ "default": false,
339
+ "description": "This enable extra buttons for configured presets and display it in HomeKit app.",
340
+ "required": false
341
+ },
342
+ "ataTemperatureSensor": {
343
+ "title": "Room",
344
+ "type": "boolean",
345
+ "default": false,
346
+ "description": "This enable extra room temperature sensor to use with automations in HomeKit app.",
347
+ "required": false
348
+ },
349
+ "ataTemperatureSensorOutdoor": {
350
+ "title": "Outdoor",
351
+ "type": "boolean",
352
+ "default": false,
353
+ "description": "This enable extra outdoor temperature sensor to use with automations in HomeKit app.",
354
+ "required": false
355
+ },
321
356
  "ataButtons": {
322
357
  "title": "Button / Sensor",
323
358
  "type": "array",
@@ -1395,8 +1430,18 @@
1395
1430
  "items": [
1396
1431
  "accounts[].ataDisplayMode",
1397
1432
  "accounts[].ataPresets",
1398
- "accounts[].ataHeatDryFanMode",
1399
- "accounts[].ataAutoDryFanMode",
1433
+ {
1434
+ "key": "accounts[]",
1435
+ "type": "section",
1436
+ "title": "Operation Modes",
1437
+ "expandable": true,
1438
+ "expanded": false,
1439
+ "items": [
1440
+ "accounts[].ataHeatDryFanMode",
1441
+ "accounts[].ataCoolDryFanMode",
1442
+ "accounts[].ataAutoDryFanMode"
1443
+ ]
1444
+ },
1400
1445
  {
1401
1446
  "key": "accounts[]",
1402
1447
  "type": "section",
package/index.js CHANGED
@@ -210,5 +210,23 @@ class MelCloudPlatform {
210
210
  };
211
211
 
212
212
  module.exports = (api) => {
213
+ const { Service, Characteristic, Units, Formats, Perms } = api.hap;
214
+ //custom characteristics
215
+ class CustomTargetHeaterCoolerState extends Characteristic {
216
+ constructor() {
217
+ super('Target Mode', '000000B2-0000-1000-8000-0026BB765291');
218
+ this.setProps({
219
+ format: Formats.UINT8,
220
+ minValue: 1,
221
+ maxValue: 2,
222
+ minStep: 1,
223
+ validValues: [1, 2],
224
+ perms: [Perms.NOTIFY, Perms.PAIRED_READ, Perms.PAIRED_WRITE]
225
+ });
226
+ this.value = this.getDefaultValue();
227
+ }
228
+ }
229
+ Characteristic.CustomTargetHeaterCoolerState = CustomTargetHeaterCoolerState;
230
+
213
231
  api.registerPlatform(CONSTANTS.PluginName, CONSTANTS.PlatformName, MelCloudPlatform, true);
214
232
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "displayName": "MELCloud Control",
3
3
  "name": "homebridge-melcloud-control",
4
- "version": "2.3.0-beta.3",
4
+ "version": "2.3.0-beta.31",
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
@@ -22,6 +22,7 @@ class DeviceAta extends EventEmitter {
22
22
  this.temperatureSensorOutdoor = account.ataTemperatureSensorOutdoor || false;
23
23
  this.presetsEnabled = account.ataPresets || false;
24
24
  this.heatDryFanMode = account.ataHeatDryFanMode || 1; //NONE, HEAT, DRY, FAN
25
+ this.coolDryFanMode = account.ataCoolDryFanMode || 1; //NONE, COOL, DRY, FAN
25
26
  this.autoDryFanMode = account.ataAutoDryFanMode || 1; //NONE, AUTO, DRY, FAN
26
27
  this.buttons = account.ataButtons || [];
27
28
  this.disableLogInfo = account.disableLogInfo || false;
@@ -38,9 +39,8 @@ class DeviceAta extends EventEmitter {
38
39
  const mqttEnabled = mqtt.enable || false;
39
40
  this.mqttConnected = false;
40
41
 
41
- //variables
42
+ //function
42
43
  this.melCloud = melCloud; //function
43
- this.startPrepareAccessory = true;
44
44
 
45
45
  //buttons configured
46
46
  this.buttonsConfigured = [];
@@ -63,6 +63,22 @@ class DeviceAta extends EventEmitter {
63
63
  }
64
64
  this.buttonsConfiguredCount = this.buttonsConfigured.length || 0;
65
65
 
66
+ //variables
67
+ this.startPrepareAccessory = true;
68
+ this.power = false;
69
+ this.offline = false;
70
+ this.currentOperationMode = 0;
71
+ this.targetOperationMode = 0;
72
+ this.fanSpeed = 0;
73
+ this.swingMode = 0;
74
+ this.lockPhysicalControls = 0;
75
+ this.useFahrenheit = 0;
76
+
77
+ this.operationModeSetPropsMinValue = 0;
78
+ this.operationModeSetPropsMaxValue = 3;
79
+ this.operationModeSetPropsValidValues = [0];
80
+ this.fanSpeedSetPropsMaxValue = 2;
81
+
66
82
  //melcloud device
67
83
  this.melCloudAta = new MelCloudAta({
68
84
  contextKey: contextKey,
@@ -170,6 +186,7 @@ class DeviceAta extends EventEmitter {
170
186
  const modelSupportsFanSpeed = deviceData.Device.ModelSupportsFanSpeed ?? false;
171
187
  const modelSupportsHeat1 = deviceData.Device.ModelSupportsHeat ?? false;
172
188
  const modelSupportsHeat = this.heatDryFanMode >= 1 && modelSupportsHeat1;
189
+ const modelSupportsCool = this.coolDryFanMode >= 1;
173
190
  const modelSupportsAuto1 = deviceData.Device.ModelSupportsAuto ?? false;
174
191
  const modelSupportsAuto = this.autoDryFanMode >= 1 && modelSupportsAuto1;
175
192
  const modelSupportsDry = deviceData.Device.ModelSupportsDry ?? false;
@@ -209,106 +226,188 @@ class DeviceAta extends EventEmitter {
209
226
  this.presetsCount = this.presetsEnabled ? presets.length : 0;
210
227
 
211
228
  //operating mode
212
- let currentOperationMode = 0;
213
- let targetOperationMode = 0;
214
- let fanSpeed = 0;
215
- let swingMode = 0;
216
- let lockPhysicalControls = 0;
217
-
218
- let operationModeSetPropsMinValue = 0;
219
- let operationModeSetPropsMaxValue = 3;
220
- let operationModeSetPropsValidValues = [0];
221
- let fanSpeedSetPropsMaxValue = 2;
222
-
223
229
  switch (displayMode) {
224
230
  case 0: //Heater Cooler
225
231
  //operating mode 0, HEAT, DRY, COOL, 4, 5, 6, FAN, AUTO, ISEE HEAT, ISEE DRY, ISEE COOL
226
- currentOperationMode = !power ? 0 : inStandbyMode ? 1 : [0, 2, 3, 3, 1, 1, 1, 1, (setTemperature < roomTemperature) ? 3 : 2, 2, 1, 3][operationMode]; //INACTIVE, IDLE, HEATING, COOLING
227
- targetOperationMode = [operationMode, 1, [1, 1, 1, 1][this.heatDryFanMode], 2, 2, 2, 2, [0, 0, 0, 0][this.autoDryFanMode], 0, 1, 1, 2][operationMode]; //AUTO, HEAT, COOL
228
- operationModeSetPropsMinValue = modelSupportsAuto && modelSupportsHeat ? 0 : !modelSupportsAuto && modelSupportsHeat ? 1 : modelSupportsAuto && !modelSupportsHeat ? 0 : 2;
229
- operationModeSetPropsMaxValue = 2
230
- operationModeSetPropsValidValues = modelSupportsAuto && modelSupportsHeat ? [0, 1, 2] : !modelSupportsAuto && modelSupportsHeat ? [1, 2] : modelSupportsAuto && !modelSupportsHeat ? [0, 2] : [2];
232
+ switch (power) {
233
+ case true:
234
+ switch (!inStandbyMode) {
235
+ case true:
236
+ switch (operationMode) {
237
+ case 1: //HEAT
238
+ this.currentOperationMode = 2; //INACTIVE, IDLE, HEATING, COOLING
239
+ this.targetOperationMode = 1; //AUTO, HEAT, COOL
240
+ break;
241
+ case 2: //DRY
242
+ this.currentOperationMode = 3;
243
+ this.targetOperationMode = 2;
244
+ break;
245
+ case 3: //COOL
246
+ this.currentOperationMode = 3;
247
+ this.targetOperationMode = 2;
248
+ break;
249
+ case 7: //FAN
250
+ this.currentOperationMode = 3;
251
+ this.targetOperationMode = 2;
252
+ break;
253
+ case 8: //AUTO
254
+ this.currentOperationMode = setTemperature < roomTemperature ? 3 : 2;
255
+ this.targetOperationMode = 0;
256
+ break;
257
+ case 9: //ISEE HEAT
258
+ this.currentOperationMode = 2
259
+ this.targetOperationMode = 1;
260
+ break;
261
+ case 10: //ISEE DRY
262
+ this.currentOperationMode = 3;
263
+ this.targetOperationMode = 2;
264
+ break;
265
+ case 11: //ISEE COOL;
266
+ this.currentOperationMode = 3;
267
+ this.targetOperationMode = 2;
268
+ break;
269
+ default:
270
+ this.emit('warn', `Unknown operating mode: ${operationMode}`);
271
+ break;
272
+ };
273
+ break;
274
+ case false:
275
+ this.currentOperationMode = 1;
276
+ break;
277
+ };
278
+ break;
279
+ case false:
280
+ this.currentOperationMode = 0;
281
+ break;
282
+ };
283
+ this.operationModeSetPropsMinValue = modelSupportsAuto && modelSupportsHeat ? 0 : !modelSupportsAuto && modelSupportsHeat ? 1 : modelSupportsAuto && !modelSupportsHeat ? 0 : 2;
284
+ this.operationModeSetPropsMaxValue = 2
285
+ this.operationModeSetPropsValidValues = modelSupportsAuto && modelSupportsHeat ? [0, 1, 2] : !modelSupportsAuto && modelSupportsHeat ? [1, 2] : modelSupportsAuto && !modelSupportsHeat ? [0, 2] : [2];
231
286
 
232
287
  //fan speed mode
233
288
  if (modelSupportsFanSpeed) {
234
289
  switch (numberOfFanSpeeds) {
235
290
  case 2: //Fan speed mode 2
236
- fanSpeed = hasAutomaticFanSpeed ? [3, 1, 2][setFanSpeed] : [0, 1, 2][setFanSpeed];
237
- fanSpeedSetPropsMaxValue = hasAutomaticFanSpeed ? 3 : 2;
291
+ this.fanSpeed = hasAutomaticFanSpeed ? [3, 1, 2][setFanSpeed] : [0, 1, 2][setFanSpeed];
292
+ this.fanSpeedSetPropsMaxValue = hasAutomaticFanSpeed ? 3 : 2;
238
293
  break;
239
294
  case 3: //Fan speed mode 3
240
- fanSpeed = hasAutomaticFanSpeed ? [4, 1, 2, 3][setFanSpeed] : [0, 1, 2, 3][setFanSpeed];
241
- fanSpeedSetPropsMaxValue = hasAutomaticFanSpeed ? 4 : 3;
295
+ this.fanSpeed = hasAutomaticFanSpeed ? [4, 1, 2, 3][setFanSpeed] : [0, 1, 2, 3][setFanSpeed];
296
+ this.fanSpeedSetPropsMaxValue = hasAutomaticFanSpeed ? 4 : 3;
242
297
  break;
243
298
  case 4: //Fan speed mode 4
244
- fanSpeed = hasAutomaticFanSpeed ? [5, 1, 2, 3, 4][setFanSpeed] : [0, 1, 2, 3, 4][setFanSpeed];
245
- fanSpeedSetPropsMaxValue = hasAutomaticFanSpeed ? 5 : 4;
299
+ this.fanSpeed = hasAutomaticFanSpeed ? [5, 1, 2, 3, 4][setFanSpeed] : [0, 1, 2, 3, 4][setFanSpeed];
300
+ this.fanSpeedSetPropsMaxValue = hasAutomaticFanSpeed ? 5 : 4;
246
301
  break;
247
302
  case 5: //Fan speed mode 5
248
- fanSpeed = hasAutomaticFanSpeed ? [6, 1, 2, 3, 4, 5][setFanSpeed] : [0, 1, 2, 3, 4, 5][setFanSpeed];
249
- fanSpeedSetPropsMaxValue = hasAutomaticFanSpeed ? 6 : 5;
303
+ this.fanSpeed = hasAutomaticFanSpeed ? [6, 1, 2, 3, 4, 5][setFanSpeed] : [0, 1, 2, 3, 4, 5][setFanSpeed];
304
+ this.fanSpeedSetPropsMaxValue = hasAutomaticFanSpeed ? 6 : 5;
250
305
  break;
251
306
  case 6: //Fan speed mode 6
252
- fanSpeed = hasAutomaticFanSpeed ? [7, 1, 2, 3, 4, 5, 6][setFanSpeed] : [0, 1, 2, 3, 4, 5, 6][setFanSpeed];
253
- fanSpeedSetPropsMaxValue = hasAutomaticFanSpeed ? 7 : 6;
307
+ this.fanSpeed = hasAutomaticFanSpeed ? [7, 1, 2, 3, 4, 5, 6][setFanSpeed] : [0, 1, 2, 3, 4, 5, 6][setFanSpeed];
308
+ this.fanSpeedSetPropsMaxValue = hasAutomaticFanSpeed ? 7 : 6;
254
309
  break;
255
310
  };
256
311
  };
257
312
 
258
313
  //swing and vane mode
259
- swingMode = swingFunction && vaneHorizontal === 12 && vaneVertical === 7 ? 1 : 0;
314
+ this.swingMode = swingFunction && vaneHorizontal === 12 && vaneVertical === 7 ? 1 : 0;
260
315
 
261
316
  //lock physical controls
262
- lockPhysicalControls = prohibitSetTemperature && prohibitOperationMode && prohibitPower ? 1 : 0;
317
+ this.lockPhysicalControls = prohibitSetTemperature && prohibitOperationMode && prohibitPower ? 1 : 0;
263
318
 
264
319
  //update characteristics
265
320
  if (this.melCloudService) {
266
321
  this.melCloudService
267
322
  .updateCharacteristic(Characteristic.Active, power)
268
- .updateCharacteristic(Characteristic.CurrentHeaterCoolerState, currentOperationMode)
269
- .updateCharacteristic(Characteristic.TargetHeaterCoolerState, targetOperationMode)
323
+ .updateCharacteristic(Characteristic.CurrentHeaterCoolerState, this.currentOperationMode)
324
+ .updateCharacteristic(Characteristic.TargetHeaterCoolerState, this.targetOperationMode)
270
325
  .updateCharacteristic(Characteristic.CurrentTemperature, roomTemperature)
271
326
  .updateCharacteristic(Characteristic.HeatingThresholdTemperature, setTemperature)
272
327
  .updateCharacteristic(Characteristic.CoolingThresholdTemperature, setTemperature)
273
- .updateCharacteristic(Characteristic.LockPhysicalControls, lockPhysicalControls)
274
- .updateCharacteristic(Characteristic.TemperatureDisplayUnits, useFahrenheit);
275
- const updateRS = modelSupportsFanSpeed ? this.melCloudService.updateCharacteristic(Characteristic.RotationSpeed, fanSpeed) : false;
276
- const updateSM = swingFunction ? this.melCloudService.updateCharacteristic(Characteristic.SwingMode, swingMode) : false;
328
+ .updateCharacteristic(Characteristic.LockPhysicalControls, this.lockPhysicalControls)
329
+ .updateCharacteristic(Characteristic.TemperatureDisplayUnits, this.useFahrenheit);
330
+ const updateRS = modelSupportsFanSpeed ? this.melCloudService.updateCharacteristic(Characteristic.RotationSpeed, this.fanSpeed) : false;
331
+ const updateSM = swingFunction ? this.melCloudService.updateCharacteristic(Characteristic.SwingMode, this.swingMode) : false;
277
332
  };
278
333
  break;
279
334
  case 1: //Thermostat
280
- //operating mode 0, HEAT, DRY, COOL, 4, 5, 6, FAN, AUTO, ISEE HEAT, ISEE DRY, ISEE COOL
281
- currentOperationMode = !power || inStandbyMode ? 0 : [0, 1, 2, 2, 2, 2, 2, 2, (setTemperature < roomTemperature) ? 2 : 1, 1, 1, 2][operationMode]; //OFF, HEAT, COOL
282
- targetOperationMode = !power || inStandbyMode ? 0 : [0, 1, [1, 1, 1, 1][this.heatDryFanMode], 2, 2, 2, 2, [3, 3, 3, 3][this.autoDryFanMode], 3, 1, 1, 2][operationMode]; //OFF, HEAT, COOL, AUTO
283
- operationModeSetPropsMinValue = 0
284
- operationModeSetPropsMaxValue = modelSupportsAuto && modelSupportsHeat ? 3 : !modelSupportsAuto && modelSupportsHeat ? 2 : modelSupportsAuto && !modelSupportsHeat ? 3 : 2;
285
- operationModeSetPropsValidValues = modelSupportsAuto && modelSupportsHeat ? [0, 1, 2, 3] : !modelSupportsAuto && modelSupportsHeat ? [0, 1, 2] : modelSupportsAuto && !modelSupportsHeat ? [0, 2, 3] : [0, 2];
335
+ switch (power) {
336
+ case true:
337
+ switch (!inStandbyMode) {
338
+ case true:
339
+ switch (operationMode) {
340
+ case 1: //HEAT
341
+ this.currentOperationMode = 1; //OFF, HEAT, COOL
342
+ this.targetOperationMode = 1; //OFF, HEAT, COOL, AUTO
343
+ break;
344
+ case 2: //DRY
345
+ this.currentOperationMode = 2;
346
+ this.targetOperationMode = 2;
347
+ break;
348
+ case 3: //COOL
349
+ this.currentOperationMode = 2;
350
+ this.targetOperationMode = 2;
351
+ break;
352
+ case 7: //FAN
353
+ this.currentOperationMode = 2;
354
+ this.targetOperationMode = 2;
355
+ break;
356
+ case 8: //AUTO
357
+ this.currentOperationMode = setTemperature < roomTemperature ? 2 : 1;
358
+ this.targetOperationMode = 3;
359
+ break;
360
+ case 9: //ISEE HEAT
361
+ this.currentOperationMode = 1
362
+ this.targetOperationMode = 1;
363
+ break;
364
+ case 10: //ISEE DRY
365
+ this.currentOperationMode = 2;
366
+ this.targetOperationMode = 2;
367
+ break;
368
+ case 11: //ISEE COOL;
369
+ this.currentOperationMode = 2;
370
+ this.targetOperationMode = 2;
371
+ break;
372
+ default:
373
+ this.emit('warn', `Unknown operating mode: ${operationMode}`);
374
+ break;
375
+ };
376
+ break;
377
+ case false:
378
+ this.currentOperationMode = 0;
379
+ this.targetOperationMode = 0;
380
+ break;
381
+ };
382
+ case false:
383
+ this.currentOperationMode = 0;
384
+ this.targetOperationMode = 0;
385
+ break;
386
+ };
387
+ this.operationModeSetPropsMinValue = 0
388
+ this.operationModeSetPropsMaxValue = modelSupportsAuto && modelSupportsHeat ? 3 : !modelSupportsAuto && modelSupportsHeat ? 2 : modelSupportsAuto && !modelSupportsHeat ? 3 : 2;
389
+ this.operationModeSetPropsValidValues = modelSupportsAuto && modelSupportsHeat ? [0, 1, 2, 3] : !modelSupportsAuto && modelSupportsHeat ? [0, 1, 2] : modelSupportsAuto && !modelSupportsHeat ? [0, 2, 3] : [0, 2];
286
390
 
287
391
  //update characteristics
288
392
  if (this.melCloudService) {
289
393
  this.melCloudService
290
- .updateCharacteristic(Characteristic.CurrentHeatingCoolingState, currentOperationMode)
291
- .updateCharacteristic(Characteristic.TargetHeatingCoolingState, targetOperationMode)
394
+ .updateCharacteristic(Characteristic.CurrentHeatingCoolingState, this.currentOperationMode)
395
+ .updateCharacteristic(Characteristic.TargetHeatingCoolingState, this.targetOperationMode)
292
396
  .updateCharacteristic(Characteristic.CurrentTemperature, roomTemperature)
293
397
  .updateCharacteristic(Characteristic.TargetTemperature, setTemperature)
294
- .updateCharacteristic(Characteristic.TemperatureDisplayUnits, useFahrenheit);
398
+ .updateCharacteristic(Characteristic.TemperatureDisplayUnits, this.useFahrenheit);
295
399
  };
296
400
  break;
297
401
  };
298
402
 
299
403
  this.power = power;
300
404
  this.offline = offline;
301
- this.currentOperationMode = currentOperationMode;
302
- this.targetOperationMode = targetOperationMode;
303
405
  this.roomTemperature = roomTemperature;
304
406
  this.outdoorTemperature = outdoorTemperature;
305
407
  this.setTemperature = setTemperature;
306
- this.fanSpeed = fanSpeed;
307
408
  this.setFanSpeed = setFanSpeed;
308
- this.swingMode = swingMode;
309
409
  this.vaneHorizontal = vaneHorizontal;
310
410
  this.vaneVertical = vaneVertical;
311
- this.lockPhysicalControls = lockPhysicalControls;
312
411
 
313
412
  if (this.roomTemperatureSensorService) {
314
413
  this.roomTemperatureSensorService
@@ -420,7 +519,7 @@ class DeviceAta extends EventEmitter {
420
519
  button.state = power ? (setFanSpeed === 6) : false;
421
520
  break;
422
521
  case 37: //PHYSICAL LOCK CONTROLS ALL
423
- button.state = (lockPhysicalControls === 1);
522
+ button.state = (this.lockPhysicalControls === 1);
424
523
  break;
425
524
  case 38: //PHYSICAL LOCK CONTROLS POWER
426
525
  button.state = (prohibitPower === true);
@@ -477,20 +576,14 @@ class DeviceAta extends EventEmitter {
477
576
  const info1 = displayMode === 0 ? this.emit('message', `Heating threshold temperature: ${setTemperature}${this.temperatureUnit}`) : false;
478
577
  const info2 = displayMode === 0 ? this.emit('message', `Cooling threshold temperature: ${setTemperature}${this.temperatureUnit}`) : false;
479
578
  const info3 = modelSupportsFanSpeed ? this.emit('message', `Fan speed mode: ${CONSTANTS.AirConditioner.FanSpeed[setFanSpeed]}`) : false;
480
- const info4 = swingFunction ? this.emit('message', `Vane swing mode: ${CONSTANTS.AirConditioner.AirDirection[swingMode ? 6 : 0]}`) : false;
579
+ const info4 = swingFunction ? this.emit('message', `Vane swing mode: ${CONSTANTS.AirConditioner.AirDirection[this.swingMode ? 6 : 0]}`) : false;
481
580
  this.emit('message', `Temperature display unit: ${this.temperatureUnit}`);
482
- this.emit('message', `Lock physical controls: ${lockPhysicalControls ? 'LOCKED' : 'UNLOCKED'}`);
581
+ this.emit('message', `Lock physical controls: ${this.lockPhysicalControls ? 'LOCKED' : 'UNLOCKED'}`);
483
582
  };
484
583
 
485
584
  //start prepare accessory
486
585
  if (this.startPrepareAccessory) {
487
586
  try {
488
- this.operationModeSetPropsMinValue = operationModeSetPropsMinValue;
489
- this.operationModeSetPropsMaxValue = operationModeSetPropsMaxValue;
490
- this.operationModeSetPropsValidValues = operationModeSetPropsValidValues;
491
- this.fanSpeedSetPropsMaxValue = fanSpeedSetPropsMaxValue;
492
-
493
- await new Promise(resolve => setTimeout(resolve, 150));
494
587
  const accessory = await this.prepareAccessory(accountInfo, deviceState, deviceId, deviceTypeText, deviceName, accountName);
495
588
  this.emit('publishAccessory', accessory);
496
589
  this.startPrepareAccessory = false;
@@ -624,14 +717,15 @@ class DeviceAta extends EventEmitter {
624
717
  const numberOfFanSpeeds = this.numberOfFanSpeeds;
625
718
  const swingFunction = this.swingFunction;
626
719
  const hasOutdoorTemperature = this.hasOutdoorTemperature;
627
- const heatDryFanMode = [deviceState.OperationMode, 8, modelSupportsDry ? 2 : deviceState.OperationMode, 7][this.heatDryFanMode]; //NONE, HEAT - 1, DRY - 2, FAN - 7
628
- const autoDryFanMode = [deviceState.OperationMode, 1, modelSupportsDry ? 2 : deviceState.OperationMode, 7][this.autoDryFanMode]; //NONE, AUTO - 8, DRY - 2, FAN - 7
720
+ const autoDryFanMode = [deviceState.OperationMode, 8, modelSupportsDry ? 2 : 8, 7][this.autoDryFanMode]; //NONE, AUTO - 8, DRY - 2, FAN - 7
721
+ const heatDryFanMode = [deviceState.OperationMode, 1, modelSupportsDry ? 2 : 1, 7][this.heatDryFanMode]; //NONE, HEAT - 1, DRY - 2, FAN - 7
722
+ const coolDryFanMode = [deviceState.OperationMode, 3, modelSupportsDry ? 2 : 3, 7][this.coolDryFanMode]; //NONE, COOL - 3, DRY - 2, FAN - 7
629
723
  const serviceName = `${deviceTypeText} ${accessoryName}`;
630
724
 
631
725
  switch (displayMode) {
632
726
  case 0: //Heater Cooler
633
- const debug = this.enableDebugMode ? this.emit('debug', `Prepare heather/cooler service`) : false;
634
- this.melCloudService = accessory.addService(Service.HeaterCooler, serviceName, `HeaterCooler ${deviceId}`);
727
+ const debug = this.enableDebugMode ? this.emit('debug', `Prepare heater/cooler service`) : false;
728
+ this.melCloudService = new Service.HeaterCooler(serviceName, `HeaterCooler ${deviceId}`);
635
729
  this.melCloudService.getCharacteristic(Characteristic.Active)
636
730
  .onGet(async () => {
637
731
  const state = this.power;
@@ -678,7 +772,7 @@ class DeviceAta extends EventEmitter {
678
772
  break;
679
773
  case 2: //COOL - COOL
680
774
  deviceState.Power = true;
681
- deviceState.OperationMode = 3;
775
+ deviceState.OperationMode = coolDryFanMode;
682
776
  deviceState.EffectiveFlags = CONSTANTS.AirConditioner.EffectiveFlags.Power + CONSTANTS.AirConditioner.EffectiveFlags.OperationMode;
683
777
  break;
684
778
  };
@@ -839,6 +933,7 @@ class DeviceAta extends EventEmitter {
839
933
  this.emit('warn', `Set temperature display unit error: ${error}`);
840
934
  };
841
935
  });
936
+ accessory.addService(this.melCloudService);
842
937
  break;
843
938
  case 1: //Thermostat
844
939
  const debug1 = this.enableDebugMode ? this.emit('debug', `Prepare thermostat service`) : false;
@@ -872,7 +967,7 @@ class DeviceAta extends EventEmitter {
872
967
  break;
873
968
  case 2: //COOL - COOL
874
969
  deviceState.Power = true;
875
- deviceState.OperationMode = 3;
970
+ deviceState.OperationMode = coolDryFanMode;
876
971
  deviceState.EffectiveFlags = CONSTANTS.AirConditioner.EffectiveFlags.Power + CONSTANTS.AirConditioner.EffectiveFlags.OperationMode;
877
972
  break;
878
973
  case 3: //AUTO - AUTO
package/src/deviceatw.js CHANGED
@@ -676,7 +676,6 @@ class DeviceAtw extends EventEmitter {
676
676
  //start prepare accessory
677
677
  if (this.startPrepareAccessory) {
678
678
  try {
679
- await new Promise(resolve => setTimeout(resolve, 150));
680
679
  const accessory = await this.prepareAccessory(accountInfo, deviceState, deviceId, deviceTypeText, deviceName, accountName);
681
680
  this.emit('publishAccessory', accessory);
682
681
  this.startPrepareAccessory = false;
package/src/deviceerv.js CHANGED
@@ -472,7 +472,6 @@ class DeviceErv extends EventEmitter {
472
472
  this.operationModeSetPropsValidValues = operationModeSetPropsValidValues;
473
473
  this.fanSpeedSetPropsMaxValue = fanSpeedSetPropsMaxValue;
474
474
 
475
- await new Promise(resolve => setTimeout(resolve, 150));
476
475
  const accessory = await this.prepareAccessory(accountInfo, deviceState, deviceId, deviceTypeText, deviceName, accountName);
477
476
  this.emit('publishAccessory', accessory);
478
477
  this.startPrepareAccessory = false;
@@ -14,7 +14,7 @@ class MelCloudAta extends EventEmitter {
14
14
  const accountInfoFile = config.accountInfoFile;
15
15
  const deviceInfoFile = config.deviceInfoFile;
16
16
  const debugLog = config.debugLog;
17
- const refreshInterval= config.refreshInterval;
17
+ const refreshInterval = config.refreshInterval;
18
18
 
19
19
  //set default values
20
20
  this.deviceData = {};
@@ -127,13 +127,13 @@ class MelCloudAta extends EventEmitter {
127
127
  const legacyDevice = device.LegacyDevice;
128
128
  const unitSupportsStandbyMode = device.UnitSupportsStandbyMode;
129
129
  const isSplitSystem = device.IsSplitSystem;
130
- const hasHalfDegreeIncrements = device.HasHalfDegreeIncrements ?? false;
131
- const hasOutdoorTemperature = device.HasOutdoorTemperature ?? false
130
+ const hasHalfDegreeIncrements = device.HasHalfDegreeIncrements;
131
+ const hasOutdoorTemperature = device.HasOutdoorTemperature;
132
132
  const modelIsAirCurtain = device.ModelIsAirCurtain;
133
- const modelSupportsFanSpeed = device.ModelSupportsFanSpeed ?? false;
134
- const modelSupportsAuto = device.ModelSupportsAuto ?? false;
135
- const modelSupportsHeat = device.ModelSupportsHeat ?? false;
136
- const modelSupportsDry = device.ModelSupportsDry ?? false;
133
+ const modelSupportsFanSpeed = device.ModelSupportsFanSpeed;
134
+ const modelSupportsAuto = device.ModelSupportsAuto;
135
+ const modelSupportsHeat = device.ModelSupportsHeat;
136
+ const modelSupportsDry = device.ModelSupportsDry;
137
137
  const modelSupportsVaneVertical = device.ModelSupportsVaneVertical;
138
138
  const modelSupportsVaneHorizontal = device.ModelSupportsVaneHorizontal;
139
139
  const modelSupportsWideVane = device.ModelSupportsWideVane;