@switchbot/homebridge-switchbot 3.6.1-beta.1 → 3.6.1-beta.10
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/dist/device/blindtilt.d.ts.map +1 -1
- package/dist/device/blindtilt.js +35 -17
- 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 +3 -2
- package/dist/device/ceilinglight.d.ts.map +1 -1
- package/dist/device/ceilinglight.js +56 -31
- package/dist/device/ceilinglight.js.map +1 -1
- package/dist/device/colorbulb.d.ts +3 -2
- package/dist/device/colorbulb.d.ts.map +1 -1
- package/dist/device/colorbulb.js +57 -29
- package/dist/device/colorbulb.js.map +1 -1
- package/dist/device/contact.d.ts.map +1 -1
- package/dist/device/contact.js +35 -18
- package/dist/device/contact.js.map +1 -1
- package/dist/device/curtain.d.ts.map +1 -1
- package/dist/device/curtain.js +7 -5
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/device.d.ts +9 -0
- package/dist/device/device.d.ts.map +1 -1
- package/dist/device/device.js +30 -3
- package/dist/device/device.js.map +1 -1
- package/dist/device/fan.d.ts.map +1 -1
- package/dist/device/fan.js +35 -18
- package/dist/device/fan.js.map +1 -1
- package/dist/device/hub.d.ts.map +1 -1
- package/dist/device/hub.js +37 -18
- package/dist/device/hub.js.map +1 -1
- package/dist/device/humidifier.d.ts.map +1 -1
- package/dist/device/humidifier.js +39 -20
- package/dist/device/humidifier.js.map +1 -1
- package/dist/device/iosensor.d.ts.map +1 -1
- package/dist/device/iosensor.js +37 -18
- package/dist/device/iosensor.js.map +1 -1
- package/dist/device/lightstrip.d.ts +4 -3
- package/dist/device/lightstrip.d.ts.map +1 -1
- package/dist/device/lightstrip.js +57 -31
- package/dist/device/lightstrip.js.map +1 -1
- package/dist/device/lock.d.ts.map +1 -1
- package/dist/device/lock.js +36 -17
- package/dist/device/lock.js.map +1 -1
- package/dist/device/meter.d.ts.map +1 -1
- package/dist/device/meter.js +37 -18
- package/dist/device/meter.js.map +1 -1
- package/dist/device/meterplus.d.ts.map +1 -1
- package/dist/device/meterplus.js +37 -18
- package/dist/device/meterplus.js.map +1 -1
- package/dist/device/motion.d.ts.map +1 -1
- package/dist/device/motion.js +35 -16
- package/dist/device/motion.js.map +1 -1
- package/dist/device/plug.d.ts.map +1 -1
- package/dist/device/plug.js +36 -17
- package/dist/device/plug.js.map +1 -1
- package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
- package/dist/device/robotvacuumcleaner.js +35 -16
- package/dist/device/robotvacuumcleaner.js.map +1 -1
- package/dist/device/waterdetector.d.ts.map +1 -1
- package/dist/device/waterdetector.js +35 -16
- 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.map +1 -1
- package/dist/platform.js +11 -2
- package/dist/platform.js.map +1 -1
- package/dist/types/bledevicestatus.d.ts +1 -0
- package/dist/types/bledevicestatus.d.ts.map +1 -1
- package/dist/utils.d.ts +8 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +16 -0
- package/dist/utils.js.map +1 -1
- package/package.json +6 -6
- package/src/device/blindtilt.ts +32 -17
- package/src/device/bot.ts +179 -406
- package/src/device/ceilinglight.ts +53 -33
- package/src/device/colorbulb.ts +55 -31
- package/src/device/contact.ts +32 -19
- package/src/device/curtain.ts +7 -6
- package/src/device/device.ts +36 -3
- package/src/device/fan.ts +32 -19
- package/src/device/hub.ts +34 -18
- package/src/device/humidifier.ts +36 -20
- package/src/device/iosensor.ts +34 -18
- package/src/device/lightstrip.ts +56 -33
- package/src/device/lock.ts +33 -17
- package/src/device/meter.ts +34 -18
- package/src/device/meterplus.ts +34 -18
- package/src/device/motion.ts +32 -16
- package/src/device/plug.ts +33 -17
- package/src/device/robotvacuumcleaner.ts +32 -16
- package/src/device/waterdetector.ts +32 -16
- package/src/irdevice/other.ts +214 -283
- package/src/platform.ts +11 -2
- package/src/types/bledevicestatus.ts +1 -0
- package/src/utils.ts +15 -0
|
@@ -261,25 +261,41 @@ export class RobotVacuumCleaner extends deviceBase {
|
|
|
261
261
|
|
|
262
262
|
async BLERefreshStatus(): Promise<void> {
|
|
263
263
|
await this.debugLog('BLERefreshStatus');
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
await this.
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
const serviceData = await this.monitorAdvertisementPackets(switchbot) as unknown as robotVacuumCleanerServiceData;
|
|
273
|
-
// Update HomeKit
|
|
274
|
-
if (serviceData.model === SwitchBotBLEModel.Unknown && serviceData.modelName === SwitchBotBLEModelName.Unknown) {
|
|
275
|
-
this.serviceData = serviceData;
|
|
264
|
+
if (this.config.options?.BLE) {
|
|
265
|
+
await this.debugLog('is listening to Platform BLE.');
|
|
266
|
+
this.device.bleMac = this.device.deviceId!.match(/.{1,2}/g)!.join(':').toLowerCase();
|
|
267
|
+
await this.debugLog(`bleMac: ${this.device.bleMac}`);
|
|
268
|
+
this.platform.bleEventHandler[this.device.bleMac] = async (context: robotVacuumCleanerServiceData) => {
|
|
269
|
+
try {
|
|
270
|
+
await this.debugLog(`received BLE: ${JSON.stringify(context)}`);
|
|
271
|
+
this.serviceData = context;
|
|
276
272
|
await this.BLEparseStatus();
|
|
277
273
|
await this.updateHomeKitCharacteristics();
|
|
278
|
-
}
|
|
279
|
-
await this.errorLog(`failed to
|
|
280
|
-
await this.BLERefreshConnection(switchbot);
|
|
274
|
+
} catch (e: any) {
|
|
275
|
+
await this.errorLog(`failed to handle BLE. Received: ${JSON.stringify(context)} Error: ${e}`);
|
|
281
276
|
}
|
|
282
|
-
}
|
|
277
|
+
};
|
|
278
|
+
} else {
|
|
279
|
+
await this.debugLog('is using Device BLE Scanning.');
|
|
280
|
+
const switchbot = await this.switchbotBLE();
|
|
281
|
+
if (switchbot === undefined) {
|
|
282
|
+
await this.BLERefreshConnection(switchbot);
|
|
283
|
+
} else {
|
|
284
|
+
// Start to monitor advertisement packets
|
|
285
|
+
(async () => {
|
|
286
|
+
// Start to monitor advertisement packets
|
|
287
|
+
const serviceData = await this.monitorAdvertisementPackets(switchbot) as unknown as robotVacuumCleanerServiceData;
|
|
288
|
+
// Update HomeKit
|
|
289
|
+
if (serviceData.model === SwitchBotBLEModel.Unknown && serviceData.modelName === SwitchBotBLEModelName.Unknown) {
|
|
290
|
+
this.serviceData = serviceData;
|
|
291
|
+
await this.BLEparseStatus();
|
|
292
|
+
await this.updateHomeKitCharacteristics();
|
|
293
|
+
} else {
|
|
294
|
+
await this.errorLog(`failed to get serviceData, serviceData: ${serviceData}`);
|
|
295
|
+
await this.BLERefreshConnection(switchbot);
|
|
296
|
+
}
|
|
297
|
+
})();
|
|
298
|
+
}
|
|
283
299
|
}
|
|
284
300
|
}
|
|
285
301
|
|
|
@@ -246,25 +246,41 @@ export class WaterDetector extends deviceBase {
|
|
|
246
246
|
|
|
247
247
|
async BLERefreshStatus(): Promise<void> {
|
|
248
248
|
await this.debugLog('BLERefreshStatus');
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
await this.
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
const serviceData = await this.monitorAdvertisementPackets(switchbot) as waterLeakDetectorServiceData;
|
|
258
|
-
// Update HomeKit
|
|
259
|
-
if (serviceData.model === SwitchBotBLEModel.Unknown && serviceData.modelName === SwitchBotBLEModelName.Unknown) {
|
|
260
|
-
this.serviceData = serviceData;
|
|
249
|
+
if (this.config.options?.BLE) {
|
|
250
|
+
await this.debugLog('is listening to Platform BLE.');
|
|
251
|
+
this.device.bleMac = this.device.deviceId!.match(/.{1,2}/g)!.join(':').toLowerCase();
|
|
252
|
+
await this.debugLog(`bleMac: ${this.device.bleMac}`);
|
|
253
|
+
this.platform.bleEventHandler[this.device.bleMac] = async (context: waterLeakDetectorServiceData) => {
|
|
254
|
+
try {
|
|
255
|
+
await this.debugLog(`received BLE: ${JSON.stringify(context)}`);
|
|
256
|
+
this.serviceData = context;
|
|
261
257
|
await this.BLEparseStatus();
|
|
262
258
|
await this.updateHomeKitCharacteristics();
|
|
263
|
-
}
|
|
264
|
-
await this.errorLog(`failed to
|
|
265
|
-
await this.BLERefreshConnection(switchbot);
|
|
259
|
+
} catch (e: any) {
|
|
260
|
+
await this.errorLog(`failed to handle BLE. Received: ${JSON.stringify(context)} Error: ${e}`);
|
|
266
261
|
}
|
|
267
|
-
}
|
|
262
|
+
};
|
|
263
|
+
} else {
|
|
264
|
+
await this.debugLog('is using Device BLE Scanning.');
|
|
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
|
+
}
|
|
268
284
|
}
|
|
269
285
|
}
|
|
270
286
|
|