@switchbot/homebridge-switchbot 2.0.0-beta.17 → 2.0.0-beta.19
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 +1 -1
- package/config.schema.json +14 -4
- package/dist/device/bot.d.ts +2 -0
- package/dist/device/bot.d.ts.map +1 -1
- package/dist/device/bot.js +201 -163
- package/dist/device/bot.js.map +1 -1
- package/dist/device/colorbulb.d.ts +2 -0
- package/dist/device/colorbulb.d.ts.map +1 -1
- package/dist/device/colorbulb.js +250 -218
- package/dist/device/colorbulb.js.map +1 -1
- package/dist/device/contact.d.ts +2 -0
- package/dist/device/contact.d.ts.map +1 -1
- package/dist/device/contact.js +85 -66
- package/dist/device/contact.js.map +1 -1
- package/dist/device/curtain.d.ts +2 -0
- package/dist/device/curtain.d.ts.map +1 -1
- package/dist/device/curtain.js +166 -136
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/humidifier.d.ts.map +1 -1
- package/dist/device/humidifier.js +126 -115
- package/dist/device/humidifier.js.map +1 -1
- package/dist/device/lock.d.ts +2 -0
- package/dist/device/lock.d.ts.map +1 -1
- package/dist/device/lock.js +156 -130
- package/dist/device/lock.js.map +1 -1
- package/dist/device/meter.d.ts +2 -0
- package/dist/device/meter.d.ts.map +1 -1
- package/dist/device/meter.js +85 -64
- package/dist/device/meter.js.map +1 -1
- package/dist/device/meterplus.d.ts +2 -0
- package/dist/device/meterplus.d.ts.map +1 -1
- package/dist/device/meterplus.js +78 -59
- package/dist/device/meterplus.js.map +1 -1
- package/dist/device/motion.d.ts +2 -0
- package/dist/device/motion.d.ts.map +1 -1
- package/dist/device/motion.js +76 -57
- package/dist/device/motion.js.map +1 -1
- package/dist/device/plug.d.ts +2 -0
- package/dist/device/plug.d.ts.map +1 -1
- package/dist/device/plug.js +133 -107
- package/dist/device/plug.js.map +1 -1
- package/dist/device/striplight.d.ts +2 -0
- package/dist/device/striplight.d.ts.map +1 -1
- package/dist/device/striplight.js +224 -195
- package/dist/device/striplight.js.map +1 -1
- package/dist/irdevice/airconditioner.d.ts +2 -0
- package/dist/irdevice/airconditioner.d.ts.map +1 -1
- package/dist/irdevice/airconditioner.js +127 -105
- package/dist/irdevice/airconditioner.js.map +1 -1
- package/dist/irdevice/airpurifier.d.ts +2 -0
- package/dist/irdevice/airpurifier.d.ts.map +1 -1
- package/dist/irdevice/airpurifier.js +83 -66
- package/dist/irdevice/airpurifier.js.map +1 -1
- package/dist/irdevice/camera.d.ts +8 -6
- package/dist/irdevice/camera.d.ts.map +1 -1
- package/dist/irdevice/camera.js +83 -68
- package/dist/irdevice/camera.js.map +1 -1
- package/dist/irdevice/fan.d.ts +7 -5
- package/dist/irdevice/fan.d.ts.map +1 -1
- package/dist/irdevice/fan.js +90 -75
- package/dist/irdevice/fan.js.map +1 -1
- package/dist/irdevice/light.d.ts +8 -6
- package/dist/irdevice/light.d.ts.map +1 -1
- package/dist/irdevice/light.js +83 -68
- package/dist/irdevice/light.js.map +1 -1
- package/dist/irdevice/other.d.ts +8 -6
- package/dist/irdevice/other.d.ts.map +1 -1
- package/dist/irdevice/other.js +93 -78
- package/dist/irdevice/other.js.map +1 -1
- package/dist/irdevice/tv.d.ts +8 -6
- package/dist/irdevice/tv.d.ts.map +1 -1
- package/dist/irdevice/tv.js +68 -52
- package/dist/irdevice/tv.js.map +1 -1
- package/dist/irdevice/vacuumcleaner.d.ts +8 -6
- package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
- package/dist/irdevice/vacuumcleaner.js +83 -69
- package/dist/irdevice/vacuumcleaner.js.map +1 -1
- package/dist/irdevice/waterheater.d.ts +2 -0
- package/dist/irdevice/waterheater.d.ts.map +1 -1
- package/dist/irdevice/waterheater.js +75 -60
- package/dist/irdevice/waterheater.js.map +1 -1
- package/dist/settings.d.ts +12 -11
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js.map +1 -1
- package/package.json +1 -1
- package/src/device/bot.ts +200 -163
- package/src/device/colorbulb.ts +252 -221
- package/src/device/contact.ts +85 -66
- package/src/device/curtain.ts +165 -136
- package/src/device/humidifier.ts +126 -115
- package/src/device/lock.ts +156 -131
- package/src/device/meter.ts +85 -64
- package/src/device/meterplus.ts +78 -59
- package/src/device/motion.ts +76 -57
- package/src/device/plug.ts +132 -107
- package/src/device/striplight.ts +226 -198
- package/src/irdevice/airconditioner.ts +126 -103
- package/src/irdevice/airpurifier.ts +84 -66
- package/src/irdevice/camera.ts +84 -68
- package/src/irdevice/fan.ts +91 -75
- package/src/irdevice/light.ts +84 -68
- package/src/irdevice/other.ts +94 -78
- package/src/irdevice/tv.ts +69 -53
- package/src/irdevice/vacuumcleaner.ts +83 -68
- package/src/irdevice/waterheater.ts +76 -60
- package/src/settings.ts +12 -11
|
@@ -46,6 +46,7 @@ export class AirConditioner {
|
|
|
46
46
|
deviceLogging!: string;
|
|
47
47
|
hide_automode?: boolean;
|
|
48
48
|
pushOn?: boolean;
|
|
49
|
+
OpenAPI?: boolean;
|
|
49
50
|
|
|
50
51
|
private readonly valid12 = [1, 2];
|
|
51
52
|
private readonly valid012 = [0, 1, 2];
|
|
@@ -111,14 +112,14 @@ export class AirConditioner {
|
|
|
111
112
|
this.TargetHeaterCoolerState = 1 || 2;
|
|
112
113
|
this.ValidValues = [1, 2];
|
|
113
114
|
this.debugLog(
|
|
114
|
-
|
|
115
|
+
`${this.device.remoteType}: ${this.accessory.displayName} ValidValues: ${superStringify(this.ValidValues)},` +
|
|
115
116
|
` hide_automode: ${this.hide_automode}, TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`,
|
|
116
117
|
);
|
|
117
118
|
} else {
|
|
118
119
|
this.TargetHeaterCoolerState = 0 || 1 || 2;
|
|
119
120
|
this.ValidValues = [0, 1, 2];
|
|
120
121
|
this.debugLog(
|
|
121
|
-
|
|
122
|
+
`${this.device.remoteType}: ${this.accessory.displayName} ValidValues: ${superStringify(this.ValidValues)},` +
|
|
122
123
|
` hide_automode: ${this.hide_automode}, TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`,
|
|
123
124
|
);
|
|
124
125
|
}
|
|
@@ -229,7 +230,8 @@ export class AirConditioner {
|
|
|
229
230
|
if (this.CurrentMode === 1) {
|
|
230
231
|
this.CurrentTemperature = 25;
|
|
231
232
|
this.debugLog(
|
|
232
|
-
|
|
233
|
+
`${this.device.remoteType}: ${this.accessory.displayName} CurrentMode: ${this.CurrentMode},`
|
|
234
|
+
+ ` CurrentTemperature: ${this.CurrentTemperature}`,
|
|
233
235
|
);
|
|
234
236
|
}
|
|
235
237
|
const parameter = `${this.CurrentTemperature},${this.CurrentMode},${this.CurrentFanSpeed},${this.state}`;
|
|
@@ -254,142 +256,148 @@ export class AirConditioner {
|
|
|
254
256
|
}
|
|
255
257
|
|
|
256
258
|
async pushChanges(body): Promise<void> {
|
|
257
|
-
|
|
259
|
+
if (this.OpenAPI) {
|
|
260
|
+
try {
|
|
258
261
|
// Make Push On request to the API
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
262
|
+
const t = Date.now();
|
|
263
|
+
const nonce = 'requestID';
|
|
264
|
+
const data = this.platform.config.credentials?.token + t + nonce;
|
|
265
|
+
const signTerm = crypto.createHmac('sha256', this.platform.config.credentials?.secret)
|
|
266
|
+
.update(Buffer.from(data, 'utf-8'))
|
|
267
|
+
.digest();
|
|
268
|
+
const sign = signTerm.toString('base64');
|
|
269
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} sign: ${sign}`);
|
|
270
|
+
this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Sending request to SwitchBot API. body: ${body},`);
|
|
271
|
+
const options = {
|
|
272
|
+
hostname: HostDomain,
|
|
273
|
+
port: 443,
|
|
274
|
+
path: `${DevicePath}/${this.device.deviceId}/commands`,
|
|
275
|
+
method: 'POST',
|
|
276
|
+
headers: {
|
|
277
|
+
'Authorization': this.platform.config.credentials?.token,
|
|
278
|
+
'sign': sign,
|
|
279
|
+
'nonce': nonce,
|
|
280
|
+
't': t,
|
|
281
|
+
'Content-Type': 'application/json',
|
|
282
|
+
'Content-Length': body.length,
|
|
283
|
+
},
|
|
284
|
+
};
|
|
285
|
+
const req = https.request(options, res => {
|
|
286
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} statusCode: ${res.statusCode}`);
|
|
287
|
+
this.statusCode({ res });
|
|
288
|
+
res.on('data', d => {
|
|
289
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} d: ${d}`);
|
|
290
|
+
});
|
|
287
291
|
});
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
292
|
+
req.on('error', (e: any) => {
|
|
293
|
+
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} error message: ${e.message}`);
|
|
294
|
+
});
|
|
295
|
+
req.write(body);
|
|
296
|
+
req.end();
|
|
297
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushchanges: ${superStringify(req)}`);
|
|
298
|
+
this.CurrentTemperatureCached = this.CurrentTemperature;
|
|
299
|
+
this.accessory.context.CurrentTemperature = this.CurrentTemperatureCached;
|
|
300
|
+
this.HeatingThresholdTemperature = this.CurrentTemperatureCached;
|
|
301
|
+
this.HeatingThresholdTemperatureCached = this.CurrentTemperatureCached;
|
|
302
|
+
this.accessory.context.HeatingThresholdTemperature = this.HeatingThresholdTemperatureCached;
|
|
303
|
+
this.CoolingThresholdTemperature = this.CurrentTemperatureCached;
|
|
304
|
+
this.CoolingThresholdTemperatureCached = this.CurrentTemperatureCached;
|
|
305
|
+
this.accessory.context.CoolingThresholdTemperature = this.CoolingThresholdTemperatureCached;
|
|
306
|
+
this.updateHomeKitCharacteristics();
|
|
307
|
+
} catch (e: any) {
|
|
308
|
+
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} failed pushChanges`);
|
|
309
|
+
if (this.deviceLogging.includes('debug')) {
|
|
310
|
+
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} failed pushChanges,`
|
|
311
|
+
+ ` Error Message: ${superStringify(e.message)}`);
|
|
312
|
+
}
|
|
313
|
+
this.apiError(e);
|
|
308
314
|
}
|
|
309
|
-
this.apiError(e);
|
|
310
315
|
}
|
|
311
316
|
}
|
|
312
317
|
|
|
313
318
|
async statusCode({ res }: { res: IncomingMessage }): Promise<void> {
|
|
314
319
|
switch (res.statusCode) {
|
|
315
320
|
case 151:
|
|
316
|
-
this.errorLog(
|
|
321
|
+
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Command not supported by this device type.`);
|
|
317
322
|
break;
|
|
318
323
|
case 152:
|
|
319
|
-
this.errorLog(
|
|
324
|
+
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Device not found.`);
|
|
320
325
|
break;
|
|
321
326
|
case 160:
|
|
322
|
-
this.errorLog(
|
|
327
|
+
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Command is not supported.`);
|
|
323
328
|
break;
|
|
324
329
|
case 161:
|
|
325
|
-
this.errorLog(
|
|
330
|
+
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Device is offline.`);
|
|
326
331
|
break;
|
|
327
332
|
case 171:
|
|
328
|
-
this.errorLog(
|
|
333
|
+
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Hub Device is offline. Hub: ${this.device.hubDeviceId}`);
|
|
329
334
|
break;
|
|
330
335
|
case 190:
|
|
331
336
|
this.errorLog(
|
|
332
|
-
|
|
337
|
+
`${this.device.remoteType}: ${this.accessory.displayName} Device internal error due to device states not synchronized` +
|
|
333
338
|
` with server, Or command: ${superStringify(res)} format is invalid`,
|
|
334
339
|
);
|
|
335
340
|
break;
|
|
336
341
|
case 100:
|
|
337
|
-
this.debugLog(
|
|
342
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Command successfully sent.`);
|
|
338
343
|
break;
|
|
339
344
|
default:
|
|
340
|
-
this.debugLog(
|
|
345
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Unknown statusCode.`);
|
|
341
346
|
}
|
|
342
347
|
}
|
|
343
348
|
|
|
344
349
|
async updateHomeKitCharacteristics(): Promise<void> {
|
|
345
350
|
if (this.Active === undefined) {
|
|
346
|
-
this.debugLog(
|
|
351
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Active: ${this.Active}`);
|
|
347
352
|
} else {
|
|
348
353
|
this.coolerService?.updateCharacteristic(this.platform.Characteristic.Active, this.Active);
|
|
349
|
-
this.debugLog(
|
|
354
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic Active: ${this.Active}`);
|
|
350
355
|
}
|
|
351
356
|
if (this.RotationSpeed === undefined) {
|
|
352
|
-
this.debugLog(
|
|
357
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} RotationSpeed: ${this.RotationSpeed}`);
|
|
353
358
|
} else {
|
|
354
359
|
this.coolerService?.updateCharacteristic(this.platform.Characteristic.RotationSpeed, this.RotationSpeed);
|
|
355
|
-
this.debugLog(
|
|
360
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic RotationSpeed: ${this.RotationSpeed}`);
|
|
356
361
|
}
|
|
357
362
|
if (this.CurrentTemperature === undefined) {
|
|
358
|
-
this.debugLog(
|
|
363
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} CurrentTemperature: ${this.CurrentTemperature}`);
|
|
359
364
|
} else {
|
|
360
365
|
this.coolerService?.updateCharacteristic(this.platform.Characteristic.CurrentTemperature, this.CurrentTemperature);
|
|
361
|
-
this.debugLog(
|
|
366
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic CurrentTemperature: ${this.CurrentTemperature}`);
|
|
362
367
|
}
|
|
363
368
|
if (this.TargetHeaterCoolerState === undefined) {
|
|
364
|
-
this.debugLog(
|
|
369
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`);
|
|
365
370
|
} else {
|
|
366
371
|
this.coolerService?.updateCharacteristic(this.platform.Characteristic.TargetHeaterCoolerState, this.TargetHeaterCoolerState);
|
|
367
372
|
this.debugLog(
|
|
368
|
-
|
|
373
|
+
`${this.device.remoteType}: ${this.accessory.displayName}` + ` updateCharacteristic TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`,
|
|
369
374
|
);
|
|
370
375
|
}
|
|
371
376
|
if (this.CurrentHeaterCoolerState === undefined) {
|
|
372
|
-
this.debugLog(
|
|
377
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`);
|
|
373
378
|
} else {
|
|
374
379
|
this.coolerService?.updateCharacteristic(this.platform.Characteristic.CurrentHeaterCoolerState, this.CurrentHeaterCoolerState);
|
|
375
380
|
this.debugLog(
|
|
376
|
-
|
|
381
|
+
`${this.device.remoteType}: ${this.accessory.displayName}`
|
|
382
|
+
+ ` updateCharacteristic CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`,
|
|
377
383
|
);
|
|
378
384
|
}
|
|
379
385
|
if (this.HeatingThresholdTemperature === undefined) {
|
|
380
|
-
this.debugLog(
|
|
386
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} HeatingThresholdTemperature: ${this.HeatingThresholdTemperature}`);
|
|
381
387
|
} else {
|
|
382
388
|
this.coolerService?.updateCharacteristic(this.platform.Characteristic.HeatingThresholdTemperature, this.HeatingThresholdTemperature);
|
|
383
389
|
this.debugLog(
|
|
384
|
-
|
|
390
|
+
`${this.device.remoteType}: ${this.accessory.displayName}`
|
|
391
|
+
+ ` updateCharacteristic HeatingThresholdTemperature: ${this.HeatingThresholdTemperature}`,
|
|
385
392
|
);
|
|
386
393
|
}
|
|
387
394
|
if (this.CoolingThresholdTemperature === undefined) {
|
|
388
|
-
this.debugLog(
|
|
395
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} CoolingThresholdTemperature: ${this.CoolingThresholdTemperature}`);
|
|
389
396
|
} else {
|
|
390
397
|
this.coolerService?.updateCharacteristic(this.platform.Characteristic.CoolingThresholdTemperature, this.CoolingThresholdTemperature);
|
|
391
398
|
this.debugLog(
|
|
392
|
-
|
|
399
|
+
`${this.device.remoteType}: ${this.accessory.displayName}`
|
|
400
|
+
+ ` updateCharacteristic CoolingThresholdTemperature: ${this.CoolingThresholdTemperature}`,
|
|
393
401
|
);
|
|
394
402
|
}
|
|
395
403
|
}
|
|
@@ -412,7 +420,7 @@ export class AirConditioner {
|
|
|
412
420
|
} else {
|
|
413
421
|
this.CurrentTemperatureCached = this.CurrentTemperature;
|
|
414
422
|
}
|
|
415
|
-
this.debugLog(
|
|
423
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Get CurrentTemperature: ${this.CurrentTemperature}`);
|
|
416
424
|
this.accessory.context.CurrentTemperature = this.CurrentTemperatureCached;
|
|
417
425
|
return this.CurrentTemperature;
|
|
418
426
|
}
|
|
@@ -425,7 +433,7 @@ export class AirConditioner {
|
|
|
425
433
|
} else {
|
|
426
434
|
this.RotationSpeed = this.CurrentFanSpeed - 1;
|
|
427
435
|
}
|
|
428
|
-
this.debugLog(
|
|
436
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Get RotationSpeed: ${this.RotationSpeed}`);
|
|
429
437
|
this.RotationSpeedCached = this.RotationSpeed;
|
|
430
438
|
this.accessory.context.RotationSpeed = this.RotationSpeedCached;
|
|
431
439
|
return this.RotationSpeed;
|
|
@@ -444,17 +452,17 @@ export class AirConditioner {
|
|
|
444
452
|
}
|
|
445
453
|
|
|
446
454
|
async ActiveSet(value: CharacteristicValue): Promise<void> {
|
|
447
|
-
this.debugLog(
|
|
455
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Set Active: ${value}`);
|
|
448
456
|
|
|
449
457
|
this.Active = value;
|
|
450
458
|
this.ActiveCached = this.Active;
|
|
451
459
|
this.accessory.context.Active = this.ActiveCached;
|
|
452
460
|
|
|
453
461
|
if (value === this.platform.Characteristic.Active.INACTIVE) {
|
|
454
|
-
this.debugLog(
|
|
462
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushAirConditionerOffChanges, Active: ${this.Active}`);
|
|
455
463
|
this.pushAirConditionerOffChanges();
|
|
456
464
|
} else {
|
|
457
|
-
this.debugLog(
|
|
465
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushAirConditionerOnChanges, Active: ${this.Active}`);
|
|
458
466
|
if (this.pushOn) {
|
|
459
467
|
this.pushAirConditionerOnChanges();
|
|
460
468
|
} else {
|
|
@@ -467,19 +475,19 @@ export class AirConditioner {
|
|
|
467
475
|
if (this.ValidValues === this.valid012) {
|
|
468
476
|
this.TargetHeaterCoolerState = this.platform.Characteristic.TargetHeaterCoolerState.AUTO;
|
|
469
477
|
this.debugLog(
|
|
470
|
-
|
|
478
|
+
`${this.device.remoteType}: ${this.accessory.displayName} Get (AUTO) TargetHeaterCoolerState: ${this.CurrentHeaterCoolerState},` +
|
|
471
479
|
` ValidValues: ${this.ValidValues}`,
|
|
472
480
|
);
|
|
473
481
|
} else if (this.ValidValues === this.valid12) {
|
|
474
482
|
this.TargetHeaterCoolerState =
|
|
475
483
|
this.platform.Characteristic.TargetHeaterCoolerState.COOL || this.platform.Characteristic.TargetHeaterCoolerState.HEAT;
|
|
476
484
|
this.debugLog(
|
|
477
|
-
|
|
485
|
+
`${this.device.remoteType}: ${this.accessory.displayName} Get (COOL/HEAT) TargetHeaterCoolerState: ${this.CurrentHeaterCoolerState},` +
|
|
478
486
|
` ValidValues: ${this.ValidValues}`,
|
|
479
487
|
);
|
|
480
488
|
} else {
|
|
481
489
|
this.debugLog(
|
|
482
|
-
|
|
490
|
+
`${this.device.remoteType}: ${this.accessory.displayName} Get TargetHeaterCoolerState: ${this.CurrentHeaterCoolerState},` +
|
|
483
491
|
` ValidValues: ${this.ValidValues}`,
|
|
484
492
|
);
|
|
485
493
|
}
|
|
@@ -496,7 +504,7 @@ export class AirConditioner {
|
|
|
496
504
|
this.TargetHeaterCoolerStateCOOL();
|
|
497
505
|
} else {
|
|
498
506
|
this.errorLog(
|
|
499
|
-
|
|
507
|
+
`${this.device.remoteType}: ${this.accessory.displayName} Set TargetHeaterCoolerState: ${this.TargetHeaterCoolerState},` +
|
|
500
508
|
` hide_automode: ${this.hide_automode} `,
|
|
501
509
|
);
|
|
502
510
|
}
|
|
@@ -509,7 +517,7 @@ export class AirConditioner {
|
|
|
509
517
|
this.TargetHeaterCoolerStateCOOL();
|
|
510
518
|
} else {
|
|
511
519
|
this.errorLog(
|
|
512
|
-
|
|
520
|
+
`${this.device.remoteType}: ${this.accessory.displayName} Set TargetHeaterCoolerState: ${this.TargetHeaterCoolerState},` +
|
|
513
521
|
` hide_automode: ${this.hide_automode} `,
|
|
514
522
|
);
|
|
515
523
|
}
|
|
@@ -522,22 +530,22 @@ export class AirConditioner {
|
|
|
522
530
|
async TargetHeaterCoolerStateAUTO(): Promise<void> {
|
|
523
531
|
this.TargetHeaterCoolerState = this.platform.Characteristic.TargetHeaterCoolerState.AUTO;
|
|
524
532
|
this.CurrentMode = 1;
|
|
525
|
-
this.debugLog(
|
|
526
|
-
this.debugLog(
|
|
533
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Set (AUTO) TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`);
|
|
534
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Switchbot CurrentMode: ${this.CurrentMode}`);
|
|
527
535
|
}
|
|
528
536
|
|
|
529
537
|
async TargetHeaterCoolerStateCOOL(): Promise<void> {
|
|
530
538
|
this.TargetHeaterCoolerState = this.platform.Characteristic.TargetHeaterCoolerState.COOL;
|
|
531
539
|
this.CurrentMode = 2;
|
|
532
|
-
this.debugLog(
|
|
533
|
-
this.debugLog(
|
|
540
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Set (COOL) TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`);
|
|
541
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Switchbot CurrentMode: ${this.CurrentMode}`);
|
|
534
542
|
}
|
|
535
543
|
|
|
536
544
|
async TargetHeaterCoolerStateHEAT(): Promise<void> {
|
|
537
545
|
this.TargetHeaterCoolerState = this.platform.Characteristic.TargetHeaterCoolerState.HEAT;
|
|
538
546
|
this.CurrentMode = 5;
|
|
539
|
-
this.debugLog(
|
|
540
|
-
this.debugLog(
|
|
547
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Set (HEAT) TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`);
|
|
548
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Switchbot CurrentMode: ${this.CurrentMode}`);
|
|
541
549
|
}
|
|
542
550
|
|
|
543
551
|
async CurrentHeaterCoolerStateGet(): Promise<CharacteristicValue> {
|
|
@@ -545,14 +553,17 @@ export class AirConditioner {
|
|
|
545
553
|
this.CurrentTemperatureUndefined();
|
|
546
554
|
if (this.CurrentTemperature < this.CurrentTemperatureCached) {
|
|
547
555
|
this.CurrentHeaterCoolerState = this.platform.Characteristic.CurrentHeaterCoolerState.COOLING;
|
|
548
|
-
this.debugLog(
|
|
556
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName}`
|
|
557
|
+
+` Get (COOLLING) CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`);
|
|
549
558
|
} else if (this.CurrentTemperature > this.CurrentTemperatureCached) {
|
|
550
559
|
this.CurrentHeaterCoolerState = this.platform.Characteristic.CurrentHeaterCoolerState.HEATING;
|
|
551
|
-
this.debugLog(
|
|
560
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName}`
|
|
561
|
+
+` Get (HEATING) CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`);
|
|
552
562
|
}
|
|
553
563
|
} else {
|
|
554
564
|
this.CurrentHeaterCoolerState = this.platform.Characteristic.CurrentHeaterCoolerState.INACTIVE;
|
|
555
|
-
this.debugLog(
|
|
565
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName}`
|
|
566
|
+
+` Get (INACTIVE) CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`);
|
|
556
567
|
}
|
|
557
568
|
this.CurrentHeaterCoolerStateCached = this.CurrentHeaterCoolerState;
|
|
558
569
|
this.accessory.context.CurrentHeaterCoolerState = this.CurrentHeaterCoolerStateCached;
|
|
@@ -565,7 +576,7 @@ export class AirConditioner {
|
|
|
565
576
|
this.HeatingThresholdTemperature = this.CurrentTemperatureCached;
|
|
566
577
|
this.HeatingThresholdTemperatureCached = this.HeatingThresholdTemperature;
|
|
567
578
|
this.accessory.context.HeatingThresholdTemperature = this.HeatingThresholdTemperatureCached;
|
|
568
|
-
this.debugLog(
|
|
579
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Get HeatingThresholdTemperature: ${this.HeatingThresholdTemperature}`);
|
|
569
580
|
return this.HeatingThresholdTemperature;
|
|
570
581
|
}
|
|
571
582
|
|
|
@@ -575,7 +586,7 @@ export class AirConditioner {
|
|
|
575
586
|
this.HeatingThresholdTemperatureCached = this.HeatingThresholdTemperature;
|
|
576
587
|
this.accessory.context.HeatingThresholdTemperature = this.HeatingThresholdTemperatureCached;
|
|
577
588
|
this.debugLog(
|
|
578
|
-
|
|
589
|
+
`${this.device.remoteType}: ${this.accessory.displayName} Set HeatingThresholdTemperature: ${this.HeatingThresholdTemperature},` +
|
|
579
590
|
` CurrentTemperatureCached: ${this.CurrentTemperatureCached}`,
|
|
580
591
|
);
|
|
581
592
|
this.pushAirConditionerStatusChanges();
|
|
@@ -587,7 +598,7 @@ export class AirConditioner {
|
|
|
587
598
|
this.CoolingThresholdTemperature = this.CurrentTemperatureCached;
|
|
588
599
|
this.CoolingThresholdTemperatureCached = this.CoolingThresholdTemperature;
|
|
589
600
|
this.accessory.context.CoolingThresholdTemperature = this.CoolingThresholdTemperatureCached;
|
|
590
|
-
this.debugLog(
|
|
601
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Get CoolingThresholdTemperature: ${this.CoolingThresholdTemperature}`);
|
|
591
602
|
return this.CoolingThresholdTemperature;
|
|
592
603
|
}
|
|
593
604
|
|
|
@@ -597,7 +608,7 @@ export class AirConditioner {
|
|
|
597
608
|
this.CoolingThresholdTemperatureCached = this.CoolingThresholdTemperature;
|
|
598
609
|
this.accessory.context.CoolingThresholdTemperature = this.CoolingThresholdTemperatureCached;
|
|
599
610
|
this.debugLog(
|
|
600
|
-
|
|
611
|
+
`${this.device.remoteType}: ${this.accessory.displayName} Set CoolingThresholdTemperature: ${this.CoolingThresholdTemperature},` +
|
|
601
612
|
` CurrentTemperatureCached: ${this.CurrentTemperatureCached}`,
|
|
602
613
|
);
|
|
603
614
|
this.pushAirConditionerStatusChanges();
|
|
@@ -612,6 +623,15 @@ export class AirConditioner {
|
|
|
612
623
|
}
|
|
613
624
|
}
|
|
614
625
|
|
|
626
|
+
async openAPI() {
|
|
627
|
+
if (!this.device.openAPI) {
|
|
628
|
+
this.OpenAPI = true;
|
|
629
|
+
} else {
|
|
630
|
+
this.OpenAPI = this.device.openAPI;
|
|
631
|
+
}
|
|
632
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Using OpenAPI: ${this.OpenAPI}`);
|
|
633
|
+
}
|
|
634
|
+
|
|
615
635
|
async config(device: irdevice & irDevicesConfig): Promise<void> {
|
|
616
636
|
let config = {};
|
|
617
637
|
if (device.irair) {
|
|
@@ -620,24 +640,27 @@ export class AirConditioner {
|
|
|
620
640
|
if (device.logging !== undefined) {
|
|
621
641
|
config['logging'] = device.logging;
|
|
622
642
|
}
|
|
643
|
+
if (device.openAPI !== undefined) {
|
|
644
|
+
config['openAPI'] = device.openAPI;
|
|
645
|
+
}
|
|
623
646
|
if (Object.entries(config).length !== 0) {
|
|
624
|
-
this.infoLog(
|
|
647
|
+
this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Config: ${superStringify(config)}`);
|
|
625
648
|
}
|
|
626
649
|
}
|
|
627
650
|
|
|
628
651
|
async logs(device: irdevice & irDevicesConfig): Promise<void> {
|
|
629
652
|
if (this.platform.debugMode) {
|
|
630
653
|
this.deviceLogging = this.accessory.context.logging = 'debugMode';
|
|
631
|
-
this.debugLog(
|
|
654
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
|
|
632
655
|
} else if (device.logging) {
|
|
633
656
|
this.deviceLogging = this.accessory.context.logging = device.logging;
|
|
634
|
-
this.debugLog(
|
|
657
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
|
|
635
658
|
} else if (this.platform.config.options?.logging) {
|
|
636
659
|
this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
|
|
637
|
-
this.debugLog(
|
|
660
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
|
|
638
661
|
} else {
|
|
639
662
|
this.deviceLogging = this.accessory.context.logging = 'standard';
|
|
640
|
-
this.debugLog(
|
|
663
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Logging Not Set, Using: ${this.deviceLogging}`);
|
|
641
664
|
}
|
|
642
665
|
}
|
|
643
666
|
|