@switchbot/homebridge-switchbot 3.6.1-beta.0 → 3.6.1-beta.2
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 +11 -0
- package/config.schema.json +11 -0
- package/dist/device/blindtilt.d.ts.map +1 -1
- package/dist/device/blindtilt.js +36 -18
- package/dist/device/blindtilt.js.map +1 -1
- package/dist/device/bot.d.ts +1 -2
- package/dist/device/bot.d.ts.map +1 -1
- package/dist/device/bot.js +186 -396
- package/dist/device/bot.js.map +1 -1
- package/dist/device/ceilinglight.d.ts.map +1 -1
- package/dist/device/ceilinglight.js +36 -19
- package/dist/device/ceilinglight.js.map +1 -1
- package/dist/device/colorbulb.d.ts.map +1 -1
- package/dist/device/colorbulb.js +36 -19
- package/dist/device/colorbulb.js.map +1 -1
- package/dist/device/contact.d.ts.map +1 -1
- package/dist/device/contact.js +36 -19
- package/dist/device/contact.js.map +1 -1
- package/dist/device/curtain.d.ts.map +1 -1
- package/dist/device/curtain.js +37 -18
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/device.js +2 -2
- package/dist/device/device.js.map +1 -1
- package/dist/device/fan.d.ts.map +1 -1
- package/dist/device/fan.js +36 -19
- package/dist/device/fan.js.map +1 -1
- package/dist/device/hub.d.ts.map +1 -1
- package/dist/device/hub.js +36 -17
- package/dist/device/hub.js.map +1 -1
- package/dist/device/humidifier.d.ts.map +1 -1
- package/dist/device/humidifier.js +36 -17
- package/dist/device/humidifier.js.map +1 -1
- package/dist/device/iosensor.d.ts.map +1 -1
- package/dist/device/iosensor.js +36 -17
- package/dist/device/iosensor.js.map +1 -1
- package/dist/device/lightstrip.d.ts.map +1 -1
- package/dist/device/lightstrip.js +36 -17
- package/dist/device/lightstrip.js.map +1 -1
- package/dist/device/lock.d.ts.map +1 -1
- package/dist/device/lock.js +37 -18
- package/dist/device/lock.js.map +1 -1
- package/dist/device/meter.d.ts.map +1 -1
- package/dist/device/meter.js +36 -17
- package/dist/device/meter.js.map +1 -1
- package/dist/device/meterplus.d.ts.map +1 -1
- package/dist/device/meterplus.js +36 -17
- package/dist/device/meterplus.js.map +1 -1
- package/dist/device/motion.d.ts.map +1 -1
- package/dist/device/motion.js +36 -17
- package/dist/device/motion.js.map +1 -1
- package/dist/device/plug.d.ts.map +1 -1
- package/dist/device/plug.js +37 -18
- package/dist/device/plug.js.map +1 -1
- package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
- package/dist/device/robotvacuumcleaner.js +36 -17
- package/dist/device/robotvacuumcleaner.js.map +1 -1
- package/dist/device/waterdetector.d.ts.map +1 -1
- package/dist/device/waterdetector.js +36 -17
- package/dist/device/waterdetector.js.map +1 -1
- package/dist/irdevice/other.d.ts +1 -0
- package/dist/irdevice/other.d.ts.map +1 -1
- package/dist/irdevice/other.js +186 -228
- package/dist/irdevice/other.js.map +1 -1
- package/dist/platform.d.ts +4 -0
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +32 -0
- package/dist/platform.js.map +1 -1
- package/dist/settings.d.ts +1 -0
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js.map +1 -1
- package/package.json +3 -3
- package/src/device/blindtilt.ts +33 -18
- package/src/device/bot.ts +179 -406
- package/src/device/ceilinglight.ts +33 -20
- package/src/device/colorbulb.ts +33 -20
- package/src/device/contact.ts +33 -20
- package/src/device/curtain.ts +34 -18
- package/src/device/device.ts +2 -2
- package/src/device/fan.ts +33 -20
- package/src/device/hub.ts +33 -17
- package/src/device/humidifier.ts +33 -17
- package/src/device/iosensor.ts +33 -17
- package/src/device/lightstrip.ts +33 -17
- package/src/device/lock.ts +34 -18
- package/src/device/meter.ts +33 -17
- package/src/device/meterplus.ts +33 -17
- package/src/device/motion.ts +33 -17
- package/src/device/plug.ts +34 -18
- package/src/device/robotvacuumcleaner.ts +33 -17
- package/src/device/waterdetector.ts +33 -17
- package/src/irdevice/other.ts +214 -283
- package/src/platform.ts +30 -0
- package/src/settings.ts +1 -0
package/src/platform.ts
CHANGED
|
@@ -78,6 +78,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
78
78
|
public readonly eve: any;
|
|
79
79
|
public readonly fakegatoAPI: any;
|
|
80
80
|
public readonly webhookEventHandler: { [x: string]: (context: any) => void } = {};
|
|
81
|
+
public readonly bleEventHandler: { [x: string]: (context: any) => void } = {};
|
|
81
82
|
|
|
82
83
|
constructor(
|
|
83
84
|
log: Logging,
|
|
@@ -148,6 +149,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
148
149
|
|
|
149
150
|
this.setupMqtt();
|
|
150
151
|
this.setupwebhook();
|
|
152
|
+
this.setupBlE();
|
|
151
153
|
}
|
|
152
154
|
|
|
153
155
|
async setupMqtt(): Promise<void> {
|
|
@@ -312,6 +314,34 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
312
314
|
}
|
|
313
315
|
}
|
|
314
316
|
|
|
317
|
+
async setupBlE() {
|
|
318
|
+
if (this.config.options?.BLE) {
|
|
319
|
+
await this.debugLog('setupBLE');
|
|
320
|
+
const SwitchBot = (await import('node-switchbot')).SwitchBot;
|
|
321
|
+
const switchbot = new SwitchBot();
|
|
322
|
+
if (switchbot === undefined) {
|
|
323
|
+
await this.errorLog(`wasn't able to establish BLE Connection, node-switchbot: ${switchbot}`);
|
|
324
|
+
} else {
|
|
325
|
+
// Start to monitor advertisement packets
|
|
326
|
+
(async () => {
|
|
327
|
+
// Start to monitor advertisement packets
|
|
328
|
+
await this.debugLog('Scanning for BLE SwitchBot devices...');
|
|
329
|
+
await switchbot.startScan();
|
|
330
|
+
// Set an event handler to monitor advertisement packets
|
|
331
|
+
switchbot.onadvertisement = async (ad: any) => {
|
|
332
|
+
try {
|
|
333
|
+
this.bleEventHandler[ad.address]?.(ad.serviceData);
|
|
334
|
+
} catch (e: any) {
|
|
335
|
+
await this.errorLog(`Failed to handle BLE event. Error:${e}`);
|
|
336
|
+
}
|
|
337
|
+
};
|
|
338
|
+
})();
|
|
339
|
+
}
|
|
340
|
+
} else {
|
|
341
|
+
await this.debugLog('Platform BLE is not enabled');
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
|
|
315
345
|
/**
|
|
316
346
|
* This function is invoked when homebridge restores cached accessories from disk at startup.
|
|
317
347
|
* It should be used to setup event handlers for characteristics and update respective values.
|