@switchbot/homebridge-switchbot 2.0.0-beta.9 → 2.0.1-beta.0
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 +10 -1
- package/README.md +3 -2
- package/config.schema.json +119 -19
- package/dist/device/bot.d.ts +34 -28
- package/dist/device/bot.d.ts.map +1 -1
- package/dist/device/bot.js +657 -648
- package/dist/device/bot.js.map +1 -1
- package/dist/device/ceilinglight.d.ts +137 -0
- package/dist/device/ceilinglight.d.ts.map +1 -0
- package/dist/device/ceilinglight.js +1127 -0
- package/dist/device/ceilinglight.js.map +1 -0
- package/dist/device/colorbulb.d.ts +36 -14
- package/dist/device/colorbulb.d.ts.map +1 -1
- package/dist/device/colorbulb.js +472 -297
- package/dist/device/colorbulb.js.map +1 -1
- package/dist/device/contact.d.ts +18 -8
- package/dist/device/contact.d.ts.map +1 -1
- package/dist/device/contact.js +306 -237
- package/dist/device/contact.js.map +1 -1
- package/dist/device/curtain.d.ts +23 -16
- package/dist/device/curtain.d.ts.map +1 -1
- package/dist/device/curtain.js +566 -502
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/humidifier.d.ts +24 -18
- package/dist/device/humidifier.d.ts.map +1 -1
- package/dist/device/humidifier.js +453 -369
- package/dist/device/humidifier.js.map +1 -1
- package/dist/device/lock.d.ts +27 -8
- package/dist/device/lock.d.ts.map +1 -1
- package/dist/device/lock.js +305 -148
- package/dist/device/lock.js.map +1 -1
- package/dist/device/meter.d.ts +22 -16
- package/dist/device/meter.d.ts.map +1 -1
- package/dist/device/meter.js +367 -267
- package/dist/device/meter.js.map +1 -1
- package/dist/device/meterplus.d.ts +24 -12
- package/dist/device/meterplus.d.ts.map +1 -1
- package/dist/device/meterplus.js +381 -213
- package/dist/device/meterplus.js.map +1 -1
- package/dist/device/motion.d.ts +18 -8
- package/dist/device/motion.d.ts.map +1 -1
- package/dist/device/motion.js +279 -216
- package/dist/device/motion.js.map +1 -1
- package/dist/device/plug.d.ts +27 -17
- package/dist/device/plug.d.ts.map +1 -1
- package/dist/device/plug.js +295 -251
- package/dist/device/plug.js.map +1 -1
- package/dist/device/striplight.d.ts +43 -19
- package/dist/device/striplight.d.ts.map +1 -1
- package/dist/device/striplight.js +506 -262
- package/dist/device/striplight.js.map +1 -1
- package/dist/irdevice/airconditioner.d.ts +12 -12
- package/dist/irdevice/airconditioner.d.ts.map +1 -1
- package/dist/irdevice/airconditioner.js +316 -234
- package/dist/irdevice/airconditioner.js.map +1 -1
- package/dist/irdevice/airpurifier.d.ts +5 -3
- package/dist/irdevice/airpurifier.d.ts.map +1 -1
- package/dist/irdevice/airpurifier.js +154 -104
- package/dist/irdevice/airpurifier.js.map +1 -1
- package/dist/irdevice/camera.d.ts +11 -8
- package/dist/irdevice/camera.d.ts.map +1 -1
- package/dist/irdevice/camera.js +133 -86
- package/dist/irdevice/camera.js.map +1 -1
- package/dist/irdevice/fan.d.ts +10 -7
- package/dist/irdevice/fan.d.ts.map +1 -1
- package/dist/irdevice/fan.js +160 -109
- package/dist/irdevice/fan.js.map +1 -1
- package/dist/irdevice/light.d.ts +11 -8
- package/dist/irdevice/light.d.ts.map +1 -1
- package/dist/irdevice/light.js +137 -103
- package/dist/irdevice/light.js.map +1 -1
- package/dist/irdevice/other.d.ts +11 -8
- package/dist/irdevice/other.d.ts.map +1 -1
- package/dist/irdevice/other.js +145 -98
- package/dist/irdevice/other.js.map +1 -1
- package/dist/irdevice/tv.d.ts +12 -9
- package/dist/irdevice/tv.d.ts.map +1 -1
- package/dist/irdevice/tv.js +143 -93
- package/dist/irdevice/tv.js.map +1 -1
- package/dist/irdevice/vacuumcleaner.d.ts +9 -10
- package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
- package/dist/irdevice/vacuumcleaner.js +132 -89
- package/dist/irdevice/vacuumcleaner.js.map +1 -1
- package/dist/irdevice/waterheater.d.ts +8 -9
- package/dist/irdevice/waterheater.d.ts.map +1 -1
- package/dist/irdevice/waterheater.js +132 -89
- package/dist/irdevice/waterheater.js.map +1 -1
- package/dist/platform.d.ts +13 -12
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +530 -421
- package/dist/platform.js.map +1 -1
- package/dist/settings.d.ts +22 -11
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js.map +1 -1
- package/homebridge-ui/public/index.html +1 -0
- package/package.json +11 -9
- package/src/device/bot.ts +656 -659
- package/src/device/ceilinglight.ts +1208 -0
- package/src/device/colorbulb.ts +482 -334
- package/src/device/contact.ts +309 -241
- package/src/device/curtain.ts +571 -516
- package/src/device/humidifier.ts +456 -403
- package/src/device/lock.ts +314 -149
- package/src/device/meter.ts +378 -280
- package/src/device/meterplus.ts +391 -219
- package/src/device/motion.ts +285 -222
- package/src/device/plug.ts +299 -260
- package/src/device/striplight.ts +522 -289
- package/src/irdevice/airconditioner.ts +322 -245
- package/src/irdevice/airpurifier.ts +151 -103
- package/src/irdevice/camera.ts +131 -85
- package/src/irdevice/fan.ts +157 -106
- package/src/irdevice/light.ts +135 -103
- package/src/irdevice/other.ts +143 -97
- package/src/irdevice/tv.ts +142 -93
- package/src/irdevice/vacuumcleaner.ts +131 -89
- package/src/irdevice/waterheater.ts +130 -89
- package/src/platform.ts +528 -449
- package/src/settings.ts +23 -11
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.AirConditioner = void 0;
|
|
7
7
|
const https_1 = __importDefault(require("https"));
|
|
8
8
|
const crypto_1 = __importDefault(require("crypto"));
|
|
9
|
+
const super_stringify_1 = __importDefault(require("super-stringify"));
|
|
9
10
|
const settings_1 = require("../settings");
|
|
10
11
|
/**
|
|
11
12
|
* Platform Accessory
|
|
@@ -24,32 +25,16 @@ class AirConditioner {
|
|
|
24
25
|
this.logs(device);
|
|
25
26
|
this.config(device);
|
|
26
27
|
this.pushOnChanges(device);
|
|
27
|
-
|
|
28
|
-
this.Active = this.platform.Characteristic.Active.INACTIVE;
|
|
29
|
-
}
|
|
30
|
-
else {
|
|
31
|
-
this.Active = this.accessory.context.Active;
|
|
32
|
-
}
|
|
33
|
-
if (this.CurrentTemperature === undefined) {
|
|
34
|
-
this.CurrentTemperature = 24;
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
this.CurrentTemperature = this.accessory.context.CurrentTemperature;
|
|
38
|
-
}
|
|
39
|
-
if (device.irair?.hide_automode) {
|
|
40
|
-
this.hide_automode = device.irair?.hide_automode;
|
|
41
|
-
this.accessory.context.hide_automode = this.hide_automode;
|
|
42
|
-
}
|
|
43
|
-
else {
|
|
44
|
-
this.hide_automode = device.irair?.hide_automode;
|
|
45
|
-
this.accessory.context.hide_automode = this.hide_automode;
|
|
46
|
-
}
|
|
28
|
+
this.context(device);
|
|
47
29
|
// set accessory information
|
|
48
30
|
accessory
|
|
49
31
|
.getService(this.platform.Service.AccessoryInformation)
|
|
50
32
|
.setCharacteristic(this.platform.Characteristic.Manufacturer, 'SwitchBot')
|
|
51
33
|
.setCharacteristic(this.platform.Characteristic.Model, device.remoteType)
|
|
52
|
-
.setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId)
|
|
34
|
+
.setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId)
|
|
35
|
+
.setCharacteristic(this.platform.Characteristic.FirmwareRevision, this.FirmwareRevision(accessory, device))
|
|
36
|
+
.getCharacteristic(this.platform.Characteristic.FirmwareRevision)
|
|
37
|
+
.updateValue(this.FirmwareRevision(accessory, device));
|
|
53
38
|
// get the Television service if it exists, otherwise create a new Television service
|
|
54
39
|
// you can create multiple services for each accessory
|
|
55
40
|
(this.coolerService = accessory.getService(this.platform.Service.HeaterCooler) || accessory.addService(this.platform.Service.HeaterCooler)),
|
|
@@ -75,13 +60,13 @@ class AirConditioner {
|
|
|
75
60
|
if (this.hide_automode) {
|
|
76
61
|
this.TargetHeaterCoolerState = 1 || 2;
|
|
77
62
|
this.ValidValues = [1, 2];
|
|
78
|
-
this.debugLog(
|
|
63
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} ValidValues: ${(0, super_stringify_1.default)(this.ValidValues)},` +
|
|
79
64
|
` hide_automode: ${this.hide_automode}, TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`);
|
|
80
65
|
}
|
|
81
66
|
else {
|
|
82
67
|
this.TargetHeaterCoolerState = 0 || 1 || 2;
|
|
83
68
|
this.ValidValues = [0, 1, 2];
|
|
84
|
-
this.debugLog(
|
|
69
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} ValidValues: ${(0, super_stringify_1.default)(this.ValidValues)},` +
|
|
85
70
|
` hide_automode: ${this.hide_automode}, TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`);
|
|
86
71
|
}
|
|
87
72
|
this.coolerService
|
|
@@ -141,19 +126,23 @@ class AirConditioner {
|
|
|
141
126
|
*/
|
|
142
127
|
async pushAirConditionerOnChanges() {
|
|
143
128
|
if (this.Active !== this.platform.Characteristic.Active.ACTIVE || this.pushOn) {
|
|
144
|
-
const
|
|
145
|
-
|
|
129
|
+
const commandType = await this.commandType();
|
|
130
|
+
const command = await this.commandOn();
|
|
131
|
+
const body = (0, super_stringify_1.default)({
|
|
132
|
+
'command': command,
|
|
146
133
|
'parameter': 'default',
|
|
147
|
-
'commandType':
|
|
134
|
+
'commandType': commandType,
|
|
148
135
|
});
|
|
149
136
|
await this.pushChanges(body);
|
|
150
137
|
}
|
|
151
138
|
}
|
|
152
139
|
async pushAirConditionerOffChanges() {
|
|
153
|
-
const
|
|
154
|
-
|
|
140
|
+
const commandType = await this.commandType();
|
|
141
|
+
const command = await this.commandOff();
|
|
142
|
+
const body = (0, super_stringify_1.default)({
|
|
143
|
+
'command': command,
|
|
155
144
|
'parameter': 'default',
|
|
156
|
-
'commandType':
|
|
145
|
+
'commandType': commandType,
|
|
157
146
|
});
|
|
158
147
|
await this.pushChanges(body);
|
|
159
148
|
}
|
|
@@ -182,22 +171,23 @@ class AirConditioner {
|
|
|
182
171
|
}
|
|
183
172
|
if (this.CurrentMode === 1) {
|
|
184
173
|
this.CurrentTemperature = 25;
|
|
185
|
-
this.debugLog(
|
|
174
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} CurrentMode: ${this.CurrentMode},`
|
|
175
|
+
+ ` CurrentTemperature: ${this.CurrentTemperature}`);
|
|
186
176
|
}
|
|
187
177
|
const parameter = `${this.CurrentTemperature},${this.CurrentMode},${this.CurrentFanSpeed},${this.state}`;
|
|
188
178
|
if (this.Active === this.platform.Characteristic.Active.ACTIVE) {
|
|
189
179
|
this.CurrentTemperatureUndefined();
|
|
190
|
-
if (this.CurrentTemperature < this.
|
|
180
|
+
if (this.CurrentTemperature < this.accessory.context.CurrentTemperature) {
|
|
191
181
|
this.CurrentHeaterCoolerState = this.platform.Characteristic.CurrentHeaterCoolerState.COOLING;
|
|
192
182
|
}
|
|
193
|
-
else if (this.CurrentTemperature > this.
|
|
183
|
+
else if (this.CurrentTemperature > this.accessory.context.CurrentTemperature) {
|
|
194
184
|
this.CurrentHeaterCoolerState = this.platform.Characteristic.CurrentHeaterCoolerState.HEATING;
|
|
195
185
|
}
|
|
196
186
|
}
|
|
197
187
|
else {
|
|
198
188
|
this.CurrentHeaterCoolerState = this.platform.Characteristic.CurrentHeaterCoolerState.INACTIVE;
|
|
199
189
|
}
|
|
200
|
-
const body =
|
|
190
|
+
const body = (0, super_stringify_1.default)({
|
|
201
191
|
'command': 'setAll',
|
|
202
192
|
'parameter': `${parameter}`,
|
|
203
193
|
'commandType': 'command',
|
|
@@ -205,161 +195,73 @@ class AirConditioner {
|
|
|
205
195
|
await this.pushChanges(body);
|
|
206
196
|
}
|
|
207
197
|
async pushChanges(body) {
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
.
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
198
|
+
if (this.device.connectionType === 'OpenAPI') {
|
|
199
|
+
try {
|
|
200
|
+
// Make Push On request to the API
|
|
201
|
+
const t = Date.now();
|
|
202
|
+
const nonce = 'requestID';
|
|
203
|
+
const data = this.platform.config.credentials?.token + t + nonce;
|
|
204
|
+
const signTerm = crypto_1.default.createHmac('sha256', this.platform.config.credentials?.secret)
|
|
205
|
+
.update(Buffer.from(data, 'utf-8'))
|
|
206
|
+
.digest();
|
|
207
|
+
const sign = signTerm.toString('base64');
|
|
208
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} sign: ${sign}`);
|
|
209
|
+
this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Sending request to SwitchBot API. body: ${body},`);
|
|
210
|
+
const options = {
|
|
211
|
+
hostname: settings_1.HostDomain,
|
|
212
|
+
port: 443,
|
|
213
|
+
path: `${settings_1.DevicePath}/${this.device.deviceId}/commands`,
|
|
214
|
+
method: 'POST',
|
|
215
|
+
headers: {
|
|
216
|
+
'Authorization': this.platform.config.credentials?.token,
|
|
217
|
+
'sign': sign,
|
|
218
|
+
'nonce': nonce,
|
|
219
|
+
't': t,
|
|
220
|
+
'Content-Type': 'application/json',
|
|
221
|
+
'Content-Length': body.length,
|
|
222
|
+
},
|
|
223
|
+
};
|
|
224
|
+
const req = https_1.default.request(options, res => {
|
|
225
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushchanges statusCode: ${res.statusCode}`);
|
|
226
|
+
this.statusCode({ res });
|
|
227
|
+
res.on('data', d => {
|
|
228
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} d: ${d}`);
|
|
229
|
+
});
|
|
238
230
|
});
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
catch (e) {
|
|
257
|
-
this.errorLog(`Air Conditioner: ${this.accessory.displayName} failed pushChanges`);
|
|
258
|
-
if (this.deviceLogging.includes('debug')) {
|
|
259
|
-
this.errorLog(`Air Conditioner: ${this.accessory.displayName} failed pushChanges,` + ` Error Message: ${JSON.stringify(e.message)}`);
|
|
231
|
+
req.on('error', (e) => {
|
|
232
|
+
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} error message: ${e.message}`);
|
|
233
|
+
});
|
|
234
|
+
req.write(body);
|
|
235
|
+
req.end();
|
|
236
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushchanges: ${(0, super_stringify_1.default)(req)}`);
|
|
237
|
+
this.accessory.context.CurrentTemperature = this.CurrentTemperature;
|
|
238
|
+
this.HeatingThresholdTemperature = this.CurrentTemperature;
|
|
239
|
+
this.CoolingThresholdTemperature = this.CurrentTemperature;
|
|
240
|
+
this.accessory.context.HeatingThresholdTemperature = this.HeatingThresholdTemperature;
|
|
241
|
+
this.accessory.context.CoolingThresholdTemperature = this.CoolingThresholdTemperature;
|
|
242
|
+
this.updateHomeKitCharacteristics();
|
|
243
|
+
}
|
|
244
|
+
catch (e) {
|
|
245
|
+
this.apiError(e);
|
|
246
|
+
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} failed pushChanges with ${this.device.connectionType} Connection,`
|
|
247
|
+
+ ` Error Message: ${(0, super_stringify_1.default)(e.message)}`);
|
|
260
248
|
}
|
|
261
|
-
this.apiError(e);
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
async statusCode({ res }) {
|
|
265
|
-
switch (res.statusCode) {
|
|
266
|
-
case 151:
|
|
267
|
-
this.errorLog(`Air Conditioner: ${this.accessory.displayName} Command not supported by this device type.`);
|
|
268
|
-
break;
|
|
269
|
-
case 152:
|
|
270
|
-
this.errorLog(`Air Conditioner: ${this.accessory.displayName} Device not found.`);
|
|
271
|
-
break;
|
|
272
|
-
case 160:
|
|
273
|
-
this.errorLog(`Air Conditioner: ${this.accessory.displayName} Command is not supported.`);
|
|
274
|
-
break;
|
|
275
|
-
case 161:
|
|
276
|
-
this.errorLog(`Air Conditioner: ${this.accessory.displayName} Device is offline.`);
|
|
277
|
-
break;
|
|
278
|
-
case 171:
|
|
279
|
-
this.errorLog(`Air Conditioner: ${this.accessory.displayName} Hub Device is offline. Hub: ${this.device.hubDeviceId}`);
|
|
280
|
-
break;
|
|
281
|
-
case 190:
|
|
282
|
-
this.errorLog(`Air Conditioner: ${this.accessory.displayName} Device internal error due to device states not synchronized` +
|
|
283
|
-
` with server, Or command: ${JSON.stringify(res)} format is invalid`);
|
|
284
|
-
break;
|
|
285
|
-
case 100:
|
|
286
|
-
this.debugLog(`Air Conditioner: ${this.accessory.displayName} Command successfully sent.`);
|
|
287
|
-
break;
|
|
288
|
-
default:
|
|
289
|
-
this.debugLog(`Air Conditioner: ${this.accessory.displayName} Unknown statusCode.`);
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
async updateHomeKitCharacteristics() {
|
|
293
|
-
if (this.Active === undefined) {
|
|
294
|
-
this.debugLog(`Air Conditioner: ${this.accessory.displayName} Active: ${this.Active}`);
|
|
295
|
-
}
|
|
296
|
-
else {
|
|
297
|
-
this.coolerService?.updateCharacteristic(this.platform.Characteristic.Active, this.Active);
|
|
298
|
-
this.debugLog(`Air Conditioner: ${this.accessory.displayName} updateCharacteristic Active: ${this.Active}`);
|
|
299
|
-
}
|
|
300
|
-
if (this.RotationSpeed === undefined) {
|
|
301
|
-
this.debugLog(`Air Conditioner: ${this.accessory.displayName} RotationSpeed: ${this.RotationSpeed}`);
|
|
302
|
-
}
|
|
303
|
-
else {
|
|
304
|
-
this.coolerService?.updateCharacteristic(this.platform.Characteristic.RotationSpeed, this.RotationSpeed);
|
|
305
|
-
this.debugLog(`Air Conditioner: ${this.accessory.displayName} updateCharacteristic RotationSpeed: ${this.RotationSpeed}`);
|
|
306
|
-
}
|
|
307
|
-
if (this.CurrentTemperature === undefined) {
|
|
308
|
-
this.debugLog(`Air Conditioner: ${this.accessory.displayName} CurrentTemperature: ${this.CurrentTemperature}`);
|
|
309
|
-
}
|
|
310
|
-
else {
|
|
311
|
-
this.coolerService?.updateCharacteristic(this.platform.Characteristic.CurrentTemperature, this.CurrentTemperature);
|
|
312
|
-
this.debugLog(`Air Conditioner: ${this.accessory.displayName} updateCharacteristic CurrentTemperature: ${this.CurrentTemperature}`);
|
|
313
|
-
}
|
|
314
|
-
if (this.TargetHeaterCoolerState === undefined) {
|
|
315
|
-
this.debugLog(`Air Conditioner: ${this.accessory.displayName} TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`);
|
|
316
|
-
}
|
|
317
|
-
else {
|
|
318
|
-
this.coolerService?.updateCharacteristic(this.platform.Characteristic.TargetHeaterCoolerState, this.TargetHeaterCoolerState);
|
|
319
|
-
this.debugLog(`Air Conditioner: ${this.accessory.displayName}` + ` updateCharacteristic TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`);
|
|
320
|
-
}
|
|
321
|
-
if (this.CurrentHeaterCoolerState === undefined) {
|
|
322
|
-
this.debugLog(`Air Conditioner: ${this.accessory.displayName} CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`);
|
|
323
|
-
}
|
|
324
|
-
else {
|
|
325
|
-
this.coolerService?.updateCharacteristic(this.platform.Characteristic.CurrentHeaterCoolerState, this.CurrentHeaterCoolerState);
|
|
326
|
-
this.debugLog(`Air Conditioner: ${this.accessory.displayName}` + ` updateCharacteristic CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`);
|
|
327
|
-
}
|
|
328
|
-
if (this.HeatingThresholdTemperature === undefined) {
|
|
329
|
-
this.debugLog(`Air Conditioner: ${this.accessory.displayName} HeatingThresholdTemperature: ${this.HeatingThresholdTemperature}`);
|
|
330
|
-
}
|
|
331
|
-
else {
|
|
332
|
-
this.coolerService?.updateCharacteristic(this.platform.Characteristic.HeatingThresholdTemperature, this.HeatingThresholdTemperature);
|
|
333
|
-
this.debugLog(`Air Conditioner: ${this.accessory.displayName}` + ` updateCharacteristic HeatingThresholdTemperature: ${this.HeatingThresholdTemperature}`);
|
|
334
|
-
}
|
|
335
|
-
if (this.CoolingThresholdTemperature === undefined) {
|
|
336
|
-
this.debugLog(`Air Conditioner: ${this.accessory.displayName} CoolingThresholdTemperature: ${this.CoolingThresholdTemperature}`);
|
|
337
249
|
}
|
|
338
250
|
else {
|
|
339
|
-
this.
|
|
340
|
-
|
|
251
|
+
this.warnLog(`${this.device.remoteType}: ${this.accessory.displayName}`
|
|
252
|
+
+ ` Connection Type: ${this.device.connectionType}, commands will not be sent to OpenAPI`);
|
|
341
253
|
}
|
|
342
254
|
}
|
|
343
|
-
async apiError(e) {
|
|
344
|
-
this.coolerService.updateCharacteristic(this.platform.Characteristic.Active, e);
|
|
345
|
-
this.coolerService.updateCharacteristic(this.platform.Characteristic.RotationSpeed, e);
|
|
346
|
-
this.coolerService.updateCharacteristic(this.platform.Characteristic.CurrentTemperature, e);
|
|
347
|
-
this.coolerService.updateCharacteristic(this.platform.Characteristic.TargetHeaterCoolerState, e);
|
|
348
|
-
this.coolerService.updateCharacteristic(this.platform.Characteristic.CurrentHeaterCoolerState, e);
|
|
349
|
-
this.coolerService.updateCharacteristic(this.platform.Characteristic.HeatingThresholdTemperature, e);
|
|
350
|
-
this.coolerService.updateCharacteristic(this.platform.Characteristic.CoolingThresholdTemperature, e);
|
|
351
|
-
//throw new this.platform.api.hap.HapStatusError(HAPStatus.SERVICE_COMMUNICATION_FAILURE);
|
|
352
|
-
}
|
|
353
255
|
async CurrentTemperatureGet() {
|
|
354
256
|
if (this.CurrentTemperature === undefined) {
|
|
355
257
|
this.CurrentTemperature = 24;
|
|
356
|
-
this.
|
|
258
|
+
this.accessory.context.CurrentTemperature = this.CurrentTemperature;
|
|
357
259
|
}
|
|
358
260
|
else {
|
|
359
|
-
this.
|
|
261
|
+
this.accessory.context.CurrentTemperature = this.CurrentTemperature;
|
|
360
262
|
}
|
|
361
|
-
this.debugLog(
|
|
362
|
-
this.accessory.context.CurrentTemperature = this.
|
|
263
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Get CurrentTemperature: ${this.CurrentTemperature}`);
|
|
264
|
+
this.accessory.context.CurrentTemperature = this.CurrentTemperature;
|
|
363
265
|
return this.CurrentTemperature;
|
|
364
266
|
}
|
|
365
267
|
async RotationSpeedGet() {
|
|
@@ -372,9 +274,8 @@ class AirConditioner {
|
|
|
372
274
|
else {
|
|
373
275
|
this.RotationSpeed = this.CurrentFanSpeed - 1;
|
|
374
276
|
}
|
|
375
|
-
this.debugLog(
|
|
376
|
-
this.
|
|
377
|
-
this.accessory.context.RotationSpeed = this.RotationSpeedCached;
|
|
277
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Get RotationSpeed: ${this.RotationSpeed}`);
|
|
278
|
+
this.accessory.context.RotationSpeed = this.RotationSpeed;
|
|
378
279
|
return this.RotationSpeed;
|
|
379
280
|
}
|
|
380
281
|
async RotationSpeedSet(value) {
|
|
@@ -385,21 +286,19 @@ class AirConditioner {
|
|
|
385
286
|
this.CurrentFanSpeed = Number(value) + 1;
|
|
386
287
|
}
|
|
387
288
|
this.RotationSpeed = this.CurrentFanSpeed;
|
|
388
|
-
this.
|
|
389
|
-
this.accessory.context.RotationSpeed = this.RotationSpeedCached;
|
|
289
|
+
this.accessory.context.RotationSpeed = this.RotationSpeed;
|
|
390
290
|
this.pushAirConditionerStatusChanges();
|
|
391
291
|
}
|
|
392
292
|
async ActiveSet(value) {
|
|
393
|
-
this.debugLog(
|
|
293
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Set Active: ${value}`);
|
|
394
294
|
this.Active = value;
|
|
395
|
-
this.
|
|
396
|
-
this.accessory.context.Active = this.ActiveCached;
|
|
295
|
+
this.accessory.context.Active = this.Active;
|
|
397
296
|
if (value === this.platform.Characteristic.Active.INACTIVE) {
|
|
398
|
-
this.debugLog(
|
|
297
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushAirConditionerOffChanges, Active: ${this.Active}`);
|
|
399
298
|
this.pushAirConditionerOffChanges();
|
|
400
299
|
}
|
|
401
300
|
else {
|
|
402
|
-
this.debugLog(
|
|
301
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushAirConditionerOnChanges, Active: ${this.Active}`);
|
|
403
302
|
if (this.pushOn) {
|
|
404
303
|
this.pushAirConditionerOnChanges();
|
|
405
304
|
}
|
|
@@ -411,21 +310,20 @@ class AirConditioner {
|
|
|
411
310
|
async TargetHeaterCoolerStateGet() {
|
|
412
311
|
if (this.ValidValues === this.valid012) {
|
|
413
312
|
this.TargetHeaterCoolerState = this.platform.Characteristic.TargetHeaterCoolerState.AUTO;
|
|
414
|
-
this.debugLog(
|
|
313
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Get (AUTO) TargetHeaterCoolerState: ${this.CurrentHeaterCoolerState},` +
|
|
415
314
|
` ValidValues: ${this.ValidValues}`);
|
|
416
315
|
}
|
|
417
316
|
else if (this.ValidValues === this.valid12) {
|
|
418
317
|
this.TargetHeaterCoolerState =
|
|
419
318
|
this.platform.Characteristic.TargetHeaterCoolerState.COOL || this.platform.Characteristic.TargetHeaterCoolerState.HEAT;
|
|
420
|
-
this.debugLog(
|
|
319
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Get (COOL/HEAT) TargetHeaterCoolerState: ${this.CurrentHeaterCoolerState},` +
|
|
421
320
|
` ValidValues: ${this.ValidValues}`);
|
|
422
321
|
}
|
|
423
322
|
else {
|
|
424
|
-
this.debugLog(
|
|
323
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Get TargetHeaterCoolerState: ${this.CurrentHeaterCoolerState},` +
|
|
425
324
|
` ValidValues: ${this.ValidValues}`);
|
|
426
325
|
}
|
|
427
|
-
this.
|
|
428
|
-
this.accessory.context.TargetHeaterCoolerState = this.TargetHeaterCoolerStateCached;
|
|
326
|
+
this.accessory.context.TargetHeaterCoolerState = this.TargetHeaterCoolerState;
|
|
429
327
|
return this.TargetHeaterCoolerState;
|
|
430
328
|
}
|
|
431
329
|
async TargetHeaterCoolerStateSet(value) {
|
|
@@ -437,7 +335,7 @@ class AirConditioner {
|
|
|
437
335
|
this.TargetHeaterCoolerStateCOOL();
|
|
438
336
|
}
|
|
439
337
|
else {
|
|
440
|
-
this.errorLog(
|
|
338
|
+
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Set TargetHeaterCoolerState: ${this.TargetHeaterCoolerState},` +
|
|
441
339
|
` hide_automode: ${this.hide_automode} `);
|
|
442
340
|
}
|
|
443
341
|
}
|
|
@@ -452,96 +350,260 @@ class AirConditioner {
|
|
|
452
350
|
this.TargetHeaterCoolerStateCOOL();
|
|
453
351
|
}
|
|
454
352
|
else {
|
|
455
|
-
this.errorLog(
|
|
353
|
+
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Set TargetHeaterCoolerState: ${this.TargetHeaterCoolerState},` +
|
|
456
354
|
` hide_automode: ${this.hide_automode} `);
|
|
457
355
|
}
|
|
458
356
|
}
|
|
459
|
-
this.
|
|
460
|
-
this.accessory.context.TargetHeaterCoolerState = this.TargetHeaterCoolerStateCached;
|
|
357
|
+
this.accessory.context.TargetHeaterCoolerState = this.TargetHeaterCoolerState;
|
|
461
358
|
this.pushAirConditionerStatusChanges();
|
|
462
359
|
}
|
|
463
360
|
async TargetHeaterCoolerStateAUTO() {
|
|
464
361
|
this.TargetHeaterCoolerState = this.platform.Characteristic.TargetHeaterCoolerState.AUTO;
|
|
465
362
|
this.CurrentMode = 1;
|
|
466
|
-
this.debugLog(
|
|
467
|
-
this.debugLog(
|
|
363
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Set (AUTO) TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`);
|
|
364
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Switchbot CurrentMode: ${this.CurrentMode}`);
|
|
468
365
|
}
|
|
469
366
|
async TargetHeaterCoolerStateCOOL() {
|
|
470
367
|
this.TargetHeaterCoolerState = this.platform.Characteristic.TargetHeaterCoolerState.COOL;
|
|
471
368
|
this.CurrentMode = 2;
|
|
472
|
-
this.debugLog(
|
|
473
|
-
this.debugLog(
|
|
369
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Set (COOL) TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`);
|
|
370
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Switchbot CurrentMode: ${this.CurrentMode}`);
|
|
474
371
|
}
|
|
475
372
|
async TargetHeaterCoolerStateHEAT() {
|
|
476
373
|
this.TargetHeaterCoolerState = this.platform.Characteristic.TargetHeaterCoolerState.HEAT;
|
|
477
374
|
this.CurrentMode = 5;
|
|
478
|
-
this.debugLog(
|
|
479
|
-
this.debugLog(
|
|
375
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Set (HEAT) TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`);
|
|
376
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Switchbot CurrentMode: ${this.CurrentMode}`);
|
|
480
377
|
}
|
|
481
378
|
async CurrentHeaterCoolerStateGet() {
|
|
482
379
|
if (this.Active === this.platform.Characteristic.Active.ACTIVE) {
|
|
483
380
|
this.CurrentTemperatureUndefined();
|
|
484
|
-
if (this.CurrentTemperature < this.
|
|
381
|
+
if (this.CurrentTemperature < this.accessory.context.CurrentTemperature) {
|
|
485
382
|
this.CurrentHeaterCoolerState = this.platform.Characteristic.CurrentHeaterCoolerState.COOLING;
|
|
486
|
-
this.debugLog(
|
|
383
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName}`
|
|
384
|
+
+ ` Get (COOLLING) CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`);
|
|
487
385
|
}
|
|
488
|
-
else if (this.CurrentTemperature > this.
|
|
386
|
+
else if (this.CurrentTemperature > this.accessory.context.CurrentTemperature) {
|
|
489
387
|
this.CurrentHeaterCoolerState = this.platform.Characteristic.CurrentHeaterCoolerState.HEATING;
|
|
490
|
-
this.debugLog(
|
|
388
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName}`
|
|
389
|
+
+ ` Get (HEATING) CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`);
|
|
491
390
|
}
|
|
492
391
|
}
|
|
493
392
|
else {
|
|
494
393
|
this.CurrentHeaterCoolerState = this.platform.Characteristic.CurrentHeaterCoolerState.INACTIVE;
|
|
495
|
-
this.debugLog(
|
|
394
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName}`
|
|
395
|
+
+ ` Get (INACTIVE) CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`);
|
|
496
396
|
}
|
|
497
|
-
this.
|
|
498
|
-
this.accessory.context.CurrentHeaterCoolerState = this.CurrentHeaterCoolerStateCached;
|
|
397
|
+
this.accessory.context.CurrentHeaterCoolerState = this.CurrentHeaterCoolerState;
|
|
499
398
|
return this.CurrentHeaterCoolerState;
|
|
500
399
|
}
|
|
501
400
|
async HeatingThresholdTemperatureGet() {
|
|
502
401
|
this.CurrentTemperatureUndefined;
|
|
503
|
-
this.CurrentTemperature = this.
|
|
504
|
-
this.HeatingThresholdTemperature = this.
|
|
505
|
-
this.
|
|
506
|
-
this.accessory.
|
|
507
|
-
this.debugLog(`Air Conditioner: ${this.accessory.displayName} Get HeatingThresholdTemperature: ${this.HeatingThresholdTemperature}`);
|
|
402
|
+
this.CurrentTemperature = this.accessory.context.CurrentTemperature;
|
|
403
|
+
this.HeatingThresholdTemperature = this.accessory.context.CurrentTemperature;
|
|
404
|
+
this.accessory.context.HeatingThresholdTemperature = this.HeatingThresholdTemperature;
|
|
405
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Get HeatingThresholdTemperature: ${this.HeatingThresholdTemperature}`);
|
|
508
406
|
return this.HeatingThresholdTemperature;
|
|
509
407
|
}
|
|
510
408
|
async HeatingThresholdTemperatureSet(value) {
|
|
511
|
-
this.
|
|
409
|
+
this.accessory.context.CurrentTemperature = this.CurrentTemperature;
|
|
512
410
|
this.CurrentTemperature = value;
|
|
513
|
-
this.
|
|
514
|
-
this.accessory.
|
|
515
|
-
|
|
516
|
-
` CurrentTemperatureCached: ${this.CurrentTemperatureCached}`);
|
|
411
|
+
this.accessory.context.HeatingThresholdTemperature = this.HeatingThresholdTemperature;
|
|
412
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Set HeatingThresholdTemperature: ${this.HeatingThresholdTemperature},` +
|
|
413
|
+
` CurrentTemperatureCached: ${this.accessory.context.CurrentTemperature}`);
|
|
517
414
|
this.pushAirConditionerStatusChanges();
|
|
518
415
|
}
|
|
519
416
|
async CoolingThresholdTemperatureGet() {
|
|
520
417
|
this.CurrentTemperatureUndefined;
|
|
521
|
-
this.CurrentTemperature = this.
|
|
522
|
-
this.CoolingThresholdTemperature = this.
|
|
523
|
-
this.
|
|
524
|
-
this.accessory.
|
|
525
|
-
this.debugLog(`Air Conditioner: ${this.accessory.displayName} Get CoolingThresholdTemperature: ${this.CoolingThresholdTemperature}`);
|
|
418
|
+
this.CurrentTemperature = this.accessory.context.CurrentTemperature;
|
|
419
|
+
this.CoolingThresholdTemperature = this.accessory.context.CurrentTemperature;
|
|
420
|
+
this.accessory.context.CoolingThresholdTemperature = this.CoolingThresholdTemperature;
|
|
421
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Get CoolingThresholdTemperature: ${this.CoolingThresholdTemperature}`);
|
|
526
422
|
return this.CoolingThresholdTemperature;
|
|
527
423
|
}
|
|
528
424
|
async CoolingThresholdTemperatureSet(value) {
|
|
529
|
-
this.
|
|
425
|
+
this.accessory.context.CurrentTemperature = this.CurrentTemperature;
|
|
530
426
|
this.CurrentTemperature = value;
|
|
531
|
-
this.
|
|
532
|
-
this.accessory.
|
|
533
|
-
|
|
534
|
-
` CurrentTemperatureCached: ${this.CurrentTemperatureCached}`);
|
|
427
|
+
this.accessory.context.CoolingThresholdTemperature = this.CoolingThresholdTemperature;
|
|
428
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Set CoolingThresholdTemperature: ${this.CoolingThresholdTemperature},` +
|
|
429
|
+
` CurrentTemperatureCached: ${this.accessory.context.CurrentTemperature}`);
|
|
535
430
|
this.pushAirConditionerStatusChanges();
|
|
536
431
|
}
|
|
537
432
|
async CurrentTemperatureUndefined() {
|
|
538
433
|
if (this.CurrentTemperature === undefined) {
|
|
539
434
|
this.CurrentTemperature = 24;
|
|
540
435
|
}
|
|
541
|
-
if (this.
|
|
436
|
+
if (this.accessory.context.CurrentTemperature === undefined) {
|
|
542
437
|
this.CurrentTemperature = 30;
|
|
543
438
|
}
|
|
544
439
|
}
|
|
440
|
+
async updateHomeKitCharacteristics() {
|
|
441
|
+
if (this.Active === undefined) {
|
|
442
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Active: ${this.Active}`);
|
|
443
|
+
}
|
|
444
|
+
else {
|
|
445
|
+
this.accessory.context.Active = this.Active;
|
|
446
|
+
this.coolerService?.updateCharacteristic(this.platform.Characteristic.Active, this.Active);
|
|
447
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic Active: ${this.Active}`);
|
|
448
|
+
}
|
|
449
|
+
if (this.RotationSpeed === undefined) {
|
|
450
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} RotationSpeed: ${this.RotationSpeed}`);
|
|
451
|
+
}
|
|
452
|
+
else {
|
|
453
|
+
this.accessory.context.RotationSpeed = this.RotationSpeed;
|
|
454
|
+
this.coolerService?.updateCharacteristic(this.platform.Characteristic.RotationSpeed, this.RotationSpeed);
|
|
455
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic RotationSpeed: ${this.RotationSpeed}`);
|
|
456
|
+
}
|
|
457
|
+
if (this.CurrentTemperature === undefined) {
|
|
458
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} CurrentTemperature: ${this.CurrentTemperature}`);
|
|
459
|
+
}
|
|
460
|
+
else {
|
|
461
|
+
this.accessory.context.CurrentTemperature = this.CurrentTemperature;
|
|
462
|
+
this.coolerService?.updateCharacteristic(this.platform.Characteristic.CurrentTemperature, this.CurrentTemperature);
|
|
463
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic CurrentTemperature: ${this.CurrentTemperature}`);
|
|
464
|
+
}
|
|
465
|
+
if (this.TargetHeaterCoolerState === undefined) {
|
|
466
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`);
|
|
467
|
+
}
|
|
468
|
+
else {
|
|
469
|
+
this.accessory.context.TargetHeaterCoolerState = this.TargetHeaterCoolerState;
|
|
470
|
+
this.coolerService?.updateCharacteristic(this.platform.Characteristic.TargetHeaterCoolerState, this.TargetHeaterCoolerState);
|
|
471
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName}` + ` updateCharacteristic TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`);
|
|
472
|
+
}
|
|
473
|
+
if (this.CurrentHeaterCoolerState === undefined) {
|
|
474
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`);
|
|
475
|
+
}
|
|
476
|
+
else {
|
|
477
|
+
this.accessory.context.CurrentHeaterCoolerState = this.CurrentHeaterCoolerState;
|
|
478
|
+
this.coolerService?.updateCharacteristic(this.platform.Characteristic.CurrentHeaterCoolerState, this.CurrentHeaterCoolerState);
|
|
479
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName}`
|
|
480
|
+
+ ` updateCharacteristic CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`);
|
|
481
|
+
}
|
|
482
|
+
if (this.HeatingThresholdTemperature === undefined) {
|
|
483
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} HeatingThresholdTemperature: ${this.HeatingThresholdTemperature}`);
|
|
484
|
+
}
|
|
485
|
+
else {
|
|
486
|
+
this.accessory.context.HeatingThresholdTemperature = this.HeatingThresholdTemperature;
|
|
487
|
+
this.coolerService?.updateCharacteristic(this.platform.Characteristic.HeatingThresholdTemperature, this.HeatingThresholdTemperature);
|
|
488
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName}`
|
|
489
|
+
+ ` updateCharacteristic HeatingThresholdTemperature: ${this.HeatingThresholdTemperature}`);
|
|
490
|
+
}
|
|
491
|
+
if (this.CoolingThresholdTemperature === undefined) {
|
|
492
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} CoolingThresholdTemperature: ${this.CoolingThresholdTemperature}`);
|
|
493
|
+
}
|
|
494
|
+
else {
|
|
495
|
+
this.accessory.context.CoolingThresholdTemperature = this.CoolingThresholdTemperature;
|
|
496
|
+
this.coolerService?.updateCharacteristic(this.platform.Characteristic.CoolingThresholdTemperature, this.CoolingThresholdTemperature);
|
|
497
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName}`
|
|
498
|
+
+ ` updateCharacteristic CoolingThresholdTemperature: ${this.CoolingThresholdTemperature}`);
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
async commandType() {
|
|
502
|
+
let commandType;
|
|
503
|
+
if (this.device.customize) {
|
|
504
|
+
commandType = 'customize';
|
|
505
|
+
}
|
|
506
|
+
else {
|
|
507
|
+
commandType = 'command';
|
|
508
|
+
}
|
|
509
|
+
return commandType;
|
|
510
|
+
}
|
|
511
|
+
async commandOn() {
|
|
512
|
+
let command;
|
|
513
|
+
if (this.device.customize && this.device.customOn) {
|
|
514
|
+
command = this.device.customOn;
|
|
515
|
+
}
|
|
516
|
+
else {
|
|
517
|
+
command = 'turnOn';
|
|
518
|
+
}
|
|
519
|
+
return command;
|
|
520
|
+
}
|
|
521
|
+
async commandOff() {
|
|
522
|
+
let command;
|
|
523
|
+
if (this.device.customize && this.device.customOn) {
|
|
524
|
+
command = this.device.customOn;
|
|
525
|
+
}
|
|
526
|
+
else {
|
|
527
|
+
command = 'turnOff';
|
|
528
|
+
}
|
|
529
|
+
return command;
|
|
530
|
+
}
|
|
531
|
+
async statusCode({ res }) {
|
|
532
|
+
switch (res.statusCode) {
|
|
533
|
+
case 151:
|
|
534
|
+
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Command not supported by this device type.`);
|
|
535
|
+
break;
|
|
536
|
+
case 152:
|
|
537
|
+
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Device not found.`);
|
|
538
|
+
break;
|
|
539
|
+
case 160:
|
|
540
|
+
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Command is not supported.`);
|
|
541
|
+
break;
|
|
542
|
+
case 161:
|
|
543
|
+
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Device is offline.`);
|
|
544
|
+
break;
|
|
545
|
+
case 171:
|
|
546
|
+
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Hub Device is offline. Hub: ${this.device.hubDeviceId}`);
|
|
547
|
+
break;
|
|
548
|
+
case 190:
|
|
549
|
+
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Device internal error due to device states not synchronized` +
|
|
550
|
+
` with server, Or command: ${(0, super_stringify_1.default)(res)} format is invalid`);
|
|
551
|
+
break;
|
|
552
|
+
case 100:
|
|
553
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Command successfully sent.`);
|
|
554
|
+
break;
|
|
555
|
+
default:
|
|
556
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Unknown statusCode.`);
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
async apiError(e) {
|
|
560
|
+
this.coolerService.updateCharacteristic(this.platform.Characteristic.Active, e);
|
|
561
|
+
this.coolerService.updateCharacteristic(this.platform.Characteristic.RotationSpeed, e);
|
|
562
|
+
this.coolerService.updateCharacteristic(this.platform.Characteristic.CurrentTemperature, e);
|
|
563
|
+
this.coolerService.updateCharacteristic(this.platform.Characteristic.TargetHeaterCoolerState, e);
|
|
564
|
+
this.coolerService.updateCharacteristic(this.platform.Characteristic.CurrentHeaterCoolerState, e);
|
|
565
|
+
this.coolerService.updateCharacteristic(this.platform.Characteristic.HeatingThresholdTemperature, e);
|
|
566
|
+
this.coolerService.updateCharacteristic(this.platform.Characteristic.CoolingThresholdTemperature, e);
|
|
567
|
+
}
|
|
568
|
+
FirmwareRevision(accessory, device) {
|
|
569
|
+
let FirmwareRevision;
|
|
570
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName}`
|
|
571
|
+
+ ` accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}`);
|
|
572
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} device.firmware: ${device.firmware}`);
|
|
573
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} this.platform.version: ${this.platform.version}`);
|
|
574
|
+
if (accessory.context.FirmwareRevision) {
|
|
575
|
+
FirmwareRevision = accessory.context.FirmwareRevision;
|
|
576
|
+
}
|
|
577
|
+
else if (device.firmware) {
|
|
578
|
+
FirmwareRevision = device.firmware;
|
|
579
|
+
}
|
|
580
|
+
else {
|
|
581
|
+
FirmwareRevision = this.platform.version;
|
|
582
|
+
}
|
|
583
|
+
return FirmwareRevision;
|
|
584
|
+
}
|
|
585
|
+
async context(device) {
|
|
586
|
+
if (this.Active === undefined) {
|
|
587
|
+
this.Active = this.platform.Characteristic.Active.INACTIVE;
|
|
588
|
+
}
|
|
589
|
+
else {
|
|
590
|
+
this.Active = this.accessory.context.Active;
|
|
591
|
+
}
|
|
592
|
+
if (this.CurrentTemperature === undefined) {
|
|
593
|
+
this.CurrentTemperature = 24;
|
|
594
|
+
}
|
|
595
|
+
else {
|
|
596
|
+
this.CurrentTemperature = this.accessory.context.CurrentTemperature;
|
|
597
|
+
}
|
|
598
|
+
if (device.irair?.hide_automode) {
|
|
599
|
+
this.hide_automode = device.irair?.hide_automode;
|
|
600
|
+
this.accessory.context.hide_automode = this.hide_automode;
|
|
601
|
+
}
|
|
602
|
+
else {
|
|
603
|
+
this.hide_automode = device.irair?.hide_automode;
|
|
604
|
+
this.accessory.context.hide_automode = this.hide_automode;
|
|
605
|
+
}
|
|
606
|
+
}
|
|
545
607
|
async config(device) {
|
|
546
608
|
let config = {};
|
|
547
609
|
if (device.irair) {
|
|
@@ -550,26 +612,32 @@ class AirConditioner {
|
|
|
550
612
|
if (device.logging !== undefined) {
|
|
551
613
|
config['logging'] = device.logging;
|
|
552
614
|
}
|
|
615
|
+
if (device.connectionType !== undefined) {
|
|
616
|
+
config['connectionType'] = device.connectionType;
|
|
617
|
+
}
|
|
618
|
+
if (device.external !== undefined) {
|
|
619
|
+
config['external'] = device.external;
|
|
620
|
+
}
|
|
553
621
|
if (Object.entries(config).length !== 0) {
|
|
554
|
-
this.infoLog(
|
|
622
|
+
this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Config: ${(0, super_stringify_1.default)(config)}`);
|
|
555
623
|
}
|
|
556
624
|
}
|
|
557
625
|
async logs(device) {
|
|
558
626
|
if (this.platform.debugMode) {
|
|
559
627
|
this.deviceLogging = this.accessory.context.logging = 'debugMode';
|
|
560
|
-
this.debugLog(
|
|
628
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
|
|
561
629
|
}
|
|
562
630
|
else if (device.logging) {
|
|
563
631
|
this.deviceLogging = this.accessory.context.logging = device.logging;
|
|
564
|
-
this.debugLog(
|
|
632
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
|
|
565
633
|
}
|
|
566
634
|
else if (this.platform.config.options?.logging) {
|
|
567
635
|
this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
|
|
568
|
-
this.debugLog(
|
|
636
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
|
|
569
637
|
}
|
|
570
638
|
else {
|
|
571
639
|
this.deviceLogging = this.accessory.context.logging = 'standard';
|
|
572
|
-
this.debugLog(
|
|
640
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Logging Not Set, Using: ${this.deviceLogging}`);
|
|
573
641
|
}
|
|
574
642
|
}
|
|
575
643
|
async pushOnChanges(device) {
|
|
@@ -593,11 +661,25 @@ class AirConditioner {
|
|
|
593
661
|
this.platform.log.warn(String(...log));
|
|
594
662
|
}
|
|
595
663
|
}
|
|
664
|
+
debugWarnLog(...log) {
|
|
665
|
+
if (this.enablingDeviceLogging()) {
|
|
666
|
+
if (this.deviceLogging?.includes('debug')) {
|
|
667
|
+
this.platform.log.warn('[DEBUG]', String(...log));
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
}
|
|
596
671
|
errorLog(...log) {
|
|
597
672
|
if (this.enablingDeviceLogging()) {
|
|
598
673
|
this.platform.log.error(String(...log));
|
|
599
674
|
}
|
|
600
675
|
}
|
|
676
|
+
debugErrorLog(...log) {
|
|
677
|
+
if (this.enablingDeviceLogging()) {
|
|
678
|
+
if (this.deviceLogging?.includes('debug')) {
|
|
679
|
+
this.platform.log.error('[DEBUG]', String(...log));
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
}
|
|
601
683
|
debugLog(...log) {
|
|
602
684
|
if (this.enablingDeviceLogging()) {
|
|
603
685
|
if (this.deviceLogging === 'debug') {
|