homebridge-gree-ac 2.1.3 → 2.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +26 -2
- package/README.md +4 -4
- 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 +136 -105
- 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,31 +47,39 @@ 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
|
+
let invalidTempFromDevice = false;
|
|
66
67
|
pack.cols.forEach((col, i) => {
|
|
67
|
-
if (
|
|
68
|
+
if (col === commands_1.default.temperature.code && (pack.dat[i] <= 0 || pack.dat[i] >= 100)) {
|
|
69
|
+
// temperature value outside of valid range (1-99 -> -39°C - +59°C) should be ignored (means: no sensor data)
|
|
70
|
+
invalidTempFromDevice = true;
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
68
73
|
this.status[col] = pack.dat[i];
|
|
69
74
|
}
|
|
70
75
|
});
|
|
71
76
|
this.platform.log.debug(`[${this.getDeviceLabel()}] Device status -> %j`, this.status);
|
|
72
|
-
if (!pack.cols.includes(commands_1.default.temperature.code)
|
|
73
|
-
pack.cols.includes(commands_1.default.targetTemperature.code)) {
|
|
77
|
+
if (!pack.cols.includes(commands_1.default.temperature.code) || invalidTempFromDevice) {
|
|
74
78
|
// temperature is not accessible -> use targetTemperature
|
|
75
|
-
|
|
79
|
+
const targetTemp = this.status[commands_1.default.targetTemperature.code] !== undefined ?
|
|
80
|
+
this.status[commands_1.default.targetTemperature.code] : 25; // use default if target temperature is also unknown
|
|
81
|
+
this.status[commands_1.default.temperature.code] = targetTemp + this.deviceConfig.sensorOffset;
|
|
82
|
+
this.platform.log.debug(`[${this.getDeviceLabel()}] Current temperature not available`, '- Threshold temperature is used as current (' + commands_1.default.targetTemperature.code + '->' + commands_1.default.temperature.code + ')');
|
|
76
83
|
if (this.TemperatureSensor !== undefined) {
|
|
77
84
|
this.accessory.removeService(this.TemperatureSensor);
|
|
78
85
|
this.TemperatureSensor = undefined;
|
|
@@ -83,7 +90,7 @@ class GreeAirConditioner {
|
|
|
83
90
|
}
|
|
84
91
|
break;
|
|
85
92
|
case 'res': // package type is response
|
|
86
|
-
if (this.bound) {
|
|
93
|
+
if (this.accessory.bound) {
|
|
87
94
|
this.platform.log.debug(`[${this.getDeviceLabel()}] Device response`);
|
|
88
95
|
const updatedParams = [];
|
|
89
96
|
pack.opt.forEach((opt, i) => {
|
|
@@ -108,13 +115,47 @@ class GreeAirConditioner {
|
|
|
108
115
|
}
|
|
109
116
|
}
|
|
110
117
|
};
|
|
111
|
-
|
|
112
|
-
|
|
118
|
+
// platform, accessory and service initialization is implemented in a separate funcion (initAccessory), because
|
|
119
|
+
// it should be made only on successful binding with network device
|
|
113
120
|
this.platform.log.debug(`[${this.getDeviceLabel()}] deviceConfig -> %j`, deviceConfig);
|
|
121
|
+
// initialize communication with device
|
|
122
|
+
this.status = {};
|
|
123
|
+
this.socket = dgram_1.default.createSocket({ type: 'udp4', reuseAddr: true });
|
|
124
|
+
this.socket.on('error', (err) => {
|
|
125
|
+
this.platform.log.error(`[${this.getDeviceLabel()}] Network - Error:`, err.message);
|
|
126
|
+
});
|
|
127
|
+
this.socket.on('message', this.handleMessage);
|
|
128
|
+
this.socket.on('close', () => {
|
|
129
|
+
this.platform.log.error(`[${this.getDeviceLabel()}] Network - Connection closed`);
|
|
130
|
+
});
|
|
131
|
+
if (this.platform.ports.indexOf(this.deviceConfig.port || 0) >= 0) {
|
|
132
|
+
this.platform.log.warn(`[${this.getDeviceLabel()}] Warning: Configured port (%i) is already used - replacing with auto assigned port`, this.deviceConfig.port);
|
|
133
|
+
this.deviceConfig.port = undefined;
|
|
134
|
+
}
|
|
135
|
+
this.socket.bind(this.deviceConfig.port, undefined, () => {
|
|
136
|
+
this.platform.log.info(`[${this.getDeviceLabel()}] Device handler is listening on UDP port %d`, this.socket.address().port);
|
|
137
|
+
this.platform.ports.push(this.socket.address().port);
|
|
138
|
+
this.socket.setBroadcast(false);
|
|
139
|
+
this.sendBindRequest();
|
|
140
|
+
setTimeout(this.checkBindingStatus.bind(this, 1), settings_1.BINDING_TIMEOUT);
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
// All platform, accessory and service initialization is made in initAccessory function
|
|
144
|
+
initAccessory() {
|
|
145
|
+
var _a, _b, _c;
|
|
146
|
+
// register accessory in homebridge by api if not registered before
|
|
147
|
+
if (!this.accessory.registered) {
|
|
148
|
+
this.platform.log.debug(`[${this.getDeviceLabel()}] registering new accessory in homebridge:`, this.accessory.context.device.mac, this.accessory.UUID);
|
|
149
|
+
this.platform.api.registerPlatformAccessories(settings_1.PLUGIN_NAME, settings_1.PLATFORM_NAME, [this.accessory]);
|
|
150
|
+
}
|
|
151
|
+
this.platform.api.updatePlatformAccessories([this.accessory]);
|
|
152
|
+
if (this.tsAccessoryMac) {
|
|
153
|
+
this.tsAccessory = new tsAccessory_1.GreeAirConditionerTS(this.platform, this.platform.getAccessory(this.accessory.context.device.mac + '_ts'));
|
|
154
|
+
}
|
|
114
155
|
// set accessory information
|
|
115
156
|
this.accessory.getService(this.platform.Service.AccessoryInformation)
|
|
116
157
|
.setCharacteristic(this.platform.Characteristic.Manufacturer, this.accessory.context.device.brand || 'Gree')
|
|
117
|
-
.setCharacteristic(this.platform.Characteristic.Model, ((
|
|
158
|
+
.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
159
|
.setCharacteristic(this.platform.Characteristic.SerialNumber, this.accessory.context.device.mac)
|
|
119
160
|
.setCharacteristic(this.platform.Characteristic.FirmwareRevision, this.accessory.context.device.hid && this.accessory.context.device.hid.lastIndexOf('V') >= 0 &&
|
|
120
161
|
this.accessory.context.device.hid.lastIndexOf('V') < this.accessory.context.device.hid.lastIndexOf('.') ?
|
|
@@ -127,7 +168,7 @@ class GreeAirConditioner {
|
|
|
127
168
|
this.HeaterCooler = this.accessory.getService(this.platform.Service.HeaterCooler) ||
|
|
128
169
|
this.accessory.addService(this.platform.Service.HeaterCooler, this.accessory.displayName, undefined);
|
|
129
170
|
this.HeaterCooler.displayName = this.accessory.displayName;
|
|
130
|
-
if (deviceConfig.temperatureSensor === settings_1.TS_TYPE.child) {
|
|
171
|
+
if (this.deviceConfig.temperatureSensor === settings_1.TS_TYPE.child) {
|
|
131
172
|
this.platform.log.debug(`[${this.getDeviceLabel()}] Add Temperature Sensor child service`);
|
|
132
173
|
this.TemperatureSensor = this.accessory.getService(this.platform.Service.TemperatureSensor) ||
|
|
133
174
|
this.accessory.addService(this.platform.Service.TemperatureSensor, 'Temperature Sensor - ' + this.accessory.displayName, undefined);
|
|
@@ -135,14 +176,14 @@ class GreeAirConditioner {
|
|
|
135
176
|
}
|
|
136
177
|
else {
|
|
137
178
|
const ts = this.accessory.getService(this.platform.Service.TemperatureSensor);
|
|
138
|
-
this.platform.log.debug(`[${this.getDeviceLabel()}] Temperature Sensor child service not allowed
|
|
179
|
+
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
180
|
if (ts !== undefined) {
|
|
140
181
|
this.platform.log.debug(`[${this.getDeviceLabel()}] Remove Temperature Sensor child service (%s)`, ts.displayName);
|
|
141
182
|
this.accessory.removeService(ts);
|
|
142
183
|
}
|
|
143
184
|
}
|
|
144
185
|
this.HeaterCooler.setPrimaryService(true);
|
|
145
|
-
(
|
|
186
|
+
(_b = this.TemperatureSensor) === null || _b === void 0 ? void 0 : _b.setPrimaryService(false);
|
|
146
187
|
// each service must implement at-minimum the "required characteristics" for the given service type
|
|
147
188
|
// see https://developers.homebridge.io/#/service/HeaterCooler
|
|
148
189
|
// register handlers for the Active Characteristic
|
|
@@ -159,7 +200,7 @@ class GreeAirConditioner {
|
|
|
159
200
|
// register handlers for the Current Temperature Characteristic
|
|
160
201
|
this.HeaterCooler.getCharacteristic(this.platform.Characteristic.CurrentTemperature)
|
|
161
202
|
.onGet(this.getCurrentTemperature.bind(this, 'Heater Cooler'));
|
|
162
|
-
(
|
|
203
|
+
(_c = this.TemperatureSensor) === null || _c === void 0 ? void 0 : _c.getCharacteristic(this.platform.Characteristic.CurrentTemperature).onGet(this.getCurrentTemperature.bind(this, 'Temperature Sensor'));
|
|
163
204
|
// register handlers for the Cooling Threshold Temperature Characteristic
|
|
164
205
|
// (minValue and maxValue can't be set here, they need an active accessory in cooling sate to set)
|
|
165
206
|
this.HeaterCooler.getCharacteristic(this.platform.Characteristic.CoolingThresholdTemperature)
|
|
@@ -189,22 +230,29 @@ class GreeAirConditioner {
|
|
|
189
230
|
})
|
|
190
231
|
.onGet(this.getRotationSpeed.bind(this))
|
|
191
232
|
.onSet(this.setRotationSpeed.bind(this));
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
this.
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
233
|
+
}
|
|
234
|
+
// this function is a callback to check the status of binding after timeout period has ellapsed
|
|
235
|
+
checkBindingStatus(bindNo) {
|
|
236
|
+
if (!this.accessory.bound) {
|
|
237
|
+
this.platform.log.debug(`[${this.getDeviceLabel()}] Device binding timeout`);
|
|
238
|
+
switch (bindNo) {
|
|
239
|
+
case 1: {
|
|
240
|
+
// 1. timeout -> repeat bind request with alternate encryption version
|
|
241
|
+
if (this.accessory.context.device.encryptionVersion === 1) {
|
|
242
|
+
this.accessory.context.device.encryptionVersion = 2;
|
|
243
|
+
}
|
|
244
|
+
else {
|
|
245
|
+
this.accessory.context.device.encryptionVersion = 1;
|
|
246
|
+
}
|
|
247
|
+
this.sendBindRequest();
|
|
248
|
+
setTimeout(this.checkBindingStatus.bind(this, bindNo + 1), settings_1.BINDING_TIMEOUT);
|
|
249
|
+
break;
|
|
250
|
+
}
|
|
251
|
+
default: {
|
|
252
|
+
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!');
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}
|
|
208
256
|
}
|
|
209
257
|
/**
|
|
210
258
|
* Handle "SET" requests from HomeKit
|
|
@@ -438,28 +486,27 @@ class GreeAirConditioner {
|
|
|
438
486
|
}
|
|
439
487
|
// helper functions
|
|
440
488
|
initThresholdTemperature(HeaterCoolerState) {
|
|
489
|
+
var _a, _b, _c, _d, _e, _f;
|
|
441
490
|
switch (HeaterCoolerState) {
|
|
442
491
|
case this.platform.Characteristic.CurrentHeaterCoolerState.COOLING:
|
|
443
|
-
if (this.HeaterCooler.getCharacteristic(this.platform.Characteristic.CoolingThresholdTemperature).props.minValue !==
|
|
492
|
+
if (((_a = this.HeaterCooler) === null || _a === void 0 ? void 0 : _a.getCharacteristic(this.platform.Characteristic.CoolingThresholdTemperature).props.minValue) !==
|
|
444
493
|
this.deviceConfig.minimumTargetTemperature ||
|
|
445
|
-
this.HeaterCooler.getCharacteristic(this.platform.Characteristic.CoolingThresholdTemperature).props.maxValue !==
|
|
494
|
+
((_b = this.HeaterCooler) === null || _b === void 0 ? void 0 : _b.getCharacteristic(this.platform.Characteristic.CoolingThresholdTemperature).props.maxValue) !==
|
|
446
495
|
this.deviceConfig.maximumTargetTemperature) {
|
|
447
496
|
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({
|
|
497
|
+
(_c = this.HeaterCooler) === null || _c === void 0 ? void 0 : _c.getCharacteristic(this.platform.Characteristic.CoolingThresholdTemperature).setProps({
|
|
450
498
|
minValue: this.deviceConfig.minimumTargetTemperature,
|
|
451
499
|
maxValue: this.deviceConfig.maximumTargetTemperature
|
|
452
500
|
});
|
|
453
501
|
}
|
|
454
502
|
break;
|
|
455
503
|
case this.platform.Characteristic.CurrentHeaterCoolerState.HEATING:
|
|
456
|
-
if (this.HeaterCooler.getCharacteristic(this.platform.Characteristic.HeatingThresholdTemperature).props.minValue !==
|
|
504
|
+
if (((_d = this.HeaterCooler) === null || _d === void 0 ? void 0 : _d.getCharacteristic(this.platform.Characteristic.HeatingThresholdTemperature).props.minValue) !==
|
|
457
505
|
this.deviceConfig.minimumTargetTemperature ||
|
|
458
|
-
this.HeaterCooler.getCharacteristic(this.platform.Characteristic.HeatingThresholdTemperature).props.maxValue !==
|
|
506
|
+
((_e = this.HeaterCooler) === null || _e === void 0 ? void 0 : _e.getCharacteristic(this.platform.Characteristic.HeatingThresholdTemperature).props.maxValue) !==
|
|
459
507
|
this.deviceConfig.maximumTargetTemperature) {
|
|
460
508
|
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({
|
|
509
|
+
(_f = this.HeaterCooler) === null || _f === void 0 ? void 0 : _f.getCharacteristic(this.platform.Characteristic.HeatingThresholdTemperature).setProps({
|
|
463
510
|
minValue: this.deviceConfig.minimumTargetTemperature,
|
|
464
511
|
maxValue: this.deviceConfig.maximumTargetTemperature
|
|
465
512
|
});
|
|
@@ -522,14 +569,15 @@ class GreeAirConditioner {
|
|
|
522
569
|
(baseFahrenheitDecimalPart >= 0.75 && baseFahrenheitDecimalPart < 0.85)) ? 1 : 0);
|
|
523
570
|
}
|
|
524
571
|
getTargetTempFromDevice(temp, offset) {
|
|
572
|
+
var _a, _b;
|
|
525
573
|
const key = temp.toString() + ',' + offset.toString();
|
|
526
574
|
const value = settings_1.TEMPERATURE_TABLE[key];
|
|
527
575
|
if (value === undefined) {
|
|
528
576
|
return 25; // default value if invalid data received from device
|
|
529
577
|
}
|
|
530
578
|
// 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;
|
|
579
|
+
const targetValue = ((_a = this.HeaterCooler) === null || _a === void 0 ? void 0 : _a.getCharacteristic(this.platform.Characteristic.CoolingThresholdTemperature).value) ||
|
|
580
|
+
((_b = this.HeaterCooler) === null || _b === void 0 ? void 0 : _b.getCharacteristic(this.platform.Characteristic.HeatingThresholdTemperature).value);
|
|
533
581
|
if ((targetValue === 17.5 && value === 18) ||
|
|
534
582
|
(targetValue === 22.5 && value === 23) ||
|
|
535
583
|
(targetValue === 27.5 && value === 28)) {
|
|
@@ -544,6 +592,7 @@ class GreeAirConditioner {
|
|
|
544
592
|
return (this.status[commands_1.default.power.code] === commands_1.default.power.value.on);
|
|
545
593
|
}
|
|
546
594
|
set power(value) {
|
|
595
|
+
var _a;
|
|
547
596
|
if (value === this.power) {
|
|
548
597
|
return;
|
|
549
598
|
}
|
|
@@ -551,7 +600,7 @@ class GreeAirConditioner {
|
|
|
551
600
|
const command = { [commands_1.default.power.code]: powerValue };
|
|
552
601
|
let logValue = 'power -> ' + this.getKeyName(commands_1.default.power.value, powerValue);
|
|
553
602
|
if (powerValue === commands_1.default.power.value.on) {
|
|
554
|
-
switch (this.HeaterCooler.getCharacteristic(this.platform.Characteristic.TargetHeaterCoolerState).value) {
|
|
603
|
+
switch ((_a = this.HeaterCooler) === null || _a === void 0 ? void 0 : _a.getCharacteristic(this.platform.Characteristic.TargetHeaterCoolerState).value) {
|
|
555
604
|
case this.platform.Characteristic.TargetHeaterCoolerState.COOL:
|
|
556
605
|
if (this.status[commands_1.default.mode.code] !== commands_1.default.mode.value.cool) {
|
|
557
606
|
command[commands_1.default.mode.code] = commands_1.default.mode.value.cool;
|
|
@@ -614,21 +663,23 @@ class GreeAirConditioner {
|
|
|
614
663
|
return this.status[commands_1.default.temperature.code] - (this.deviceConfig.sensorOffset) || 25;
|
|
615
664
|
}
|
|
616
665
|
get targetTemperature() {
|
|
666
|
+
var _a, _b, _c, _d;
|
|
617
667
|
let minValue = this.deviceConfig.minimumTargetTemperature;
|
|
618
668
|
let maxValue = this.deviceConfig.maximumTargetTemperature;
|
|
619
669
|
switch (this.status[commands_1.default.mode.code]) {
|
|
620
670
|
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);
|
|
671
|
+
minValue = Math.max(this.deviceConfig.minimumTargetTemperature, ((_a = this.HeaterCooler) === null || _a === void 0 ? void 0 : _a.getCharacteristic(this.platform.Characteristic.CoolingThresholdTemperature).props.minValue) || 10);
|
|
672
|
+
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
673
|
break;
|
|
624
674
|
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);
|
|
675
|
+
minValue = Math.max(this.deviceConfig.minimumTargetTemperature, ((_c = this.HeaterCooler) === null || _c === void 0 ? void 0 : _c.getCharacteristic(this.platform.Characteristic.HeatingThresholdTemperature).props.minValue) || 0);
|
|
676
|
+
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
677
|
break;
|
|
628
678
|
}
|
|
629
679
|
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
680
|
}
|
|
631
681
|
set targetTemperature(value) {
|
|
682
|
+
var _a;
|
|
632
683
|
if (value === this.targetTemperature) {
|
|
633
684
|
return;
|
|
634
685
|
}
|
|
@@ -638,7 +689,7 @@ class GreeAirConditioner {
|
|
|
638
689
|
const tempOffset = this.calcDeviceTargetOffset(value);
|
|
639
690
|
command[commands_1.default.temperatureOffset.code] = tempOffset;
|
|
640
691
|
logValue += ', temperatureOffset -> ' + tempOffset.toString();
|
|
641
|
-
const displayUnits = this.HeaterCooler.getCharacteristic(this.platform.Characteristic.TemperatureDisplayUnits).value;
|
|
692
|
+
const displayUnits = (_a = this.HeaterCooler) === null || _a === void 0 ? void 0 : _a.getCharacteristic(this.platform.Characteristic.TemperatureDisplayUnits).value;
|
|
642
693
|
const deviceDisplayUnits = (displayUnits === this.platform.Characteristic.TemperatureDisplayUnits.CELSIUS) ?
|
|
643
694
|
commands_1.default.units.value.celsius : commands_1.default.units.value.fahrenheit;
|
|
644
695
|
if (deviceDisplayUnits === commands_1.default.units.value.fahrenheit) {
|
|
@@ -736,13 +787,12 @@ class GreeAirConditioner {
|
|
|
736
787
|
this.sendCommand(command);
|
|
737
788
|
}
|
|
738
789
|
updateStatus(props) {
|
|
739
|
-
var _a, _b, _c;
|
|
790
|
+
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
791
|
this.platform.log.debug(`[${this.getDeviceLabel()}] updateStatus -> %j`, props);
|
|
741
792
|
// Active
|
|
742
793
|
if (props.includes(commands_1.default.power.code)) {
|
|
743
794
|
this.platform.log.debug(`[${this.getDeviceLabel()}] updateStatus (Active) ->`, this.power ? 'ACTIVE' : 'INACTIVE');
|
|
744
|
-
this.HeaterCooler.getCharacteristic(this.platform.Characteristic.Active)
|
|
745
|
-
.updateValue(this.power ?
|
|
795
|
+
(_a = this.HeaterCooler) === null || _a === void 0 ? void 0 : _a.getCharacteristic(this.platform.Characteristic.Active).updateValue(this.power ?
|
|
746
796
|
this.platform.Characteristic.Active.ACTIVE : this.platform.Characteristic.Active.INACTIVE);
|
|
747
797
|
}
|
|
748
798
|
// Current Heater-Cooler State
|
|
@@ -751,43 +801,36 @@ class GreeAirConditioner {
|
|
|
751
801
|
switch (this.mode) {
|
|
752
802
|
case commands_1.default.mode.value.cool:
|
|
753
803
|
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);
|
|
804
|
+
(_b = this.HeaterCooler) === null || _b === void 0 ? void 0 : _b.getCharacteristic(this.platform.Characteristic.CurrentHeaterCoolerState).updateValue(this.platform.Characteristic.CurrentHeaterCoolerState.COOLING);
|
|
756
805
|
break;
|
|
757
806
|
case commands_1.default.mode.value.heat:
|
|
758
807
|
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);
|
|
808
|
+
(_c = this.HeaterCooler) === null || _c === void 0 ? void 0 : _c.getCharacteristic(this.platform.Characteristic.CurrentHeaterCoolerState).updateValue(this.platform.Characteristic.CurrentHeaterCoolerState.HEATING);
|
|
761
809
|
break;
|
|
762
810
|
case commands_1.default.mode.value.fan:
|
|
763
811
|
case commands_1.default.mode.value.dry:
|
|
764
812
|
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);
|
|
813
|
+
(_d = this.HeaterCooler) === null || _d === void 0 ? void 0 : _d.getCharacteristic(this.platform.Characteristic.CurrentHeaterCoolerState).updateValue(this.platform.Characteristic.CurrentHeaterCoolerState.IDLE);
|
|
767
814
|
break;
|
|
768
815
|
case commands_1.default.mode.value.auto:
|
|
769
816
|
if (this.currentTemperature > this.targetTemperature + 1.5) {
|
|
770
817
|
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);
|
|
818
|
+
(_e = this.HeaterCooler) === null || _e === void 0 ? void 0 : _e.getCharacteristic(this.platform.Characteristic.CurrentHeaterCoolerState).updateValue(this.platform.Characteristic.CurrentHeaterCoolerState.COOLING);
|
|
773
819
|
}
|
|
774
820
|
else if (this.currentTemperature < this.targetTemperature - 1.5) {
|
|
775
821
|
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);
|
|
822
|
+
(_f = this.HeaterCooler) === null || _f === void 0 ? void 0 : _f.getCharacteristic(this.platform.Characteristic.CurrentHeaterCoolerState).updateValue(this.platform.Characteristic.CurrentHeaterCoolerState.HEATING);
|
|
778
823
|
}
|
|
779
824
|
else {
|
|
780
825
|
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);
|
|
826
|
+
(_g = this.HeaterCooler) === null || _g === void 0 ? void 0 : _g.getCharacteristic(this.platform.Characteristic.CurrentHeaterCoolerState).updateValue(this.platform.Characteristic.CurrentHeaterCoolerState.IDLE);
|
|
783
827
|
}
|
|
784
828
|
break;
|
|
785
829
|
}
|
|
786
830
|
}
|
|
787
831
|
else {
|
|
788
832
|
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);
|
|
833
|
+
(_h = this.HeaterCooler) === null || _h === void 0 ? void 0 : _h.getCharacteristic(this.platform.Characteristic.CurrentHeaterCoolerState).updateValue(this.platform.Characteristic.CurrentHeaterCoolerState.INACTIVE);
|
|
791
834
|
}
|
|
792
835
|
}
|
|
793
836
|
// Target Heater-Cooler State
|
|
@@ -795,54 +838,46 @@ class GreeAirConditioner {
|
|
|
795
838
|
switch (this.mode) {
|
|
796
839
|
case commands_1.default.mode.value.cool:
|
|
797
840
|
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);
|
|
841
|
+
(_j = this.HeaterCooler) === null || _j === void 0 ? void 0 : _j.getCharacteristic(this.platform.Characteristic.TargetHeaterCoolerState).updateValue(this.platform.Characteristic.TargetHeaterCoolerState.COOL);
|
|
800
842
|
break;
|
|
801
843
|
case commands_1.default.mode.value.heat:
|
|
802
844
|
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);
|
|
845
|
+
(_k = this.HeaterCooler) === null || _k === void 0 ? void 0 : _k.getCharacteristic(this.platform.Characteristic.TargetHeaterCoolerState).updateValue(this.platform.Characteristic.TargetHeaterCoolerState.HEAT);
|
|
805
846
|
break;
|
|
806
847
|
default:
|
|
807
848
|
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);
|
|
849
|
+
(_l = this.HeaterCooler) === null || _l === void 0 ? void 0 : _l.getCharacteristic(this.platform.Characteristic.TargetHeaterCoolerState).updateValue(this.platform.Characteristic.TargetHeaterCoolerState.AUTO);
|
|
810
850
|
}
|
|
811
851
|
}
|
|
812
852
|
// Current Temperature
|
|
813
853
|
if (props.includes(commands_1.default.temperature.code)) {
|
|
814
854
|
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);
|
|
855
|
+
(_m = this.HeaterCooler) === null || _m === void 0 ? void 0 : _m.getCharacteristic(this.platform.Characteristic.CurrentTemperature).updateValue(this.currentTemperature);
|
|
856
|
+
(_o = this.TemperatureSensor) === null || _o === void 0 ? void 0 : _o.getCharacteristic(this.platform.Characteristic.CurrentTemperature).updateValue(this.currentTemperature);
|
|
857
|
+
(_p = this.tsAccessory) === null || _p === void 0 ? void 0 : _p.setCurrentTemperature(this.currentTemperature);
|
|
858
|
+
(_q = this.tsAccessory) === null || _q === void 0 ? void 0 : _q.TemperatureSensor.getCharacteristic(this.platform.Characteristic.CurrentTemperature).updateValue(this.currentTemperature);
|
|
820
859
|
}
|
|
821
860
|
else if (props.includes(commands_1.default.targetTemperature.code) && this.TemperatureSensor === undefined) {
|
|
822
861
|
// temperature is not accessible -> targetTemperature is saved as currentTemperature
|
|
823
862
|
this.platform.log.debug(`[${this.getDeviceLabel()}] updateStatus (Current Temperature) ->`, this.currentTemperature);
|
|
824
|
-
this.HeaterCooler.getCharacteristic(this.platform.Characteristic.CurrentTemperature)
|
|
825
|
-
.updateValue(this.currentTemperature);
|
|
863
|
+
(_r = this.HeaterCooler) === null || _r === void 0 ? void 0 : _r.getCharacteristic(this.platform.Characteristic.CurrentTemperature).updateValue(this.currentTemperature);
|
|
826
864
|
}
|
|
827
865
|
// Cooling Threshold Temperature
|
|
828
866
|
if (props.includes(commands_1.default.targetTemperature.code) && this.power &&
|
|
829
867
|
(this.mode === commands_1.default.mode.value.cool || this.mode === commands_1.default.mode.value.auto)) {
|
|
830
868
|
this.platform.log.debug(`[${this.getDeviceLabel()}] updateStatus (Cooling Threshold Temperature) ->`, this.targetTemperature);
|
|
831
|
-
this.HeaterCooler.getCharacteristic(this.platform.Characteristic.CoolingThresholdTemperature)
|
|
832
|
-
.updateValue(this.targetTemperature);
|
|
869
|
+
(_s = this.HeaterCooler) === null || _s === void 0 ? void 0 : _s.getCharacteristic(this.platform.Characteristic.CoolingThresholdTemperature).updateValue(this.targetTemperature);
|
|
833
870
|
}
|
|
834
871
|
// Heating Threshold Temperature
|
|
835
872
|
if (props.includes(commands_1.default.targetTemperature.code) && this.power &&
|
|
836
873
|
(this.mode === commands_1.default.mode.value.heat || this.mode === commands_1.default.mode.value.auto)) {
|
|
837
874
|
this.platform.log.debug(`[${this.getDeviceLabel()}] updateStatus (Heating Threshold Temperature) ->`, this.targetTemperature);
|
|
838
|
-
this.HeaterCooler.getCharacteristic(this.platform.Characteristic.HeatingThresholdTemperature)
|
|
839
|
-
.updateValue(this.targetTemperature);
|
|
875
|
+
(_t = this.HeaterCooler) === null || _t === void 0 ? void 0 : _t.getCharacteristic(this.platform.Characteristic.HeatingThresholdTemperature).updateValue(this.targetTemperature);
|
|
840
876
|
}
|
|
841
877
|
// Temperature Display Units
|
|
842
878
|
if (props.includes(commands_1.default.units.code)) {
|
|
843
879
|
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 ?
|
|
880
|
+
(_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
881
|
this.platform.Characteristic.TemperatureDisplayUnits.CELSIUS : this.platform.Characteristic.TemperatureDisplayUnits.FAHRENHEIT);
|
|
847
882
|
}
|
|
848
883
|
// Swing Mode
|
|
@@ -865,8 +900,7 @@ class GreeAirConditioner {
|
|
|
865
900
|
break;
|
|
866
901
|
}
|
|
867
902
|
this.platform.log.debug(`[${this.getDeviceLabel()}] updateStatus (Swing Mode) ->`, logValue);
|
|
868
|
-
this.HeaterCooler.getCharacteristic(this.platform.Characteristic.SwingMode)
|
|
869
|
-
.updateValue(swing);
|
|
903
|
+
(_v = this.HeaterCooler) === null || _v === void 0 ? void 0 : _v.getCharacteristic(this.platform.Characteristic.SwingMode).updateValue(swing);
|
|
870
904
|
}
|
|
871
905
|
// Rotation Speed
|
|
872
906
|
if (this.power) {
|
|
@@ -874,15 +908,13 @@ class GreeAirConditioner {
|
|
|
874
908
|
if (props.includes(commands_1.default.quietMode.code) && this.quietMode === commands_1.default.quietMode.value.on) {
|
|
875
909
|
// quietMode -> on
|
|
876
910
|
this.platform.log.debug(`[${this.getDeviceLabel()}] updateStatus (Rotation Speed) -> 1 (quiet)`);
|
|
877
|
-
this.HeaterCooler.getCharacteristic(this.platform.Characteristic.RotationSpeed)
|
|
878
|
-
.updateValue(1);
|
|
911
|
+
(_w = this.HeaterCooler) === null || _w === void 0 ? void 0 : _w.getCharacteristic(this.platform.Characteristic.RotationSpeed).updateValue(1);
|
|
879
912
|
}
|
|
880
913
|
else if (props.includes(commands_1.default.powerfulMode.code) && this.powerfulMode === commands_1.default.powerfulMode.value.on) {
|
|
881
914
|
// powerfulMode -> on
|
|
882
915
|
logValue = `${this.deviceConfig.speedSteps + 3} (powerful)`;
|
|
883
916
|
this.platform.log.debug(`[${this.getDeviceLabel()}] updateStatus (Rotation Speed) ->`, logValue);
|
|
884
|
-
this.HeaterCooler.getCharacteristic(this.platform.Characteristic.RotationSpeed)
|
|
885
|
-
.updateValue(this.deviceConfig.speedSteps + 3);
|
|
917
|
+
(_x = this.HeaterCooler) === null || _x === void 0 ? void 0 : _x.getCharacteristic(this.platform.Characteristic.RotationSpeed).updateValue(this.deviceConfig.speedSteps + 3);
|
|
886
918
|
}
|
|
887
919
|
else if (props.includes(commands_1.default.speed.code)) {
|
|
888
920
|
// speed
|
|
@@ -910,8 +942,7 @@ class GreeAirConditioner {
|
|
|
910
942
|
break;
|
|
911
943
|
}
|
|
912
944
|
this.platform.log.debug(`[${this.getDeviceLabel()}] updateStatus (Rotation Speed) ->`, logValue);
|
|
913
|
-
this.HeaterCooler.getCharacteristic(this.platform.Characteristic.RotationSpeed)
|
|
914
|
-
.updateValue(speedValue);
|
|
945
|
+
(_y = this.HeaterCooler) === null || _y === void 0 ? void 0 : _y.getCharacteristic(this.platform.Characteristic.RotationSpeed).updateValue(speedValue);
|
|
915
946
|
}
|
|
916
947
|
}
|
|
917
948
|
}
|