@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
package/src/device/humidifier.ts
CHANGED
|
@@ -135,11 +135,11 @@ export class Humidifier {
|
|
|
135
135
|
|
|
136
136
|
// Temperature Sensor Service
|
|
137
137
|
if (device.humidifier?.hide_temperature || device.ble) {
|
|
138
|
-
this.debugLog(
|
|
138
|
+
this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Removing Temperature Sensor Service`);
|
|
139
139
|
this.temperatureservice = this.accessory.getService(this.platform.Service.TemperatureSensor);
|
|
140
140
|
accessory.removeService(this.temperatureservice!);
|
|
141
141
|
} else if (!this.temperatureservice && !device.ble) {
|
|
142
|
-
this.debugLog(
|
|
142
|
+
this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Add Temperature Sensor Service`);
|
|
143
143
|
(this.temperatureservice =
|
|
144
144
|
this.accessory.getService(this.platform.Service.TemperatureSensor) || this.accessory.addService(this.platform.Service.TemperatureSensor)),
|
|
145
145
|
`${accessory.displayName} Temperature Sensor`;
|
|
@@ -158,7 +158,7 @@ export class Humidifier {
|
|
|
158
158
|
return this.CurrentTemperature;
|
|
159
159
|
});
|
|
160
160
|
} else {
|
|
161
|
-
this.debugLog(
|
|
161
|
+
this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Temperature Sensor Service Not Added`);
|
|
162
162
|
}
|
|
163
163
|
|
|
164
164
|
// Retrieve initial values and updateHomekit
|
|
@@ -184,9 +184,10 @@ export class Humidifier {
|
|
|
184
184
|
try {
|
|
185
185
|
await this.pushChanges();
|
|
186
186
|
} catch (e: any) {
|
|
187
|
-
this.errorLog(
|
|
187
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed pushChanges`);
|
|
188
188
|
if (this.deviceLogging.includes('debug')) {
|
|
189
|
-
this.errorLog(
|
|
189
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed pushChanges,`
|
|
190
|
+
+ ` Error Message: ${superStringify(e.message)}`);
|
|
190
191
|
}
|
|
191
192
|
this.apiError(e);
|
|
192
193
|
}
|
|
@@ -206,29 +207,29 @@ export class Humidifier {
|
|
|
206
207
|
}
|
|
207
208
|
|
|
208
209
|
async BLEparseStatus(): Promise<void> {
|
|
209
|
-
this.debugLog(
|
|
210
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} BLE parseStatus`);
|
|
210
211
|
// Current Relative Humidity
|
|
211
212
|
this.CurrentRelativeHumidity = this.percentage!;
|
|
212
|
-
this.debugLog(
|
|
213
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} CurrentRelativeHumidity: ${this.CurrentRelativeHumidity}`);
|
|
213
214
|
// Active
|
|
214
215
|
if (this.onState) {
|
|
215
216
|
this.Active = this.platform.Characteristic.Active.ACTIVE;
|
|
216
217
|
} else {
|
|
217
218
|
this.Active = this.platform.Characteristic.Active.INACTIVE;
|
|
218
219
|
}
|
|
219
|
-
this.debugLog(
|
|
220
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Active: ${this.Active}`);
|
|
220
221
|
}
|
|
221
222
|
|
|
222
223
|
async openAPIparseStatus(): Promise<void> {
|
|
223
224
|
if (this.platform.config.credentials?.token) {
|
|
224
|
-
this.debugLog(
|
|
225
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} OpenAPI parseStatus`);
|
|
225
226
|
// Current Relative Humidity
|
|
226
227
|
this.CurrentRelativeHumidity = this.humidity!;
|
|
227
|
-
this.debugLog(
|
|
228
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} CurrentRelativeHumidity: ${this.CurrentRelativeHumidity}`);
|
|
228
229
|
// Current Temperature
|
|
229
230
|
if (!this.device.humidifier?.hide_temperature) {
|
|
230
231
|
this.CurrentTemperature = this.temperature!;
|
|
231
|
-
this.debugLog(
|
|
232
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} CurrentTemperature: ${this.CurrentTemperature}`);
|
|
232
233
|
}
|
|
233
234
|
// Target Humidifier Dehumidifier State
|
|
234
235
|
switch (this.auto) {
|
|
@@ -252,11 +253,14 @@ export class Humidifier {
|
|
|
252
253
|
this.CurrentHumidifierDehumidifierState = this.platform.Characteristic.CurrentHumidifierDehumidifierState.HUMIDIFYING;
|
|
253
254
|
}
|
|
254
255
|
}
|
|
255
|
-
this.debugLog(
|
|
256
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName}`
|
|
257
|
+
+ ` TargetHumidifierDehumidifierState: ${this.TargetHumidifierDehumidifierState}`);
|
|
256
258
|
this.debugLog(
|
|
257
|
-
|
|
259
|
+
`${this.device.deviceType}: ${this.accessory.displayName}`
|
|
260
|
+
+ ` RelativeHumidityHumidifierThreshold: ${this.RelativeHumidityHumidifierThreshold}`,
|
|
258
261
|
);
|
|
259
|
-
this.debugLog(
|
|
262
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName}`
|
|
263
|
+
+ ` CurrentHumidifierDehumidifierState: ${this.CurrentHumidifierDehumidifierState}`);
|
|
260
264
|
// Active
|
|
261
265
|
switch (this.power) {
|
|
262
266
|
case 'on':
|
|
@@ -265,14 +269,14 @@ export class Humidifier {
|
|
|
265
269
|
default:
|
|
266
270
|
this.Active = this.platform.Characteristic.Active.INACTIVE;
|
|
267
271
|
}
|
|
268
|
-
this.debugLog(
|
|
272
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Active: ${this.Active}`);
|
|
269
273
|
// Water Level
|
|
270
274
|
if (this.lackWater) {
|
|
271
275
|
this.WaterLevel = 0;
|
|
272
276
|
} else {
|
|
273
277
|
this.WaterLevel = 100;
|
|
274
278
|
}
|
|
275
|
-
this.debugLog(
|
|
279
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} WaterLevel: ${this.WaterLevel}`);
|
|
276
280
|
}
|
|
277
281
|
}
|
|
278
282
|
|
|
@@ -288,14 +292,14 @@ export class Humidifier {
|
|
|
288
292
|
}
|
|
289
293
|
|
|
290
294
|
async BLERefreshStatus(): Promise<void> {
|
|
291
|
-
this.debugLog(
|
|
295
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} BLE refreshStatus`);
|
|
292
296
|
const switchbot = await this.platform.connectBLE();
|
|
293
297
|
// Convert to BLE Address
|
|
294
298
|
this.device.bleMac = this.device
|
|
295
299
|
.deviceId!.match(/.{1,2}/g)!
|
|
296
300
|
.join(':')
|
|
297
301
|
.toLowerCase();
|
|
298
|
-
this.debugLog(
|
|
302
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} BLE Address: ${this.device.bleMac}`);
|
|
299
303
|
this.getCustomBLEAddress(switchbot);
|
|
300
304
|
// Start to monitor advertisement packets
|
|
301
305
|
if (switchbot !== false) {
|
|
@@ -311,25 +315,25 @@ export class Humidifier {
|
|
|
311
315
|
if (this.deviceLogging.includes('debug')) {
|
|
312
316
|
this.infoLog(this.address);
|
|
313
317
|
this.infoLog(this.device.bleMac);
|
|
314
|
-
this.infoLog(
|
|
315
|
-
this.infoLog(
|
|
318
|
+
this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} BLE Address Found: ${this.address}`);
|
|
319
|
+
this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Config BLE Address: ${this.device.bleMac}`);
|
|
316
320
|
}
|
|
317
321
|
this.serviceData = ad.serviceData;
|
|
318
322
|
this.autoMode = ad.serviceData.autoMode;
|
|
319
323
|
this.onState = ad.serviceData.onState;
|
|
320
324
|
this.percentage = ad.serviceData.percentage;
|
|
321
|
-
this.debugLog(
|
|
325
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} serviceData: ${superStringify(ad.serviceData)}`);
|
|
322
326
|
this.debugLog(
|
|
323
|
-
|
|
327
|
+
`${this.device.deviceType}: ${this.accessory.displayName} model: ${ad.serviceData.model}, modelName: ${ad.serviceData.modelName},` +
|
|
324
328
|
`autoMode: ${ad.serviceData.autoMode}, onState: ${ad.serviceData.onState}, percentage: ${ad.serviceData.percentage}`,
|
|
325
329
|
);
|
|
326
330
|
|
|
327
331
|
if (this.serviceData) {
|
|
328
332
|
this.connected = true;
|
|
329
|
-
this.debugLog(
|
|
333
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} connected: ${this.connected}`);
|
|
330
334
|
} else {
|
|
331
335
|
this.connected = false;
|
|
332
|
-
this.debugLog(
|
|
336
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} connected: ${this.connected}`);
|
|
333
337
|
}
|
|
334
338
|
};
|
|
335
339
|
// Wait 2 seconds
|
|
@@ -346,14 +350,15 @@ export class Humidifier {
|
|
|
346
350
|
}
|
|
347
351
|
})
|
|
348
352
|
.catch(async (e: any) => {
|
|
349
|
-
this.errorLog(
|
|
353
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed refreshStatus with BLE Connection`);
|
|
350
354
|
if (this.deviceLogging.includes('debug')) {
|
|
351
355
|
this.errorLog(
|
|
352
|
-
|
|
356
|
+
`${this.device.deviceType}: ${this.accessory.displayName} failed refreshStatus with BLE Connection,`
|
|
357
|
+
+ ` Error Message: ${superStringify(e.message)}`,
|
|
353
358
|
);
|
|
354
359
|
}
|
|
355
360
|
if (this.platform.config.credentials?.token) {
|
|
356
|
-
this.warnLog(
|
|
361
|
+
this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} Using OpenAPI Connection`);
|
|
357
362
|
await this.openAPIRefreshStatus();
|
|
358
363
|
}
|
|
359
364
|
this.apiError(e);
|
|
@@ -372,7 +377,7 @@ export class Humidifier {
|
|
|
372
377
|
});
|
|
373
378
|
// Set an event handler
|
|
374
379
|
switchbot.onadvertisement = (ad: any) => {
|
|
375
|
-
this.warnLog(
|
|
380
|
+
this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} ad: ${superStringify(ad, null, ' ')}`);
|
|
376
381
|
};
|
|
377
382
|
await switchbot.wait(10000);
|
|
378
383
|
// Stop to monitor
|
|
@@ -382,23 +387,23 @@ export class Humidifier {
|
|
|
382
387
|
}
|
|
383
388
|
|
|
384
389
|
async BLEconnection(switchbot: any): Promise<void> {
|
|
385
|
-
this.errorLog(
|
|
390
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} wasn't able to establish BLE Connection, node-switchbot: ${switchbot}`);
|
|
386
391
|
if (this.platform.config.credentials?.token) {
|
|
387
|
-
this.warnLog(
|
|
392
|
+
this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} Using OpenAPI Connection`);
|
|
388
393
|
await this.openAPIRefreshStatus();
|
|
389
394
|
}
|
|
390
395
|
}
|
|
391
396
|
|
|
392
397
|
async openAPIRefreshStatus(): Promise<void> {
|
|
393
|
-
if (this.platform.config.credentials?.token && this.
|
|
394
|
-
this.debugLog(
|
|
398
|
+
if (this.platform.config.credentials?.token && this.OpenAPI) {
|
|
399
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} OpenAPI refreshStatus`);
|
|
395
400
|
try {
|
|
396
401
|
const t = Date.now();
|
|
397
402
|
const nonce = 'requestID';
|
|
398
403
|
const data = this.platform.config.credentials?.token + t + nonce;
|
|
399
404
|
const signTerm = crypto.createHmac('sha256', this.platform.config.credentials?.secret).update(Buffer.from(data, 'utf-8')).digest();
|
|
400
405
|
const sign = signTerm.toString('base64');
|
|
401
|
-
this.debugLog(
|
|
406
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} sign: ${sign}`);
|
|
402
407
|
const options = {
|
|
403
408
|
hostname: HostDomain,
|
|
404
409
|
port: 443,
|
|
@@ -413,16 +418,16 @@ export class Humidifier {
|
|
|
413
418
|
},
|
|
414
419
|
};
|
|
415
420
|
const req = https.request(options, (res) => {
|
|
416
|
-
this.debugLog(
|
|
421
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} statusCode: ${res.statusCode}`);
|
|
417
422
|
let rawData = '';
|
|
418
423
|
res.on('data', (d) => {
|
|
419
424
|
rawData += d;
|
|
420
|
-
this.debugLog(
|
|
425
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} d: ${d}`);
|
|
421
426
|
});
|
|
422
427
|
res.on('end', () => {
|
|
423
428
|
try {
|
|
424
429
|
this.deviceStatus = JSON.parse(rawData);
|
|
425
|
-
this.debugLog(
|
|
430
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} refreshStatus: ${superStringify(this.deviceStatus)}`);
|
|
426
431
|
this.auto = this.deviceStatus.body.auto;
|
|
427
432
|
this.power = this.deviceStatus.body.power;
|
|
428
433
|
this.lackWater = this.deviceStatus.body.lackWater;
|
|
@@ -432,19 +437,19 @@ export class Humidifier {
|
|
|
432
437
|
this.parseStatus();
|
|
433
438
|
this.updateHomeKitCharacteristics();
|
|
434
439
|
} catch (e: any) {
|
|
435
|
-
this.errorLog(
|
|
440
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} error message: ${e.message}`);
|
|
436
441
|
}
|
|
437
442
|
});
|
|
438
443
|
});
|
|
439
444
|
req.on('error', (e: any) => {
|
|
440
|
-
this.errorLog(
|
|
445
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} error message: ${e.message}`);
|
|
441
446
|
});
|
|
442
447
|
req.end();
|
|
443
448
|
} catch (e: any) {
|
|
444
|
-
this.errorLog(
|
|
449
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection`);
|
|
445
450
|
if (this.deviceLogging.includes('debug')) {
|
|
446
451
|
this.errorLog(
|
|
447
|
-
|
|
452
|
+
`${this.device.deviceType}: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection,` +
|
|
448
453
|
` Error Message: ${superStringify(e.message)}`,
|
|
449
454
|
);
|
|
450
455
|
}
|
|
@@ -452,7 +457,7 @@ export class Humidifier {
|
|
|
452
457
|
}
|
|
453
458
|
} else {
|
|
454
459
|
if (this.deviceLogging.includes('debug')) {
|
|
455
|
-
this.warnLog(
|
|
460
|
+
this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} OpenAPI is disabled, device status will not be sent.`);
|
|
456
461
|
}
|
|
457
462
|
}
|
|
458
463
|
}
|
|
@@ -474,14 +479,14 @@ export class Humidifier {
|
|
|
474
479
|
}
|
|
475
480
|
|
|
476
481
|
async BLEpushChanges(): Promise<void> {
|
|
477
|
-
this.debugLog(
|
|
482
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} BLE pushChanges`);
|
|
478
483
|
const switchbot = await this.platform.connectBLE();
|
|
479
484
|
// Convert to BLE Address
|
|
480
485
|
this.device.bleMac = this.device
|
|
481
486
|
.deviceId!.match(/.{1,2}/g)!
|
|
482
487
|
.join(':')
|
|
483
488
|
.toLowerCase();
|
|
484
|
-
this.debugLog(
|
|
489
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} BLE Address: ${this.device.bleMac}`);
|
|
485
490
|
if (switchbot !== false) {
|
|
486
491
|
switchbot
|
|
487
492
|
.discover({ model: 'e', quick: true, id: this.device.bleMac })
|
|
@@ -490,33 +495,34 @@ export class Humidifier {
|
|
|
490
495
|
return device_list[0].percentage(this.RelativeHumidityHumidifierThreshold);
|
|
491
496
|
})
|
|
492
497
|
.then(() => {
|
|
493
|
-
this.debugLog(
|
|
498
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Done.`);
|
|
494
499
|
})
|
|
495
500
|
.catch(async (e: any) => {
|
|
496
|
-
this.errorLog(
|
|
501
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed pushChanges with BLE Connection`);
|
|
497
502
|
if (this.deviceLogging.includes('debug')) {
|
|
498
503
|
this.errorLog(
|
|
499
|
-
|
|
504
|
+
`${this.device.deviceType}: ${this.accessory.displayName} failed pushChanges with BLE Connection,`
|
|
505
|
+
+ ` Error Message: ${superStringify(e.message)}`,
|
|
500
506
|
);
|
|
501
507
|
}
|
|
502
508
|
if (this.platform.config.credentials?.token) {
|
|
503
|
-
this.warnLog(
|
|
509
|
+
this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} Using OpenAPI Connection`);
|
|
504
510
|
await this.openAPIpushChanges();
|
|
505
511
|
}
|
|
506
512
|
this.apiError(e);
|
|
507
513
|
});
|
|
508
514
|
} else {
|
|
509
|
-
this.errorLog(
|
|
515
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} wasn't able to establish BLE Connection`);
|
|
510
516
|
if (this.platform.config.credentials?.token) {
|
|
511
|
-
this.warnLog(
|
|
517
|
+
this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} Using OpenAPI Connection`);
|
|
512
518
|
await this.openAPIpushChanges();
|
|
513
519
|
}
|
|
514
520
|
}
|
|
515
521
|
}
|
|
516
522
|
|
|
517
523
|
async openAPIpushChanges(): Promise<void> {
|
|
518
|
-
if (this.platform.config.credentials?.token && this.
|
|
519
|
-
this.debugLog(
|
|
524
|
+
if (this.platform.config.credentials?.token && this.OpenAPI) {
|
|
525
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} OpenAPI pushChanges`);
|
|
520
526
|
if (
|
|
521
527
|
this.TargetHumidifierDehumidifierState === this.platform.Characteristic.TargetHumidifierDehumidifierState.HUMIDIFIER &&
|
|
522
528
|
this.Active === this.platform.Characteristic.Active.ACTIVE
|
|
@@ -529,14 +535,14 @@ export class Humidifier {
|
|
|
529
535
|
.update(Buffer.from(data, 'utf-8'))
|
|
530
536
|
.digest();
|
|
531
537
|
const sign = signTerm.toString('base64');
|
|
532
|
-
this.debugLog(
|
|
538
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} sign: ${sign}`);
|
|
533
539
|
this.debugLog(`Pushing Manual: ${this.RelativeHumidityHumidifierThreshold}!`);
|
|
534
540
|
const body = superStringify({
|
|
535
541
|
'command': 'setMode',
|
|
536
542
|
'parameter': `${this.RelativeHumidityHumidifierThreshold}`,
|
|
537
543
|
'commandType': 'command',
|
|
538
544
|
});
|
|
539
|
-
this.infoLog(
|
|
545
|
+
this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API. body: ${body},`);
|
|
540
546
|
const options = {
|
|
541
547
|
hostname: HostDomain,
|
|
542
548
|
port: 443,
|
|
@@ -552,18 +558,18 @@ export class Humidifier {
|
|
|
552
558
|
},
|
|
553
559
|
};
|
|
554
560
|
const req = https.request(options, res => {
|
|
555
|
-
this.debugLog(
|
|
561
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} statusCode: ${res.statusCode}`);
|
|
556
562
|
res.on('data', d => {
|
|
557
|
-
this.debugLog(
|
|
563
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} d: ${d}`);
|
|
558
564
|
});
|
|
559
565
|
});
|
|
560
566
|
req.on('error', (e: any) => {
|
|
561
|
-
this.errorLog(
|
|
567
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} error message: ${e.message}`);
|
|
562
568
|
this.apiError(e);
|
|
563
569
|
});
|
|
564
570
|
req.write(body);
|
|
565
571
|
req.end();
|
|
566
|
-
this.debugLog(
|
|
572
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} openAPIpushChanges: ${superStringify(req)}`);
|
|
567
573
|
} else if (
|
|
568
574
|
this.TargetHumidifierDehumidifierState === this.platform.Characteristic.TargetHumidifierDehumidifierState.HUMIDIFIER_OR_DEHUMIDIFIER &&
|
|
569
575
|
this.Active === this.platform.Characteristic.Active.ACTIVE
|
|
@@ -573,7 +579,7 @@ export class Humidifier {
|
|
|
573
579
|
await this.pushActiveChanges();
|
|
574
580
|
}
|
|
575
581
|
} else {
|
|
576
|
-
this.warnLog(
|
|
582
|
+
this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} OpenAPI is disabled, commands will not be sent.`);
|
|
577
583
|
}
|
|
578
584
|
}
|
|
579
585
|
|
|
@@ -594,14 +600,14 @@ export class Humidifier {
|
|
|
594
600
|
.update(Buffer.from(data, 'utf-8'))
|
|
595
601
|
.digest();
|
|
596
602
|
const sign = signTerm.toString('base64');
|
|
597
|
-
this.debugLog(
|
|
603
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} sign: ${sign}`);
|
|
598
604
|
this.debugLog('Pushing Auto!');
|
|
599
605
|
const body = superStringify({
|
|
600
606
|
'command': 'setMode',
|
|
601
607
|
'parameter': 'auto',
|
|
602
608
|
'commandType': 'command',
|
|
603
609
|
});
|
|
604
|
-
this.infoLog(
|
|
610
|
+
this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API. body: ${body},`);
|
|
605
611
|
const options = {
|
|
606
612
|
hostname: HostDomain,
|
|
607
613
|
port: 443,
|
|
@@ -617,24 +623,24 @@ export class Humidifier {
|
|
|
617
623
|
},
|
|
618
624
|
};
|
|
619
625
|
const req = https.request(options, res => {
|
|
620
|
-
this.debugLog(
|
|
626
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} statusCode: ${res.statusCode}`);
|
|
621
627
|
this.statusCode({ res });
|
|
622
628
|
res.on('data', d => {
|
|
623
|
-
this.debugLog(
|
|
629
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} d: ${d}`);
|
|
624
630
|
});
|
|
625
631
|
});
|
|
626
632
|
req.on('error', (e: any) => {
|
|
627
|
-
this.errorLog(
|
|
633
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} error message: ${e.message}`);
|
|
628
634
|
});
|
|
629
635
|
req.write(body);
|
|
630
636
|
req.end();
|
|
631
|
-
this.debugLog(
|
|
637
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} pushAutoChanges: ${superStringify(req)}`);
|
|
632
638
|
}
|
|
633
639
|
} catch (e: any) {
|
|
634
|
-
this.errorLog(
|
|
640
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed pushAutoChanges with OpenAPI Connection`);
|
|
635
641
|
if (this.deviceLogging.includes('debug')) {
|
|
636
642
|
this.errorLog(
|
|
637
|
-
|
|
643
|
+
`${this.device.deviceType}: ${this.accessory.displayName} failed pushAutoChanges with OpenAPI Connection,` +
|
|
638
644
|
` Error Message: ${superStringify(e.message)}`,
|
|
639
645
|
);
|
|
640
646
|
}
|
|
@@ -656,14 +662,14 @@ export class Humidifier {
|
|
|
656
662
|
.update(Buffer.from(data, 'utf-8'))
|
|
657
663
|
.digest();
|
|
658
664
|
const sign = signTerm.toString('base64');
|
|
659
|
-
this.debugLog(
|
|
665
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} sign: ${sign}`);
|
|
660
666
|
this.debugLog('Pushing Off!');
|
|
661
667
|
const body = superStringify({
|
|
662
668
|
'command': 'turnOff',
|
|
663
669
|
'parameter': 'default',
|
|
664
670
|
'commandType': 'command',
|
|
665
671
|
});
|
|
666
|
-
this.infoLog(
|
|
672
|
+
this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API. body: ${body},`);
|
|
667
673
|
const options = {
|
|
668
674
|
hostname: HostDomain,
|
|
669
675
|
port: 443,
|
|
@@ -679,24 +685,24 @@ export class Humidifier {
|
|
|
679
685
|
},
|
|
680
686
|
};
|
|
681
687
|
const req = https.request(options, res => {
|
|
682
|
-
this.debugLog(
|
|
688
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} statusCode: ${res.statusCode}`);
|
|
683
689
|
this.statusCode({ res });
|
|
684
690
|
res.on('data', d => {
|
|
685
|
-
this.debugLog(
|
|
691
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} d: ${d}`);
|
|
686
692
|
});
|
|
687
693
|
});
|
|
688
694
|
req.on('error', (e: any) => {
|
|
689
|
-
this.errorLog(
|
|
695
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} error message: ${e.message}`);
|
|
690
696
|
});
|
|
691
697
|
req.write(body);
|
|
692
698
|
req.end();
|
|
693
|
-
this.debugLog(
|
|
699
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} pushActiveChanges: ${superStringify(req)}`);
|
|
694
700
|
}
|
|
695
701
|
} catch (e: any) {
|
|
696
|
-
this.errorLog(
|
|
702
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed pushActiveChanges with OpenAPI Connection`);
|
|
697
703
|
if (this.deviceLogging.includes('debug')) {
|
|
698
704
|
this.errorLog(
|
|
699
|
-
|
|
705
|
+
`${this.device.deviceType}: ${this.accessory.displayName} failed pushActiveChanges with OpenAPI Connection,` +
|
|
700
706
|
` Error Message: ${superStringify(e.message)}`,
|
|
701
707
|
);
|
|
702
708
|
}
|
|
@@ -709,52 +715,56 @@ export class Humidifier {
|
|
|
709
715
|
*/
|
|
710
716
|
async updateHomeKitCharacteristics(): Promise<void> {
|
|
711
717
|
if (this.CurrentRelativeHumidity === undefined) {
|
|
712
|
-
this.debugLog(
|
|
718
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} CurrentRelativeHumidity: ${this.CurrentRelativeHumidity}`);
|
|
713
719
|
} else {
|
|
714
720
|
this.humidifierService.updateCharacteristic(this.platform.Characteristic.CurrentRelativeHumidity, this.CurrentRelativeHumidity);
|
|
715
|
-
this.debugLog(
|
|
721
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName}`
|
|
722
|
+
+ ` updateCharacteristic CurrentRelativeHumidity: ${this.CurrentRelativeHumidity}`);
|
|
716
723
|
}
|
|
717
724
|
if (!this.device.ble) {
|
|
718
725
|
if (this.WaterLevel === undefined) {
|
|
719
|
-
this.debugLog(
|
|
726
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} WaterLevel: ${this.WaterLevel}`);
|
|
720
727
|
} else {
|
|
721
728
|
this.humidifierService.updateCharacteristic(this.platform.Characteristic.WaterLevel, this.WaterLevel);
|
|
722
|
-
this.debugLog(
|
|
729
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic WaterLevel: ${this.WaterLevel}`);
|
|
723
730
|
}
|
|
724
731
|
}
|
|
725
732
|
if (this.CurrentHumidifierDehumidifierState === undefined) {
|
|
726
|
-
this.debugLog(
|
|
733
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName}`
|
|
734
|
+
+ ` CurrentHumidifierDehumidifierState: ${this.CurrentHumidifierDehumidifierState}`);
|
|
727
735
|
} else {
|
|
728
736
|
this.humidifierService.updateCharacteristic(
|
|
729
737
|
this.platform.Characteristic.CurrentHumidifierDehumidifierState,
|
|
730
738
|
this.CurrentHumidifierDehumidifierState,
|
|
731
739
|
);
|
|
732
740
|
this.debugLog(
|
|
733
|
-
|
|
741
|
+
`${this.device.deviceType}: ${this.accessory.displayName}` +
|
|
734
742
|
` updateCharacteristic CurrentHumidifierDehumidifierState: ${this.CurrentHumidifierDehumidifierState}`,
|
|
735
743
|
);
|
|
736
744
|
}
|
|
737
745
|
if (this.TargetHumidifierDehumidifierState === undefined) {
|
|
738
|
-
this.debugLog(
|
|
746
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName}`
|
|
747
|
+
+` TargetHumidifierDehumidifierState: ${this.TargetHumidifierDehumidifierState}`);
|
|
739
748
|
} else {
|
|
740
749
|
this.humidifierService.updateCharacteristic(
|
|
741
750
|
this.platform.Characteristic.TargetHumidifierDehumidifierState,
|
|
742
751
|
this.TargetHumidifierDehumidifierState,
|
|
743
752
|
);
|
|
744
753
|
this.debugLog(
|
|
745
|
-
|
|
754
|
+
`${this.device.deviceType}: ${this.accessory.displayName}` +
|
|
746
755
|
` updateCharacteristic TargetHumidifierDehumidifierState: ${this.TargetHumidifierDehumidifierState}`,
|
|
747
756
|
);
|
|
748
757
|
}
|
|
749
758
|
if (this.Active === undefined) {
|
|
750
|
-
this.debugLog(
|
|
759
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Active: ${this.Active}`);
|
|
751
760
|
} else {
|
|
752
761
|
this.humidifierService.updateCharacteristic(this.platform.Characteristic.Active, this.Active);
|
|
753
|
-
this.debugLog(
|
|
762
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic Active: ${this.Active}`);
|
|
754
763
|
}
|
|
755
764
|
if (this.RelativeHumidityHumidifierThreshold === undefined) {
|
|
756
765
|
this.debugLog(
|
|
757
|
-
|
|
766
|
+
`${this.device.deviceType}: ${this.accessory.displayName}`
|
|
767
|
+
+ ` RelativeHumidityHumidifierThreshold: ${this.RelativeHumidityHumidifierThreshold}`,
|
|
758
768
|
);
|
|
759
769
|
} else {
|
|
760
770
|
this.humidifierService.updateCharacteristic(
|
|
@@ -762,16 +772,16 @@ export class Humidifier {
|
|
|
762
772
|
this.RelativeHumidityHumidifierThreshold,
|
|
763
773
|
);
|
|
764
774
|
this.debugLog(
|
|
765
|
-
|
|
775
|
+
`${this.device.deviceType}: ${this.accessory.displayName}` +
|
|
766
776
|
` updateCharacteristic RelativeHumidityHumidifierThreshold: ${this.RelativeHumidityHumidifierThreshold}`,
|
|
767
777
|
);
|
|
768
778
|
}
|
|
769
779
|
if (!this.device.humidifier?.hide_temperature && !this.device.ble) {
|
|
770
780
|
if (this.CurrentTemperature === undefined) {
|
|
771
|
-
this.debugLog(
|
|
781
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} CurrentTemperature: ${this.CurrentTemperature}`);
|
|
772
782
|
} else {
|
|
773
783
|
this.temperatureservice?.updateCharacteristic(this.platform.Characteristic.CurrentTemperature, this.CurrentTemperature);
|
|
774
|
-
this.debugLog(
|
|
784
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic CurrentTemperature: ${this.CurrentTemperature}`);
|
|
775
785
|
}
|
|
776
786
|
}
|
|
777
787
|
}
|
|
@@ -794,33 +804,33 @@ export class Humidifier {
|
|
|
794
804
|
async statusCode({ res }: { res: IncomingMessage }): Promise<void> {
|
|
795
805
|
switch (res.statusCode) {
|
|
796
806
|
case 151:
|
|
797
|
-
this.errorLog(
|
|
807
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} Command not supported by this device type.`);
|
|
798
808
|
break;
|
|
799
809
|
case 152:
|
|
800
|
-
this.errorLog(
|
|
810
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} Device not found.`);
|
|
801
811
|
break;
|
|
802
812
|
case 160:
|
|
803
|
-
this.errorLog(
|
|
813
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} Command is not supported.`);
|
|
804
814
|
break;
|
|
805
815
|
case 161:
|
|
806
|
-
this.errorLog(
|
|
816
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} Device is offline.`);
|
|
807
817
|
this.offlineOff();
|
|
808
818
|
break;
|
|
809
819
|
case 171:
|
|
810
|
-
this.errorLog(
|
|
820
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} Hub Device is offline. Hub: ${this.device.hubDeviceId}`);
|
|
811
821
|
this.offlineOff();
|
|
812
822
|
break;
|
|
813
823
|
case 190:
|
|
814
824
|
this.errorLog(
|
|
815
|
-
|
|
825
|
+
`${this.device.deviceType}: ${this.accessory.displayName} Device internal error due to device states not synchronized with server,` +
|
|
816
826
|
` Or command: ${superStringify(res)} format is invalid`,
|
|
817
827
|
);
|
|
818
828
|
break;
|
|
819
829
|
case 100:
|
|
820
|
-
this.debugLog(
|
|
830
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Command successfully sent.`);
|
|
821
831
|
break;
|
|
822
832
|
default:
|
|
823
|
-
this.debugLog(
|
|
833
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Unknown statusCode.`);
|
|
824
834
|
}
|
|
825
835
|
}
|
|
826
836
|
|
|
@@ -835,7 +845,7 @@ export class Humidifier {
|
|
|
835
845
|
* Handle requests to set the "Target Humidifier Dehumidifier State" characteristic
|
|
836
846
|
*/
|
|
837
847
|
async handleTargetHumidifierDehumidifierStateSet(value: CharacteristicValue): Promise<void> {
|
|
838
|
-
this.debugLog(
|
|
848
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} TargetHumidifierDehumidifierState: ${value}`);
|
|
839
849
|
|
|
840
850
|
this.TargetHumidifierDehumidifierState = value;
|
|
841
851
|
this.doHumidifierUpdate.next();
|
|
@@ -845,7 +855,7 @@ export class Humidifier {
|
|
|
845
855
|
* Handle requests to set the "Active" characteristic
|
|
846
856
|
*/
|
|
847
857
|
async handleActiveSet(value: CharacteristicValue): Promise<void> {
|
|
848
|
-
this.debugLog(
|
|
858
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Active: ${value}`);
|
|
849
859
|
this.Active = value;
|
|
850
860
|
this.doHumidifierUpdate.next();
|
|
851
861
|
}
|
|
@@ -854,7 +864,7 @@ export class Humidifier {
|
|
|
854
864
|
* Handle requests to set the "Relative Humidity Humidifier Threshold" characteristic
|
|
855
865
|
*/
|
|
856
866
|
async handleRelativeHumidityHumidifierThresholdSet(value: CharacteristicValue): Promise<void> {
|
|
857
|
-
this.debugLog(
|
|
867
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} RelativeHumidityHumidifierThreshold: ${value}`);
|
|
858
868
|
|
|
859
869
|
this.RelativeHumidityHumidifierThreshold = value;
|
|
860
870
|
if (this.Active === this.platform.Characteristic.Active.INACTIVE) {
|
|
@@ -872,6 +882,9 @@ export class Humidifier {
|
|
|
872
882
|
if (device.ble !== undefined) {
|
|
873
883
|
config['ble'] = device.ble;
|
|
874
884
|
}
|
|
885
|
+
if (device.openAPI !== undefined) {
|
|
886
|
+
config['openAPI'] = device.openAPI;
|
|
887
|
+
}
|
|
875
888
|
if (device.logging !== undefined) {
|
|
876
889
|
config['logging'] = device.logging;
|
|
877
890
|
}
|
|
@@ -884,21 +897,18 @@ export class Humidifier {
|
|
|
884
897
|
if (device.offline !== undefined) {
|
|
885
898
|
config['offline'] = device.offline;
|
|
886
899
|
}
|
|
887
|
-
if (device.openAPI !== undefined) {
|
|
888
|
-
config['openAPI'] = device.openAPI;
|
|
889
|
-
}
|
|
890
900
|
if (Object.entries(config).length !== 0) {
|
|
891
|
-
this.infoLog(
|
|
901
|
+
this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Config: ${superStringify(config)}`);
|
|
892
902
|
}
|
|
893
903
|
}
|
|
894
904
|
|
|
895
905
|
async refreshRate(device: device & devicesConfig): Promise<void> {
|
|
896
906
|
if (device.refreshRate) {
|
|
897
907
|
this.deviceRefreshRate = this.accessory.context.refreshRate = device.refreshRate;
|
|
898
|
-
this.debugLog(
|
|
908
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Using Device Config refreshRate: ${this.deviceRefreshRate}`);
|
|
899
909
|
} else if (this.platform.config.options!.refreshRate) {
|
|
900
910
|
this.deviceRefreshRate = this.accessory.context.refreshRate = this.platform.config.options!.refreshRate;
|
|
901
|
-
this.debugLog(
|
|
911
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Using Platform Config refreshRate: ${this.deviceRefreshRate}`);
|
|
902
912
|
}
|
|
903
913
|
}
|
|
904
914
|
|
|
@@ -908,19 +918,19 @@ export class Humidifier {
|
|
|
908
918
|
} else {
|
|
909
919
|
this.OpenAPI = this.device.openAPI;
|
|
910
920
|
}
|
|
911
|
-
this.debugLog(
|
|
921
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Using OpenAPI: ${this.OpenAPI}`);
|
|
912
922
|
}
|
|
913
923
|
|
|
914
924
|
async scan(device: device & devicesConfig): Promise<void> {
|
|
915
925
|
if (device.scanDuration) {
|
|
916
926
|
this.scanDuration = this.accessory.context.scanDuration = device.scanDuration;
|
|
917
927
|
if (device.ble) {
|
|
918
|
-
this.debugLog(
|
|
928
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Using Device Config scanDuration: ${this.scanDuration}`);
|
|
919
929
|
}
|
|
920
930
|
} else {
|
|
921
931
|
this.scanDuration = this.accessory.context.scanDuration = 1;
|
|
922
932
|
if (this.device.ble) {
|
|
923
|
-
this.debugLog(
|
|
933
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Using Default scanDuration: ${this.scanDuration}`);
|
|
924
934
|
}
|
|
925
935
|
}
|
|
926
936
|
}
|
|
@@ -928,24 +938,25 @@ export class Humidifier {
|
|
|
928
938
|
async logs(device: device & devicesConfig): Promise<void> {
|
|
929
939
|
if (this.platform.debugMode) {
|
|
930
940
|
this.deviceLogging = this.accessory.context.logging = 'debugMode';
|
|
931
|
-
this.debugLog(
|
|
941
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
|
|
932
942
|
} else if (device.logging) {
|
|
933
943
|
this.deviceLogging = this.accessory.context.logging = device.logging;
|
|
934
|
-
this.debugLog(
|
|
944
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
|
|
935
945
|
} else if (this.platform.config.options?.logging) {
|
|
936
946
|
this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
|
|
937
|
-
this.debugLog(
|
|
947
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
|
|
938
948
|
} else {
|
|
939
949
|
this.deviceLogging = this.accessory.context.logging = 'standard';
|
|
940
|
-
this.debugLog(
|
|
950
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Logging Not Set, Using: ${this.deviceLogging}`);
|
|
941
951
|
}
|
|
942
952
|
}
|
|
943
953
|
|
|
944
954
|
FirmwareRevision(accessory: PlatformAccessory<Context>, device: device & devicesConfig): CharacteristicValue {
|
|
945
955
|
let FirmwareRevision: string;
|
|
946
|
-
this.debugLog(
|
|
947
|
-
|
|
948
|
-
this.debugLog(
|
|
956
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName}`
|
|
957
|
+
+ ` accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}`);
|
|
958
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} device.firmware: ${device.firmware}`);
|
|
959
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} this.platform.version: ${this.platform.version}`);
|
|
949
960
|
if (accessory.context.FirmwareRevision) {
|
|
950
961
|
FirmwareRevision = accessory.context.FirmwareRevision;
|
|
951
962
|
} else if (device.firmware) {
|