homebridge-gree-ac 2.1.7 → 2.2.0-beta.2
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 +32 -0
- package/README.md +120 -42
- package/config.schema.json +33 -18
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +65 -20
- package/dist/platform.js.map +1 -1
- package/dist/platformAccessory.d.ts +13 -4
- package/dist/platformAccessory.d.ts.map +1 -1
- package/dist/platformAccessory.js +718 -146
- package/dist/platformAccessory.js.map +1 -1
- package/dist/settings.d.ts +9 -1
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/ha_fan.jpg +0 -0
- package/ha_settings.jpg +0 -0
- package/package.json +1 -1
- package/uiconfig.jpg +0 -0
- package/uiconfigcustdef.jpg +0 -0
|
@@ -21,6 +21,8 @@ class GreeAirConditioner {
|
|
|
21
21
|
this.deviceConfig = deviceConfig;
|
|
22
22
|
this.tsAccessoryMac = tsAccessoryMac;
|
|
23
23
|
this.tsAccessory = null;
|
|
24
|
+
this.powerPending = -1;
|
|
25
|
+
this.modePending = -1;
|
|
24
26
|
// device communication functions
|
|
25
27
|
this.handleMessage = (msg, rinfo) => {
|
|
26
28
|
if (this.accessory.context.device.address === rinfo.address) {
|
|
@@ -72,6 +74,12 @@ class GreeAirConditioner {
|
|
|
72
74
|
else {
|
|
73
75
|
this.status[col] = pack.dat[i];
|
|
74
76
|
}
|
|
77
|
+
if (col === commands_1.default.power.code && pack.dat[i] === this.powerPending) {
|
|
78
|
+
this.powerPending = -1;
|
|
79
|
+
}
|
|
80
|
+
if (col === commands_1.default.mode.code && pack.dat[i] === this.modePending) {
|
|
81
|
+
this.modePending = -1;
|
|
82
|
+
}
|
|
75
83
|
});
|
|
76
84
|
this.platform.log.debug(`[${this.getDeviceLabel()}] Device status -> %j`, this.status);
|
|
77
85
|
if (!pack.cols.includes(commands_1.default.temperature.code) || invalidTempFromDevice) {
|
|
@@ -91,7 +99,7 @@ class GreeAirConditioner {
|
|
|
91
99
|
break;
|
|
92
100
|
case 'res': // package type is response
|
|
93
101
|
if (this.accessory.bound) {
|
|
94
|
-
this.platform.log.debug(`[${this.getDeviceLabel()}] Device response
|
|
102
|
+
this.platform.log.debug(`[${this.getDeviceLabel()}] Device response`, pack.opt, pack.p || pack.val);
|
|
95
103
|
const updatedParams = [];
|
|
96
104
|
pack.opt.forEach((opt, i) => {
|
|
97
105
|
const value = pack.p !== undefined ? pack.p[i] : pack.val[i];
|
|
@@ -102,10 +110,17 @@ class GreeAirConditioner {
|
|
|
102
110
|
updatedParams.push(`${cmd}: ${oldval} -> ${newval}`);
|
|
103
111
|
}
|
|
104
112
|
this.status[opt] = value;
|
|
113
|
+
if (opt === commands_1.default.power.code && value === this.powerPending) {
|
|
114
|
+
this.powerPending = -1;
|
|
115
|
+
}
|
|
116
|
+
if (opt === commands_1.default.mode.code && value === this.modePending) {
|
|
117
|
+
this.modePending = -1;
|
|
118
|
+
}
|
|
105
119
|
});
|
|
106
120
|
if (updatedParams.length > 0) {
|
|
107
121
|
this.platform.log.info(`[${this.getDeviceLabel()}] Device updated (%j)`, updatedParams);
|
|
108
122
|
}
|
|
123
|
+
this.updateStatus(pack.opt);
|
|
109
124
|
}
|
|
110
125
|
break;
|
|
111
126
|
default:
|
|
@@ -173,7 +188,7 @@ class GreeAirConditioner {
|
|
|
173
188
|
}
|
|
174
189
|
// All platform, accessory and service initialization is made in initAccessory function
|
|
175
190
|
initAccessory() {
|
|
176
|
-
var _a, _b, _c;
|
|
191
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
|
|
177
192
|
// register accessory in homebridge by api if not registered before
|
|
178
193
|
if (!this.accessory.registered) {
|
|
179
194
|
this.platform.log.debug(`[${this.getDeviceLabel()}] Registering new accessory in homebridge:`, this.accessory.context.device.mac, this.accessory.UUID);
|
|
@@ -196,6 +211,18 @@ class GreeAirConditioner {
|
|
|
196
211
|
if (this.tsAccessoryMac) {
|
|
197
212
|
this.tsAccessory = new tsAccessory_1.GreeAirConditionerTS(this.platform, this.platform.getAccessory(this.accessory.context.device.mac + '_ts'));
|
|
198
213
|
}
|
|
214
|
+
// init TargetHeaterCoolerState default value
|
|
215
|
+
if (!this.accessory.context.TargetHeaterCoolerState) {
|
|
216
|
+
this.accessory.context.TargetHeaterCoolerState =
|
|
217
|
+
((_b = this.HeaterCooler) === null || _b === void 0 ? void 0 : _b.getCharacteristic(this.platform.Characteristic.TargetHeaterCoolerState).value) ||
|
|
218
|
+
this.platform.Characteristic.TargetHeaterCoolerState.AUTO;
|
|
219
|
+
}
|
|
220
|
+
// init HeaterCoolerRotationSpeed default value
|
|
221
|
+
if (this.accessory.context.HeaterCoolerRotationSpeed === undefined) {
|
|
222
|
+
this.accessory.context.HeaterCoolerRotationSpeed =
|
|
223
|
+
((_c = this.HeaterCooler) === null || _c === void 0 ? void 0 : _c.getCharacteristic(this.platform.Characteristic.RotationSpeed).value) ||
|
|
224
|
+
((_d = this.HeaterCooler) === null || _d === void 0 ? void 0 : _d.getCharacteristic(this.platform.Characteristic.RotationSpeed).props.minValue) || 0;
|
|
225
|
+
}
|
|
199
226
|
// set accessory information
|
|
200
227
|
this.accessory.getService(this.platform.Service.AccessoryInformation)
|
|
201
228
|
.setCharacteristic(this.platform.Characteristic.FirmwareRevision, this.accessory.context.device.hid && this.accessory.context.device.hid.lastIndexOf('V') >= 0 &&
|
|
@@ -207,28 +234,61 @@ class GreeAirConditioner {
|
|
|
207
234
|
this.HeaterCooler = this.accessory.getService(this.platform.Service.HeaterCooler);
|
|
208
235
|
if (!this.HeaterCooler) {
|
|
209
236
|
this.platform.log.debug(`[${this.getDeviceLabel()}] HeaterCooler service doesn't exist - adding service`);
|
|
210
|
-
this.HeaterCooler = this.accessory.addService(this.platform.Service.HeaterCooler, this.accessory.displayName
|
|
237
|
+
this.HeaterCooler = this.accessory.addService(this.platform.Service.HeaterCooler, this.accessory.displayName);
|
|
211
238
|
// set static characeristics
|
|
212
239
|
this.initCharacteristics();
|
|
213
240
|
}
|
|
214
241
|
}
|
|
215
242
|
// TemperatureSensor service
|
|
243
|
+
// we don't use subtype because we add only one service with this type
|
|
244
|
+
const tss = this.accessory.getService(this.platform.Service.TemperatureSensor);
|
|
216
245
|
if (this.deviceConfig.temperatureSensor === settings_1.TS_TYPE.child) {
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
246
|
+
if (tss) {
|
|
247
|
+
this.TemperatureSensor = tss;
|
|
248
|
+
}
|
|
249
|
+
else {
|
|
250
|
+
this.platform.log.debug(`[${this.getDeviceLabel()}] Add Temperature Sensor child service`);
|
|
251
|
+
this.TemperatureSensor =
|
|
252
|
+
this.accessory.addService(this.platform.Service.TemperatureSensor, 'Temperature Sensor ' + this.HeaterCooler.displayName);
|
|
253
|
+
}
|
|
221
254
|
}
|
|
222
255
|
else {
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
this.
|
|
227
|
-
|
|
256
|
+
this.platform.log.debug(`[${this.getDeviceLabel()}] Temperature Sensor child service not allowed`, (tss === null || tss === void 0 ? void 0 : tss.displayName) !== undefined ? '(' + (tss === null || tss === void 0 ? void 0 : tss.displayName) + ')' : '');
|
|
257
|
+
if (tss !== undefined) {
|
|
258
|
+
this.platform.log.debug(`[${this.getDeviceLabel()}] Remove Temperature Sensor child service (%s)`, tss.displayName);
|
|
259
|
+
this.accessory.removeService(tss);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
// Fan service
|
|
263
|
+
// we don't use subtype because we add only one service with this type
|
|
264
|
+
const fs = this.accessory.getService(this.platform.Service.Fanv2);
|
|
265
|
+
if (this.deviceConfig.fanControlEnabled) {
|
|
266
|
+
if (fs) {
|
|
267
|
+
this.Fan = fs;
|
|
268
|
+
}
|
|
269
|
+
else {
|
|
270
|
+
this.platform.log.debug(`[${this.getDeviceLabel()}] Add Fan child service`);
|
|
271
|
+
this.Fan =
|
|
272
|
+
this.accessory.addService(this.platform.Service.Fanv2, 'Fan ' + this.HeaterCooler.displayName);
|
|
273
|
+
// set static characeristics
|
|
274
|
+
(_e = this.Fan) === null || _e === void 0 ? void 0 : _e.getCharacteristic(this.platform.Characteristic.RotationSpeed).setProps({
|
|
275
|
+
minValue: 0,
|
|
276
|
+
maxValue: 100,
|
|
277
|
+
minStep: 100 / (this.deviceConfig.speedSteps + 1)
|
|
278
|
+
});
|
|
279
|
+
this.platform.log.debug(`[${this.getDeviceLabel()}] Fan RotationSpeed - minValue: %s, maxValue: %s, minStep: %s`, (_g = (_f = this.Fan) === null || _f === void 0 ? void 0 : _f.getCharacteristic(this.platform.Characteristic.RotationSpeed).props.minValue) === null || _g === void 0 ? void 0 : _g.toString(), (_j = (_h = this.Fan) === null || _h === void 0 ? void 0 : _h.getCharacteristic(this.platform.Characteristic.RotationSpeed).props.maxValue) === null || _j === void 0 ? void 0 : _j.toString(), (_l = (_k = this.Fan) === null || _k === void 0 ? void 0 : _k.getCharacteristic(this.platform.Characteristic.RotationSpeed).props.minStep) === null || _l === void 0 ? void 0 : _l.toString());
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
else {
|
|
283
|
+
this.platform.log.debug(`[${this.getDeviceLabel()}] Fan child service not allowed`, (fs === null || fs === void 0 ? void 0 : fs.displayName) !== undefined ? '(' + (fs === null || fs === void 0 ? void 0 : fs.displayName) + ')' : '');
|
|
284
|
+
if (fs !== undefined) {
|
|
285
|
+
this.platform.log.debug(`[${this.getDeviceLabel()}] Remove Fan child service (%s)`, fs.displayName);
|
|
286
|
+
this.accessory.removeService(fs);
|
|
228
287
|
}
|
|
229
288
|
}
|
|
230
289
|
this.HeaterCooler.setPrimaryService(true);
|
|
231
|
-
(
|
|
290
|
+
(_m = this.TemperatureSensor) === null || _m === void 0 ? void 0 : _m.setPrimaryService(false);
|
|
291
|
+
(_o = this.Fan) === null || _o === void 0 ? void 0 : _o.setPrimaryService(false);
|
|
232
292
|
this.platform.api.updatePlatformAccessories([this.accessory]);
|
|
233
293
|
// each service must implement at-minimum the "required characteristics" for the given service type
|
|
234
294
|
// see https://developers.homebridge.io/#/service/HeaterCooler
|
|
@@ -236,17 +296,20 @@ class GreeAirConditioner {
|
|
|
236
296
|
this.HeaterCooler.getCharacteristic(this.platform.Characteristic.Active)
|
|
237
297
|
.onSet(this.setActive.bind(this))
|
|
238
298
|
.onGet(this.getActive.bind(this));
|
|
299
|
+
(_p = this.Fan) === null || _p === void 0 ? void 0 : _p.getCharacteristic(this.platform.Characteristic.Active).onSet(this.setFanActive.bind(this)).onGet(this.getFanActive.bind(this));
|
|
239
300
|
// register handlers for the Current Heater-Cooler State Characteristic
|
|
240
301
|
this.HeaterCooler.getCharacteristic(this.platform.Characteristic.CurrentHeaterCoolerState)
|
|
241
302
|
.onGet(this.getCurrentHeaterCoolerState.bind(this));
|
|
303
|
+
// register handlers for the Current Fan State Characteristic
|
|
304
|
+
(_q = this.Fan) === null || _q === void 0 ? void 0 : _q.getCharacteristic(this.platform.Characteristic.CurrentFanState).onGet(this.getCurrentFanState.bind(this));
|
|
242
305
|
// register handlers for the Target Heater-Cooler State Characteristic
|
|
243
306
|
this.HeaterCooler.getCharacteristic(this.platform.Characteristic.TargetHeaterCoolerState)
|
|
244
307
|
.onGet(this.getTargetHeaterCoolerState.bind(this))
|
|
245
308
|
.onSet(this.setTargetHeaterCoolerState.bind(this));
|
|
246
309
|
// register handlers for the Current Temperature Characteristic
|
|
247
310
|
this.HeaterCooler.getCharacteristic(this.platform.Characteristic.CurrentTemperature)
|
|
248
|
-
.onGet(this.getCurrentTemperature.bind(this, 'Heater
|
|
249
|
-
(
|
|
311
|
+
.onGet(this.getCurrentTemperature.bind(this, 'Heater-Cooler'));
|
|
312
|
+
(_r = this.TemperatureSensor) === null || _r === void 0 ? void 0 : _r.getCharacteristic(this.platform.Characteristic.CurrentTemperature).onGet(this.getCurrentTemperature.bind(this, 'Temperature Sensor'));
|
|
250
313
|
// register handlers for the Cooling Threshold Temperature Characteristic
|
|
251
314
|
this.HeaterCooler.getCharacteristic(this.platform.Characteristic.CoolingThresholdTemperature)
|
|
252
315
|
.onGet(this.getTargetTemperature.bind(this, 'CoolingThresholdTemperature'))
|
|
@@ -263,10 +326,12 @@ class GreeAirConditioner {
|
|
|
263
326
|
this.HeaterCooler.getCharacteristic(this.platform.Characteristic.SwingMode)
|
|
264
327
|
.onGet(this.getSwingMode.bind(this))
|
|
265
328
|
.onSet(this.setSwingMode.bind(this));
|
|
329
|
+
(_s = this.Fan) === null || _s === void 0 ? void 0 : _s.getCharacteristic(this.platform.Characteristic.SwingMode).onGet(this.getSwingMode.bind(this)).onSet(this.setSwingMode.bind(this));
|
|
266
330
|
// register handlers for the Rotation Speed Characteristic
|
|
267
331
|
this.HeaterCooler.getCharacteristic(this.platform.Characteristic.RotationSpeed)
|
|
268
332
|
.onGet(this.getRotationSpeed.bind(this))
|
|
269
333
|
.onSet(this.setRotationSpeed.bind(this));
|
|
334
|
+
(_t = this.Fan) === null || _t === void 0 ? void 0 : _t.getCharacteristic(this.platform.Characteristic.RotationSpeed).onGet(this.getFanRotationSpeed.bind(this)).onSet(this.setFanRotationSpeed.bind(this));
|
|
270
335
|
// register handlers for the Name Characteristic
|
|
271
336
|
this.HeaterCooler.getCharacteristic(this.platform.Characteristic.Name)
|
|
272
337
|
.onGet(this.getName.bind(this));
|
|
@@ -299,9 +364,24 @@ class GreeAirConditioner {
|
|
|
299
364
|
* These are sent when the user changes the state of an accessory
|
|
300
365
|
*/
|
|
301
366
|
async setActive(value) {
|
|
367
|
+
var _a, _b;
|
|
302
368
|
const powerValue = (value === this.platform.Characteristic.Active.ACTIVE);
|
|
303
|
-
this.platform.log.debug(`[${this.getDeviceLabel()}] Set Active ->`, powerValue ? 'ACTIVE' : 'INACTIVE');
|
|
369
|
+
this.platform.log.debug(`[${this.getDeviceLabel()}] Set Heater-Cooler Active ->`, powerValue ? 'ACTIVE' : 'INACTIVE');
|
|
304
370
|
this.power = powerValue;
|
|
371
|
+
if (powerValue &&
|
|
372
|
+
((_a = this.Fan) === null || _a === void 0 ? void 0 : _a.getCharacteristic(this.platform.Characteristic.Active).value) === this.platform.Characteristic.Active.ACTIVE) {
|
|
373
|
+
(_b = this.Fan) === null || _b === void 0 ? void 0 : _b.getCharacteristic(this.platform.Characteristic.Active).updateValue(this.platform.Characteristic.Active.INACTIVE);
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
async setFanActive(value) {
|
|
377
|
+
var _a, _b;
|
|
378
|
+
const powerValue = (value === this.platform.Characteristic.Active.ACTIVE);
|
|
379
|
+
this.platform.log.debug(`[${this.getDeviceLabel()}] Set Fan Active ->`, powerValue ? 'ACTIVE' : 'INACTIVE');
|
|
380
|
+
this.fanpower = powerValue;
|
|
381
|
+
if (powerValue &&
|
|
382
|
+
((_a = this.HeaterCooler) === null || _a === void 0 ? void 0 : _a.getCharacteristic(this.platform.Characteristic.Active).value) === this.platform.Characteristic.Active.ACTIVE) {
|
|
383
|
+
(_b = this.HeaterCooler) === null || _b === void 0 ? void 0 : _b.getCharacteristic(this.platform.Characteristic.Active).updateValue(this.platform.Characteristic.Active.INACTIVE);
|
|
384
|
+
}
|
|
305
385
|
}
|
|
306
386
|
async setTargetHeaterCoolerState(value) {
|
|
307
387
|
let modeValue = commands_1.default.mode.value.auto;
|
|
@@ -318,6 +398,8 @@ class GreeAirConditioner {
|
|
|
318
398
|
}
|
|
319
399
|
this.platform.log.debug(`[${this.getDeviceLabel()}] Set TargetHeaterCoolerState ->`, logValue);
|
|
320
400
|
this.mode = modeValue;
|
|
401
|
+
this.accessory.context.TargetHeaterCoolerState = value;
|
|
402
|
+
this.platform.api.updatePlatformAccessories([this.accessory]);
|
|
321
403
|
}
|
|
322
404
|
async setTargetTemperature(value) {
|
|
323
405
|
this.platform.log.debug(`[${this.getDeviceLabel()}] Set ThresholdTemperature ->`, value);
|
|
@@ -334,62 +416,108 @@ class GreeAirConditioner {
|
|
|
334
416
|
this.platform.log.debug(`[${this.getDeviceLabel()}] Set SwingMode ->`, logValue);
|
|
335
417
|
this.swingMode = (value === this.platform.Characteristic.SwingMode.SWING_ENABLED) ?
|
|
336
418
|
commands_1.default.swingVertical.value.full : (this.deviceConfig.overrideDefaultVerticalSwing === settings_1.OVERRIDE_DEFAULT_SWING.always) ?
|
|
337
|
-
this.deviceConfig.defaultVerticalSwing : commands_1.default.swingVertical.value.default;
|
|
419
|
+
this.deviceConfig.defaultVerticalSwing || settings_1.DEFAULT_DEVICE_CONFIG.defaultVerticalSwing : commands_1.default.swingVertical.value.default;
|
|
338
420
|
}
|
|
339
421
|
async setRotationSpeed(value) {
|
|
422
|
+
var _a;
|
|
423
|
+
const maxSpeed = ((_a = this.HeaterCooler) === null || _a === void 0 ? void 0 : _a.getCharacteristic(this.platform.Characteristic.RotationSpeed).props.maxValue) ||
|
|
424
|
+
this.deviceConfig.speedSteps + 3;
|
|
340
425
|
switch (value) {
|
|
426
|
+
case 0: // inactive -> rotation speed change not needed
|
|
427
|
+
return;
|
|
341
428
|
case 1: // quiet
|
|
342
|
-
this.platform.log.debug(`[${this.getDeviceLabel()}] Set RotationSpeed ->`, value + ' (quiet)');
|
|
429
|
+
this.platform.log.debug(`[${this.getDeviceLabel()}] Set Heater-Cooler RotationSpeed ->`, value + ' (quiet)');
|
|
343
430
|
this.quietMode = commands_1.default.quietMode.value.on;
|
|
344
431
|
break;
|
|
345
432
|
case 2: // auto
|
|
346
|
-
this.platform.log.debug(`[${this.getDeviceLabel()}] Set RotationSpeed ->`, value +
|
|
433
|
+
this.platform.log.debug(`[${this.getDeviceLabel()}] Set Heater-Cooler RotationSpeed ->`, value +
|
|
347
434
|
' (' + this.getKeyName(commands_1.default.speed.value, commands_1.default.speed.value.auto) + ')');
|
|
348
435
|
this.speed = commands_1.default.speed.value.auto;
|
|
349
436
|
break;
|
|
350
437
|
case 3: // low
|
|
351
|
-
this.platform.log.debug(`[${this.getDeviceLabel()}] Set RotationSpeed ->`, value +
|
|
438
|
+
this.platform.log.debug(`[${this.getDeviceLabel()}] Set Heater-Cooler RotationSpeed ->`, value +
|
|
352
439
|
' (' + this.getKeyName(commands_1.default.speed.value, commands_1.default.speed.value.low) + ')');
|
|
353
440
|
this.speed = commands_1.default.speed.value.low;
|
|
354
441
|
break;
|
|
355
442
|
case 4: // mediumLow / medium
|
|
356
|
-
this.platform.log.debug(`[${this.getDeviceLabel()}] Set RotationSpeed ->`, value + ' (' +
|
|
357
|
-
this.getKeyName(commands_1.default.speed.value, (
|
|
358
|
-
this.speed = (
|
|
443
|
+
this.platform.log.debug(`[${this.getDeviceLabel()}] Set Heater-Cooler RotationSpeed ->`, value + ' (' +
|
|
444
|
+
this.getKeyName(commands_1.default.speed.value, (maxSpeed === 8) ? commands_1.default.speed.value.mediumLow : commands_1.default.speed.value.medium) + ')');
|
|
445
|
+
this.speed = (maxSpeed === 8) ? commands_1.default.speed.value.mediumLow : commands_1.default.speed.value.medium;
|
|
359
446
|
break;
|
|
360
447
|
case 5: // medium / high
|
|
361
|
-
this.platform.log.debug(`[${this.getDeviceLabel()}] Set RotationSpeed ->`, value + ' (' +
|
|
362
|
-
this.getKeyName(commands_1.default.speed.value, (
|
|
363
|
-
this.speed = (
|
|
448
|
+
this.platform.log.debug(`[${this.getDeviceLabel()}] Set Heater-Cooler RotationSpeed ->`, value + ' (' +
|
|
449
|
+
this.getKeyName(commands_1.default.speed.value, (maxSpeed === 8) ? commands_1.default.speed.value.medium : commands_1.default.speed.value.high) + ')');
|
|
450
|
+
this.speed = (maxSpeed === 8) ? commands_1.default.speed.value.medium : commands_1.default.speed.value.high;
|
|
364
451
|
break;
|
|
365
452
|
case 6: // mediumHigh / powerful
|
|
366
|
-
if (
|
|
453
|
+
if (maxSpeed === 8) {
|
|
367
454
|
// mediumHigh
|
|
368
|
-
this.platform.log.debug(`[${this.getDeviceLabel()}] Set RotationSpeed ->`, value +
|
|
455
|
+
this.platform.log.debug(`[${this.getDeviceLabel()}] Set Heater-Cooler RotationSpeed ->`, value +
|
|
369
456
|
' (' + this.getKeyName(commands_1.default.speed.value, commands_1.default.speed.value.mediumHigh) + ')');
|
|
370
457
|
this.speed = commands_1.default.speed.value.mediumHigh;
|
|
371
458
|
}
|
|
372
459
|
else {
|
|
373
460
|
// powerful
|
|
374
|
-
this.platform.log.debug(`[${this.getDeviceLabel()}] Set RotationSpeed ->`, value + ' (powerful)');
|
|
461
|
+
this.platform.log.debug(`[${this.getDeviceLabel()}] Set Heater-Cooler RotationSpeed ->`, value + ' (powerful)');
|
|
375
462
|
this.powerfulMode = commands_1.default.powerfulMode.value.on;
|
|
376
463
|
}
|
|
377
464
|
break;
|
|
378
465
|
case 7: // high
|
|
379
|
-
this.platform.log.debug(`[${this.getDeviceLabel()}] Set RotationSpeed ->`, value +
|
|
466
|
+
this.platform.log.debug(`[${this.getDeviceLabel()}] Set Heater-Cooler RotationSpeed ->`, value +
|
|
380
467
|
' (' + this.getKeyName(commands_1.default.speed.value, commands_1.default.speed.value.high) + ')');
|
|
381
468
|
this.speed = commands_1.default.speed.value.high;
|
|
382
469
|
break;
|
|
383
470
|
case 8: // powerful
|
|
384
|
-
this.platform.log.debug(`[${this.getDeviceLabel()}] Set RotationSpeed ->`, value + ' (powerful)');
|
|
471
|
+
this.platform.log.debug(`[${this.getDeviceLabel()}] Set Heater-Cooler RotationSpeed ->`, value + ' (powerful)');
|
|
385
472
|
this.powerfulMode = commands_1.default.powerfulMode.value.on;
|
|
386
473
|
break;
|
|
387
474
|
default: // auto
|
|
388
|
-
this.platform.log.debug(`[${this.getDeviceLabel()}] Set RotationSpeed ->`, value +
|
|
475
|
+
this.platform.log.debug(`[${this.getDeviceLabel()}] Set Heater-Cooler RotationSpeed ->`, value +
|
|
389
476
|
' (' + this.getKeyName(commands_1.default.speed.value, commands_1.default.speed.value.auto) + ')');
|
|
390
477
|
this.speed = commands_1.default.speed.value.auto;
|
|
391
478
|
break;
|
|
392
479
|
}
|
|
480
|
+
this.accessory.context.HeaterCoolerRotationSpeed = value;
|
|
481
|
+
this.platform.api.updatePlatformAccessories([this.accessory]);
|
|
482
|
+
}
|
|
483
|
+
async setFanRotationSpeed(value) {
|
|
484
|
+
var _a, _b;
|
|
485
|
+
if (value !== 0 &&
|
|
486
|
+
((_a = this.Fan) === null || _a === void 0 ? void 0 : _a.getCharacteristic(this.platform.Characteristic.Active).value) !== this.platform.Characteristic.Active.ACTIVE) {
|
|
487
|
+
(_b = this.Fan) === null || _b === void 0 ? void 0 : _b.getCharacteristic(this.platform.Characteristic.Active).setValue(this.platform.Characteristic.Active.ACTIVE);
|
|
488
|
+
}
|
|
489
|
+
let logMsg = `[${this.getDeviceLabel()}] Set Fan RotationSpeed -> ${Math.round(value)}%`;
|
|
490
|
+
switch (Math.round(value)) {
|
|
491
|
+
case 0: // inactive -> rotation speed change not needed
|
|
492
|
+
return;
|
|
493
|
+
case 17: // low - 5 step model
|
|
494
|
+
case 25: // low - 3 step model
|
|
495
|
+
logMsg += ` (${this.getKeyName(commands_1.default.speed.value, commands_1.default.speed.value.low)})`;
|
|
496
|
+
this.speed = commands_1.default.speed.value.low;
|
|
497
|
+
break;
|
|
498
|
+
case 33: // mediumLow
|
|
499
|
+
logMsg += ` (${this.getKeyName(commands_1.default.speed.value, commands_1.default.speed.value.mediumLow)})`;
|
|
500
|
+
this.speed = commands_1.default.speed.value.mediumLow;
|
|
501
|
+
break;
|
|
502
|
+
case 50: // medium
|
|
503
|
+
logMsg += ` (${this.getKeyName(commands_1.default.speed.value, commands_1.default.speed.value.medium)}) - ${Math.round(value)}%`;
|
|
504
|
+
this.speed = commands_1.default.speed.value.medium;
|
|
505
|
+
break;
|
|
506
|
+
case 67: // mediumHigh
|
|
507
|
+
logMsg += ` (${this.getKeyName(commands_1.default.speed.value, commands_1.default.speed.value.mediumHigh)}) - ${Math.round(value)}%`;
|
|
508
|
+
this.speed = commands_1.default.speed.value.mediumHigh;
|
|
509
|
+
break;
|
|
510
|
+
case 75: // high - 3 step model
|
|
511
|
+
case 83: // high - 5 step model
|
|
512
|
+
logMsg += ` (${this.getKeyName(commands_1.default.speed.value, commands_1.default.speed.value.high)}) - ${Math.round(value)}%`;
|
|
513
|
+
this.speed = commands_1.default.speed.value.high;
|
|
514
|
+
break;
|
|
515
|
+
default: // auto
|
|
516
|
+
logMsg += ` (${this.getKeyName(commands_1.default.speed.value, commands_1.default.speed.value.auto)}) - ${Math.round(value)}%`;
|
|
517
|
+
this.speed = commands_1.default.speed.value.auto;
|
|
518
|
+
break;
|
|
519
|
+
}
|
|
520
|
+
this.platform.log.debug(logMsg);
|
|
393
521
|
}
|
|
394
522
|
/**
|
|
395
523
|
* Handle the "GET" requests from HomeKit
|
|
@@ -408,10 +536,14 @@ class GreeAirConditioner {
|
|
|
408
536
|
* throw new this.platform.api.hap.HapStatusError(this.platform.api.hap.HAPStatus.SERVICE_COMMUNICATION_FAILURE);
|
|
409
537
|
*/
|
|
410
538
|
async getActive() {
|
|
411
|
-
const currentPower = this.power;
|
|
412
|
-
this.platform.log.debug(`[${this.getDeviceLabel()}] Get Active ->`, currentPower ? 'ACTIVE' : 'INACTIVE');
|
|
413
|
-
return currentPower ?
|
|
414
|
-
|
|
539
|
+
const currentPower = this.power && [commands_1.default.mode.value.cool, commands_1.default.mode.value.heat, commands_1.default.mode.value.auto].includes(this.mode);
|
|
540
|
+
this.platform.log.debug(`[${this.getDeviceLabel()}] Get Heater-Cooler Active ->`, currentPower ? 'ACTIVE' : 'INACTIVE');
|
|
541
|
+
return currentPower ? this.platform.Characteristic.Active.ACTIVE : this.platform.Characteristic.Active.INACTIVE;
|
|
542
|
+
}
|
|
543
|
+
async getFanActive() {
|
|
544
|
+
const currentPower = this.power && this.mode === commands_1.default.mode.value.fan;
|
|
545
|
+
this.platform.log.debug(`[${this.getDeviceLabel()}] Get Fan Active ->`, currentPower ? 'ACTIVE' : 'INACTIVE');
|
|
546
|
+
return currentPower ? this.platform.Characteristic.Active.ACTIVE : this.platform.Characteristic.Active.INACTIVE;
|
|
415
547
|
}
|
|
416
548
|
async getCurrentHeaterCoolerState() {
|
|
417
549
|
if (this.power) {
|
|
@@ -422,10 +554,6 @@ class GreeAirConditioner {
|
|
|
422
554
|
case commands_1.default.mode.value.heat:
|
|
423
555
|
this.platform.log.debug(`[${this.getDeviceLabel()}] Get CurrentHeaterCoolerState -> HEATING`);
|
|
424
556
|
return this.platform.Characteristic.CurrentHeaterCoolerState.HEATING;
|
|
425
|
-
case commands_1.default.mode.value.fan:
|
|
426
|
-
case commands_1.default.mode.value.dry:
|
|
427
|
-
this.platform.log.debug(`[${this.getDeviceLabel()}] Get CurrentHeaterCoolerState -> IDLE`);
|
|
428
|
-
return this.platform.Characteristic.CurrentHeaterCoolerState.IDLE;
|
|
429
557
|
case commands_1.default.mode.value.auto:
|
|
430
558
|
if (this.currentTemperature > this.status[commands_1.default.targetTemperature.code]) {
|
|
431
559
|
this.platform.log.debug(`[${this.getDeviceLabel()}] Get CurrentHeaterCoolerState -> COOLING`);
|
|
@@ -442,6 +570,14 @@ class GreeAirConditioner {
|
|
|
442
570
|
this.platform.log.debug(`[${this.getDeviceLabel()}] Get CurrentHeaterCoolerState -> INACTIVE`);
|
|
443
571
|
return this.platform.Characteristic.CurrentHeaterCoolerState.INACTIVE;
|
|
444
572
|
}
|
|
573
|
+
async getCurrentFanState() {
|
|
574
|
+
if (this.power && this.mode === commands_1.default.mode.value.fan) {
|
|
575
|
+
this.platform.log.debug(`[${this.getDeviceLabel()}] Get CurrentFanState -> BLOWING_AIR`);
|
|
576
|
+
return this.platform.Characteristic.CurrentFanState.BLOWING_AIR;
|
|
577
|
+
}
|
|
578
|
+
this.platform.log.debug(`[${this.getDeviceLabel()}] Get CurrentFanState -> INACTIVE`);
|
|
579
|
+
return this.platform.Characteristic.CurrentFanState.INACTIVE;
|
|
580
|
+
}
|
|
445
581
|
async getTargetHeaterCoolerState() {
|
|
446
582
|
switch (this.mode) {
|
|
447
583
|
case commands_1.default.mode.value.cool:
|
|
@@ -450,9 +586,23 @@ class GreeAirConditioner {
|
|
|
450
586
|
case commands_1.default.mode.value.heat:
|
|
451
587
|
this.platform.log.debug(`[${this.getDeviceLabel()}] Get TargetHeaterCoolerState -> HEAT`);
|
|
452
588
|
return this.platform.Characteristic.TargetHeaterCoolerState.HEAT;
|
|
589
|
+
case commands_1.default.mode.value.auto:
|
|
590
|
+
this.platform.log.debug(`[${this.getDeviceLabel()}] Get TargetHeaterCoolerState -> AUTO`);
|
|
591
|
+
return this.platform.Characteristic.TargetHeaterCoolerState.AUTO;
|
|
592
|
+
}
|
|
593
|
+
// not in heating-cooling mode (e.g. fan mode)
|
|
594
|
+
switch (this.accessory.context.TargetHeaterCoolerState) {
|
|
595
|
+
case this.platform.Characteristic.TargetHeaterCoolerState.COOL:
|
|
596
|
+
this.platform.log.debug(`[${this.getDeviceLabel()}] Get TargetHeaterCoolerState -> COOL`);
|
|
597
|
+
break;
|
|
598
|
+
case this.platform.Characteristic.TargetHeaterCoolerState.HEAT:
|
|
599
|
+
this.platform.log.debug(`[${this.getDeviceLabel()}] Get TargetHeaterCoolerState -> HEAT`);
|
|
600
|
+
break;
|
|
601
|
+
case this.platform.Characteristic.TargetHeaterCoolerState.AUTO:
|
|
602
|
+
this.platform.log.debug(`[${this.getDeviceLabel()}] Get TargetHeaterCoolerState -> AUTO`);
|
|
603
|
+
break;
|
|
453
604
|
}
|
|
454
|
-
this.
|
|
455
|
-
return this.platform.Characteristic.TargetHeaterCoolerState.AUTO;
|
|
605
|
+
return this.accessory.context.TargetHeaterCoolerState;
|
|
456
606
|
}
|
|
457
607
|
async getCurrentTemperature(service) {
|
|
458
608
|
const currentValue = this.currentTemperature;
|
|
@@ -485,13 +635,16 @@ class GreeAirConditioner {
|
|
|
485
635
|
return this.platform.Characteristic.SwingMode.SWING_ENABLED;
|
|
486
636
|
}
|
|
487
637
|
async getRotationSpeed() {
|
|
638
|
+
var _a;
|
|
639
|
+
const maxSpeed = ((_a = this.HeaterCooler) === null || _a === void 0 ? void 0 : _a.getCharacteristic(this.platform.Characteristic.RotationSpeed).props.maxValue) ||
|
|
640
|
+
this.deviceConfig.speedSteps + 3;
|
|
488
641
|
if (this.quietMode === commands_1.default.quietMode.value.on) {
|
|
489
|
-
this.platform.log.debug(`[${this.getDeviceLabel()}] Get RotationSpeed -> 1 (quiet)`);
|
|
642
|
+
this.platform.log.debug(`[${this.getDeviceLabel()}] Get Heater-Cooler RotationSpeed -> 1 (quiet)`);
|
|
490
643
|
return 1;
|
|
491
644
|
}
|
|
492
645
|
if (this.powerfulMode === commands_1.default.powerfulMode.value.on) {
|
|
493
|
-
this.platform.log.debug(`[${this.getDeviceLabel()}] Get RotationSpeed
|
|
494
|
-
return
|
|
646
|
+
this.platform.log.debug(`[${this.getDeviceLabel()}] Get Heater-Cooler RotationSpeed -> ${maxSpeed} (powerful)`);
|
|
647
|
+
return maxSpeed;
|
|
495
648
|
}
|
|
496
649
|
let value = 2; // default to auto
|
|
497
650
|
let logValue = this.getKeyName(commands_1.default.speed.value, commands_1.default.speed.value.auto);
|
|
@@ -502,22 +655,53 @@ class GreeAirConditioner {
|
|
|
502
655
|
break;
|
|
503
656
|
case commands_1.default.speed.value.mediumLow:
|
|
504
657
|
value = 4;
|
|
505
|
-
logValue = this.getKeyName(commands_1.default.speed.value, (
|
|
658
|
+
logValue = this.getKeyName(commands_1.default.speed.value, (maxSpeed === 8) ? commands_1.default.speed.value.mediumLow : commands_1.default.speed.value.medium);
|
|
506
659
|
break;
|
|
507
660
|
case commands_1.default.speed.value.medium:
|
|
508
|
-
value = (
|
|
661
|
+
value = (maxSpeed === 8) ? 5 : 4;
|
|
509
662
|
logValue = this.getKeyName(commands_1.default.speed.value, commands_1.default.speed.value.medium);
|
|
510
663
|
break;
|
|
511
664
|
case commands_1.default.speed.value.mediumHigh:
|
|
512
|
-
value = (
|
|
513
|
-
logValue = this.getKeyName(commands_1.default.speed.value, (
|
|
665
|
+
value = (maxSpeed === 8) ? 6 : 4;
|
|
666
|
+
logValue = this.getKeyName(commands_1.default.speed.value, (maxSpeed === 8) ? commands_1.default.speed.value.mediumHigh : commands_1.default.speed.value.medium);
|
|
514
667
|
break;
|
|
515
668
|
case commands_1.default.speed.value.high:
|
|
516
|
-
value = (
|
|
669
|
+
value = (maxSpeed === 8) ? 7 : 5;
|
|
517
670
|
logValue = this.getKeyName(commands_1.default.speed.value, commands_1.default.speed.value.high);
|
|
518
671
|
break;
|
|
519
672
|
}
|
|
520
|
-
this.platform.log.debug(`[${this.getDeviceLabel()}] Get RotationSpeed ->`, value + ' (' + logValue + ')');
|
|
673
|
+
this.platform.log.debug(`[${this.getDeviceLabel()}] Get Heater-Cooler RotationSpeed ->`, value + ' (' + logValue + ')');
|
|
674
|
+
return value;
|
|
675
|
+
}
|
|
676
|
+
async getFanRotationSpeed() {
|
|
677
|
+
var _a;
|
|
678
|
+
const minStep = ((_a = this.Fan) === null || _a === void 0 ? void 0 : _a.getCharacteristic(this.platform.Characteristic.RotationSpeed).props.minStep) ||
|
|
679
|
+
100 / (this.deviceConfig.speedSteps + 1);
|
|
680
|
+
let value = 100; // default to auto
|
|
681
|
+
let logValueName = this.getKeyName(commands_1.default.speed.value, commands_1.default.speed.value.auto);
|
|
682
|
+
switch (this.speed) {
|
|
683
|
+
case commands_1.default.speed.value.low:
|
|
684
|
+
value = minStep;
|
|
685
|
+
logValueName = this.getKeyName(commands_1.default.speed.value, commands_1.default.speed.value.low);
|
|
686
|
+
break;
|
|
687
|
+
case commands_1.default.speed.value.mediumLow:
|
|
688
|
+
value = 2 * minStep;
|
|
689
|
+
logValueName = this.getKeyName(commands_1.default.speed.value, (minStep !== 25) ? commands_1.default.speed.value.mediumLow : commands_1.default.speed.value.medium);
|
|
690
|
+
break;
|
|
691
|
+
case commands_1.default.speed.value.medium:
|
|
692
|
+
value = (minStep !== 25 ? 3 : 2) * minStep;
|
|
693
|
+
logValueName = this.getKeyName(commands_1.default.speed.value, commands_1.default.speed.value.medium);
|
|
694
|
+
break;
|
|
695
|
+
case commands_1.default.speed.value.mediumHigh:
|
|
696
|
+
value = (minStep !== 25 ? 4 : 2) * minStep;
|
|
697
|
+
logValueName = this.getKeyName(commands_1.default.speed.value, (minStep !== 25) ? commands_1.default.speed.value.mediumHigh : commands_1.default.speed.value.medium);
|
|
698
|
+
break;
|
|
699
|
+
case commands_1.default.speed.value.high:
|
|
700
|
+
value = (minStep !== 25 ? 5 : 3) * minStep;
|
|
701
|
+
logValueName = this.getKeyName(commands_1.default.speed.value, commands_1.default.speed.value.high);
|
|
702
|
+
break;
|
|
703
|
+
}
|
|
704
|
+
this.platform.log.debug(`[${this.getDeviceLabel()}] Get Fan RotationSpeed -> ${Math.round(value)}% (${logValueName})`);
|
|
521
705
|
return value;
|
|
522
706
|
}
|
|
523
707
|
async getName() {
|
|
@@ -527,7 +711,7 @@ class GreeAirConditioner {
|
|
|
527
711
|
}
|
|
528
712
|
// helper functions
|
|
529
713
|
getDeviceLabel() {
|
|
530
|
-
return `${this.accessory.displayName} -- ${this.accessory.context.device.address}
|
|
714
|
+
return `${this.accessory.displayName} -- ${this.accessory.context.device.address}`;
|
|
531
715
|
}
|
|
532
716
|
getCols() {
|
|
533
717
|
if (!this.cols) {
|
|
@@ -602,7 +786,7 @@ class GreeAirConditioner {
|
|
|
602
786
|
let targetValue;
|
|
603
787
|
const heatingTargetValue = ((_a = this.HeaterCooler) === null || _a === void 0 ? void 0 : _a.getCharacteristic(this.platform.Characteristic.HeatingThresholdTemperature).value) || 25;
|
|
604
788
|
const coolingTargetValue = ((_b = this.HeaterCooler) === null || _b === void 0 ? void 0 : _b.getCharacteristic(this.platform.Characteristic.CoolingThresholdTemperature).value) || 25;
|
|
605
|
-
switch (this.
|
|
789
|
+
switch (this.mode) {
|
|
606
790
|
case commands_1.default.mode.value.heat:
|
|
607
791
|
targetValue = heatingTargetValue;
|
|
608
792
|
break;
|
|
@@ -640,69 +824,385 @@ class GreeAirConditioner {
|
|
|
640
824
|
return (this.status[commands_1.default.power.code] === commands_1.default.power.value.on);
|
|
641
825
|
}
|
|
642
826
|
set power(value) {
|
|
643
|
-
var _a;
|
|
644
|
-
if (value === this.power)
|
|
827
|
+
var _a, _b, _c, _d, _e;
|
|
828
|
+
if ((value === this.power && [commands_1.default.mode.value.cool, commands_1.default.mode.value.heat, commands_1.default.mode.value.auto].includes(this.mode)) ||
|
|
829
|
+
this.powerPending !== -1 || this.modePending !== -1) {
|
|
830
|
+
this.platform.log.debug(`[${this.getDeviceLabel()}] power -> no change (${this.power}, ${this.powerPending}, ${this.mode},`, `${this.modePending})`);
|
|
831
|
+
return;
|
|
832
|
+
}
|
|
833
|
+
if (!value && ![commands_1.default.mode.value.cool, commands_1.default.mode.value.heat, commands_1.default.mode.value.auto].includes(this.mode)) {
|
|
834
|
+
this.platform.log.debug(`[${this.getDeviceLabel()}] power -> set inactive but no power off (${this.mode})`);
|
|
645
835
|
return;
|
|
646
836
|
}
|
|
647
837
|
const powerValue = value ? commands_1.default.power.value.on : commands_1.default.power.value.off;
|
|
648
|
-
const command = {
|
|
649
|
-
let logValue = '
|
|
838
|
+
const command = {};
|
|
839
|
+
let logValue = '';
|
|
840
|
+
if (value !== this.power) {
|
|
841
|
+
command[commands_1.default.power.code] = powerValue;
|
|
842
|
+
logValue += (logValue ? ', ' : '') + 'power -> ' + this.getKeyName(commands_1.default.power.value, powerValue);
|
|
843
|
+
}
|
|
650
844
|
if (powerValue === commands_1.default.power.value.on) {
|
|
651
|
-
switch ((_a = this.HeaterCooler) === null || _a === void 0 ? void 0 : _a.getCharacteristic(this.platform.Characteristic.TargetHeaterCoolerState).value)
|
|
845
|
+
switch (((_a = this.HeaterCooler) === null || _a === void 0 ? void 0 : _a.getCharacteristic(this.platform.Characteristic.TargetHeaterCoolerState).value) ||
|
|
846
|
+
this.accessory.context.TargetHeaterCoolerState) {
|
|
652
847
|
case this.platform.Characteristic.TargetHeaterCoolerState.COOL:
|
|
653
|
-
if (this.
|
|
848
|
+
if (this.mode !== commands_1.default.mode.value.cool) {
|
|
654
849
|
command[commands_1.default.mode.code] = commands_1.default.mode.value.cool;
|
|
655
|
-
logValue += ', mode -> ' + this.getKeyName(commands_1.default.mode.value, commands_1.default.mode.value.cool);
|
|
850
|
+
logValue += (logValue ? ', ' : '') + 'mode -> ' + this.getKeyName(commands_1.default.mode.value, commands_1.default.mode.value.cool);
|
|
656
851
|
if (this.deviceConfig.xFanEnabled && (this.status[commands_1.default.xFan.code] || commands_1.default.xFan.value.off) !== commands_1.default.xFan.value.on) {
|
|
657
852
|
// turn on xFan in Cool mode if xFan is enabled for this device
|
|
658
|
-
logValue += ', xFan -> ' + this.getKeyName(commands_1.default.xFan.value, commands_1.default.xFan.value.on);
|
|
853
|
+
logValue += (logValue ? ', ' : '') + 'xFan -> ' + this.getKeyName(commands_1.default.xFan.value, commands_1.default.xFan.value.on);
|
|
659
854
|
command[commands_1.default.xFan.code] = commands_1.default.xFan.value.on;
|
|
660
855
|
}
|
|
661
856
|
}
|
|
662
857
|
break;
|
|
663
858
|
case this.platform.Characteristic.TargetHeaterCoolerState.HEAT:
|
|
664
|
-
if (this.
|
|
859
|
+
if (this.mode !== commands_1.default.mode.value.heat) {
|
|
665
860
|
command[commands_1.default.mode.code] = commands_1.default.mode.value.heat;
|
|
666
|
-
logValue += ', mode -> ' + this.getKeyName(commands_1.default.mode.value, commands_1.default.mode.value.heat);
|
|
861
|
+
logValue += (logValue ? ', ' : '') + 'mode -> ' + this.getKeyName(commands_1.default.mode.value, commands_1.default.mode.value.heat);
|
|
862
|
+
if (this.deviceConfig.xFanEnabled && (this.status[commands_1.default.xFan.code] || commands_1.default.xFan.value.on) !== commands_1.default.xFan.value.off) {
|
|
863
|
+
// turn off xFan in unsupported modes (only Cool and Dry modes support xFan)
|
|
864
|
+
logValue += (logValue ? ', ' : '') + 'xFan -> ' + this.getKeyName(commands_1.default.xFan.value, commands_1.default.xFan.value.off);
|
|
865
|
+
command[commands_1.default.xFan.code] = commands_1.default.xFan.value.off;
|
|
866
|
+
}
|
|
667
867
|
}
|
|
668
868
|
break;
|
|
669
869
|
case this.platform.Characteristic.TargetHeaterCoolerState.AUTO:
|
|
670
|
-
if (this.
|
|
870
|
+
if (this.mode !== commands_1.default.mode.value.auto) {
|
|
671
871
|
command[commands_1.default.mode.code] = commands_1.default.mode.value.auto;
|
|
672
|
-
logValue += ', mode -> ' + this.getKeyName(commands_1.default.mode.value, commands_1.default.mode.value.auto);
|
|
872
|
+
logValue += (logValue ? ', ' : '') + 'mode -> ' + this.getKeyName(commands_1.default.mode.value, commands_1.default.mode.value.auto);
|
|
873
|
+
if (this.deviceConfig.xFanEnabled && (this.status[commands_1.default.xFan.code] || commands_1.default.xFan.value.on) !== commands_1.default.xFan.value.off) {
|
|
874
|
+
// turn off xFan in unsupported modes (only Cool and Dry modes support xFan)
|
|
875
|
+
logValue += (logValue ? ', ' : '') + 'xFan -> ' + this.getKeyName(commands_1.default.xFan.value, commands_1.default.xFan.value.off);
|
|
876
|
+
command[commands_1.default.xFan.code] = commands_1.default.xFan.value.off;
|
|
877
|
+
}
|
|
673
878
|
}
|
|
674
879
|
break;
|
|
675
880
|
}
|
|
881
|
+
if (this.accessory.context.HeaterCoolerRotationSpeed !== 0) {
|
|
882
|
+
// restore rotation speed on power on
|
|
883
|
+
const maxSpeed = ((_b = this.HeaterCooler) === null || _b === void 0 ? void 0 : _b.getCharacteristic(this.platform.Characteristic.RotationSpeed).props.maxValue) ||
|
|
884
|
+
this.deviceConfig.speedSteps + 3;
|
|
885
|
+
switch (this.accessory.context.HeaterCoolerRotationSpeed) {
|
|
886
|
+
case 1: // quiet
|
|
887
|
+
if ([this.platform.Characteristic.TargetHeaterCoolerState.COOL, this.platform.Characteristic.TargetHeaterCoolerState.HEAT]
|
|
888
|
+
.includes(((_c = this.HeaterCooler) === null || _c === void 0 ? void 0 : _c.getCharacteristic(this.platform.Characteristic.TargetHeaterCoolerState).value) ||
|
|
889
|
+
this.accessory.context.TargetHeaterCoolerState)) {
|
|
890
|
+
command[commands_1.default.quietMode.code] = commands_1.default.quietMode.value.on;
|
|
891
|
+
logValue += (logValue ? ', ' : '') + 'quietMode -> ' + this.getKeyName(commands_1.default.quietMode.value, commands_1.default.quietMode.value.on);
|
|
892
|
+
}
|
|
893
|
+
else {
|
|
894
|
+
command[commands_1.default.quietMode.code] = commands_1.default.quietMode.value.off;
|
|
895
|
+
logValue += (logValue ? ', ' : '') + 'quietMode -> ' +
|
|
896
|
+
this.getKeyName(commands_1.default.quietMode.value, commands_1.default.quietMode.value.off);
|
|
897
|
+
}
|
|
898
|
+
command[commands_1.default.powerfulMode.code] = commands_1.default.powerfulMode.value.off;
|
|
899
|
+
logValue += (logValue ? ', ' : '') + 'powerfulMode -> ' +
|
|
900
|
+
this.getKeyName(commands_1.default.powerfulMode.value, commands_1.default.powerfulMode.value.off);
|
|
901
|
+
command[commands_1.default.speed.code] = commands_1.default.speed.value.low;
|
|
902
|
+
logValue += (logValue ? ', ' : '') + 'speed -> ' + this.getKeyName(commands_1.default.speed.value, commands_1.default.speed.value.low);
|
|
903
|
+
break;
|
|
904
|
+
case 2: // auto
|
|
905
|
+
if (this.quietMode !== commands_1.default.quietMode.value.off || this.powerfulMode !== commands_1.default.powerfulMode.value.off) {
|
|
906
|
+
command[commands_1.default.quietMode.code] = commands_1.default.quietMode.value.off;
|
|
907
|
+
logValue += (logValue ? ', ' : '') + 'quietMode -> ' +
|
|
908
|
+
this.getKeyName(commands_1.default.quietMode.value, commands_1.default.quietMode.value.off);
|
|
909
|
+
command[commands_1.default.powerfulMode.code] = commands_1.default.powerfulMode.value.off;
|
|
910
|
+
logValue += (logValue ? ', ' : '') + 'powerfulMode -> ' +
|
|
911
|
+
this.getKeyName(commands_1.default.powerfulMode.value, commands_1.default.powerfulMode.value.off);
|
|
912
|
+
}
|
|
913
|
+
command[commands_1.default.speed.code] = commands_1.default.speed.value.auto;
|
|
914
|
+
logValue += (logValue ? ', ' : '') + 'speed -> ' + this.getKeyName(commands_1.default.speed.value, commands_1.default.speed.value.auto);
|
|
915
|
+
break;
|
|
916
|
+
case 3: // low
|
|
917
|
+
if (this.quietMode !== commands_1.default.quietMode.value.off || this.powerfulMode !== commands_1.default.powerfulMode.value.off) {
|
|
918
|
+
command[commands_1.default.quietMode.code] = commands_1.default.quietMode.value.off;
|
|
919
|
+
logValue += (logValue ? ', ' : '') + 'quietMode -> ' +
|
|
920
|
+
this.getKeyName(commands_1.default.quietMode.value, commands_1.default.quietMode.value.off);
|
|
921
|
+
command[commands_1.default.powerfulMode.code] = commands_1.default.powerfulMode.value.off;
|
|
922
|
+
logValue += (logValue ? ', ' : '') + 'powerfulMode -> ' +
|
|
923
|
+
this.getKeyName(commands_1.default.powerfulMode.value, commands_1.default.powerfulMode.value.off);
|
|
924
|
+
}
|
|
925
|
+
command[commands_1.default.speed.code] = commands_1.default.speed.value.low;
|
|
926
|
+
logValue += (logValue ? ', ' : '') + 'speed -> ' + this.getKeyName(commands_1.default.speed.value, commands_1.default.speed.value.low);
|
|
927
|
+
break;
|
|
928
|
+
case 4: // mediumLow / medium
|
|
929
|
+
if (this.quietMode !== commands_1.default.quietMode.value.off || this.powerfulMode !== commands_1.default.powerfulMode.value.off) {
|
|
930
|
+
command[commands_1.default.quietMode.code] = commands_1.default.quietMode.value.off;
|
|
931
|
+
logValue += (logValue ? ', ' : '') + 'quietMode -> ' +
|
|
932
|
+
this.getKeyName(commands_1.default.quietMode.value, commands_1.default.quietMode.value.off);
|
|
933
|
+
command[commands_1.default.powerfulMode.code] = commands_1.default.powerfulMode.value.off;
|
|
934
|
+
logValue += (logValue ? ', ' : '') + 'powerfulMode -> ' +
|
|
935
|
+
this.getKeyName(commands_1.default.powerfulMode.value, commands_1.default.powerfulMode.value.off);
|
|
936
|
+
}
|
|
937
|
+
command[commands_1.default.speed.code] = maxSpeed === 8 ? commands_1.default.speed.value.mediumLow : commands_1.default.speed.value.medium;
|
|
938
|
+
logValue += (logValue ? ', ' : '') + 'speed -> ' + this.getKeyName(commands_1.default.speed.value, command[commands_1.default.speed.code]);
|
|
939
|
+
break;
|
|
940
|
+
case 5: // medium / high
|
|
941
|
+
if (this.quietMode !== commands_1.default.quietMode.value.off || this.powerfulMode !== commands_1.default.powerfulMode.value.off) {
|
|
942
|
+
command[commands_1.default.quietMode.code] = commands_1.default.quietMode.value.off;
|
|
943
|
+
logValue += (logValue ? ', ' : '') + 'quietMode -> ' +
|
|
944
|
+
this.getKeyName(commands_1.default.quietMode.value, commands_1.default.quietMode.value.off);
|
|
945
|
+
command[commands_1.default.powerfulMode.code] = commands_1.default.powerfulMode.value.off;
|
|
946
|
+
logValue += (logValue ? ', ' : '') + 'powerfulMode -> ' +
|
|
947
|
+
this.getKeyName(commands_1.default.powerfulMode.value, commands_1.default.powerfulMode.value.off);
|
|
948
|
+
}
|
|
949
|
+
command[commands_1.default.speed.code] = maxSpeed === 8 ? commands_1.default.speed.value.medium : commands_1.default.speed.value.high;
|
|
950
|
+
logValue += (logValue ? ', ' : '') + 'speed -> ' + this.getKeyName(commands_1.default.speed.value, command[commands_1.default.speed.code]);
|
|
951
|
+
break;
|
|
952
|
+
case 6: // mediumHigh / powerful
|
|
953
|
+
if (maxSpeed === 8) {
|
|
954
|
+
if (this.quietMode !== commands_1.default.quietMode.value.off || this.powerfulMode !== commands_1.default.powerfulMode.value.off) {
|
|
955
|
+
command[commands_1.default.quietMode.code] = commands_1.default.quietMode.value.off;
|
|
956
|
+
logValue += (logValue ? ', ' : '') + 'quietMode -> ' +
|
|
957
|
+
this.getKeyName(commands_1.default.quietMode.value, commands_1.default.quietMode.value.off);
|
|
958
|
+
command[commands_1.default.powerfulMode.code] = commands_1.default.powerfulMode.value.off;
|
|
959
|
+
logValue += (logValue ? ', ' : '') + 'powerfulMode -> ' +
|
|
960
|
+
this.getKeyName(commands_1.default.powerfulMode.value, commands_1.default.powerfulMode.value.off);
|
|
961
|
+
}
|
|
962
|
+
command[commands_1.default.speed.code] = commands_1.default.speed.value.mediumHigh;
|
|
963
|
+
logValue += (logValue ? ', ' : '') + 'speed -> ' + this.getKeyName(commands_1.default.speed.value, commands_1.default.speed.value.mediumHigh);
|
|
964
|
+
}
|
|
965
|
+
else {
|
|
966
|
+
command[commands_1.default.quietMode.code] = commands_1.default.quietMode.value.off;
|
|
967
|
+
logValue += (logValue ? ', ' : '') + 'quietMode -> ' +
|
|
968
|
+
this.getKeyName(commands_1.default.quietMode.value, commands_1.default.quietMode.value.off);
|
|
969
|
+
if ([this.platform.Characteristic.TargetHeaterCoolerState.COOL, this.platform.Characteristic.TargetHeaterCoolerState.HEAT]
|
|
970
|
+
.includes(((_d = this.HeaterCooler) === null || _d === void 0 ? void 0 : _d.getCharacteristic(this.platform.Characteristic.TargetHeaterCoolerState).value) ||
|
|
971
|
+
this.accessory.context.TargetHeaterCoolerState)) {
|
|
972
|
+
command[commands_1.default.powerfulMode.code] = commands_1.default.powerfulMode.value.on;
|
|
973
|
+
logValue += (logValue ? ', ' : '') + 'powerfulMode -> ' +
|
|
974
|
+
this.getKeyName(commands_1.default.powerfulMode.value, commands_1.default.powerfulMode.value.on);
|
|
975
|
+
}
|
|
976
|
+
else {
|
|
977
|
+
command[commands_1.default.powerfulMode.code] = commands_1.default.powerfulMode.value.off;
|
|
978
|
+
logValue += (logValue ? ', ' : '') + 'powerfulMode -> ' +
|
|
979
|
+
this.getKeyName(commands_1.default.powerfulMode.value, commands_1.default.powerfulMode.value.off);
|
|
980
|
+
}
|
|
981
|
+
command[commands_1.default.speed.code] = commands_1.default.speed.value.high;
|
|
982
|
+
logValue += (logValue ? ', ' : '') + 'speed -> ' + this.getKeyName(commands_1.default.speed.value, commands_1.default.speed.value.high);
|
|
983
|
+
}
|
|
984
|
+
break;
|
|
985
|
+
case 7: // high
|
|
986
|
+
if (this.quietMode !== commands_1.default.quietMode.value.off || this.powerfulMode !== commands_1.default.powerfulMode.value.off) {
|
|
987
|
+
command[commands_1.default.quietMode.code] = commands_1.default.quietMode.value.off;
|
|
988
|
+
logValue += (logValue ? ', ' : '') + 'quietMode -> ' +
|
|
989
|
+
this.getKeyName(commands_1.default.quietMode.value, commands_1.default.quietMode.value.off);
|
|
990
|
+
command[commands_1.default.powerfulMode.code] = commands_1.default.powerfulMode.value.off;
|
|
991
|
+
logValue += (logValue ? ', ' : '') + 'powerfulMode -> ' +
|
|
992
|
+
this.getKeyName(commands_1.default.powerfulMode.value, commands_1.default.powerfulMode.value.off);
|
|
993
|
+
}
|
|
994
|
+
command[commands_1.default.speed.code] = commands_1.default.speed.value.high;
|
|
995
|
+
logValue += (logValue ? ', ' : '') + 'speed -> ' + this.getKeyName(commands_1.default.speed.value, commands_1.default.speed.value.high);
|
|
996
|
+
break;
|
|
997
|
+
case 8: // powerful
|
|
998
|
+
command[commands_1.default.quietMode.code] = commands_1.default.quietMode.value.off;
|
|
999
|
+
logValue += (logValue ? ', ' : '') + 'quietMode -> ' +
|
|
1000
|
+
this.getKeyName(commands_1.default.quietMode.value, commands_1.default.quietMode.value.off);
|
|
1001
|
+
if ([this.platform.Characteristic.TargetHeaterCoolerState.COOL, this.platform.Characteristic.TargetHeaterCoolerState.HEAT]
|
|
1002
|
+
.includes(((_e = this.HeaterCooler) === null || _e === void 0 ? void 0 : _e.getCharacteristic(this.platform.Characteristic.TargetHeaterCoolerState).value) ||
|
|
1003
|
+
this.accessory.context.TargetHeaterCoolerState)) {
|
|
1004
|
+
command[commands_1.default.powerfulMode.code] = commands_1.default.powerfulMode.value.on;
|
|
1005
|
+
logValue += (logValue ? ', ' : '') + 'powerfulMode -> ' +
|
|
1006
|
+
this.getKeyName(commands_1.default.powerfulMode.value, commands_1.default.powerfulMode.value.on);
|
|
1007
|
+
}
|
|
1008
|
+
else {
|
|
1009
|
+
command[commands_1.default.powerfulMode.code] = commands_1.default.powerfulMode.value.off;
|
|
1010
|
+
logValue += (logValue ? ', ' : '') + 'powerfulMode -> ' +
|
|
1011
|
+
this.getKeyName(commands_1.default.powerfulMode.value, commands_1.default.powerfulMode.value.off);
|
|
1012
|
+
}
|
|
1013
|
+
command[commands_1.default.speed.code] = commands_1.default.speed.value.high;
|
|
1014
|
+
logValue += (logValue ? ', ' : '') + 'speed -> ' + this.getKeyName(commands_1.default.speed.value, commands_1.default.speed.value.high);
|
|
1015
|
+
break;
|
|
1016
|
+
}
|
|
1017
|
+
}
|
|
676
1018
|
if ([settings_1.OVERRIDE_DEFAULT_SWING.always, settings_1.OVERRIDE_DEFAULT_SWING.powerOn].includes(this.deviceConfig.overrideDefaultVerticalSwing ||
|
|
677
|
-
settings_1.
|
|
678
|
-
const value =
|
|
1019
|
+
settings_1.DEFAULT_DEVICE_CONFIG.overrideDefaultVerticalSwing) && this.swingMode === commands_1.default.swingVertical.value.default) {
|
|
1020
|
+
const value = this.deviceConfig.defaultVerticalSwing || settings_1.DEFAULT_DEVICE_CONFIG.defaultVerticalSwing;
|
|
679
1021
|
command[commands_1.default.swingVertical.code] = value;
|
|
680
|
-
logValue += ', swingVertical -> ' + this.getKeyName(commands_1.default.swingVertical.value, value);
|
|
1022
|
+
logValue += (logValue ? ', ' : '') + 'swingVertical -> ' + this.getKeyName(commands_1.default.swingVertical.value, value);
|
|
681
1023
|
}
|
|
682
1024
|
}
|
|
683
1025
|
this.platform.log.info(`[${this.getDeviceLabel()}]`, logValue);
|
|
684
1026
|
this.sendCommand(command);
|
|
685
1027
|
}
|
|
1028
|
+
set fanpower(value) {
|
|
1029
|
+
if (this.powerPending !== -1 || this.modePending !== -1) {
|
|
1030
|
+
this.platform.log.debug(`[${this.getDeviceLabel()}] fanpower -> no change (${this.powerPending}, ${this.modePending})`);
|
|
1031
|
+
return;
|
|
1032
|
+
}
|
|
1033
|
+
if (!value && this.mode !== commands_1.default.mode.value.fan) {
|
|
1034
|
+
this.platform.log.debug(`[${this.getDeviceLabel()}] fanpower -> set inactive but no power off (${this.mode})`);
|
|
1035
|
+
return;
|
|
1036
|
+
}
|
|
1037
|
+
const powerValue = value ? commands_1.default.power.value.on : commands_1.default.power.value.off;
|
|
1038
|
+
const command = {};
|
|
1039
|
+
let logValue = '';
|
|
1040
|
+
if (value !== this.power) {
|
|
1041
|
+
command[commands_1.default.power.code] = powerValue;
|
|
1042
|
+
logValue += (logValue ? ', ' : '') + 'power -> ' + this.getKeyName(commands_1.default.power.value, powerValue);
|
|
1043
|
+
}
|
|
1044
|
+
if (powerValue === commands_1.default.power.value.on && this.mode !== commands_1.default.mode.value.fan) {
|
|
1045
|
+
command[commands_1.default.mode.code] = commands_1.default.mode.value.fan;
|
|
1046
|
+
logValue += (logValue ? ', ' : '') + 'mode -> ' + this.getKeyName(commands_1.default.mode.value, commands_1.default.mode.value.fan);
|
|
1047
|
+
}
|
|
1048
|
+
if (logValue) {
|
|
1049
|
+
if (powerValue === commands_1.default.power.value.on) {
|
|
1050
|
+
command[commands_1.default.quietMode.code] = commands_1.default.quietMode.value.off;
|
|
1051
|
+
logValue += (logValue ? ', ' : '') + 'quietMode -> ' + this.getKeyName(commands_1.default.quietMode.value, commands_1.default.quietMode.value.off);
|
|
1052
|
+
command[commands_1.default.powerfulMode.code] = commands_1.default.powerfulMode.value.off;
|
|
1053
|
+
logValue += (logValue ? ', ' : '') + 'powerfulMode -> ' +
|
|
1054
|
+
this.getKeyName(commands_1.default.powerfulMode.value, commands_1.default.powerfulMode.value.off);
|
|
1055
|
+
if ([settings_1.OVERRIDE_DEFAULT_SWING.always, settings_1.OVERRIDE_DEFAULT_SWING.powerOn].includes(this.deviceConfig.overrideDefaultVerticalSwing ||
|
|
1056
|
+
settings_1.DEFAULT_DEVICE_CONFIG.overrideDefaultVerticalSwing) && this.swingMode === commands_1.default.swingVertical.value.default) {
|
|
1057
|
+
const value = this.deviceConfig.defaultVerticalSwing || settings_1.DEFAULT_DEVICE_CONFIG.defaultVerticalSwing;
|
|
1058
|
+
command[commands_1.default.swingVertical.code] = value;
|
|
1059
|
+
logValue += (logValue ? ', ' : '') + 'swingVertical -> ' + this.getKeyName(commands_1.default.swingVertical.value, value);
|
|
1060
|
+
}
|
|
1061
|
+
}
|
|
1062
|
+
this.platform.log.info(`[${this.getDeviceLabel()}]`, logValue);
|
|
1063
|
+
this.sendCommand(command);
|
|
1064
|
+
}
|
|
1065
|
+
}
|
|
686
1066
|
get mode() {
|
|
687
1067
|
return this.status[commands_1.default.mode.code] || commands_1.default.mode.value.auto;
|
|
688
1068
|
}
|
|
689
1069
|
set mode(value) {
|
|
690
|
-
|
|
1070
|
+
var _a;
|
|
1071
|
+
if (value === this.mode || this.modePending !== -1) {
|
|
1072
|
+
this.platform.log.debug(`[${this.getDeviceLabel()}] mode -> no change (${value}, ${this.modePending})`);
|
|
691
1073
|
return;
|
|
692
1074
|
}
|
|
693
1075
|
let logValue = 'mode -> ' + this.getKeyName(commands_1.default.mode.value, value);
|
|
694
1076
|
const command = { [commands_1.default.mode.code]: value };
|
|
695
1077
|
if (this.deviceConfig.xFanEnabled && (this.status[commands_1.default.xFan.code] || commands_1.default.xFan.value.off) !== commands_1.default.xFan.value.on &&
|
|
696
|
-
|
|
1078
|
+
[commands_1.default.mode.value.cool, commands_1.default.mode.value.dry].includes(value)) {
|
|
697
1079
|
// turn on xFan in Cool and Dry mode if xFan is enabled for this device
|
|
698
1080
|
logValue += ', xFan -> ' + this.getKeyName(commands_1.default.xFan.value, commands_1.default.xFan.value.on);
|
|
699
1081
|
command[commands_1.default.xFan.code] = commands_1.default.xFan.value.on;
|
|
700
1082
|
}
|
|
701
|
-
if (
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
1083
|
+
else if (this.deviceConfig.xFanEnabled && (this.status[commands_1.default.xFan.code] || commands_1.default.xFan.value.on) !== commands_1.default.xFan.value.off &&
|
|
1084
|
+
![commands_1.default.mode.value.cool, commands_1.default.mode.value.dry].includes(value)) {
|
|
1085
|
+
// turn off xFan in unsupported modes (only Cool and Dry modes support xFan)
|
|
1086
|
+
logValue += ', xFan -> ' + this.getKeyName(commands_1.default.xFan.value, commands_1.default.xFan.value.off);
|
|
1087
|
+
command[commands_1.default.xFan.code] = commands_1.default.xFan.value.off;
|
|
1088
|
+
}
|
|
1089
|
+
if (this.accessory.context.HeaterCoolerRotationSpeed !== 0 &&
|
|
1090
|
+
[commands_1.default.mode.value.cool, commands_1.default.mode.value.heat, commands_1.default.mode.value.auto].includes(value)) {
|
|
1091
|
+
// restore rotation speed on mode change
|
|
1092
|
+
const maxSpeed = ((_a = this.HeaterCooler) === null || _a === void 0 ? void 0 : _a.getCharacteristic(this.platform.Characteristic.RotationSpeed).props.maxValue) ||
|
|
1093
|
+
this.deviceConfig.speedSteps + 3;
|
|
1094
|
+
switch (this.accessory.context.HeaterCoolerRotationSpeed) {
|
|
1095
|
+
case 1: // quiet
|
|
1096
|
+
command[commands_1.default.quietMode.code] = value === commands_1.default.mode.value.auto ? commands_1.default.quietMode.value.off :
|
|
1097
|
+
commands_1.default.quietMode.value.on;
|
|
1098
|
+
logValue += (logValue ? ', ' : '') + 'quietMode -> ' + this.getKeyName(commands_1.default.quietMode.value, value === commands_1.default.mode.value.auto ? commands_1.default.quietMode.value.off : commands_1.default.quietMode.value.on);
|
|
1099
|
+
command[commands_1.default.powerfulMode.code] = commands_1.default.powerfulMode.value.off;
|
|
1100
|
+
logValue += (logValue ? ', ' : '') + 'powerfulMode -> ' +
|
|
1101
|
+
this.getKeyName(commands_1.default.powerfulMode.value, commands_1.default.powerfulMode.value.off);
|
|
1102
|
+
command[commands_1.default.speed.code] = commands_1.default.speed.value.low;
|
|
1103
|
+
logValue += (logValue ? ', ' : '') + 'speed -> ' + this.getKeyName(commands_1.default.speed.value, commands_1.default.speed.value.low);
|
|
1104
|
+
break;
|
|
1105
|
+
case 2: // auto
|
|
1106
|
+
if (this.quietMode !== commands_1.default.quietMode.value.off || this.powerfulMode !== commands_1.default.powerfulMode.value.off) {
|
|
1107
|
+
command[commands_1.default.quietMode.code] = commands_1.default.quietMode.value.off;
|
|
1108
|
+
logValue += (logValue ? ', ' : '') + 'quietMode -> ' +
|
|
1109
|
+
this.getKeyName(commands_1.default.quietMode.value, commands_1.default.quietMode.value.off);
|
|
1110
|
+
command[commands_1.default.powerfulMode.code] = commands_1.default.powerfulMode.value.off;
|
|
1111
|
+
logValue += (logValue ? ', ' : '') + 'powerfulMode -> ' +
|
|
1112
|
+
this.getKeyName(commands_1.default.powerfulMode.value, commands_1.default.powerfulMode.value.off);
|
|
1113
|
+
}
|
|
1114
|
+
command[commands_1.default.speed.code] = commands_1.default.speed.value.auto;
|
|
1115
|
+
logValue += (logValue ? ', ' : '') + 'speed -> ' + this.getKeyName(commands_1.default.speed.value, commands_1.default.speed.value.auto);
|
|
1116
|
+
break;
|
|
1117
|
+
case 3: // low
|
|
1118
|
+
if (this.quietMode !== commands_1.default.quietMode.value.off || this.powerfulMode !== commands_1.default.powerfulMode.value.off) {
|
|
1119
|
+
command[commands_1.default.quietMode.code] = commands_1.default.quietMode.value.off;
|
|
1120
|
+
logValue += (logValue ? ', ' : '') + 'quietMode -> ' +
|
|
1121
|
+
this.getKeyName(commands_1.default.quietMode.value, commands_1.default.quietMode.value.off);
|
|
1122
|
+
command[commands_1.default.powerfulMode.code] = commands_1.default.powerfulMode.value.off;
|
|
1123
|
+
logValue += (logValue ? ', ' : '') + 'powerfulMode -> ' +
|
|
1124
|
+
this.getKeyName(commands_1.default.powerfulMode.value, commands_1.default.powerfulMode.value.off);
|
|
1125
|
+
}
|
|
1126
|
+
command[commands_1.default.speed.code] = commands_1.default.speed.value.low;
|
|
1127
|
+
logValue += (logValue ? ', ' : '') + 'speed -> ' + this.getKeyName(commands_1.default.speed.value, commands_1.default.speed.value.low);
|
|
1128
|
+
break;
|
|
1129
|
+
case 4: // mediumLow / medium
|
|
1130
|
+
if (this.quietMode !== commands_1.default.quietMode.value.off || this.powerfulMode !== commands_1.default.powerfulMode.value.off) {
|
|
1131
|
+
command[commands_1.default.quietMode.code] = commands_1.default.quietMode.value.off;
|
|
1132
|
+
logValue += (logValue ? ', ' : '') + 'quietMode -> ' +
|
|
1133
|
+
this.getKeyName(commands_1.default.quietMode.value, commands_1.default.quietMode.value.off);
|
|
1134
|
+
command[commands_1.default.powerfulMode.code] = commands_1.default.powerfulMode.value.off;
|
|
1135
|
+
logValue += (logValue ? ', ' : '') + 'powerfulMode -> ' +
|
|
1136
|
+
this.getKeyName(commands_1.default.powerfulMode.value, commands_1.default.powerfulMode.value.off);
|
|
1137
|
+
}
|
|
1138
|
+
command[commands_1.default.speed.code] = maxSpeed === 8 ? commands_1.default.speed.value.mediumLow : commands_1.default.speed.value.medium;
|
|
1139
|
+
logValue += (logValue ? ', ' : '') + 'speed -> ' + this.getKeyName(commands_1.default.speed.value, command[commands_1.default.speed.code]);
|
|
1140
|
+
break;
|
|
1141
|
+
case 5: // medium / high
|
|
1142
|
+
if (this.quietMode !== commands_1.default.quietMode.value.off || this.powerfulMode !== commands_1.default.powerfulMode.value.off) {
|
|
1143
|
+
command[commands_1.default.quietMode.code] = commands_1.default.quietMode.value.off;
|
|
1144
|
+
logValue += (logValue ? ', ' : '') + 'quietMode -> ' +
|
|
1145
|
+
this.getKeyName(commands_1.default.quietMode.value, commands_1.default.quietMode.value.off);
|
|
1146
|
+
command[commands_1.default.powerfulMode.code] = commands_1.default.powerfulMode.value.off;
|
|
1147
|
+
logValue += (logValue ? ', ' : '') + 'powerfulMode -> ' +
|
|
1148
|
+
this.getKeyName(commands_1.default.powerfulMode.value, commands_1.default.powerfulMode.value.off);
|
|
1149
|
+
}
|
|
1150
|
+
command[commands_1.default.speed.code] = maxSpeed === 8 ? commands_1.default.speed.value.medium : commands_1.default.speed.value.high;
|
|
1151
|
+
logValue += (logValue ? ', ' : '') + 'speed -> ' + this.getKeyName(commands_1.default.speed.value, command[commands_1.default.speed.code]);
|
|
1152
|
+
break;
|
|
1153
|
+
case 6: // mediumHigh / powerful
|
|
1154
|
+
if (maxSpeed === 8) {
|
|
1155
|
+
if (this.quietMode !== commands_1.default.quietMode.value.off || this.powerfulMode !== commands_1.default.powerfulMode.value.off) {
|
|
1156
|
+
command[commands_1.default.quietMode.code] = commands_1.default.quietMode.value.off;
|
|
1157
|
+
logValue += (logValue ? ', ' : '') + 'quietMode -> ' +
|
|
1158
|
+
this.getKeyName(commands_1.default.quietMode.value, commands_1.default.quietMode.value.off);
|
|
1159
|
+
command[commands_1.default.powerfulMode.code] = commands_1.default.powerfulMode.value.off;
|
|
1160
|
+
logValue += (logValue ? ', ' : '') + 'powerfulMode -> ' +
|
|
1161
|
+
this.getKeyName(commands_1.default.powerfulMode.value, commands_1.default.powerfulMode.value.off);
|
|
1162
|
+
}
|
|
1163
|
+
command[commands_1.default.speed.code] = commands_1.default.speed.value.mediumHigh;
|
|
1164
|
+
logValue += (logValue ? ', ' : '') + 'speed -> ' + this.getKeyName(commands_1.default.speed.value, commands_1.default.speed.value.mediumHigh);
|
|
1165
|
+
}
|
|
1166
|
+
else {
|
|
1167
|
+
command[commands_1.default.quietMode.code] = commands_1.default.quietMode.value.off;
|
|
1168
|
+
logValue += (logValue ? ', ' : '') + 'quietMode -> ' +
|
|
1169
|
+
this.getKeyName(commands_1.default.quietMode.value, commands_1.default.quietMode.value.off);
|
|
1170
|
+
command[commands_1.default.powerfulMode.code] = value === commands_1.default.mode.value.auto ? commands_1.default.powerfulMode.value.off :
|
|
1171
|
+
commands_1.default.powerfulMode.value.on;
|
|
1172
|
+
logValue += (logValue ? ', ' : '') + 'powerfulMode -> ' +
|
|
1173
|
+
this.getKeyName(commands_1.default.powerfulMode.value, value === commands_1.default.mode.value.auto ? commands_1.default.powerfulMode.value.off :
|
|
1174
|
+
commands_1.default.powerfulMode.value.on);
|
|
1175
|
+
command[commands_1.default.speed.code] = commands_1.default.speed.value.high;
|
|
1176
|
+
logValue += (logValue ? ', ' : '') + 'speed -> ' + this.getKeyName(commands_1.default.speed.value, commands_1.default.speed.value.high);
|
|
1177
|
+
}
|
|
1178
|
+
break;
|
|
1179
|
+
case 7: // high
|
|
1180
|
+
if (this.quietMode !== commands_1.default.quietMode.value.off || this.powerfulMode !== commands_1.default.powerfulMode.value.off) {
|
|
1181
|
+
command[commands_1.default.quietMode.code] = commands_1.default.quietMode.value.off;
|
|
1182
|
+
logValue += (logValue ? ', ' : '') + 'quietMode -> ' +
|
|
1183
|
+
this.getKeyName(commands_1.default.quietMode.value, commands_1.default.quietMode.value.off);
|
|
1184
|
+
command[commands_1.default.powerfulMode.code] = commands_1.default.powerfulMode.value.off;
|
|
1185
|
+
logValue += (logValue ? ', ' : '') + 'powerfulMode -> ' +
|
|
1186
|
+
this.getKeyName(commands_1.default.powerfulMode.value, commands_1.default.powerfulMode.value.off);
|
|
1187
|
+
}
|
|
1188
|
+
command[commands_1.default.speed.code] = commands_1.default.speed.value.high;
|
|
1189
|
+
logValue += (logValue ? ', ' : '') + 'speed -> ' + this.getKeyName(commands_1.default.speed.value, commands_1.default.speed.value.high);
|
|
1190
|
+
break;
|
|
1191
|
+
case 8: // powerful
|
|
1192
|
+
if ([commands_1.default.mode.value.cool, commands_1.default.mode.value.heat].includes(value)) {
|
|
1193
|
+
command[commands_1.default.quietMode.code] = commands_1.default.quietMode.value.off;
|
|
1194
|
+
logValue += (logValue ? ', ' : '') + 'quietMode -> ' +
|
|
1195
|
+
this.getKeyName(commands_1.default.quietMode.value, commands_1.default.quietMode.value.off);
|
|
1196
|
+
command[commands_1.default.powerfulMode.code] = value === commands_1.default.mode.value.auto ? commands_1.default.powerfulMode.value.off :
|
|
1197
|
+
commands_1.default.powerfulMode.value.on;
|
|
1198
|
+
logValue += (logValue ? ', ' : '') + 'powerfulMode -> ' +
|
|
1199
|
+
this.getKeyName(commands_1.default.powerfulMode.value, value === commands_1.default.mode.value.auto ? commands_1.default.powerfulMode.value.off :
|
|
1200
|
+
commands_1.default.powerfulMode.value.on);
|
|
1201
|
+
}
|
|
1202
|
+
command[commands_1.default.speed.code] = commands_1.default.speed.value.high;
|
|
1203
|
+
logValue += (logValue ? ', ' : '') + 'speed -> ' + this.getKeyName(commands_1.default.speed.value, commands_1.default.speed.value.high);
|
|
1204
|
+
break;
|
|
1205
|
+
}
|
|
706
1206
|
}
|
|
707
1207
|
this.platform.log.info(`[${this.getDeviceLabel()}]`, logValue);
|
|
708
1208
|
this.sendCommand(command);
|
|
@@ -714,7 +1214,7 @@ class GreeAirConditioner {
|
|
|
714
1214
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
715
1215
|
let minValue = this.deviceConfig.minimumTargetTemperature;
|
|
716
1216
|
let maxValue = this.deviceConfig.maximumTargetTemperature;
|
|
717
|
-
switch (this.
|
|
1217
|
+
switch (this.mode) {
|
|
718
1218
|
case commands_1.default.mode.value.cool:
|
|
719
1219
|
minValue = Math.max(this.deviceConfig.minimumTargetTemperature, ((_a = this.HeaterCooler) === null || _a === void 0 ? void 0 : _a.getCharacteristic(this.platform.Characteristic.CoolingThresholdTemperature).props.minValue) || 10);
|
|
720
1220
|
maxValue = Math.min(this.deviceConfig.maximumTargetTemperature, ((_b = this.HeaterCooler) === null || _b === void 0 ? void 0 : _b.getCharacteristic(this.platform.Characteristic.CoolingThresholdTemperature).props.maxValue) || 35);
|
|
@@ -732,6 +1232,7 @@ class GreeAirConditioner {
|
|
|
732
1232
|
set targetTemperature(value) {
|
|
733
1233
|
var _a;
|
|
734
1234
|
if (value === this.targetTemperature) {
|
|
1235
|
+
this.platform.log.debug(`[${this.getDeviceLabel()}] targetTemperature -> no change (${value})`);
|
|
735
1236
|
return;
|
|
736
1237
|
}
|
|
737
1238
|
const tempValue = this.calcDeviceTargetTemp(value);
|
|
@@ -761,6 +1262,7 @@ class GreeAirConditioner {
|
|
|
761
1262
|
}
|
|
762
1263
|
set units(value) {
|
|
763
1264
|
if (value === this.units) {
|
|
1265
|
+
this.platform.log.debug(`[${this.getDeviceLabel()}] units -> no change (${value})`);
|
|
764
1266
|
return;
|
|
765
1267
|
}
|
|
766
1268
|
const command = { [commands_1.default.units.code]: value };
|
|
@@ -785,6 +1287,7 @@ class GreeAirConditioner {
|
|
|
785
1287
|
}
|
|
786
1288
|
set swingMode(value) {
|
|
787
1289
|
if (value === this.swingMode) {
|
|
1290
|
+
this.platform.log.debug(`[${this.getDeviceLabel()}] swingMode -> no change (${value})`);
|
|
788
1291
|
return;
|
|
789
1292
|
}
|
|
790
1293
|
const command = { [commands_1.default.swingVertical.code]: value };
|
|
@@ -795,7 +1298,8 @@ class GreeAirConditioner {
|
|
|
795
1298
|
return this.status[commands_1.default.speed.code] || commands_1.default.speed.value.auto;
|
|
796
1299
|
}
|
|
797
1300
|
set speed(value) {
|
|
798
|
-
if (value === this.speed) {
|
|
1301
|
+
if (value === this.speed && this.quietMode === commands_1.default.quietMode.value.off && this.powerfulMode === commands_1.default.powerfulMode.value.off) {
|
|
1302
|
+
this.platform.log.debug(`[${this.getDeviceLabel()}] speed -> no change (${value}, ${this.quietMode}, ${this.powerfulMode})`);
|
|
799
1303
|
return;
|
|
800
1304
|
}
|
|
801
1305
|
const command = { [commands_1.default.speed.code]: value };
|
|
@@ -810,54 +1314,78 @@ class GreeAirConditioner {
|
|
|
810
1314
|
return this.status[commands_1.default.quietMode.code] || commands_1.default.quietMode.value.off;
|
|
811
1315
|
}
|
|
812
1316
|
set quietMode(value) {
|
|
813
|
-
|
|
1317
|
+
var _a;
|
|
1318
|
+
if (value === this.quietMode || value !== commands_1.default.quietMode.value.on) {
|
|
1319
|
+
this.platform.log.debug(`[${this.getDeviceLabel()}] quietMode -> not turning on (${value})`);
|
|
814
1320
|
return;
|
|
815
1321
|
}
|
|
816
|
-
|
|
817
|
-
|
|
1322
|
+
let logValue = '';
|
|
1323
|
+
const command = {};
|
|
1324
|
+
if ([this.platform.Characteristic.TargetHeaterCoolerState.COOL, this.platform.Characteristic.TargetHeaterCoolerState.HEAT]
|
|
1325
|
+
.includes(((_a = this.HeaterCooler) === null || _a === void 0 ? void 0 : _a.getCharacteristic(this.platform.Characteristic.TargetHeaterCoolerState).value) ||
|
|
1326
|
+
this.accessory.context.TargetHeaterCoolerState)) {
|
|
1327
|
+
command[commands_1.default.quietMode.code] = value;
|
|
1328
|
+
logValue += 'quietMode -> ' + this.getKeyName(commands_1.default.quietMode.value, value);
|
|
1329
|
+
}
|
|
1330
|
+
else {
|
|
1331
|
+
// quiet mode is supported only in heating and cooling mode
|
|
1332
|
+
command[commands_1.default.quietMode.code] = commands_1.default.quietMode.value.off;
|
|
1333
|
+
logValue += 'quietMode -> ' + this.getKeyName(commands_1.default.quietMode.value, commands_1.default.quietMode.value.off);
|
|
1334
|
+
}
|
|
818
1335
|
if (value === commands_1.default.quietMode.value.on) {
|
|
819
1336
|
command[commands_1.default.powerfulMode.code] = commands_1.default.powerfulMode.value.off;
|
|
820
1337
|
logValue += ', powerfulMode -> ' + this.getKeyName(commands_1.default.powerfulMode.value, commands_1.default.powerfulMode.value.off);
|
|
821
1338
|
command[commands_1.default.speed.code] = commands_1.default.speed.value.low;
|
|
822
1339
|
logValue += ', speed -> ' + this.getKeyName(commands_1.default.speed.value, commands_1.default.speed.value.low);
|
|
1340
|
+
this.platform.log.info(`[${this.getDeviceLabel()}]`, logValue);
|
|
1341
|
+
this.sendCommand(command);
|
|
823
1342
|
}
|
|
824
|
-
else {
|
|
825
|
-
command[commands_1.default.speed.code] = commands_1.default.speed.value.auto;
|
|
826
|
-
logValue += ', speed -> ' + this.getKeyName(commands_1.default.speed.value, commands_1.default.speed.value.auto);
|
|
827
|
-
}
|
|
828
|
-
this.platform.log.info(`[${this.getDeviceLabel()}]`, logValue);
|
|
829
|
-
this.sendCommand(command);
|
|
830
1343
|
}
|
|
831
1344
|
get powerfulMode() {
|
|
832
1345
|
return this.status[commands_1.default.powerfulMode.code] || commands_1.default.powerfulMode.value.off;
|
|
833
1346
|
}
|
|
834
1347
|
set powerfulMode(value) {
|
|
835
|
-
|
|
1348
|
+
var _a;
|
|
1349
|
+
if (value === this.powerfulMode || value !== commands_1.default.powerfulMode.value.on) {
|
|
1350
|
+
this.platform.log.debug(`[${this.getDeviceLabel()}] powerfulMode -> not turning on (${value})`);
|
|
836
1351
|
return;
|
|
837
1352
|
}
|
|
838
|
-
let logValue = '
|
|
839
|
-
const command = {
|
|
1353
|
+
let logValue = '';
|
|
1354
|
+
const command = {};
|
|
1355
|
+
if ([this.platform.Characteristic.TargetHeaterCoolerState.COOL, this.platform.Characteristic.TargetHeaterCoolerState.HEAT]
|
|
1356
|
+
.includes(((_a = this.HeaterCooler) === null || _a === void 0 ? void 0 : _a.getCharacteristic(this.platform.Characteristic.TargetHeaterCoolerState).value) ||
|
|
1357
|
+
this.accessory.context.TargetHeaterCoolerState)) {
|
|
1358
|
+
command[commands_1.default.powerfulMode.code] = value;
|
|
1359
|
+
logValue += 'powerfulMode -> ' + this.getKeyName(commands_1.default.powerfulMode.value, value);
|
|
1360
|
+
}
|
|
1361
|
+
else {
|
|
1362
|
+
// powerful mode is supported only in heating and cooling mode
|
|
1363
|
+
command[commands_1.default.powerfulMode.code] = commands_1.default.powerfulMode.value.off;
|
|
1364
|
+
logValue += 'powerfulMode -> ' + this.getKeyName(commands_1.default.powerfulMode.value, commands_1.default.powerfulMode.value.off);
|
|
1365
|
+
}
|
|
840
1366
|
if (value === commands_1.default.powerfulMode.value.on) {
|
|
841
1367
|
command[commands_1.default.quietMode.code] = commands_1.default.quietMode.value.off;
|
|
842
1368
|
logValue += ', quietMode -> ' + this.getKeyName(commands_1.default.quietMode.value, commands_1.default.quietMode.value.off);
|
|
843
1369
|
command[commands_1.default.speed.code] = commands_1.default.speed.value.high;
|
|
844
1370
|
logValue += ', speed -> ' + this.getKeyName(commands_1.default.speed.value, commands_1.default.speed.value.high);
|
|
1371
|
+
this.platform.log.info(`[${this.getDeviceLabel()}]`, logValue);
|
|
1372
|
+
this.sendCommand(command);
|
|
845
1373
|
}
|
|
846
|
-
else {
|
|
847
|
-
command[commands_1.default.speed.code] = commands_1.default.speed.value.auto;
|
|
848
|
-
logValue += ', speed -> ' + this.getKeyName(commands_1.default.speed.value, commands_1.default.speed.value.auto);
|
|
849
|
-
}
|
|
850
|
-
this.platform.log.info(`[${this.getDeviceLabel()}]`, logValue);
|
|
851
|
-
this.sendCommand(command);
|
|
852
1374
|
}
|
|
853
1375
|
updateStatus(props) {
|
|
854
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y;
|
|
1376
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3;
|
|
855
1377
|
this.platform.log.debug(`[${this.getDeviceLabel()}] updateStatus -> %j`, props);
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
1378
|
+
const hcActive = this.power && [commands_1.default.mode.value.cool, commands_1.default.mode.value.heat, commands_1.default.mode.value.auto].includes(this.mode);
|
|
1379
|
+
const fanActive = this.power && this.mode === commands_1.default.mode.value.fan;
|
|
1380
|
+
// Heater-Cooler Active
|
|
1381
|
+
if (props.includes(commands_1.default.power.code) || props.includes(commands_1.default.mode.code)) {
|
|
1382
|
+
this.platform.log.debug(`[${this.getDeviceLabel()}] updateStatus (Heater-Cooler Active) ->`, hcActive ? 'ACTIVE' : 'INACTIVE');
|
|
1383
|
+
(_a = this.HeaterCooler) === null || _a === void 0 ? void 0 : _a.getCharacteristic(this.platform.Characteristic.Active).updateValue(hcActive ? this.platform.Characteristic.Active.ACTIVE : this.platform.Characteristic.Active.INACTIVE);
|
|
1384
|
+
}
|
|
1385
|
+
// Fan Active
|
|
1386
|
+
if (this.Fan && (props.includes(commands_1.default.power.code) || props.includes(commands_1.default.mode.code))) {
|
|
1387
|
+
this.platform.log.debug(`[${this.getDeviceLabel()}] updateStatus (Fan Active) ->`, fanActive ? 'ACTIVE' : 'INACTIVE');
|
|
1388
|
+
(_b = this.Fan) === null || _b === void 0 ? void 0 : _b.getCharacteristic(this.platform.Characteristic.Active).updateValue(fanActive ? this.platform.Characteristic.Active.ACTIVE : this.platform.Characteristic.Active.INACTIVE);
|
|
861
1389
|
}
|
|
862
1390
|
// Current Heater-Cooler State
|
|
863
1391
|
if (props.includes(commands_1.default.mode.code)) {
|
|
@@ -865,16 +1393,11 @@ class GreeAirConditioner {
|
|
|
865
1393
|
switch (this.mode) {
|
|
866
1394
|
case commands_1.default.mode.value.cool:
|
|
867
1395
|
this.platform.log.debug(`[${this.getDeviceLabel()}] updateStatus (Current Heater-Cooler State) -> COOLING`);
|
|
868
|
-
(
|
|
1396
|
+
(_c = this.HeaterCooler) === null || _c === void 0 ? void 0 : _c.getCharacteristic(this.platform.Characteristic.CurrentHeaterCoolerState).updateValue(this.platform.Characteristic.CurrentHeaterCoolerState.COOLING);
|
|
869
1397
|
break;
|
|
870
1398
|
case commands_1.default.mode.value.heat:
|
|
871
1399
|
this.platform.log.debug(`[${this.getDeviceLabel()}] updateStatus (Current Heater-Cooler State) -> HEATING`);
|
|
872
|
-
(
|
|
873
|
-
break;
|
|
874
|
-
case commands_1.default.mode.value.fan:
|
|
875
|
-
case commands_1.default.mode.value.dry:
|
|
876
|
-
this.platform.log.debug(`[${this.getDeviceLabel()}] updateStatus (Current Heater-Cooler State) -> IDLE`);
|
|
877
|
-
(_d = this.HeaterCooler) === null || _d === void 0 ? void 0 : _d.getCharacteristic(this.platform.Characteristic.CurrentHeaterCoolerState).updateValue(this.platform.Characteristic.CurrentHeaterCoolerState.IDLE);
|
|
1400
|
+
(_d = this.HeaterCooler) === null || _d === void 0 ? void 0 : _d.getCharacteristic(this.platform.Characteristic.CurrentHeaterCoolerState).updateValue(this.platform.Characteristic.CurrentHeaterCoolerState.HEATING);
|
|
878
1401
|
break;
|
|
879
1402
|
case commands_1.default.mode.value.auto:
|
|
880
1403
|
if (this.currentTemperature > this.targetTemperature + 1.5) {
|
|
@@ -897,57 +1420,79 @@ class GreeAirConditioner {
|
|
|
897
1420
|
(_h = this.HeaterCooler) === null || _h === void 0 ? void 0 : _h.getCharacteristic(this.platform.Characteristic.CurrentHeaterCoolerState).updateValue(this.platform.Characteristic.CurrentHeaterCoolerState.INACTIVE);
|
|
898
1421
|
}
|
|
899
1422
|
}
|
|
1423
|
+
// Current Fan State
|
|
1424
|
+
if (this.Fan && props.includes(commands_1.default.mode.code)) {
|
|
1425
|
+
if (this.power && this.mode === commands_1.default.mode.value.fan) {
|
|
1426
|
+
this.platform.log.debug(`[${this.getDeviceLabel()}] updateStatus (Current Fan State) -> BLOWING_AIR`);
|
|
1427
|
+
(_j = this.Fan) === null || _j === void 0 ? void 0 : _j.getCharacteristic(this.platform.Characteristic.CurrentFanState).updateValue(this.platform.Characteristic.CurrentFanState.BLOWING_AIR);
|
|
1428
|
+
}
|
|
1429
|
+
else {
|
|
1430
|
+
this.platform.log.debug(`[${this.getDeviceLabel()}] updateStatus (Current Fan State) -> INACTIVE`);
|
|
1431
|
+
(_k = this.Fan) === null || _k === void 0 ? void 0 : _k.getCharacteristic(this.platform.Characteristic.CurrentFanState).updateValue(this.platform.Characteristic.CurrentFanState.INACTIVE);
|
|
1432
|
+
}
|
|
1433
|
+
}
|
|
900
1434
|
// Target Heater-Cooler State
|
|
901
|
-
if (props.includes(commands_1.default.mode.code) && this.power
|
|
1435
|
+
if (props.includes(commands_1.default.mode.code) && this.power &&
|
|
1436
|
+
[commands_1.default.mode.value.cool, commands_1.default.mode.value.heat, commands_1.default.mode.value.auto].includes(this.mode)) {
|
|
902
1437
|
switch (this.mode) {
|
|
903
1438
|
case commands_1.default.mode.value.cool:
|
|
904
1439
|
this.platform.log.debug(`[${this.getDeviceLabel()}] updateStatus (Target Heater-Cooler State) -> COOL`);
|
|
905
|
-
(
|
|
1440
|
+
(_l = this.HeaterCooler) === null || _l === void 0 ? void 0 : _l.getCharacteristic(this.platform.Characteristic.TargetHeaterCoolerState).updateValue(this.platform.Characteristic.TargetHeaterCoolerState.COOL);
|
|
1441
|
+
this.accessory.context.TargetHeaterCoolerState = this.platform.Characteristic.TargetHeaterCoolerState.COOL;
|
|
906
1442
|
break;
|
|
907
1443
|
case commands_1.default.mode.value.heat:
|
|
908
1444
|
this.platform.log.debug(`[${this.getDeviceLabel()}] updateStatus (Target Heater-Cooler State) -> HEAT`);
|
|
909
|
-
(
|
|
1445
|
+
(_m = this.HeaterCooler) === null || _m === void 0 ? void 0 : _m.getCharacteristic(this.platform.Characteristic.TargetHeaterCoolerState).updateValue(this.platform.Characteristic.TargetHeaterCoolerState.HEAT);
|
|
1446
|
+
this.accessory.context.TargetHeaterCoolerState = this.platform.Characteristic.TargetHeaterCoolerState.HEAT;
|
|
910
1447
|
break;
|
|
911
|
-
default:
|
|
1448
|
+
case commands_1.default.mode.value.auto:
|
|
912
1449
|
this.platform.log.debug(`[${this.getDeviceLabel()}] updateStatus (Target Heater-Cooler State) -> AUTO`);
|
|
913
|
-
(
|
|
1450
|
+
(_o = this.HeaterCooler) === null || _o === void 0 ? void 0 : _o.getCharacteristic(this.platform.Characteristic.TargetHeaterCoolerState).updateValue(this.platform.Characteristic.TargetHeaterCoolerState.AUTO);
|
|
1451
|
+
this.accessory.context.TargetHeaterCoolerState = this.platform.Characteristic.TargetHeaterCoolerState.AUTO;
|
|
1452
|
+
break;
|
|
914
1453
|
}
|
|
1454
|
+
this.platform.api.updatePlatformAccessories([this.accessory]);
|
|
915
1455
|
}
|
|
916
1456
|
// Current Temperature
|
|
917
1457
|
if (props.includes(commands_1.default.temperature.code)) {
|
|
918
1458
|
this.platform.log.debug(`[${this.getDeviceLabel()}] updateStatus (Current Temperature) ->`, this.currentTemperature);
|
|
919
|
-
(
|
|
920
|
-
(
|
|
921
|
-
(
|
|
922
|
-
(
|
|
1459
|
+
(_p = this.HeaterCooler) === null || _p === void 0 ? void 0 : _p.getCharacteristic(this.platform.Characteristic.CurrentTemperature).updateValue(this.currentTemperature);
|
|
1460
|
+
(_q = this.TemperatureSensor) === null || _q === void 0 ? void 0 : _q.getCharacteristic(this.platform.Characteristic.CurrentTemperature).updateValue(this.currentTemperature);
|
|
1461
|
+
(_r = this.tsAccessory) === null || _r === void 0 ? void 0 : _r.setCurrentTemperature(this.currentTemperature);
|
|
1462
|
+
(_s = this.tsAccessory) === null || _s === void 0 ? void 0 : _s.TemperatureSensor.getCharacteristic(this.platform.Characteristic.CurrentTemperature).updateValue(this.currentTemperature);
|
|
923
1463
|
}
|
|
924
1464
|
else if (props.includes(commands_1.default.targetTemperature.code) && this.TemperatureSensor === undefined) {
|
|
925
1465
|
// temperature is not accessible -> targetTemperature is saved as currentTemperature
|
|
926
1466
|
this.platform.log.debug(`[${this.getDeviceLabel()}] updateStatus (Current Temperature) ->`, this.currentTemperature);
|
|
927
|
-
(
|
|
1467
|
+
(_t = this.HeaterCooler) === null || _t === void 0 ? void 0 : _t.getCharacteristic(this.platform.Characteristic.CurrentTemperature).updateValue(this.currentTemperature);
|
|
928
1468
|
}
|
|
929
1469
|
// Cooling Threshold Temperature
|
|
930
1470
|
if (props.includes(commands_1.default.targetTemperature.code) && this.power &&
|
|
931
1471
|
(this.mode === commands_1.default.mode.value.cool || this.mode === commands_1.default.mode.value.auto)) {
|
|
932
1472
|
this.platform.log.debug(`[${this.getDeviceLabel()}] updateStatus (Cooling Threshold Temperature) ->`, this.targetTemperature);
|
|
933
|
-
(
|
|
1473
|
+
(_u = this.HeaterCooler) === null || _u === void 0 ? void 0 : _u.getCharacteristic(this.platform.Characteristic.CoolingThresholdTemperature).updateValue(this.targetTemperature);
|
|
934
1474
|
}
|
|
935
1475
|
// Heating Threshold Temperature
|
|
936
1476
|
if (props.includes(commands_1.default.targetTemperature.code) && this.power &&
|
|
937
1477
|
(this.mode === commands_1.default.mode.value.heat || this.mode === commands_1.default.mode.value.auto)) {
|
|
938
1478
|
this.platform.log.debug(`[${this.getDeviceLabel()}] updateStatus (Heating Threshold Temperature) ->`, this.targetTemperature);
|
|
939
|
-
(
|
|
1479
|
+
(_v = this.HeaterCooler) === null || _v === void 0 ? void 0 : _v.getCharacteristic(this.platform.Characteristic.HeatingThresholdTemperature).updateValue(this.targetTemperature);
|
|
940
1480
|
}
|
|
941
1481
|
// Temperature Display Units
|
|
942
1482
|
if (props.includes(commands_1.default.units.code)) {
|
|
943
1483
|
this.platform.log.debug(`[${this.getDeviceLabel()}] updateStatus (Temperature Display Units) ->`, this.units === commands_1.default.units.value.celsius ? 'CELSIUS' : 'FAHRENHEIT');
|
|
944
|
-
(
|
|
1484
|
+
(_w = this.HeaterCooler) === null || _w === void 0 ? void 0 : _w.getCharacteristic(this.platform.Characteristic.TemperatureDisplayUnits).updateValue(this.units === commands_1.default.units.value.celsius ?
|
|
945
1485
|
this.platform.Characteristic.TemperatureDisplayUnits.CELSIUS : this.platform.Characteristic.TemperatureDisplayUnits.FAHRENHEIT);
|
|
946
1486
|
}
|
|
947
1487
|
// Swing Mode
|
|
948
1488
|
if (props.includes(commands_1.default.swingVertical.code) && this.power) {
|
|
949
1489
|
let swing = this.platform.Characteristic.SwingMode.SWING_ENABLED;
|
|
950
1490
|
let logValue = 'ENABLED';
|
|
1491
|
+
if ([commands_1.default.swingVertical.value.full, commands_1.default.swingVertical.value.swingHigher,
|
|
1492
|
+
commands_1.default.swingVertical.value.swingHighest, commands_1.default.swingVertical.value.swingLower, commands_1.default.swingVertical.value.swingLowest,
|
|
1493
|
+
commands_1.default.swingVertical.value.swingMiddle].includes(this.swingMode)) {
|
|
1494
|
+
logValue += ` (type: ${this.getKeyName(commands_1.default.swingVertical.value, this.swingMode)})`;
|
|
1495
|
+
}
|
|
951
1496
|
switch (this.swingMode) {
|
|
952
1497
|
case commands_1.default.swingVertical.value.default:
|
|
953
1498
|
case commands_1.default.swingVertical.value.fixedHighest:
|
|
@@ -956,58 +1501,79 @@ class GreeAirConditioner {
|
|
|
956
1501
|
case commands_1.default.swingVertical.value.fixedLower:
|
|
957
1502
|
case commands_1.default.swingVertical.value.fixedLowest:
|
|
958
1503
|
swing = this.platform.Characteristic.SwingMode.SWING_DISABLED;
|
|
959
|
-
logValue =
|
|
960
|
-
if ([settings_1.OVERRIDE_DEFAULT_SWING.always, settings_1.OVERRIDE_DEFAULT_SWING.powerOn].includes(this.deviceConfig.overrideDefaultVerticalSwing ||
|
|
961
|
-
settings_1.OVERRIDE_DEFAULT_SWING.never)) {
|
|
962
|
-
logValue += ' (' + this.getKeyName(commands_1.default.swingVertical.value, this.swingMode) + ')';
|
|
963
|
-
}
|
|
1504
|
+
logValue = `DISABLED (position: ${this.getKeyName(commands_1.default.swingVertical.value, this.swingMode)})`;
|
|
964
1505
|
break;
|
|
965
1506
|
}
|
|
966
1507
|
this.platform.log.debug(`[${this.getDeviceLabel()}] updateStatus (Swing Mode) ->`, logValue);
|
|
967
|
-
(
|
|
1508
|
+
(_x = this.HeaterCooler) === null || _x === void 0 ? void 0 : _x.getCharacteristic(this.platform.Characteristic.SwingMode).updateValue(swing);
|
|
968
1509
|
}
|
|
969
|
-
// Rotation Speed
|
|
970
|
-
if (
|
|
971
|
-
|
|
1510
|
+
// Heater-Cooler Rotation Speed
|
|
1511
|
+
if (hcActive) {
|
|
1512
|
+
const maxSpeed = ((_y = this.HeaterCooler) === null || _y === void 0 ? void 0 : _y.getCharacteristic(this.platform.Characteristic.RotationSpeed).props.maxValue) ||
|
|
1513
|
+
this.deviceConfig.speedSteps + 3;
|
|
972
1514
|
if (props.includes(commands_1.default.quietMode.code) && this.quietMode === commands_1.default.quietMode.value.on) {
|
|
973
1515
|
// quietMode -> on
|
|
974
|
-
this.platform.log.debug(`[${this.getDeviceLabel()}] updateStatus (Rotation Speed) -> 1 (quiet)`);
|
|
975
|
-
(
|
|
1516
|
+
this.platform.log.debug(`[${this.getDeviceLabel()}] updateStatus (Heater-Cooler Rotation Speed) -> 1 (quiet)`);
|
|
1517
|
+
(_z = this.HeaterCooler) === null || _z === void 0 ? void 0 : _z.getCharacteristic(this.platform.Characteristic.RotationSpeed).updateValue(1);
|
|
1518
|
+
this.accessory.context.HeaterCoolerRotationSpeed = 1;
|
|
976
1519
|
}
|
|
977
1520
|
else if (props.includes(commands_1.default.powerfulMode.code) && this.powerfulMode === commands_1.default.powerfulMode.value.on) {
|
|
978
1521
|
// powerfulMode -> on
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
1522
|
+
this.platform.log.debug(`[${this.getDeviceLabel()}] updateStatus (Heater-Cooler Rotation Speed) ->`, `${maxSpeed.toString()} (powerful)`);
|
|
1523
|
+
(_0 = this.HeaterCooler) === null || _0 === void 0 ? void 0 : _0.getCharacteristic(this.platform.Characteristic.RotationSpeed).updateValue(maxSpeed);
|
|
1524
|
+
this.accessory.context.HeaterCoolerRotationSpeed = maxSpeed;
|
|
982
1525
|
}
|
|
983
1526
|
else if (props.includes(commands_1.default.speed.code)) {
|
|
984
|
-
// speed
|
|
985
1527
|
let speedValue = 2; // default: auto
|
|
986
1528
|
switch (this.speed) {
|
|
987
1529
|
case commands_1.default.speed.value.low:
|
|
988
|
-
logValue = '3 (low)';
|
|
989
1530
|
speedValue = 3;
|
|
990
1531
|
break;
|
|
991
1532
|
case commands_1.default.speed.value.mediumLow:
|
|
992
|
-
logValue = '4 (mediumLow)';
|
|
993
1533
|
speedValue = 4;
|
|
994
1534
|
break;
|
|
995
1535
|
case commands_1.default.speed.value.medium:
|
|
996
|
-
|
|
997
|
-
speedValue = (this.deviceConfig.speedSteps === 5) ? 5 : 4;
|
|
1536
|
+
speedValue = (maxSpeed === 8) ? 5 : 4;
|
|
998
1537
|
break;
|
|
999
1538
|
case commands_1.default.speed.value.mediumHigh:
|
|
1000
|
-
|
|
1001
|
-
speedValue = (this.deviceConfig.speedSteps === 5) ? 6 : 4;
|
|
1539
|
+
speedValue = (maxSpeed === 8) ? 6 : 4;
|
|
1002
1540
|
break;
|
|
1003
1541
|
case commands_1.default.speed.value.high:
|
|
1004
|
-
|
|
1005
|
-
speedValue = (this.deviceConfig.speedSteps === 5) ? 7 : 5;
|
|
1542
|
+
speedValue = (maxSpeed === 8) ? 7 : 5;
|
|
1006
1543
|
break;
|
|
1007
1544
|
}
|
|
1008
|
-
this.
|
|
1009
|
-
(
|
|
1545
|
+
const speedName = this.getKeyName(commands_1.default.speed.value, this.speed);
|
|
1546
|
+
this.platform.log.debug(`[${this.getDeviceLabel()}] updateStatus (Heater-Cooler Rotation Speed) ->`, `${speedValue.toString()} (${speedName})`);
|
|
1547
|
+
(_1 = this.HeaterCooler) === null || _1 === void 0 ? void 0 : _1.getCharacteristic(this.platform.Characteristic.RotationSpeed).updateValue(speedValue);
|
|
1548
|
+
this.accessory.context.HeaterCoolerRotationSpeed = speedValue;
|
|
1010
1549
|
}
|
|
1550
|
+
this.platform.api.updatePlatformAccessories([this.accessory]);
|
|
1551
|
+
}
|
|
1552
|
+
// Fan Rotation Speed
|
|
1553
|
+
if (fanActive) {
|
|
1554
|
+
const minStep = ((_2 = this.Fan) === null || _2 === void 0 ? void 0 : _2.getCharacteristic(this.platform.Characteristic.RotationSpeed).props.minStep) ||
|
|
1555
|
+
100 / (this.deviceConfig.speedSteps + 1);
|
|
1556
|
+
let fanSpeedValue = 100; // default: auto
|
|
1557
|
+
switch (this.speed) {
|
|
1558
|
+
case commands_1.default.speed.value.low:
|
|
1559
|
+
fanSpeedValue = minStep;
|
|
1560
|
+
break;
|
|
1561
|
+
case commands_1.default.speed.value.mediumLow:
|
|
1562
|
+
fanSpeedValue = 2 * minStep;
|
|
1563
|
+
break;
|
|
1564
|
+
case commands_1.default.speed.value.medium:
|
|
1565
|
+
fanSpeedValue = (minStep !== 25 ? 3 : 2) * minStep;
|
|
1566
|
+
break;
|
|
1567
|
+
case commands_1.default.speed.value.mediumHigh:
|
|
1568
|
+
fanSpeedValue = (minStep !== 25 ? 4 : 2) * minStep;
|
|
1569
|
+
break;
|
|
1570
|
+
case commands_1.default.speed.value.high:
|
|
1571
|
+
fanSpeedValue = (minStep !== 25 ? 5 : 3) * minStep;
|
|
1572
|
+
break;
|
|
1573
|
+
}
|
|
1574
|
+
const speedName = this.getKeyName(commands_1.default.speed.value, this.speed);
|
|
1575
|
+
this.platform.log.debug(`[${this.getDeviceLabel()}] updateStatus (Fan Rotation Speed) ->`, `${Math.round(fanSpeedValue)}% (${speedName})`);
|
|
1576
|
+
(_3 = this.Fan) === null || _3 === void 0 ? void 0 : _3.getCharacteristic(this.platform.Characteristic.RotationSpeed).updateValue(fanSpeedValue);
|
|
1011
1577
|
}
|
|
1012
1578
|
}
|
|
1013
1579
|
sendMessage(message) {
|
|
@@ -1070,6 +1636,12 @@ class GreeAirConditioner {
|
|
|
1070
1636
|
opt: keys,
|
|
1071
1637
|
p: values,
|
|
1072
1638
|
};
|
|
1639
|
+
if (keys.includes(commands_1.default.power.code)) {
|
|
1640
|
+
this.powerPending = values[keys.indexOf(commands_1.default.power.code)];
|
|
1641
|
+
}
|
|
1642
|
+
if (keys.includes(commands_1.default.mode.code)) {
|
|
1643
|
+
this.modePending = values[keys.indexOf(commands_1.default.mode.code)];
|
|
1644
|
+
}
|
|
1073
1645
|
this.sendMessage(message);
|
|
1074
1646
|
}
|
|
1075
1647
|
requestDeviceStatus() {
|