@switchbot/homebridge-switchbot 3.7.1-beta.2 → 3.7.1-beta.3
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 +3 -1
- package/dist/device/blindtilt.d.ts.map +1 -1
- package/dist/device/blindtilt.js +38 -24
- package/dist/device/blindtilt.js.map +1 -1
- package/dist/device/bot.d.ts +1 -0
- package/dist/device/bot.d.ts.map +1 -1
- package/dist/device/bot.js +30 -24
- package/dist/device/bot.js.map +1 -1
- package/dist/device/ceilinglight.d.ts +1 -0
- package/dist/device/ceilinglight.d.ts.map +1 -1
- package/dist/device/ceilinglight.js +30 -24
- package/dist/device/ceilinglight.js.map +1 -1
- package/dist/device/colorbulb.d.ts +1 -0
- package/dist/device/colorbulb.d.ts.map +1 -1
- package/dist/device/colorbulb.js +30 -24
- package/dist/device/colorbulb.js.map +1 -1
- package/dist/device/contact.d.ts +1 -0
- package/dist/device/contact.d.ts.map +1 -1
- package/dist/device/contact.js +30 -24
- 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 +51 -39
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/fan.d.ts +1 -0
- package/dist/device/fan.d.ts.map +1 -1
- package/dist/device/fan.js +30 -24
- package/dist/device/fan.js.map +1 -1
- package/dist/device/hub.d.ts +1 -0
- package/dist/device/hub.d.ts.map +1 -1
- package/dist/device/hub.js +30 -24
- package/dist/device/hub.js.map +1 -1
- package/dist/device/humidifier.d.ts +1 -0
- package/dist/device/humidifier.d.ts.map +1 -1
- package/dist/device/humidifier.js +30 -24
- package/dist/device/humidifier.js.map +1 -1
- package/dist/device/iosensor.d.ts +1 -0
- package/dist/device/iosensor.d.ts.map +1 -1
- package/dist/device/iosensor.js +30 -24
- package/dist/device/iosensor.js.map +1 -1
- package/dist/device/lightstrip.d.ts +1 -0
- package/dist/device/lightstrip.d.ts.map +1 -1
- package/dist/device/lightstrip.js +30 -24
- package/dist/device/lightstrip.js.map +1 -1
- package/dist/device/lock.d.ts +1 -0
- package/dist/device/lock.d.ts.map +1 -1
- package/dist/device/lock.js +31 -25
- package/dist/device/lock.js.map +1 -1
- package/dist/device/meter.d.ts +1 -0
- package/dist/device/meter.d.ts.map +1 -1
- package/dist/device/meter.js +30 -24
- package/dist/device/meter.js.map +1 -1
- package/dist/device/meterplus.d.ts +1 -0
- package/dist/device/meterplus.d.ts.map +1 -1
- package/dist/device/meterplus.js +30 -24
- package/dist/device/meterplus.js.map +1 -1
- package/dist/device/motion.d.ts +1 -0
- package/dist/device/motion.d.ts.map +1 -1
- package/dist/device/motion.js +30 -24
- package/dist/device/motion.js.map +1 -1
- package/dist/device/plug.d.ts +1 -0
- package/dist/device/plug.d.ts.map +1 -1
- package/dist/device/plug.js +31 -25
- package/dist/device/plug.js.map +1 -1
- package/dist/device/robotvacuumcleaner.d.ts +1 -0
- package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
- package/dist/device/robotvacuumcleaner.js +30 -24
- package/dist/device/robotvacuumcleaner.js.map +1 -1
- package/dist/device/waterdetector.d.ts +1 -0
- package/dist/device/waterdetector.d.ts.map +1 -1
- package/dist/device/waterdetector.js +30 -24
- package/dist/device/waterdetector.js.map +1 -1
- package/package.json +3 -3
- package/src/device/blindtilt.ts +39 -23
- package/src/device/bot.ts +30 -22
- package/src/device/ceilinglight.ts +31 -23
- package/src/device/colorbulb.ts +30 -22
- package/src/device/contact.ts +30 -22
- package/src/device/curtain.ts +50 -36
- package/src/device/fan.ts +30 -22
- package/src/device/hub.ts +30 -22
- package/src/device/humidifier.ts +30 -22
- package/src/device/iosensor.ts +30 -22
- package/src/device/lightstrip.ts +30 -22
- package/src/device/lock.ts +31 -23
- package/src/device/meter.ts +30 -22
- package/src/device/meterplus.ts +30 -22
- package/src/device/motion.ts +30 -22
- package/src/device/plug.ts +31 -23
- package/src/device/robotvacuumcleaner.ts +30 -22
- package/src/device/waterdetector.ts +30 -22
|
@@ -121,10 +121,14 @@ export class WaterDetector extends deviceBase {
|
|
|
121
121
|
this.debugLog('Retrieve initial values and update Homekit');
|
|
122
122
|
this.refreshStatus();
|
|
123
123
|
|
|
124
|
-
//regisiter webhook event handler
|
|
124
|
+
//regisiter webhook event handler if enabled
|
|
125
125
|
this.debugLog('Registering Webhook Event Handler');
|
|
126
126
|
this.registerWebhook();
|
|
127
127
|
|
|
128
|
+
//regisiter platform BLE event handler if enabled
|
|
129
|
+
this.debugLog('Registering Platform BLE Event Handler');
|
|
130
|
+
this.registerPlatformBLE();
|
|
131
|
+
|
|
128
132
|
// Start an update interval
|
|
129
133
|
interval(this.deviceRefreshRate * 1000)
|
|
130
134
|
.pipe(skipWhile(() => this.WaterDetectorUpdateInProgress))
|
|
@@ -234,7 +238,7 @@ export class WaterDetector extends deviceBase {
|
|
|
234
238
|
async refreshStatus(): Promise<void> {
|
|
235
239
|
if (!this.device.enableCloudService && this.OpenAPI) {
|
|
236
240
|
await this.errorLog(`refreshStatus enableCloudService: ${this.device.enableCloudService}`);
|
|
237
|
-
} else if (this.BLE
|
|
241
|
+
} else if (this.BLE) {
|
|
238
242
|
await this.BLERefreshStatus();
|
|
239
243
|
} else if (this.OpenAPI && this.platform.config.credentials?.token) {
|
|
240
244
|
await this.openAPIRefreshStatus();
|
|
@@ -246,6 +250,29 @@ export class WaterDetector extends deviceBase {
|
|
|
246
250
|
|
|
247
251
|
async BLERefreshStatus(): Promise<void> {
|
|
248
252
|
await this.debugLog('BLERefreshStatus');
|
|
253
|
+
const switchbot = await this.switchbotBLE();
|
|
254
|
+
if (switchbot === undefined) {
|
|
255
|
+
await this.BLERefreshConnection(switchbot);
|
|
256
|
+
} else {
|
|
257
|
+
// Start to monitor advertisement packets
|
|
258
|
+
(async () => {
|
|
259
|
+
// Start to monitor advertisement packets
|
|
260
|
+
const serviceData = await this.monitorAdvertisementPackets(switchbot) as waterLeakDetectorServiceData;
|
|
261
|
+
// Update HomeKit
|
|
262
|
+
if (serviceData.model === SwitchBotBLEModel.Unknown && serviceData.modelName === SwitchBotBLEModelName.Unknown) {
|
|
263
|
+
this.serviceData = serviceData;
|
|
264
|
+
await this.BLEparseStatus();
|
|
265
|
+
await this.updateHomeKitCharacteristics();
|
|
266
|
+
} else {
|
|
267
|
+
await this.errorLog(`failed to get serviceData, serviceData: ${serviceData}`);
|
|
268
|
+
await this.BLERefreshConnection(switchbot);
|
|
269
|
+
}
|
|
270
|
+
})();
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
async registerPlatformBLE(): Promise<void> {
|
|
275
|
+
await this.debugLog('registerPlatformBLE');
|
|
249
276
|
if (this.config.options?.BLE) {
|
|
250
277
|
await this.debugLog('is listening to Platform BLE.');
|
|
251
278
|
this.device.bleMac = this.device.deviceId!.match(/.{1,2}/g)!.join(':').toLowerCase();
|
|
@@ -261,26 +288,7 @@ export class WaterDetector extends deviceBase {
|
|
|
261
288
|
}
|
|
262
289
|
};
|
|
263
290
|
} else {
|
|
264
|
-
await this.debugLog('is
|
|
265
|
-
const switchbot = await this.switchbotBLE();
|
|
266
|
-
if (switchbot === undefined) {
|
|
267
|
-
await this.BLERefreshConnection(switchbot);
|
|
268
|
-
} else {
|
|
269
|
-
// Start to monitor advertisement packets
|
|
270
|
-
(async () => {
|
|
271
|
-
// Start to monitor advertisement packets
|
|
272
|
-
const serviceData = await this.monitorAdvertisementPackets(switchbot) as waterLeakDetectorServiceData;
|
|
273
|
-
// Update HomeKit
|
|
274
|
-
if (serviceData.model === SwitchBotBLEModel.Unknown && serviceData.modelName === SwitchBotBLEModelName.Unknown) {
|
|
275
|
-
this.serviceData = serviceData;
|
|
276
|
-
await this.BLEparseStatus();
|
|
277
|
-
await this.updateHomeKitCharacteristics();
|
|
278
|
-
} else {
|
|
279
|
-
await this.errorLog(`failed to get serviceData, serviceData: ${serviceData}`);
|
|
280
|
-
await this.BLERefreshConnection(switchbot);
|
|
281
|
-
}
|
|
282
|
-
})();
|
|
283
|
-
}
|
|
291
|
+
await this.debugLog('is not listening to Platform BLE');
|
|
284
292
|
}
|
|
285
293
|
}
|
|
286
294
|
|