@switchbot/homebridge-switchbot 4.1.8-beta.3 → 4.1.8-beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/device/blindtilt.d.ts.map +1 -1
- package/dist/device/blindtilt.js +25 -8
- package/dist/device/blindtilt.js.map +1 -1
- package/dist/device/bot.d.ts.map +1 -1
- package/dist/device/bot.js +25 -8
- package/dist/device/bot.js.map +1 -1
- package/dist/device/ceilinglight.d.ts.map +1 -1
- package/dist/device/ceilinglight.js +25 -8
- package/dist/device/ceilinglight.js.map +1 -1
- package/dist/device/colorbulb.d.ts.map +1 -1
- package/dist/device/colorbulb.js +25 -8
- package/dist/device/colorbulb.js.map +1 -1
- package/dist/device/contact.d.ts.map +1 -1
- package/dist/device/contact.js +25 -8
- package/dist/device/contact.js.map +1 -1
- package/dist/device/curtain.d.ts.map +1 -1
- package/dist/device/curtain.js +25 -8
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/device.js +1 -1
- package/dist/device/device.js.map +1 -1
- package/dist/device/fan.d.ts.map +1 -1
- package/dist/device/fan.js +25 -8
- package/dist/device/fan.js.map +1 -1
- package/dist/device/hub.d.ts.map +1 -1
- package/dist/device/hub.js +25 -8
- package/dist/device/hub.js.map +1 -1
- package/dist/device/humidifier.d.ts.map +1 -1
- package/dist/device/humidifier.js +25 -8
- package/dist/device/humidifier.js.map +1 -1
- package/dist/device/iosensor.d.ts.map +1 -1
- package/dist/device/iosensor.js +25 -8
- package/dist/device/iosensor.js.map +1 -1
- package/dist/device/lightstrip.d.ts.map +1 -1
- package/dist/device/lightstrip.js +25 -8
- package/dist/device/lightstrip.js.map +1 -1
- package/dist/device/lock.d.ts.map +1 -1
- package/dist/device/lock.js +25 -8
- package/dist/device/lock.js.map +1 -1
- package/dist/device/meter.d.ts.map +1 -1
- package/dist/device/meter.js +25 -8
- package/dist/device/meter.js.map +1 -1
- package/dist/device/meterplus.d.ts.map +1 -1
- package/dist/device/meterplus.js +25 -8
- package/dist/device/meterplus.js.map +1 -1
- package/dist/device/meterpro.d.ts.map +1 -1
- package/dist/device/meterpro.js +25 -8
- package/dist/device/meterpro.js.map +1 -1
- package/dist/device/motion.d.ts.map +1 -1
- package/dist/device/motion.js +25 -8
- package/dist/device/motion.js.map +1 -1
- package/dist/device/plug.d.ts.map +1 -1
- package/dist/device/plug.js +25 -8
- package/dist/device/plug.js.map +1 -1
- package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
- package/dist/device/robotvacuumcleaner.js +25 -8
- package/dist/device/robotvacuumcleaner.js.map +1 -1
- package/dist/device/waterdetector.d.ts.map +1 -1
- package/dist/device/waterdetector.js +25 -8
- package/dist/device/waterdetector.js.map +1 -1
- package/docs/assets/dmt/dmt-component-data.js +1 -0
- package/docs/assets/dmt/dmt-components.css +20 -0
- package/docs/assets/dmt/dmt-components.js +67 -0
- package/docs/assets/dmt/dmt-search.cmp +0 -0
- package/docs/assets/dmt/dmt-theme.css +1 -0
- package/docs/assets/main.js +1 -1
- package/docs/functions/default.html +2 -1
- package/docs/index.html +7 -6
- package/docs/modules.html +2 -1
- package/package.json +5 -3
- package/src/device/blindtilt.ts +22 -8
- package/src/device/bot.ts +22 -8
- package/src/device/ceilinglight.ts +22 -8
- package/src/device/colorbulb.ts +22 -8
- package/src/device/contact.ts +22 -8
- package/src/device/curtain.ts +22 -8
- package/src/device/device.ts +1 -1
- package/src/device/fan.ts +22 -8
- package/src/device/hub.ts +22 -8
- package/src/device/humidifier.ts +22 -8
- package/src/device/iosensor.ts +22 -8
- package/src/device/lightstrip.ts +22 -8
- package/src/device/lock.ts +22 -8
- package/src/device/meter.ts +22 -8
- package/src/device/meterplus.ts +22 -8
- package/src/device/meterpro.ts +22 -8
- package/src/device/motion.ts +22 -8
- package/src/device/plug.ts +22 -8
- package/src/device/robotvacuumcleaner.ts +22 -8
- package/src/device/waterdetector.ts +22 -8
- package/typedoc.json +4 -0
- package/docs/assets/navigation.js +0 -1
- package/docs/assets/search.js +0 -1
package/src/device/contact.ts
CHANGED
|
@@ -309,8 +309,13 @@ export class Contact extends deviceBase {
|
|
|
309
309
|
// Update HomeKit
|
|
310
310
|
if (serviceData.model === SwitchBotBLEModel.ContactSensor && serviceData.modelName === SwitchBotBLEModelName.ContactSensor) {
|
|
311
311
|
this.serviceData = serviceData
|
|
312
|
-
|
|
313
|
-
|
|
312
|
+
if (serviceData !== undefined || serviceData !== null) {
|
|
313
|
+
await this.BLEparseStatus()
|
|
314
|
+
await this.updateHomeKitCharacteristics()
|
|
315
|
+
} else {
|
|
316
|
+
this.errorLog(`serviceData is either undefined or null, serviceData: ${JSON.stringify(serviceData)}`)
|
|
317
|
+
await this.BLERefreshConnection(switchBotBLE)
|
|
318
|
+
}
|
|
314
319
|
} else {
|
|
315
320
|
this.errorLog(`failed to get serviceData, serviceData: ${JSON.stringify(serviceData)}`)
|
|
316
321
|
await this.BLERefreshConnection(switchBotBLE)
|
|
@@ -329,10 +334,15 @@ export class Contact extends deviceBase {
|
|
|
329
334
|
this.debugLog(`bleMac: ${this.device.bleMac}`)
|
|
330
335
|
this.platform.bleEventHandler[this.device.bleMac] = async (context: contactSensorServiceData) => {
|
|
331
336
|
try {
|
|
332
|
-
this.debugLog(`received BLE: ${JSON.stringify(context)}`)
|
|
333
337
|
this.serviceData = context
|
|
334
|
-
|
|
335
|
-
|
|
338
|
+
if (context !== undefined || context !== null) {
|
|
339
|
+
this.debugLog(`received BLE: ${JSON.stringify(context)}`)
|
|
340
|
+
await this.BLEparseStatus()
|
|
341
|
+
await this.updateHomeKitCharacteristics()
|
|
342
|
+
} else {
|
|
343
|
+
this.errorLog(`context is either undefined or null, context: ${JSON.stringify(context)}`)
|
|
344
|
+
await this.BLERefreshConnection(context)
|
|
345
|
+
}
|
|
336
346
|
} catch (e: any) {
|
|
337
347
|
this.errorLog(`failed to handle BLE. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`)
|
|
338
348
|
}
|
|
@@ -370,10 +380,14 @@ export class Contact extends deviceBase {
|
|
|
370
380
|
this.debugLog('is listening webhook.')
|
|
371
381
|
this.platform.webhookEventHandler[this.device.deviceId] = async (context: contactSensorWebhookContext) => {
|
|
372
382
|
try {
|
|
373
|
-
this.debugLog(`received Webhook: ${JSON.stringify(context)}`)
|
|
374
383
|
this.webhookContext = context
|
|
375
|
-
|
|
376
|
-
|
|
384
|
+
if (context !== undefined || context !== null) {
|
|
385
|
+
this.debugLog(`received Webhook: ${JSON.stringify(context)}`)
|
|
386
|
+
await this.parseStatusWebhook()
|
|
387
|
+
await this.updateHomeKitCharacteristics()
|
|
388
|
+
} else {
|
|
389
|
+
this.errorLog(`context is either undefined or null, context: ${JSON.stringify(context)}`)
|
|
390
|
+
}
|
|
377
391
|
} catch (e: any) {
|
|
378
392
|
this.errorLog(`failed to handle webhook. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`)
|
|
379
393
|
}
|
package/src/device/curtain.ts
CHANGED
|
@@ -494,8 +494,13 @@ export class Curtain extends deviceBase {
|
|
|
494
494
|
if ((serviceData.model === SwitchBotBLEModel.Curtain || SwitchBotBLEModel.Curtain3)
|
|
495
495
|
&& (serviceData.modelName === SwitchBotBLEModelName.Curtain || SwitchBotBLEModelName.Curtain3)) {
|
|
496
496
|
this.serviceData = serviceData
|
|
497
|
-
|
|
498
|
-
|
|
497
|
+
if (serviceData !== undefined || serviceData !== null) {
|
|
498
|
+
await this.BLEparseStatus()
|
|
499
|
+
await this.updateHomeKitCharacteristics()
|
|
500
|
+
} else {
|
|
501
|
+
this.errorLog(`serviceData is either undefined or null, serviceData: ${JSON.stringify(serviceData)}`)
|
|
502
|
+
await this.BLERefreshConnection(switchBotBLE)
|
|
503
|
+
}
|
|
499
504
|
} else {
|
|
500
505
|
this.errorLog(`failed to get serviceData, serviceData: ${JSON.stringify(serviceData)}`)
|
|
501
506
|
await this.BLERefreshConnection(switchBotBLE)
|
|
@@ -529,10 +534,14 @@ export class Curtain extends deviceBase {
|
|
|
529
534
|
this.debugLog('is listening webhook.')
|
|
530
535
|
this.platform.webhookEventHandler[this.device.deviceId] = async (context: curtainWebhookContext | curtain3WebhookContext) => {
|
|
531
536
|
try {
|
|
532
|
-
this.debugLog(`received Webhook: ${JSON.stringify(context)}`)
|
|
533
537
|
this.webhookContext = context
|
|
534
|
-
|
|
535
|
-
|
|
538
|
+
if (context !== undefined || context !== null) {
|
|
539
|
+
this.debugLog(`received Webhook: ${JSON.stringify(context)}`)
|
|
540
|
+
await this.parseStatusWebhook()
|
|
541
|
+
await this.updateHomeKitCharacteristics()
|
|
542
|
+
} else {
|
|
543
|
+
this.errorLog(`context is either undefined or null, context: ${JSON.stringify(context)}`)
|
|
544
|
+
}
|
|
536
545
|
} catch (e: any) {
|
|
537
546
|
this.errorLog(`failed to handle webhook. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`)
|
|
538
547
|
}
|
|
@@ -552,10 +561,15 @@ export class Curtain extends deviceBase {
|
|
|
552
561
|
this.debugLog(`bleMac: ${this.device.bleMac}`)
|
|
553
562
|
this.platform.bleEventHandler[this.device.bleMac] = async (context: curtainServiceData | curtain3ServiceData) => {
|
|
554
563
|
try {
|
|
555
|
-
this.debugLog(`received BLE: ${JSON.stringify(context)}`)
|
|
556
564
|
this.serviceData = context
|
|
557
|
-
|
|
558
|
-
|
|
565
|
+
if (context !== undefined || context !== null) {
|
|
566
|
+
this.debugLog(`received BLE: ${JSON.stringify(context)}`)
|
|
567
|
+
await this.BLEparseStatus()
|
|
568
|
+
await this.updateHomeKitCharacteristics()
|
|
569
|
+
} else {
|
|
570
|
+
this.errorLog(`context is either undefined or null, context: ${JSON.stringify(context)}`)
|
|
571
|
+
await this.BLERefreshConnection(context)
|
|
572
|
+
}
|
|
559
573
|
} catch (e: any) {
|
|
560
574
|
this.errorLog(`failed to handle BLE. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`)
|
|
561
575
|
}
|
package/src/device/device.ts
CHANGED
|
@@ -386,7 +386,7 @@ export abstract class deviceBase {
|
|
|
386
386
|
*
|
|
387
387
|
*/
|
|
388
388
|
async updateCharacteristic(Service: Service, Characteristic: any, CharacteristicValue: CharacteristicValue | undefined, CharacteristicName: string, history?: object): Promise<void> {
|
|
389
|
-
if (CharacteristicValue === undefined) {
|
|
389
|
+
if (CharacteristicValue === undefined || CharacteristicValue === null) {
|
|
390
390
|
this.debugLog(`${CharacteristicName}: ${CharacteristicValue}`)
|
|
391
391
|
} else {
|
|
392
392
|
await this.mqtt(CharacteristicName, CharacteristicValue)
|
package/src/device/fan.ts
CHANGED
|
@@ -331,8 +331,13 @@ export class Fan extends deviceBase {
|
|
|
331
331
|
// Update HomeKit
|
|
332
332
|
if (serviceData.model === SwitchBotBLEModel.Unknown && SwitchBotBLEModelName.Unknown) {
|
|
333
333
|
this.serviceData = serviceData
|
|
334
|
-
|
|
335
|
-
|
|
334
|
+
if (serviceData !== undefined || serviceData !== null) {
|
|
335
|
+
await this.BLEparseStatus()
|
|
336
|
+
await this.updateHomeKitCharacteristics()
|
|
337
|
+
} else {
|
|
338
|
+
this.errorLog(`serviceData is either undefined or null, serviceData: ${JSON.stringify(serviceData)}`)
|
|
339
|
+
await this.BLERefreshConnection(switchBotBLE)
|
|
340
|
+
}
|
|
336
341
|
} else {
|
|
337
342
|
this.errorLog(`failed to get serviceData, serviceData: ${JSON.stringify(serviceData)}`)
|
|
338
343
|
await this.BLERefreshConnection(switchBotBLE)
|
|
@@ -351,10 +356,15 @@ export class Fan extends deviceBase {
|
|
|
351
356
|
this.debugLog(`bleMac: ${this.device.bleMac}`)
|
|
352
357
|
this.platform.bleEventHandler[this.device.bleMac] = async (context: batteryCirculatorFanServiceData) => {
|
|
353
358
|
try {
|
|
354
|
-
this.debugLog(`received BLE: ${JSON.stringify(context)}`)
|
|
355
359
|
this.serviceData = context
|
|
356
|
-
|
|
357
|
-
|
|
360
|
+
if (context !== undefined || context !== null) {
|
|
361
|
+
this.debugLog(`received BLE: ${JSON.stringify(context)}`)
|
|
362
|
+
await this.BLEparseStatus()
|
|
363
|
+
await this.updateHomeKitCharacteristics()
|
|
364
|
+
} else {
|
|
365
|
+
this.errorLog(`context is either undefined or null, context: ${JSON.stringify(context)}`)
|
|
366
|
+
await this.BLERefreshConnection(context)
|
|
367
|
+
}
|
|
358
368
|
} catch (e: any) {
|
|
359
369
|
this.errorLog(`failed to handle BLE. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`)
|
|
360
370
|
}
|
|
@@ -392,10 +402,14 @@ export class Fan extends deviceBase {
|
|
|
392
402
|
this.debugLog('is listening webhook.')
|
|
393
403
|
this.platform.webhookEventHandler[this.device.deviceId] = async (context: batteryCirculatorFanWebhookContext) => {
|
|
394
404
|
try {
|
|
395
|
-
this.debugLog(`received Webhook: ${JSON.stringify(context)}`)
|
|
396
405
|
this.webhookContext = context
|
|
397
|
-
|
|
398
|
-
|
|
406
|
+
if (context !== undefined || context !== null) {
|
|
407
|
+
this.debugLog(`received Webhook: ${JSON.stringify(context)}`)
|
|
408
|
+
await this.parseStatusWebhook()
|
|
409
|
+
await this.updateHomeKitCharacteristics()
|
|
410
|
+
} else {
|
|
411
|
+
this.errorLog(`context is either undefined or null, context: ${JSON.stringify(context)}`)
|
|
412
|
+
}
|
|
399
413
|
} catch (e: any) {
|
|
400
414
|
this.errorLog(`failed to handle webhook. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`)
|
|
401
415
|
}
|
package/src/device/hub.ts
CHANGED
|
@@ -298,8 +298,13 @@ export class Hub extends deviceBase {
|
|
|
298
298
|
// Update HomeKit
|
|
299
299
|
if (serviceData.model === SwitchBotBLEModel.Hub2 && serviceData.modelName === SwitchBotBLEModelName.Hub2) {
|
|
300
300
|
this.serviceData = serviceData
|
|
301
|
-
|
|
302
|
-
|
|
301
|
+
if (serviceData !== undefined || serviceData !== null) {
|
|
302
|
+
await this.BLEparseStatus()
|
|
303
|
+
await this.updateHomeKitCharacteristics()
|
|
304
|
+
} else {
|
|
305
|
+
this.errorLog(`serviceData is either undefined or null, serviceData: ${JSON.stringify(serviceData)}`)
|
|
306
|
+
await this.BLERefreshConnection(switchBotBLE)
|
|
307
|
+
}
|
|
303
308
|
} else {
|
|
304
309
|
this.errorLog(`failed to get serviceData, serviceData: ${JSON.stringify(serviceData)}`)
|
|
305
310
|
await this.BLERefreshConnection(switchBotBLE)
|
|
@@ -318,10 +323,15 @@ export class Hub extends deviceBase {
|
|
|
318
323
|
this.debugLog(`bleMac: ${this.device.bleMac}`)
|
|
319
324
|
this.platform.bleEventHandler[this.device.bleMac] = async (context: hub2ServiceData) => {
|
|
320
325
|
try {
|
|
321
|
-
this.debugLog(`received BLE: ${JSON.stringify(context)}`)
|
|
322
326
|
this.serviceData = context
|
|
323
|
-
|
|
324
|
-
|
|
327
|
+
if (context !== undefined || context !== null) {
|
|
328
|
+
this.debugLog(`received BLE: ${JSON.stringify(context)}`)
|
|
329
|
+
await this.BLEparseStatus()
|
|
330
|
+
await this.updateHomeKitCharacteristics()
|
|
331
|
+
} else {
|
|
332
|
+
this.errorLog(`context is either undefined or null, context: ${JSON.stringify(context)}`)
|
|
333
|
+
await this.BLERefreshConnection(context)
|
|
334
|
+
}
|
|
325
335
|
} catch (e: any) {
|
|
326
336
|
this.errorLog(`failed to handle BLE. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`)
|
|
327
337
|
}
|
|
@@ -359,10 +369,14 @@ export class Hub extends deviceBase {
|
|
|
359
369
|
this.debugLog('is listening webhook.')
|
|
360
370
|
this.platform.webhookEventHandler[this.device.deviceId] = async (context: hub2WebhookContext) => {
|
|
361
371
|
try {
|
|
362
|
-
this.debugLog(`received Webhook: ${JSON.stringify(context)}`)
|
|
363
372
|
this.webhookContext = context
|
|
364
|
-
|
|
365
|
-
|
|
373
|
+
if (context !== undefined || context !== null) {
|
|
374
|
+
this.debugLog(`received Webhook: ${JSON.stringify(context)}`)
|
|
375
|
+
await this.parseStatusWebhook()
|
|
376
|
+
await this.updateHomeKitCharacteristics()
|
|
377
|
+
} else {
|
|
378
|
+
this.errorLog(`context is either undefined or null, context: ${JSON.stringify(context)}`)
|
|
379
|
+
}
|
|
366
380
|
} catch (e: any) {
|
|
367
381
|
this.errorLog(`failed to handle webhook. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`)
|
|
368
382
|
}
|
package/src/device/humidifier.ts
CHANGED
|
@@ -328,8 +328,13 @@ export class Humidifier extends deviceBase {
|
|
|
328
328
|
// Update HomeKit
|
|
329
329
|
if (serviceData.model === SwitchBotBLEModel.Humidifier && serviceData.modelName === SwitchBotBLEModelName.Humidifier) {
|
|
330
330
|
this.serviceData = serviceData
|
|
331
|
-
|
|
332
|
-
|
|
331
|
+
if (serviceData !== undefined || serviceData !== null) {
|
|
332
|
+
await this.BLEparseStatus()
|
|
333
|
+
await this.updateHomeKitCharacteristics()
|
|
334
|
+
} else {
|
|
335
|
+
this.errorLog(`serviceData is either undefined or null, serviceData: ${JSON.stringify(serviceData)}`)
|
|
336
|
+
await this.BLERefreshConnection(switchBotBLE)
|
|
337
|
+
}
|
|
333
338
|
} else {
|
|
334
339
|
this.errorLog(`failed to get serviceData, serviceData: ${JSON.stringify(serviceData)}`)
|
|
335
340
|
await this.BLERefreshConnection(switchBotBLE)
|
|
@@ -348,10 +353,15 @@ export class Humidifier extends deviceBase {
|
|
|
348
353
|
this.debugLog(`bleMac: ${this.device.bleMac}`)
|
|
349
354
|
this.platform.bleEventHandler[this.device.bleMac] = async (context: humidifierServiceData | humidifier2ServiceData) => {
|
|
350
355
|
try {
|
|
351
|
-
this.debugLog(`received BLE: ${JSON.stringify(context)}`)
|
|
352
356
|
this.serviceData = context
|
|
353
|
-
|
|
354
|
-
|
|
357
|
+
if (context !== undefined || context !== null) {
|
|
358
|
+
this.debugLog(`received BLE: ${JSON.stringify(context)}`)
|
|
359
|
+
await this.BLEparseStatus()
|
|
360
|
+
await this.updateHomeKitCharacteristics()
|
|
361
|
+
} else {
|
|
362
|
+
this.errorLog(`context is either undefined or null, context: ${JSON.stringify(context)}`)
|
|
363
|
+
await this.BLERefreshConnection(context)
|
|
364
|
+
}
|
|
355
365
|
} catch (e: any) {
|
|
356
366
|
this.errorLog(`failed to handle BLE. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`)
|
|
357
367
|
}
|
|
@@ -389,10 +399,14 @@ export class Humidifier extends deviceBase {
|
|
|
389
399
|
this.debugLog('is listening webhook.')
|
|
390
400
|
this.platform.webhookEventHandler[this.device.deviceId] = async (context: humidifierWebhookContext | humidifier2WebhookContext) => {
|
|
391
401
|
try {
|
|
392
|
-
this.debugLog(`received Webhook: ${JSON.stringify(context)}`)
|
|
393
402
|
this.webhookContext = context
|
|
394
|
-
|
|
395
|
-
|
|
403
|
+
if (context !== undefined || context !== null) {
|
|
404
|
+
this.debugLog(`received Webhook: ${JSON.stringify(context)}`)
|
|
405
|
+
await this.parseStatusWebhook()
|
|
406
|
+
await this.updateHomeKitCharacteristics()
|
|
407
|
+
} else {
|
|
408
|
+
this.errorLog(`context is either undefined or null, context: ${JSON.stringify(context)}`)
|
|
409
|
+
}
|
|
396
410
|
} catch (e: any) {
|
|
397
411
|
this.errorLog(`failed to handle webhook. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`)
|
|
398
412
|
}
|
package/src/device/iosensor.ts
CHANGED
|
@@ -292,8 +292,13 @@ export class IOSensor extends deviceBase {
|
|
|
292
292
|
// Update HomeKit
|
|
293
293
|
if (serviceData.model === SwitchBotBLEModel.OutdoorMeter && serviceData.modelName === SwitchBotBLEModelName.OutdoorMeter) {
|
|
294
294
|
this.serviceData = serviceData
|
|
295
|
-
|
|
296
|
-
|
|
295
|
+
if (serviceData !== undefined || serviceData !== null) {
|
|
296
|
+
await this.BLEparseStatus()
|
|
297
|
+
await this.updateHomeKitCharacteristics()
|
|
298
|
+
} else {
|
|
299
|
+
this.errorLog(`serviceData is either undefined or null, serviceData: ${JSON.stringify(serviceData)}`)
|
|
300
|
+
await this.BLERefreshConnection(switchBotBLE)
|
|
301
|
+
}
|
|
297
302
|
} else {
|
|
298
303
|
this.errorLog(`failed to get serviceData, serviceData: ${JSON.stringify(serviceData)}`)
|
|
299
304
|
await this.BLERefreshConnection(switchBotBLE)
|
|
@@ -312,10 +317,15 @@ export class IOSensor extends deviceBase {
|
|
|
312
317
|
this.debugLog(`bleMac: ${this.device.bleMac}`)
|
|
313
318
|
this.platform.bleEventHandler[this.device.bleMac] = async (context: outdoorMeterServiceData) => {
|
|
314
319
|
try {
|
|
315
|
-
this.debugLog(`received BLE: ${JSON.stringify(context)}`)
|
|
316
320
|
this.serviceData = context
|
|
317
|
-
|
|
318
|
-
|
|
321
|
+
if (context !== undefined || context !== null) {
|
|
322
|
+
this.debugLog(`received BLE: ${JSON.stringify(context)}`)
|
|
323
|
+
await this.BLEparseStatus()
|
|
324
|
+
await this.updateHomeKitCharacteristics()
|
|
325
|
+
} else {
|
|
326
|
+
this.errorLog(`context is either undefined or null, context: ${JSON.stringify(context)}`)
|
|
327
|
+
await this.BLERefreshConnection(context)
|
|
328
|
+
}
|
|
319
329
|
} catch (e: any) {
|
|
320
330
|
this.errorLog(`failed to handle BLE. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`)
|
|
321
331
|
}
|
|
@@ -353,10 +363,14 @@ export class IOSensor extends deviceBase {
|
|
|
353
363
|
this.debugLog('is listening webhook.')
|
|
354
364
|
this.platform.webhookEventHandler[this.device.deviceId] = async (context: outdoorMeterWebhookContext) => {
|
|
355
365
|
try {
|
|
356
|
-
this.debugLog(`received Webhook: ${JSON.stringify(context)}`)
|
|
357
366
|
this.webhookContext = context
|
|
358
|
-
|
|
359
|
-
|
|
367
|
+
if (context !== undefined || context !== null) {
|
|
368
|
+
this.debugLog(`received Webhook: ${JSON.stringify(context)}`)
|
|
369
|
+
await this.parseStatusWebhook()
|
|
370
|
+
await this.updateHomeKitCharacteristics()
|
|
371
|
+
} else {
|
|
372
|
+
this.errorLog(`context is either undefined or null, context: ${JSON.stringify(context)}`)
|
|
373
|
+
}
|
|
360
374
|
} catch (e: any) {
|
|
361
375
|
this.errorLog(`failed to handle webhook. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`)
|
|
362
376
|
}
|
package/src/device/lightstrip.ts
CHANGED
|
@@ -320,8 +320,13 @@ export class StripLight extends deviceBase {
|
|
|
320
320
|
// Update HomeKit
|
|
321
321
|
if (serviceData.model === SwitchBotBLEModel.StripLight && serviceData.modelName === SwitchBotBLEModelName.StripLight) {
|
|
322
322
|
this.serviceData = serviceData
|
|
323
|
-
|
|
324
|
-
|
|
323
|
+
if (serviceData !== undefined || serviceData !== null) {
|
|
324
|
+
await this.BLEparseStatus()
|
|
325
|
+
await this.updateHomeKitCharacteristics()
|
|
326
|
+
} else {
|
|
327
|
+
this.errorLog(`serviceData is either undefined or null, serviceData: ${JSON.stringify(serviceData)}`)
|
|
328
|
+
await this.BLERefreshConnection(switchBotBLE)
|
|
329
|
+
}
|
|
325
330
|
} else {
|
|
326
331
|
this.errorLog(`failed to get serviceData, serviceData: ${JSON.stringify(serviceData)}`)
|
|
327
332
|
await this.BLERefreshConnection(switchBotBLE)
|
|
@@ -340,10 +345,15 @@ export class StripLight extends deviceBase {
|
|
|
340
345
|
this.debugLog(`bleMac: ${this.device.bleMac}`)
|
|
341
346
|
this.platform.bleEventHandler[this.device.bleMac] = async (context: stripLightServiceData) => {
|
|
342
347
|
try {
|
|
343
|
-
this.debugLog(`received BLE: ${JSON.stringify(context)}`)
|
|
344
348
|
this.serviceData = context
|
|
345
|
-
|
|
346
|
-
|
|
349
|
+
if (context !== undefined || context !== null) {
|
|
350
|
+
this.debugLog(`received BLE: ${JSON.stringify(context)}`)
|
|
351
|
+
await this.BLEparseStatus()
|
|
352
|
+
await this.updateHomeKitCharacteristics()
|
|
353
|
+
} else {
|
|
354
|
+
this.errorLog(`context is either undefined or null, context: ${JSON.stringify(context)}`)
|
|
355
|
+
await this.BLERefreshConnection(context)
|
|
356
|
+
}
|
|
347
357
|
} catch (e: any) {
|
|
348
358
|
this.errorLog(`failed to handle BLE. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`)
|
|
349
359
|
}
|
|
@@ -381,10 +391,14 @@ export class StripLight extends deviceBase {
|
|
|
381
391
|
this.debugLog('is listening webhook.')
|
|
382
392
|
this.platform.webhookEventHandler[this.device.deviceId] = async (context: stripLightWebhookContext) => {
|
|
383
393
|
try {
|
|
384
|
-
this.debugLog(`received Webhook: ${JSON.stringify(context)}`)
|
|
385
394
|
this.webhookContext = context
|
|
386
|
-
|
|
387
|
-
|
|
395
|
+
if (context !== undefined || context !== null) {
|
|
396
|
+
this.debugLog(`received Webhook: ${JSON.stringify(context)}`)
|
|
397
|
+
await this.parseStatusWebhook()
|
|
398
|
+
await this.updateHomeKitCharacteristics()
|
|
399
|
+
} else {
|
|
400
|
+
this.errorLog(`context is either undefined or null, context: ${JSON.stringify(context)}`)
|
|
401
|
+
}
|
|
388
402
|
} catch (e: any) {
|
|
389
403
|
this.errorLog(`failed to handle webhook. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`)
|
|
390
404
|
}
|
package/src/device/lock.ts
CHANGED
|
@@ -334,8 +334,13 @@ export class Lock extends deviceBase {
|
|
|
334
334
|
if ((serviceData.model === SwitchBotBLEModel.Lock || SwitchBotBLEModel.LockPro)
|
|
335
335
|
&& (serviceData.modelName === SwitchBotBLEModelName.Lock || SwitchBotBLEModelName.LockPro)) {
|
|
336
336
|
this.serviceData = serviceData
|
|
337
|
-
|
|
338
|
-
|
|
337
|
+
if (serviceData !== undefined || serviceData !== null) {
|
|
338
|
+
await this.BLEparseStatus()
|
|
339
|
+
await this.updateHomeKitCharacteristics()
|
|
340
|
+
} else {
|
|
341
|
+
this.errorLog(`serviceData is either undefined or null, serviceData: ${JSON.stringify(serviceData)}`)
|
|
342
|
+
await this.BLERefreshConnection(switchBotBLE)
|
|
343
|
+
}
|
|
339
344
|
} else {
|
|
340
345
|
this.errorLog(`failed to get serviceData, serviceData: ${JSON.stringify(serviceData)}`)
|
|
341
346
|
await this.BLERefreshConnection(switchBotBLE)
|
|
@@ -354,10 +359,15 @@ export class Lock extends deviceBase {
|
|
|
354
359
|
this.debugLog(`bleMac: ${this.device.bleMac}`)
|
|
355
360
|
this.platform.bleEventHandler[this.device.bleMac] = async (context: lockServiceData | lockProServiceData) => {
|
|
356
361
|
try {
|
|
357
|
-
this.debugLog(`received BLE: ${JSON.stringify(context)}`)
|
|
358
362
|
this.serviceData = context
|
|
359
|
-
|
|
360
|
-
|
|
363
|
+
if (context !== undefined || context !== null) {
|
|
364
|
+
this.debugLog(`received BLE: ${JSON.stringify(context)}`)
|
|
365
|
+
await this.BLEparseStatus()
|
|
366
|
+
await this.updateHomeKitCharacteristics()
|
|
367
|
+
} else {
|
|
368
|
+
this.errorLog(`context is either undefined or null, context: ${JSON.stringify(context)}`)
|
|
369
|
+
await this.BLERefreshConnection(context)
|
|
370
|
+
}
|
|
361
371
|
} catch (e: any) {
|
|
362
372
|
this.errorLog(`failed to handle BLE. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`)
|
|
363
373
|
}
|
|
@@ -395,10 +405,14 @@ export class Lock extends deviceBase {
|
|
|
395
405
|
this.debugLog('is listening webhook.')
|
|
396
406
|
this.platform.webhookEventHandler[this.device.deviceId] = async (context: lockWebhookContext | lockProWebhookContext) => {
|
|
397
407
|
try {
|
|
398
|
-
this.debugLog(`received Webhook: ${JSON.stringify(context)}`)
|
|
399
408
|
this.webhookContext = context
|
|
400
|
-
|
|
401
|
-
|
|
409
|
+
if (context !== undefined || context !== null) {
|
|
410
|
+
this.debugLog(`received Webhook: ${JSON.stringify(context)}`)
|
|
411
|
+
await this.parseStatusWebhook()
|
|
412
|
+
await this.updateHomeKitCharacteristics()
|
|
413
|
+
} else {
|
|
414
|
+
this.errorLog(`context is either undefined or null, context: ${JSON.stringify(context)}`)
|
|
415
|
+
}
|
|
402
416
|
} catch (e: any) {
|
|
403
417
|
this.errorLog(`failed to handle webhook. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`)
|
|
404
418
|
}
|
package/src/device/meter.ts
CHANGED
|
@@ -289,8 +289,13 @@ export class Meter extends deviceBase {
|
|
|
289
289
|
// Update HomeKit
|
|
290
290
|
if (serviceData.model === SwitchBotBLEModel.Meter && serviceData.modelName === SwitchBotBLEModelName.Meter) {
|
|
291
291
|
this.serviceData = serviceData
|
|
292
|
-
|
|
293
|
-
|
|
292
|
+
if (serviceData !== undefined || serviceData !== null) {
|
|
293
|
+
await this.BLEparseStatus()
|
|
294
|
+
await this.updateHomeKitCharacteristics()
|
|
295
|
+
} else {
|
|
296
|
+
this.errorLog(`serviceData is either undefined or null, serviceData: ${JSON.stringify(serviceData)}`)
|
|
297
|
+
await this.BLERefreshConnection(switchBotBLE)
|
|
298
|
+
}
|
|
294
299
|
} else {
|
|
295
300
|
this.errorLog(`failed to get serviceData, serviceData: ${JSON.stringify(serviceData)}`)
|
|
296
301
|
await this.BLERefreshConnection(switchBotBLE)
|
|
@@ -309,10 +314,15 @@ export class Meter extends deviceBase {
|
|
|
309
314
|
this.debugLog(`bleMac: ${this.device.bleMac}`)
|
|
310
315
|
this.platform.bleEventHandler[this.device.bleMac] = async (context: meterServiceData) => {
|
|
311
316
|
try {
|
|
312
|
-
this.debugLog(`received BLE: ${JSON.stringify(context)}`)
|
|
313
317
|
this.serviceData = context
|
|
314
|
-
|
|
315
|
-
|
|
318
|
+
if (context !== undefined || context !== null) {
|
|
319
|
+
this.debugLog(`received BLE: ${JSON.stringify(context)}`)
|
|
320
|
+
await this.BLEparseStatus()
|
|
321
|
+
await this.updateHomeKitCharacteristics()
|
|
322
|
+
} else {
|
|
323
|
+
this.errorLog(`context is either undefined or null, context: ${JSON.stringify(context)}`)
|
|
324
|
+
await this.BLERefreshConnection(context)
|
|
325
|
+
}
|
|
316
326
|
} catch (e: any) {
|
|
317
327
|
this.errorLog(`failed to handle BLE. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`)
|
|
318
328
|
}
|
|
@@ -350,10 +360,14 @@ export class Meter extends deviceBase {
|
|
|
350
360
|
this.debugLog('is listening webhook.')
|
|
351
361
|
this.platform.webhookEventHandler[this.device.deviceId] = async (context: meterWebhookContext) => {
|
|
352
362
|
try {
|
|
353
|
-
this.debugLog(`received Webhook: ${JSON.stringify(context)}`)
|
|
354
363
|
this.webhookContext = context
|
|
355
|
-
|
|
356
|
-
|
|
364
|
+
if (context !== undefined || context !== null) {
|
|
365
|
+
this.debugLog(`received Webhook: ${JSON.stringify(context)}`)
|
|
366
|
+
await this.parseStatusWebhook()
|
|
367
|
+
await this.updateHomeKitCharacteristics()
|
|
368
|
+
} else {
|
|
369
|
+
this.errorLog(`context is either undefined or null, context: ${JSON.stringify(context)}`)
|
|
370
|
+
}
|
|
357
371
|
} catch (e: any) {
|
|
358
372
|
this.errorLog(`failed to handle webhook. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`)
|
|
359
373
|
}
|
package/src/device/meterplus.ts
CHANGED
|
@@ -293,8 +293,13 @@ export class MeterPlus extends deviceBase {
|
|
|
293
293
|
// Update HomeKit
|
|
294
294
|
if (serviceData.model === SwitchBotBLEModel.MeterPlus && serviceData.modelName === SwitchBotBLEModelName.MeterPlus) {
|
|
295
295
|
this.serviceData = serviceData
|
|
296
|
-
|
|
297
|
-
|
|
296
|
+
if (serviceData !== undefined || serviceData !== null) {
|
|
297
|
+
await this.BLEparseStatus()
|
|
298
|
+
await this.updateHomeKitCharacteristics()
|
|
299
|
+
} else {
|
|
300
|
+
this.errorLog(`serviceData is either undefined or null, serviceData: ${JSON.stringify(serviceData)}`)
|
|
301
|
+
await this.BLERefreshConnection(switchBotBLE)
|
|
302
|
+
}
|
|
298
303
|
} else {
|
|
299
304
|
this.errorLog(`failed to get serviceData, serviceData: ${JSON.stringify(serviceData)}`)
|
|
300
305
|
await this.BLERefreshConnection(switchBotBLE)
|
|
@@ -313,10 +318,15 @@ export class MeterPlus extends deviceBase {
|
|
|
313
318
|
this.debugLog(`bleMac: ${this.device.bleMac}`)
|
|
314
319
|
this.platform.bleEventHandler[this.device.bleMac] = async (context: meterPlusServiceData) => {
|
|
315
320
|
try {
|
|
316
|
-
this.debugLog(`received BLE: ${JSON.stringify(context)}`)
|
|
317
321
|
this.serviceData = context
|
|
318
|
-
|
|
319
|
-
|
|
322
|
+
if (context !== undefined || context !== null) {
|
|
323
|
+
this.debugLog(`received BLE: ${JSON.stringify(context)}`)
|
|
324
|
+
await this.BLEparseStatus()
|
|
325
|
+
await this.updateHomeKitCharacteristics()
|
|
326
|
+
} else {
|
|
327
|
+
this.errorLog(`context is either undefined or null, context: ${JSON.stringify(context)}`)
|
|
328
|
+
await this.BLERefreshConnection(context)
|
|
329
|
+
}
|
|
320
330
|
} catch (e: any) {
|
|
321
331
|
this.errorLog(`failed to handle BLE. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`)
|
|
322
332
|
}
|
|
@@ -354,10 +364,14 @@ export class MeterPlus extends deviceBase {
|
|
|
354
364
|
this.debugLog('is listening webhook.')
|
|
355
365
|
this.platform.webhookEventHandler[this.device.deviceId] = async (context: meterPlusWebhookContext) => {
|
|
356
366
|
try {
|
|
357
|
-
this.debugLog(`received Webhook: ${JSON.stringify(context)}`)
|
|
358
367
|
this.webhookContext = context
|
|
359
|
-
|
|
360
|
-
|
|
368
|
+
if (context !== undefined || context !== null) {
|
|
369
|
+
this.debugLog(`received Webhook: ${JSON.stringify(context)}`)
|
|
370
|
+
await this.parseStatusWebhook()
|
|
371
|
+
await this.updateHomeKitCharacteristics()
|
|
372
|
+
} else {
|
|
373
|
+
this.errorLog(`context is either undefined or null, context: ${JSON.stringify(context)}`)
|
|
374
|
+
}
|
|
361
375
|
} catch (e: any) {
|
|
362
376
|
this.errorLog(`failed to handle webhook. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`)
|
|
363
377
|
}
|
package/src/device/meterpro.ts
CHANGED
|
@@ -369,8 +369,13 @@ export class MeterPro extends deviceBase {
|
|
|
369
369
|
// Update HomeKit
|
|
370
370
|
if (serviceData.model === SwitchBotBLEModel.MeterPro && serviceData.modelName === SwitchBotBLEModelName.MeterPro) {
|
|
371
371
|
this.serviceData = serviceData
|
|
372
|
-
|
|
373
|
-
|
|
372
|
+
if (serviceData !== undefined || serviceData !== null) {
|
|
373
|
+
await this.BLEparseStatus()
|
|
374
|
+
await this.updateHomeKitCharacteristics()
|
|
375
|
+
} else {
|
|
376
|
+
this.errorLog(`serviceData is either undefined or null, serviceData: ${JSON.stringify(serviceData)}`)
|
|
377
|
+
await this.BLERefreshConnection(switchBotBLE)
|
|
378
|
+
}
|
|
374
379
|
} else {
|
|
375
380
|
this.errorLog(`failed to get serviceData, serviceData: ${JSON.stringify(serviceData)}`)
|
|
376
381
|
await this.BLERefreshConnection(switchBotBLE)
|
|
@@ -389,10 +394,15 @@ export class MeterPro extends deviceBase {
|
|
|
389
394
|
this.debugLog(`bleMac: ${this.device.bleMac}`)
|
|
390
395
|
this.platform.bleEventHandler[this.device.bleMac] = async (context: meterProServiceData) => {
|
|
391
396
|
try {
|
|
392
|
-
this.debugLog(`received BLE: ${JSON.stringify(context)}`)
|
|
393
397
|
this.serviceData = context
|
|
394
|
-
|
|
395
|
-
|
|
398
|
+
if (context !== undefined || context !== null) {
|
|
399
|
+
this.debugLog(`received BLE: ${JSON.stringify(context)}`)
|
|
400
|
+
await this.BLEparseStatus()
|
|
401
|
+
await this.updateHomeKitCharacteristics()
|
|
402
|
+
} else {
|
|
403
|
+
this.errorLog(`context is either undefined or null, context: ${JSON.stringify(context)}`)
|
|
404
|
+
await this.BLERefreshConnection(context)
|
|
405
|
+
}
|
|
396
406
|
} catch (e: any) {
|
|
397
407
|
this.errorLog(`failed to handle BLE. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`)
|
|
398
408
|
}
|
|
@@ -430,10 +440,14 @@ export class MeterPro extends deviceBase {
|
|
|
430
440
|
this.debugLog('is listening webhook.')
|
|
431
441
|
this.platform.webhookEventHandler[this.device.deviceId] = async (context: meterProWebhookContext) => {
|
|
432
442
|
try {
|
|
433
|
-
this.debugLog(`received Webhook: ${JSON.stringify(context)}`)
|
|
434
443
|
this.webhookContext = context
|
|
435
|
-
|
|
436
|
-
|
|
444
|
+
if (context !== undefined || context !== null) {
|
|
445
|
+
this.debugLog(`received Webhook: ${JSON.stringify(context)}`)
|
|
446
|
+
await this.parseStatusWebhook()
|
|
447
|
+
await this.updateHomeKitCharacteristics()
|
|
448
|
+
} else {
|
|
449
|
+
this.errorLog(`context is either undefined or null, context: ${JSON.stringify(context)}`)
|
|
450
|
+
}
|
|
437
451
|
} catch (e: any) {
|
|
438
452
|
this.errorLog(`failed to handle webhook. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`)
|
|
439
453
|
}
|
package/src/device/motion.ts
CHANGED
|
@@ -264,8 +264,13 @@ export class Motion extends deviceBase {
|
|
|
264
264
|
// Update HomeKit
|
|
265
265
|
if (serviceData.model === SwitchBotBLEModel.MotionSensor && serviceData.modelName === SwitchBotBLEModelName.MotionSensor) {
|
|
266
266
|
this.serviceData = serviceData
|
|
267
|
-
|
|
268
|
-
|
|
267
|
+
if (serviceData !== undefined || serviceData !== null) {
|
|
268
|
+
await this.BLEparseStatus()
|
|
269
|
+
await this.updateHomeKitCharacteristics()
|
|
270
|
+
} else {
|
|
271
|
+
this.errorLog(`serviceData is either undefined or null, serviceData: ${JSON.stringify(serviceData)}`)
|
|
272
|
+
await this.BLERefreshConnection(switchBotBLE)
|
|
273
|
+
}
|
|
269
274
|
} else {
|
|
270
275
|
this.errorLog(`failed to get serviceData, serviceData: ${JSON.stringify(serviceData)}`)
|
|
271
276
|
await this.BLERefreshConnection(switchBotBLE)
|
|
@@ -284,10 +289,15 @@ export class Motion extends deviceBase {
|
|
|
284
289
|
this.debugLog(`bleMac: ${this.device.bleMac}`)
|
|
285
290
|
this.platform.bleEventHandler[this.device.bleMac] = async (context: motionSensorServiceData) => {
|
|
286
291
|
try {
|
|
287
|
-
this.debugLog(`received BLE: ${JSON.stringify(context)}`)
|
|
288
292
|
this.serviceData = context
|
|
289
|
-
|
|
290
|
-
|
|
293
|
+
if (context !== undefined || context !== null) {
|
|
294
|
+
this.debugLog(`received BLE: ${JSON.stringify(context)}`)
|
|
295
|
+
await this.BLEparseStatus()
|
|
296
|
+
await this.updateHomeKitCharacteristics()
|
|
297
|
+
} else {
|
|
298
|
+
this.errorLog(`context is either undefined or null, context: ${JSON.stringify(context)}`)
|
|
299
|
+
await this.BLERefreshConnection(context)
|
|
300
|
+
}
|
|
291
301
|
} catch (e: any) {
|
|
292
302
|
this.errorLog(`failed to handle BLE. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`)
|
|
293
303
|
}
|
|
@@ -325,10 +335,14 @@ export class Motion extends deviceBase {
|
|
|
325
335
|
this.debugLog('is listening webhook.')
|
|
326
336
|
this.platform.webhookEventHandler[this.device.deviceId] = async (context: motionSensorWebhookContext) => {
|
|
327
337
|
try {
|
|
328
|
-
this.debugLog(`received Webhook: ${JSON.stringify(context)}`)
|
|
329
338
|
this.webhookContext = context
|
|
330
|
-
|
|
331
|
-
|
|
339
|
+
if (context !== undefined || context !== null) {
|
|
340
|
+
this.debugLog(`received Webhook: ${JSON.stringify(context)}`)
|
|
341
|
+
await this.parseStatusWebhook()
|
|
342
|
+
await this.updateHomeKitCharacteristics()
|
|
343
|
+
} else {
|
|
344
|
+
this.errorLog(`context is either undefined or null, context: ${JSON.stringify(context)}`)
|
|
345
|
+
}
|
|
332
346
|
} catch (e: any) {
|
|
333
347
|
this.errorLog(`failed to handle webhook. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`)
|
|
334
348
|
}
|