homebridge-gree-ac 2.1.3 → 2.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -2
- package/README.md +3 -3
- package/dist/platform.d.ts +9 -3
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +47 -35
- package/dist/platform.js.map +1 -1
- package/dist/platformAccessory.d.ts +7 -8
- package/dist/platformAccessory.d.ts.map +1 -1
- package/dist/platformAccessory.js +125 -101
- package/dist/platformAccessory.js.map +1 -1
- package/dist/settings.d.ts +1 -0
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js +4 -3
- package/dist/settings.js.map +1 -1
- package/dist/tsAccessory.d.ts +3 -6
- package/dist/tsAccessory.d.ts.map +1 -1
- package/dist/tsAccessory.js +9 -7
- package/dist/tsAccessory.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.GreeAirConditioner = void 0;
|
|
7
7
|
const dgram_1 = __importDefault(require("dgram"));
|
|
8
8
|
const settings_1 = require("./settings");
|
|
9
|
+
const tsAccessory_1 = require("./tsAccessory");
|
|
9
10
|
const crypto_1 = __importDefault(require("./crypto"));
|
|
10
11
|
const commands_1 = __importDefault(require("./commands"));
|
|
11
12
|
/**
|
|
@@ -14,16 +15,14 @@ const commands_1 = __importDefault(require("./commands"));
|
|
|
14
15
|
* Each accessory may expose multiple services of different service types.
|
|
15
16
|
*/
|
|
16
17
|
class GreeAirConditioner {
|
|
17
|
-
constructor(platform, accessory, deviceConfig,
|
|
18
|
-
var _a, _b, _c, _d;
|
|
18
|
+
constructor(platform, accessory, deviceConfig, tsAccessoryMac) {
|
|
19
19
|
this.platform = platform;
|
|
20
20
|
this.accessory = accessory;
|
|
21
21
|
this.deviceConfig = deviceConfig;
|
|
22
|
-
this.
|
|
23
|
-
this.
|
|
22
|
+
this.tsAccessoryMac = tsAccessoryMac;
|
|
23
|
+
this.tsAccessory = null;
|
|
24
24
|
// device communication functions
|
|
25
25
|
this.handleMessage = (msg, rinfo) => {
|
|
26
|
-
var _a;
|
|
27
26
|
if (this.accessory.context.device.address === rinfo.address) {
|
|
28
27
|
this.platform.log.debug(`[${this.getDeviceLabel()}] handleMessage -> %s`, msg.toString());
|
|
29
28
|
this.platform.log.debug(`[${this.getDeviceLabel()}] handleMessage -> Encryption version: %i`, this.accessory.context.device.encryptionVersion);
|
|
@@ -48,21 +47,22 @@ class GreeAirConditioner {
|
|
|
48
47
|
this.platform.log.debug(`[${this.getDeviceLabel()}] handleMessage - Package -> %j`, pack);
|
|
49
48
|
switch (pack.t) {
|
|
50
49
|
case 'bindok': // package type is binding confirmation
|
|
51
|
-
this.
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
50
|
+
if (!this.accessory.bound) {
|
|
51
|
+
this.platform.log.debug(`[${this.getDeviceLabel()}] Device binding in progress`);
|
|
52
|
+
this.key = pack.key;
|
|
53
|
+
this.initAccessory();
|
|
54
|
+
this.accessory.bound = true;
|
|
55
|
+
this.platform.log.info(`[${this.getDeviceLabel()}] Device is bound -> ${pack.mac}`);
|
|
56
|
+
this.platform.log.debug(`[${this.getDeviceLabel()}] Device key -> ${this.key}`);
|
|
57
|
+
this.requestDeviceStatus();
|
|
58
|
+
setInterval(this.requestDeviceStatus.bind(this), this.deviceConfig.statusUpdateInterval * 1000); // statusUpdateInterval in seconds
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
this.platform.log.debug(`[${this.getDeviceLabel()}] Binding response received from already bound device`);
|
|
60
62
|
}
|
|
61
|
-
this.requestDeviceStatus();
|
|
62
|
-
this.updateTimer = setInterval(this.requestDeviceStatus.bind(this), this.deviceConfig.statusUpdateInterval * 1000); // statusUpdateInterval in seconds
|
|
63
63
|
break;
|
|
64
64
|
case 'dat': // package type is device status
|
|
65
|
-
if (this.bound) {
|
|
65
|
+
if (this.accessory.bound) {
|
|
66
66
|
pack.cols.forEach((col, i) => {
|
|
67
67
|
if (!(col === commands_1.default.temperature.code && i === 0)) { // temperature value 0 should be ignored (means: no sensor data)
|
|
68
68
|
this.status[col] = pack.dat[i];
|
|
@@ -83,7 +83,7 @@ class GreeAirConditioner {
|
|
|
83
83
|
}
|
|
84
84
|
break;
|
|
85
85
|
case 'res': // package type is response
|
|
86
|
-
if (this.bound) {
|
|
86
|
+
if (this.accessory.bound) {
|
|
87
87
|
this.platform.log.debug(`[${this.getDeviceLabel()}] Device response`);
|
|
88
88
|
const updatedParams = [];
|
|
89
89
|
pack.opt.forEach((opt, i) => {
|
|
@@ -108,13 +108,47 @@ class GreeAirConditioner {
|
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
110
|
};
|
|
111
|
-
|
|
112
|
-
|
|
111
|
+
// platform, accessory and service initialization is implemented in a separate funcion (initAccessory), because
|
|
112
|
+
// it should be made only on successful binding with network device
|
|
113
113
|
this.platform.log.debug(`[${this.getDeviceLabel()}] deviceConfig -> %j`, deviceConfig);
|
|
114
|
+
// initialize communication with device
|
|
115
|
+
this.status = {};
|
|
116
|
+
this.socket = dgram_1.default.createSocket({ type: 'udp4', reuseAddr: true });
|
|
117
|
+
this.socket.on('error', (err) => {
|
|
118
|
+
this.platform.log.error(`[${this.getDeviceLabel()}] Network - Error:`, err.message);
|
|
119
|
+
});
|
|
120
|
+
this.socket.on('message', this.handleMessage);
|
|
121
|
+
this.socket.on('close', () => {
|
|
122
|
+
this.platform.log.error(`[${this.getDeviceLabel()}] Network - Connection closed`);
|
|
123
|
+
});
|
|
124
|
+
if (this.platform.ports.indexOf(this.deviceConfig.port || 0) >= 0) {
|
|
125
|
+
this.platform.log.warn(`[${this.getDeviceLabel()}] Warning: Configured port (%i) is already used - replacing with auto assigned port`, this.deviceConfig.port);
|
|
126
|
+
this.deviceConfig.port = undefined;
|
|
127
|
+
}
|
|
128
|
+
this.socket.bind(this.deviceConfig.port, undefined, () => {
|
|
129
|
+
this.platform.log.info(`[${this.getDeviceLabel()}] Device handler is listening on UDP port %d`, this.socket.address().port);
|
|
130
|
+
this.platform.ports.push(this.socket.address().port);
|
|
131
|
+
this.socket.setBroadcast(false);
|
|
132
|
+
this.sendBindRequest();
|
|
133
|
+
setTimeout(this.checkBindingStatus.bind(this, 1), settings_1.BINDING_TIMEOUT);
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
// All platform, accessory and service initialization is made in initAccessory function
|
|
137
|
+
initAccessory() {
|
|
138
|
+
var _a, _b, _c;
|
|
139
|
+
// register accessory in homebridge by api if not registered before
|
|
140
|
+
if (!this.accessory.registered) {
|
|
141
|
+
this.platform.log.debug(`[${this.getDeviceLabel()}] registering new accessory in homebridge:`, this.accessory.context.device.mac, this.accessory.UUID);
|
|
142
|
+
this.platform.api.registerPlatformAccessories(settings_1.PLUGIN_NAME, settings_1.PLATFORM_NAME, [this.accessory]);
|
|
143
|
+
}
|
|
144
|
+
this.platform.api.updatePlatformAccessories([this.accessory]);
|
|
145
|
+
if (this.tsAccessoryMac) {
|
|
146
|
+
this.tsAccessory = new tsAccessory_1.GreeAirConditionerTS(this.platform, this.platform.getAccessory(this.accessory.context.device.mac + '_ts'));
|
|
147
|
+
}
|
|
114
148
|
// set accessory information
|
|
115
149
|
this.accessory.getService(this.platform.Service.AccessoryInformation)
|
|
116
150
|
.setCharacteristic(this.platform.Characteristic.Manufacturer, this.accessory.context.device.brand || 'Gree')
|
|
117
|
-
.setCharacteristic(this.platform.Characteristic.Model, ((
|
|
151
|
+
.setCharacteristic(this.platform.Characteristic.Model, ((_a = this.deviceConfig) === null || _a === void 0 ? void 0 : _a.model) || this.accessory.context.device.model || this.accessory.context.device.name || 'Air Conditioner')
|
|
118
152
|
.setCharacteristic(this.platform.Characteristic.SerialNumber, this.accessory.context.device.mac)
|
|
119
153
|
.setCharacteristic(this.platform.Characteristic.FirmwareRevision, this.accessory.context.device.hid && this.accessory.context.device.hid.lastIndexOf('V') >= 0 &&
|
|
120
154
|
this.accessory.context.device.hid.lastIndexOf('V') < this.accessory.context.device.hid.lastIndexOf('.') ?
|
|
@@ -127,7 +161,7 @@ class GreeAirConditioner {
|
|
|
127
161
|
this.HeaterCooler = this.accessory.getService(this.platform.Service.HeaterCooler) ||
|
|
128
162
|
this.accessory.addService(this.platform.Service.HeaterCooler, this.accessory.displayName, undefined);
|
|
129
163
|
this.HeaterCooler.displayName = this.accessory.displayName;
|
|
130
|
-
if (deviceConfig.temperatureSensor === settings_1.TS_TYPE.child) {
|
|
164
|
+
if (this.deviceConfig.temperatureSensor === settings_1.TS_TYPE.child) {
|
|
131
165
|
this.platform.log.debug(`[${this.getDeviceLabel()}] Add Temperature Sensor child service`);
|
|
132
166
|
this.TemperatureSensor = this.accessory.getService(this.platform.Service.TemperatureSensor) ||
|
|
133
167
|
this.accessory.addService(this.platform.Service.TemperatureSensor, 'Temperature Sensor - ' + this.accessory.displayName, undefined);
|
|
@@ -135,14 +169,14 @@ class GreeAirConditioner {
|
|
|
135
169
|
}
|
|
136
170
|
else {
|
|
137
171
|
const ts = this.accessory.getService(this.platform.Service.TemperatureSensor);
|
|
138
|
-
this.platform.log.debug(`[${this.getDeviceLabel()}] Temperature Sensor child service not allowed
|
|
172
|
+
this.platform.log.debug(`[${this.getDeviceLabel()}] Temperature Sensor child service not allowed`, (ts === null || ts === void 0 ? void 0 : ts.displayName) !== undefined ? '(' + (ts === null || ts === void 0 ? void 0 : ts.displayName) + ')' : '');
|
|
139
173
|
if (ts !== undefined) {
|
|
140
174
|
this.platform.log.debug(`[${this.getDeviceLabel()}] Remove Temperature Sensor child service (%s)`, ts.displayName);
|
|
141
175
|
this.accessory.removeService(ts);
|
|
142
176
|
}
|
|
143
177
|
}
|
|
144
178
|
this.HeaterCooler.setPrimaryService(true);
|
|
145
|
-
(
|
|
179
|
+
(_b = this.TemperatureSensor) === null || _b === void 0 ? void 0 : _b.setPrimaryService(false);
|
|
146
180
|
// each service must implement at-minimum the "required characteristics" for the given service type
|
|
147
181
|
// see https://developers.homebridge.io/#/service/HeaterCooler
|
|
148
182
|
// register handlers for the Active Characteristic
|
|
@@ -159,7 +193,7 @@ class GreeAirConditioner {
|
|
|
159
193
|
// register handlers for the Current Temperature Characteristic
|
|
160
194
|
this.HeaterCooler.getCharacteristic(this.platform.Characteristic.CurrentTemperature)
|
|
161
195
|
.onGet(this.getCurrentTemperature.bind(this, 'Heater Cooler'));
|
|
162
|
-
(
|
|
196
|
+
(_c = this.TemperatureSensor) === null || _c === void 0 ? void 0 : _c.getCharacteristic(this.platform.Characteristic.CurrentTemperature).onGet(this.getCurrentTemperature.bind(this, 'Temperature Sensor'));
|
|
163
197
|
// register handlers for the Cooling Threshold Temperature Characteristic
|
|
164
198
|
// (minValue and maxValue can't be set here, they need an active accessory in cooling sate to set)
|
|
165
199
|
this.HeaterCooler.getCharacteristic(this.platform.Characteristic.CoolingThresholdTemperature)
|
|
@@ -189,22 +223,29 @@ class GreeAirConditioner {
|
|
|
189
223
|
})
|
|
190
224
|
.onGet(this.getRotationSpeed.bind(this))
|
|
191
225
|
.onSet(this.setRotationSpeed.bind(this));
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
this.
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
226
|
+
}
|
|
227
|
+
// this function is a callback to check the status of binding after timeout period has ellapsed
|
|
228
|
+
checkBindingStatus(bindNo) {
|
|
229
|
+
if (!this.accessory.bound) {
|
|
230
|
+
this.platform.log.debug(`[${this.getDeviceLabel()}] Device binding timeout`);
|
|
231
|
+
switch (bindNo) {
|
|
232
|
+
case 1: {
|
|
233
|
+
// 1. timeout -> repeat bind request with alternate encryption version
|
|
234
|
+
if (this.accessory.context.device.encryptionVersion === 1) {
|
|
235
|
+
this.accessory.context.device.encryptionVersion = 2;
|
|
236
|
+
}
|
|
237
|
+
else {
|
|
238
|
+
this.accessory.context.device.encryptionVersion = 1;
|
|
239
|
+
}
|
|
240
|
+
this.sendBindRequest();
|
|
241
|
+
setTimeout(this.checkBindingStatus.bind(this, bindNo + 1), settings_1.BINDING_TIMEOUT);
|
|
242
|
+
break;
|
|
243
|
+
}
|
|
244
|
+
default: {
|
|
245
|
+
this.platform.log.error(`[${this.getDeviceLabel()}] Error: Device is not bound`, '(unknown device type or device is malfunctioning [turning the power supply off and on may help])', '- Restart homebridge when issue has fixed!');
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
208
249
|
}
|
|
209
250
|
/**
|
|
210
251
|
* Handle "SET" requests from HomeKit
|
|
@@ -438,28 +479,27 @@ class GreeAirConditioner {
|
|
|
438
479
|
}
|
|
439
480
|
// helper functions
|
|
440
481
|
initThresholdTemperature(HeaterCoolerState) {
|
|
482
|
+
var _a, _b, _c, _d, _e, _f;
|
|
441
483
|
switch (HeaterCoolerState) {
|
|
442
484
|
case this.platform.Characteristic.CurrentHeaterCoolerState.COOLING:
|
|
443
|
-
if (this.HeaterCooler.getCharacteristic(this.platform.Characteristic.CoolingThresholdTemperature).props.minValue !==
|
|
485
|
+
if (((_a = this.HeaterCooler) === null || _a === void 0 ? void 0 : _a.getCharacteristic(this.platform.Characteristic.CoolingThresholdTemperature).props.minValue) !==
|
|
444
486
|
this.deviceConfig.minimumTargetTemperature ||
|
|
445
|
-
this.HeaterCooler.getCharacteristic(this.platform.Characteristic.CoolingThresholdTemperature).props.maxValue !==
|
|
487
|
+
((_b = this.HeaterCooler) === null || _b === void 0 ? void 0 : _b.getCharacteristic(this.platform.Characteristic.CoolingThresholdTemperature).props.maxValue) !==
|
|
446
488
|
this.deviceConfig.maximumTargetTemperature) {
|
|
447
489
|
this.platform.log.debug(`[${this.getDeviceLabel()}] Set CoolingThresholdTemperature minValue -> %i, maxValue -> %i`, this.deviceConfig.minimumTargetTemperature, this.deviceConfig.maximumTargetTemperature);
|
|
448
|
-
this.HeaterCooler.getCharacteristic(this.platform.Characteristic.CoolingThresholdTemperature)
|
|
449
|
-
.setProps({
|
|
490
|
+
(_c = this.HeaterCooler) === null || _c === void 0 ? void 0 : _c.getCharacteristic(this.platform.Characteristic.CoolingThresholdTemperature).setProps({
|
|
450
491
|
minValue: this.deviceConfig.minimumTargetTemperature,
|
|
451
492
|
maxValue: this.deviceConfig.maximumTargetTemperature
|
|
452
493
|
});
|
|
453
494
|
}
|
|
454
495
|
break;
|
|
455
496
|
case this.platform.Characteristic.CurrentHeaterCoolerState.HEATING:
|
|
456
|
-
if (this.HeaterCooler.getCharacteristic(this.platform.Characteristic.HeatingThresholdTemperature).props.minValue !==
|
|
497
|
+
if (((_d = this.HeaterCooler) === null || _d === void 0 ? void 0 : _d.getCharacteristic(this.platform.Characteristic.HeatingThresholdTemperature).props.minValue) !==
|
|
457
498
|
this.deviceConfig.minimumTargetTemperature ||
|
|
458
|
-
this.HeaterCooler.getCharacteristic(this.platform.Characteristic.HeatingThresholdTemperature).props.maxValue !==
|
|
499
|
+
((_e = this.HeaterCooler) === null || _e === void 0 ? void 0 : _e.getCharacteristic(this.platform.Characteristic.HeatingThresholdTemperature).props.maxValue) !==
|
|
459
500
|
this.deviceConfig.maximumTargetTemperature) {
|
|
460
501
|
this.platform.log.debug(`[${this.getDeviceLabel()}] Set HeatingThresholdTemperature minValue -> %i, maxValue -> %i`, this.deviceConfig.minimumTargetTemperature, this.deviceConfig.maximumTargetTemperature);
|
|
461
|
-
this.HeaterCooler.getCharacteristic(this.platform.Characteristic.HeatingThresholdTemperature)
|
|
462
|
-
.setProps({
|
|
502
|
+
(_f = this.HeaterCooler) === null || _f === void 0 ? void 0 : _f.getCharacteristic(this.platform.Characteristic.HeatingThresholdTemperature).setProps({
|
|
463
503
|
minValue: this.deviceConfig.minimumTargetTemperature,
|
|
464
504
|
maxValue: this.deviceConfig.maximumTargetTemperature
|
|
465
505
|
});
|
|
@@ -522,14 +562,15 @@ class GreeAirConditioner {
|
|
|
522
562
|
(baseFahrenheitDecimalPart >= 0.75 && baseFahrenheitDecimalPart < 0.85)) ? 1 : 0);
|
|
523
563
|
}
|
|
524
564
|
getTargetTempFromDevice(temp, offset) {
|
|
565
|
+
var _a, _b;
|
|
525
566
|
const key = temp.toString() + ',' + offset.toString();
|
|
526
567
|
const value = settings_1.TEMPERATURE_TABLE[key];
|
|
527
568
|
if (value === undefined) {
|
|
528
569
|
return 25; // default value if invalid data received from device
|
|
529
570
|
}
|
|
530
571
|
// some temperature values are the same on the physical AC unit -> fix this issue:
|
|
531
|
-
const targetValue = this.HeaterCooler.getCharacteristic(this.platform.Characteristic.CoolingThresholdTemperature).value ||
|
|
532
|
-
this.HeaterCooler.getCharacteristic(this.platform.Characteristic.HeatingThresholdTemperature).value;
|
|
572
|
+
const targetValue = ((_a = this.HeaterCooler) === null || _a === void 0 ? void 0 : _a.getCharacteristic(this.platform.Characteristic.CoolingThresholdTemperature).value) ||
|
|
573
|
+
((_b = this.HeaterCooler) === null || _b === void 0 ? void 0 : _b.getCharacteristic(this.platform.Characteristic.HeatingThresholdTemperature).value);
|
|
533
574
|
if ((targetValue === 17.5 && value === 18) ||
|
|
534
575
|
(targetValue === 22.5 && value === 23) ||
|
|
535
576
|
(targetValue === 27.5 && value === 28)) {
|
|
@@ -544,6 +585,7 @@ class GreeAirConditioner {
|
|
|
544
585
|
return (this.status[commands_1.default.power.code] === commands_1.default.power.value.on);
|
|
545
586
|
}
|
|
546
587
|
set power(value) {
|
|
588
|
+
var _a;
|
|
547
589
|
if (value === this.power) {
|
|
548
590
|
return;
|
|
549
591
|
}
|
|
@@ -551,7 +593,7 @@ class GreeAirConditioner {
|
|
|
551
593
|
const command = { [commands_1.default.power.code]: powerValue };
|
|
552
594
|
let logValue = 'power -> ' + this.getKeyName(commands_1.default.power.value, powerValue);
|
|
553
595
|
if (powerValue === commands_1.default.power.value.on) {
|
|
554
|
-
switch (this.HeaterCooler.getCharacteristic(this.platform.Characteristic.TargetHeaterCoolerState).value) {
|
|
596
|
+
switch ((_a = this.HeaterCooler) === null || _a === void 0 ? void 0 : _a.getCharacteristic(this.platform.Characteristic.TargetHeaterCoolerState).value) {
|
|
555
597
|
case this.platform.Characteristic.TargetHeaterCoolerState.COOL:
|
|
556
598
|
if (this.status[commands_1.default.mode.code] !== commands_1.default.mode.value.cool) {
|
|
557
599
|
command[commands_1.default.mode.code] = commands_1.default.mode.value.cool;
|
|
@@ -614,21 +656,23 @@ class GreeAirConditioner {
|
|
|
614
656
|
return this.status[commands_1.default.temperature.code] - (this.deviceConfig.sensorOffset) || 25;
|
|
615
657
|
}
|
|
616
658
|
get targetTemperature() {
|
|
659
|
+
var _a, _b, _c, _d;
|
|
617
660
|
let minValue = this.deviceConfig.minimumTargetTemperature;
|
|
618
661
|
let maxValue = this.deviceConfig.maximumTargetTemperature;
|
|
619
662
|
switch (this.status[commands_1.default.mode.code]) {
|
|
620
663
|
case commands_1.default.mode.value.cool:
|
|
621
|
-
minValue = Math.max(this.deviceConfig.minimumTargetTemperature, this.HeaterCooler.getCharacteristic(this.platform.Characteristic.CoolingThresholdTemperature).props.minValue || 10);
|
|
622
|
-
maxValue = Math.min(this.deviceConfig.maximumTargetTemperature, this.HeaterCooler.getCharacteristic(this.platform.Characteristic.CoolingThresholdTemperature).props.maxValue || 35);
|
|
664
|
+
minValue = Math.max(this.deviceConfig.minimumTargetTemperature, ((_a = this.HeaterCooler) === null || _a === void 0 ? void 0 : _a.getCharacteristic(this.platform.Characteristic.CoolingThresholdTemperature).props.minValue) || 10);
|
|
665
|
+
maxValue = Math.min(this.deviceConfig.maximumTargetTemperature, ((_b = this.HeaterCooler) === null || _b === void 0 ? void 0 : _b.getCharacteristic(this.platform.Characteristic.CoolingThresholdTemperature).props.maxValue) || 35);
|
|
623
666
|
break;
|
|
624
667
|
case commands_1.default.mode.value.heat:
|
|
625
|
-
minValue = Math.max(this.deviceConfig.minimumTargetTemperature, this.HeaterCooler.getCharacteristic(this.platform.Characteristic.HeatingThresholdTemperature).props.minValue || 0);
|
|
626
|
-
maxValue = Math.min(this.deviceConfig.maximumTargetTemperature, this.HeaterCooler.getCharacteristic(this.platform.Characteristic.HeatingThresholdTemperature).props.maxValue || 25);
|
|
668
|
+
minValue = Math.max(this.deviceConfig.minimumTargetTemperature, ((_c = this.HeaterCooler) === null || _c === void 0 ? void 0 : _c.getCharacteristic(this.platform.Characteristic.HeatingThresholdTemperature).props.minValue) || 0);
|
|
669
|
+
maxValue = Math.min(this.deviceConfig.maximumTargetTemperature, ((_d = this.HeaterCooler) === null || _d === void 0 ? void 0 : _d.getCharacteristic(this.platform.Characteristic.HeatingThresholdTemperature).props.maxValue) || 25);
|
|
627
670
|
break;
|
|
628
671
|
}
|
|
629
672
|
return Math.max(Math.min(this.getTargetTempFromDevice(this.status[commands_1.default.targetTemperature.code] || 25, this.status[commands_1.default.temperatureOffset.code] || 0), (maxValue)), (minValue));
|
|
630
673
|
}
|
|
631
674
|
set targetTemperature(value) {
|
|
675
|
+
var _a;
|
|
632
676
|
if (value === this.targetTemperature) {
|
|
633
677
|
return;
|
|
634
678
|
}
|
|
@@ -638,7 +682,7 @@ class GreeAirConditioner {
|
|
|
638
682
|
const tempOffset = this.calcDeviceTargetOffset(value);
|
|
639
683
|
command[commands_1.default.temperatureOffset.code] = tempOffset;
|
|
640
684
|
logValue += ', temperatureOffset -> ' + tempOffset.toString();
|
|
641
|
-
const displayUnits = this.HeaterCooler.getCharacteristic(this.platform.Characteristic.TemperatureDisplayUnits).value;
|
|
685
|
+
const displayUnits = (_a = this.HeaterCooler) === null || _a === void 0 ? void 0 : _a.getCharacteristic(this.platform.Characteristic.TemperatureDisplayUnits).value;
|
|
642
686
|
const deviceDisplayUnits = (displayUnits === this.platform.Characteristic.TemperatureDisplayUnits.CELSIUS) ?
|
|
643
687
|
commands_1.default.units.value.celsius : commands_1.default.units.value.fahrenheit;
|
|
644
688
|
if (deviceDisplayUnits === commands_1.default.units.value.fahrenheit) {
|
|
@@ -736,13 +780,12 @@ class GreeAirConditioner {
|
|
|
736
780
|
this.sendCommand(command);
|
|
737
781
|
}
|
|
738
782
|
updateStatus(props) {
|
|
739
|
-
var _a, _b, _c;
|
|
783
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y;
|
|
740
784
|
this.platform.log.debug(`[${this.getDeviceLabel()}] updateStatus -> %j`, props);
|
|
741
785
|
// Active
|
|
742
786
|
if (props.includes(commands_1.default.power.code)) {
|
|
743
787
|
this.platform.log.debug(`[${this.getDeviceLabel()}] updateStatus (Active) ->`, this.power ? 'ACTIVE' : 'INACTIVE');
|
|
744
|
-
this.HeaterCooler.getCharacteristic(this.platform.Characteristic.Active)
|
|
745
|
-
.updateValue(this.power ?
|
|
788
|
+
(_a = this.HeaterCooler) === null || _a === void 0 ? void 0 : _a.getCharacteristic(this.platform.Characteristic.Active).updateValue(this.power ?
|
|
746
789
|
this.platform.Characteristic.Active.ACTIVE : this.platform.Characteristic.Active.INACTIVE);
|
|
747
790
|
}
|
|
748
791
|
// Current Heater-Cooler State
|
|
@@ -751,43 +794,36 @@ class GreeAirConditioner {
|
|
|
751
794
|
switch (this.mode) {
|
|
752
795
|
case commands_1.default.mode.value.cool:
|
|
753
796
|
this.platform.log.debug(`[${this.getDeviceLabel()}] updateStatus (Current Heater-Cooler State) -> COOLING`);
|
|
754
|
-
this.HeaterCooler.getCharacteristic(this.platform.Characteristic.CurrentHeaterCoolerState)
|
|
755
|
-
.updateValue(this.platform.Characteristic.CurrentHeaterCoolerState.COOLING);
|
|
797
|
+
(_b = this.HeaterCooler) === null || _b === void 0 ? void 0 : _b.getCharacteristic(this.platform.Characteristic.CurrentHeaterCoolerState).updateValue(this.platform.Characteristic.CurrentHeaterCoolerState.COOLING);
|
|
756
798
|
break;
|
|
757
799
|
case commands_1.default.mode.value.heat:
|
|
758
800
|
this.platform.log.debug(`[${this.getDeviceLabel()}] updateStatus (Current Heater-Cooler State) -> HEATING`);
|
|
759
|
-
this.HeaterCooler.getCharacteristic(this.platform.Characteristic.CurrentHeaterCoolerState)
|
|
760
|
-
.updateValue(this.platform.Characteristic.CurrentHeaterCoolerState.HEATING);
|
|
801
|
+
(_c = this.HeaterCooler) === null || _c === void 0 ? void 0 : _c.getCharacteristic(this.platform.Characteristic.CurrentHeaterCoolerState).updateValue(this.platform.Characteristic.CurrentHeaterCoolerState.HEATING);
|
|
761
802
|
break;
|
|
762
803
|
case commands_1.default.mode.value.fan:
|
|
763
804
|
case commands_1.default.mode.value.dry:
|
|
764
805
|
this.platform.log.debug(`[${this.getDeviceLabel()}] updateStatus (Current Heater-Cooler State) -> IDLE`);
|
|
765
|
-
this.HeaterCooler.getCharacteristic(this.platform.Characteristic.CurrentHeaterCoolerState)
|
|
766
|
-
.updateValue(this.platform.Characteristic.CurrentHeaterCoolerState.IDLE);
|
|
806
|
+
(_d = this.HeaterCooler) === null || _d === void 0 ? void 0 : _d.getCharacteristic(this.platform.Characteristic.CurrentHeaterCoolerState).updateValue(this.platform.Characteristic.CurrentHeaterCoolerState.IDLE);
|
|
767
807
|
break;
|
|
768
808
|
case commands_1.default.mode.value.auto:
|
|
769
809
|
if (this.currentTemperature > this.targetTemperature + 1.5) {
|
|
770
810
|
this.platform.log.debug(`[${this.getDeviceLabel()}] updateStatus (Current Heater-Cooler State) -> COOLING`);
|
|
771
|
-
this.HeaterCooler.getCharacteristic(this.platform.Characteristic.CurrentHeaterCoolerState)
|
|
772
|
-
.updateValue(this.platform.Characteristic.CurrentHeaterCoolerState.COOLING);
|
|
811
|
+
(_e = this.HeaterCooler) === null || _e === void 0 ? void 0 : _e.getCharacteristic(this.platform.Characteristic.CurrentHeaterCoolerState).updateValue(this.platform.Characteristic.CurrentHeaterCoolerState.COOLING);
|
|
773
812
|
}
|
|
774
813
|
else if (this.currentTemperature < this.targetTemperature - 1.5) {
|
|
775
814
|
this.platform.log.debug(`[${this.getDeviceLabel()}] updateStatus (Current Heater-Cooler State) -> HEATING`);
|
|
776
|
-
this.HeaterCooler.getCharacteristic(this.platform.Characteristic.CurrentHeaterCoolerState)
|
|
777
|
-
.updateValue(this.platform.Characteristic.CurrentHeaterCoolerState.HEATING);
|
|
815
|
+
(_f = this.HeaterCooler) === null || _f === void 0 ? void 0 : _f.getCharacteristic(this.platform.Characteristic.CurrentHeaterCoolerState).updateValue(this.platform.Characteristic.CurrentHeaterCoolerState.HEATING);
|
|
778
816
|
}
|
|
779
817
|
else {
|
|
780
818
|
this.platform.log.debug(`[${this.getDeviceLabel()}] updateStatus (Current Heater-Cooler State) -> IDLE`);
|
|
781
|
-
this.HeaterCooler.getCharacteristic(this.platform.Characteristic.CurrentHeaterCoolerState)
|
|
782
|
-
.updateValue(this.platform.Characteristic.CurrentHeaterCoolerState.IDLE);
|
|
819
|
+
(_g = this.HeaterCooler) === null || _g === void 0 ? void 0 : _g.getCharacteristic(this.platform.Characteristic.CurrentHeaterCoolerState).updateValue(this.platform.Characteristic.CurrentHeaterCoolerState.IDLE);
|
|
783
820
|
}
|
|
784
821
|
break;
|
|
785
822
|
}
|
|
786
823
|
}
|
|
787
824
|
else {
|
|
788
825
|
this.platform.log.debug(`[${this.getDeviceLabel()}] updateStatus (Current Heater-Cooler State) -> INACTIVE`);
|
|
789
|
-
this.HeaterCooler.getCharacteristic(this.platform.Characteristic.CurrentHeaterCoolerState)
|
|
790
|
-
.updateValue(this.platform.Characteristic.CurrentHeaterCoolerState.INACTIVE);
|
|
826
|
+
(_h = this.HeaterCooler) === null || _h === void 0 ? void 0 : _h.getCharacteristic(this.platform.Characteristic.CurrentHeaterCoolerState).updateValue(this.platform.Characteristic.CurrentHeaterCoolerState.INACTIVE);
|
|
791
827
|
}
|
|
792
828
|
}
|
|
793
829
|
// Target Heater-Cooler State
|
|
@@ -795,54 +831,46 @@ class GreeAirConditioner {
|
|
|
795
831
|
switch (this.mode) {
|
|
796
832
|
case commands_1.default.mode.value.cool:
|
|
797
833
|
this.platform.log.debug(`[${this.getDeviceLabel()}] updateStatus (Target Heater-Cooler State) -> COOL`);
|
|
798
|
-
this.HeaterCooler.getCharacteristic(this.platform.Characteristic.TargetHeaterCoolerState)
|
|
799
|
-
.updateValue(this.platform.Characteristic.TargetHeaterCoolerState.COOL);
|
|
834
|
+
(_j = this.HeaterCooler) === null || _j === void 0 ? void 0 : _j.getCharacteristic(this.platform.Characteristic.TargetHeaterCoolerState).updateValue(this.platform.Characteristic.TargetHeaterCoolerState.COOL);
|
|
800
835
|
break;
|
|
801
836
|
case commands_1.default.mode.value.heat:
|
|
802
837
|
this.platform.log.debug(`[${this.getDeviceLabel()}] updateStatus (Target Heater-Cooler State) -> HEAT`);
|
|
803
|
-
this.HeaterCooler.getCharacteristic(this.platform.Characteristic.TargetHeaterCoolerState)
|
|
804
|
-
.updateValue(this.platform.Characteristic.TargetHeaterCoolerState.HEAT);
|
|
838
|
+
(_k = this.HeaterCooler) === null || _k === void 0 ? void 0 : _k.getCharacteristic(this.platform.Characteristic.TargetHeaterCoolerState).updateValue(this.platform.Characteristic.TargetHeaterCoolerState.HEAT);
|
|
805
839
|
break;
|
|
806
840
|
default:
|
|
807
841
|
this.platform.log.debug(`[${this.getDeviceLabel()}] updateStatus (Target Heater-Cooler State) -> AUTO`);
|
|
808
|
-
this.HeaterCooler.getCharacteristic(this.platform.Characteristic.TargetHeaterCoolerState)
|
|
809
|
-
.updateValue(this.platform.Characteristic.TargetHeaterCoolerState.AUTO);
|
|
842
|
+
(_l = this.HeaterCooler) === null || _l === void 0 ? void 0 : _l.getCharacteristic(this.platform.Characteristic.TargetHeaterCoolerState).updateValue(this.platform.Characteristic.TargetHeaterCoolerState.AUTO);
|
|
810
843
|
}
|
|
811
844
|
}
|
|
812
845
|
// Current Temperature
|
|
813
846
|
if (props.includes(commands_1.default.temperature.code)) {
|
|
814
847
|
this.platform.log.debug(`[${this.getDeviceLabel()}] updateStatus (Current Temperature) ->`, this.currentTemperature);
|
|
815
|
-
this.HeaterCooler.getCharacteristic(this.platform.Characteristic.CurrentTemperature)
|
|
816
|
-
|
|
817
|
-
(
|
|
818
|
-
(
|
|
819
|
-
(_c = this.platform_ts) === null || _c === void 0 ? void 0 : _c.TemperatureSensor.getCharacteristic(this.platform.Characteristic.CurrentTemperature).updateValue(this.currentTemperature);
|
|
848
|
+
(_m = this.HeaterCooler) === null || _m === void 0 ? void 0 : _m.getCharacteristic(this.platform.Characteristic.CurrentTemperature).updateValue(this.currentTemperature);
|
|
849
|
+
(_o = this.TemperatureSensor) === null || _o === void 0 ? void 0 : _o.getCharacteristic(this.platform.Characteristic.CurrentTemperature).updateValue(this.currentTemperature);
|
|
850
|
+
(_p = this.tsAccessory) === null || _p === void 0 ? void 0 : _p.setCurrentTemperature(this.currentTemperature);
|
|
851
|
+
(_q = this.tsAccessory) === null || _q === void 0 ? void 0 : _q.TemperatureSensor.getCharacteristic(this.platform.Characteristic.CurrentTemperature).updateValue(this.currentTemperature);
|
|
820
852
|
}
|
|
821
853
|
else if (props.includes(commands_1.default.targetTemperature.code) && this.TemperatureSensor === undefined) {
|
|
822
854
|
// temperature is not accessible -> targetTemperature is saved as currentTemperature
|
|
823
855
|
this.platform.log.debug(`[${this.getDeviceLabel()}] updateStatus (Current Temperature) ->`, this.currentTemperature);
|
|
824
|
-
this.HeaterCooler.getCharacteristic(this.platform.Characteristic.CurrentTemperature)
|
|
825
|
-
.updateValue(this.currentTemperature);
|
|
856
|
+
(_r = this.HeaterCooler) === null || _r === void 0 ? void 0 : _r.getCharacteristic(this.platform.Characteristic.CurrentTemperature).updateValue(this.currentTemperature);
|
|
826
857
|
}
|
|
827
858
|
// Cooling Threshold Temperature
|
|
828
859
|
if (props.includes(commands_1.default.targetTemperature.code) && this.power &&
|
|
829
860
|
(this.mode === commands_1.default.mode.value.cool || this.mode === commands_1.default.mode.value.auto)) {
|
|
830
861
|
this.platform.log.debug(`[${this.getDeviceLabel()}] updateStatus (Cooling Threshold Temperature) ->`, this.targetTemperature);
|
|
831
|
-
this.HeaterCooler.getCharacteristic(this.platform.Characteristic.CoolingThresholdTemperature)
|
|
832
|
-
.updateValue(this.targetTemperature);
|
|
862
|
+
(_s = this.HeaterCooler) === null || _s === void 0 ? void 0 : _s.getCharacteristic(this.platform.Characteristic.CoolingThresholdTemperature).updateValue(this.targetTemperature);
|
|
833
863
|
}
|
|
834
864
|
// Heating Threshold Temperature
|
|
835
865
|
if (props.includes(commands_1.default.targetTemperature.code) && this.power &&
|
|
836
866
|
(this.mode === commands_1.default.mode.value.heat || this.mode === commands_1.default.mode.value.auto)) {
|
|
837
867
|
this.platform.log.debug(`[${this.getDeviceLabel()}] updateStatus (Heating Threshold Temperature) ->`, this.targetTemperature);
|
|
838
|
-
this.HeaterCooler.getCharacteristic(this.platform.Characteristic.HeatingThresholdTemperature)
|
|
839
|
-
.updateValue(this.targetTemperature);
|
|
868
|
+
(_t = this.HeaterCooler) === null || _t === void 0 ? void 0 : _t.getCharacteristic(this.platform.Characteristic.HeatingThresholdTemperature).updateValue(this.targetTemperature);
|
|
840
869
|
}
|
|
841
870
|
// Temperature Display Units
|
|
842
871
|
if (props.includes(commands_1.default.units.code)) {
|
|
843
872
|
this.platform.log.debug(`[${this.getDeviceLabel()}] updateStatus (Temperature Display Units) ->`, this.units === commands_1.default.units.value.celsius ? 'CELSIUS' : 'FAHRENHEIT');
|
|
844
|
-
this.HeaterCooler.getCharacteristic(this.platform.Characteristic.TemperatureDisplayUnits)
|
|
845
|
-
.updateValue(this.units === commands_1.default.units.value.celsius ?
|
|
873
|
+
(_u = this.HeaterCooler) === null || _u === void 0 ? void 0 : _u.getCharacteristic(this.platform.Characteristic.TemperatureDisplayUnits).updateValue(this.units === commands_1.default.units.value.celsius ?
|
|
846
874
|
this.platform.Characteristic.TemperatureDisplayUnits.CELSIUS : this.platform.Characteristic.TemperatureDisplayUnits.FAHRENHEIT);
|
|
847
875
|
}
|
|
848
876
|
// Swing Mode
|
|
@@ -865,8 +893,7 @@ class GreeAirConditioner {
|
|
|
865
893
|
break;
|
|
866
894
|
}
|
|
867
895
|
this.platform.log.debug(`[${this.getDeviceLabel()}] updateStatus (Swing Mode) ->`, logValue);
|
|
868
|
-
this.HeaterCooler.getCharacteristic(this.platform.Characteristic.SwingMode)
|
|
869
|
-
.updateValue(swing);
|
|
896
|
+
(_v = this.HeaterCooler) === null || _v === void 0 ? void 0 : _v.getCharacteristic(this.platform.Characteristic.SwingMode).updateValue(swing);
|
|
870
897
|
}
|
|
871
898
|
// Rotation Speed
|
|
872
899
|
if (this.power) {
|
|
@@ -874,15 +901,13 @@ class GreeAirConditioner {
|
|
|
874
901
|
if (props.includes(commands_1.default.quietMode.code) && this.quietMode === commands_1.default.quietMode.value.on) {
|
|
875
902
|
// quietMode -> on
|
|
876
903
|
this.platform.log.debug(`[${this.getDeviceLabel()}] updateStatus (Rotation Speed) -> 1 (quiet)`);
|
|
877
|
-
this.HeaterCooler.getCharacteristic(this.platform.Characteristic.RotationSpeed)
|
|
878
|
-
.updateValue(1);
|
|
904
|
+
(_w = this.HeaterCooler) === null || _w === void 0 ? void 0 : _w.getCharacteristic(this.platform.Characteristic.RotationSpeed).updateValue(1);
|
|
879
905
|
}
|
|
880
906
|
else if (props.includes(commands_1.default.powerfulMode.code) && this.powerfulMode === commands_1.default.powerfulMode.value.on) {
|
|
881
907
|
// powerfulMode -> on
|
|
882
908
|
logValue = `${this.deviceConfig.speedSteps + 3} (powerful)`;
|
|
883
909
|
this.platform.log.debug(`[${this.getDeviceLabel()}] updateStatus (Rotation Speed) ->`, logValue);
|
|
884
|
-
this.HeaterCooler.getCharacteristic(this.platform.Characteristic.RotationSpeed)
|
|
885
|
-
.updateValue(this.deviceConfig.speedSteps + 3);
|
|
910
|
+
(_x = this.HeaterCooler) === null || _x === void 0 ? void 0 : _x.getCharacteristic(this.platform.Characteristic.RotationSpeed).updateValue(this.deviceConfig.speedSteps + 3);
|
|
886
911
|
}
|
|
887
912
|
else if (props.includes(commands_1.default.speed.code)) {
|
|
888
913
|
// speed
|
|
@@ -910,8 +935,7 @@ class GreeAirConditioner {
|
|
|
910
935
|
break;
|
|
911
936
|
}
|
|
912
937
|
this.platform.log.debug(`[${this.getDeviceLabel()}] updateStatus (Rotation Speed) ->`, logValue);
|
|
913
|
-
this.HeaterCooler.getCharacteristic(this.platform.Characteristic.RotationSpeed)
|
|
914
|
-
.updateValue(speedValue);
|
|
938
|
+
(_y = this.HeaterCooler) === null || _y === void 0 ? void 0 : _y.getCharacteristic(this.platform.Characteristic.RotationSpeed).updateValue(speedValue);
|
|
915
939
|
}
|
|
916
940
|
}
|
|
917
941
|
}
|