@switchbot/homebridge-switchbot 3.7.1-beta.2 → 3.7.1-beta.4
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 +8 -0
- package/dist/device/blindtilt.d.ts +3 -1
- package/dist/device/blindtilt.d.ts.map +1 -1
- package/dist/device/blindtilt.js +61 -28
- 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 +53 -28
- 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 +53 -28
- 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 +53 -28
- 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 +53 -28
- 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 +74 -43
- 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 +53 -28
- 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 +53 -28
- 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 +53 -28
- 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 +53 -28
- 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 +53 -28
- 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 +54 -29
- 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 +53 -28
- 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 +53 -28
- 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 +53 -28
- 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 +54 -29
- 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 +53 -28
- 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 +53 -28
- package/dist/device/waterdetector.js.map +1 -1
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +22 -3
- package/dist/platform.js.map +1 -1
- package/package.json +7 -7
- package/src/device/blindtilt.ts +59 -27
- package/src/device/bot.ts +50 -26
- package/src/device/ceilinglight.ts +51 -27
- package/src/device/colorbulb.ts +50 -26
- package/src/device/contact.ts +50 -26
- package/src/device/curtain.ts +71 -40
- package/src/device/fan.ts +50 -26
- package/src/device/hub.ts +50 -26
- package/src/device/humidifier.ts +50 -26
- package/src/device/iosensor.ts +50 -26
- package/src/device/lightstrip.ts +50 -26
- package/src/device/lock.ts +51 -27
- package/src/device/meter.ts +50 -26
- package/src/device/meterplus.ts +50 -26
- package/src/device/motion.ts +50 -26
- package/src/device/plug.ts +51 -27
- package/src/device/robotvacuumcleaner.ts +50 -26
- package/src/device/waterdetector.ts +50 -26
- package/src/platform.ts +19 -3
|
@@ -3,6 +3,10 @@
|
|
|
3
3
|
* robotvacuumcleaner.ts: @switchbot/homebridge-switchbot.
|
|
4
4
|
*/
|
|
5
5
|
import { deviceBase } from './device.js';
|
|
6
|
+
/*
|
|
7
|
+
* For Testing Locally:
|
|
8
|
+
* import { SwitchBotBLEModel, SwitchBotBLEModelName } from '/Users/Shared/GitHub/OpenWonderLabs/node-switchbot/dist/index.js';
|
|
9
|
+
*/
|
|
6
10
|
import { SwitchBotBLEModel, SwitchBotBLEModelName } from 'node-switchbot';
|
|
7
11
|
import { Subject, debounceTime, interval, skipWhile, take, tap } from 'rxjs';
|
|
8
12
|
|
|
@@ -127,12 +131,28 @@ export class RobotVacuumCleaner extends deviceBase {
|
|
|
127
131
|
});
|
|
128
132
|
|
|
129
133
|
// Retrieve initial values and updateHomekit
|
|
130
|
-
|
|
131
|
-
|
|
134
|
+
try {
|
|
135
|
+
this.debugLog('Retrieve initial values and update Homekit');
|
|
136
|
+
this.refreshStatus();
|
|
137
|
+
} catch (e: any) {
|
|
138
|
+
this.errorLog(`failed to retrieve initial values and update Homekit, Error: ${e}`);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
//regisiter webhook event handler if enabled
|
|
142
|
+
try {
|
|
143
|
+
this.debugLog('Registering Webhook Event Handler');
|
|
144
|
+
this.registerWebhook();
|
|
145
|
+
} catch (e: any) {
|
|
146
|
+
this.errorLog(`failed to registerWebhook, Error: ${e}`);
|
|
147
|
+
}
|
|
132
148
|
|
|
133
|
-
//regisiter
|
|
134
|
-
|
|
135
|
-
|
|
149
|
+
//regisiter platform BLE event handler if enabled
|
|
150
|
+
try {
|
|
151
|
+
this.debugLog('Registering Platform BLE Event Handler');
|
|
152
|
+
this.registerPlatformBLE();
|
|
153
|
+
} catch (e: any) {
|
|
154
|
+
this.errorLog(`failed to registerPlatformBLE, Error: ${e}`);
|
|
155
|
+
}
|
|
136
156
|
|
|
137
157
|
// Start an update interval
|
|
138
158
|
interval(this.deviceRefreshRate * 1000)
|
|
@@ -249,7 +269,7 @@ export class RobotVacuumCleaner extends deviceBase {
|
|
|
249
269
|
async refreshStatus(): Promise<void> {
|
|
250
270
|
if (!this.device.enableCloudService && this.OpenAPI) {
|
|
251
271
|
await this.errorLog(`refreshStatus enableCloudService: ${this.device.enableCloudService}`);
|
|
252
|
-
} else if (this.BLE
|
|
272
|
+
} else if (this.BLE) {
|
|
253
273
|
await this.BLERefreshStatus();
|
|
254
274
|
} else if (this.OpenAPI && this.platform.config.credentials?.token) {
|
|
255
275
|
await this.openAPIRefreshStatus();
|
|
@@ -261,6 +281,29 @@ export class RobotVacuumCleaner extends deviceBase {
|
|
|
261
281
|
|
|
262
282
|
async BLERefreshStatus(): Promise<void> {
|
|
263
283
|
await this.debugLog('BLERefreshStatus');
|
|
284
|
+
const switchbot = await this.switchbotBLE();
|
|
285
|
+
if (switchbot === undefined) {
|
|
286
|
+
await this.BLERefreshConnection(switchbot);
|
|
287
|
+
} else {
|
|
288
|
+
// Start to monitor advertisement packets
|
|
289
|
+
(async () => {
|
|
290
|
+
// Start to monitor advertisement packets
|
|
291
|
+
const serviceData = await this.monitorAdvertisementPackets(switchbot) as unknown as robotVacuumCleanerServiceData;
|
|
292
|
+
// Update HomeKit
|
|
293
|
+
if (serviceData.model === SwitchBotBLEModel.Unknown && serviceData.modelName === SwitchBotBLEModelName.Unknown) {
|
|
294
|
+
this.serviceData = serviceData;
|
|
295
|
+
await this.BLEparseStatus();
|
|
296
|
+
await this.updateHomeKitCharacteristics();
|
|
297
|
+
} else {
|
|
298
|
+
await this.errorLog(`failed to get serviceData, serviceData: ${serviceData}`);
|
|
299
|
+
await this.BLERefreshConnection(switchbot);
|
|
300
|
+
}
|
|
301
|
+
})();
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
async registerPlatformBLE(): Promise<void> {
|
|
306
|
+
await this.debugLog('registerPlatformBLE');
|
|
264
307
|
if (this.config.options?.BLE) {
|
|
265
308
|
await this.debugLog('is listening to Platform BLE.');
|
|
266
309
|
this.device.bleMac = this.device.deviceId!.match(/.{1,2}/g)!.join(':').toLowerCase();
|
|
@@ -276,26 +319,7 @@ export class RobotVacuumCleaner extends deviceBase {
|
|
|
276
319
|
}
|
|
277
320
|
};
|
|
278
321
|
} else {
|
|
279
|
-
await this.debugLog('is
|
|
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
|
-
}
|
|
322
|
+
await this.debugLog('is not listening to Platform BLE');
|
|
299
323
|
}
|
|
300
324
|
}
|
|
301
325
|
|
|
@@ -4,6 +4,10 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { deviceBase } from './device.js';
|
|
6
6
|
import { Subject, interval, skipWhile } from 'rxjs';
|
|
7
|
+
/*
|
|
8
|
+
* For Testing Locally:
|
|
9
|
+
* import { SwitchBotBLEModel, SwitchBotBLEModelName } from '/Users/Shared/GitHub/OpenWonderLabs/node-switchbot/dist/index.js';
|
|
10
|
+
*/
|
|
7
11
|
import { SwitchBotBLEModel, SwitchBotBLEModelName } from 'node-switchbot';
|
|
8
12
|
|
|
9
13
|
import type { devicesConfig } from '../settings.js';
|
|
@@ -118,12 +122,28 @@ export class WaterDetector extends deviceBase {
|
|
|
118
122
|
}
|
|
119
123
|
|
|
120
124
|
// Retrieve initial values and updateHomekit
|
|
121
|
-
|
|
122
|
-
|
|
125
|
+
try {
|
|
126
|
+
this.debugLog('Retrieve initial values and update Homekit');
|
|
127
|
+
this.refreshStatus();
|
|
128
|
+
} catch (e: any) {
|
|
129
|
+
this.errorLog(`failed to retrieve initial values and update Homekit, Error: ${e}`);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
//regisiter webhook event handler if enabled
|
|
133
|
+
try {
|
|
134
|
+
this.debugLog('Registering Webhook Event Handler');
|
|
135
|
+
this.registerWebhook();
|
|
136
|
+
} catch (e: any) {
|
|
137
|
+
this.errorLog(`failed to registerWebhook, Error: ${e}`);
|
|
138
|
+
}
|
|
123
139
|
|
|
124
|
-
//regisiter
|
|
125
|
-
|
|
126
|
-
|
|
140
|
+
//regisiter platform BLE event handler if enabled
|
|
141
|
+
try {
|
|
142
|
+
this.debugLog('Registering Platform BLE Event Handler');
|
|
143
|
+
this.registerPlatformBLE();
|
|
144
|
+
} catch (e: any) {
|
|
145
|
+
this.errorLog(`failed to registerPlatformBLE, Error: ${e}`);
|
|
146
|
+
}
|
|
127
147
|
|
|
128
148
|
// Start an update interval
|
|
129
149
|
interval(this.deviceRefreshRate * 1000)
|
|
@@ -234,7 +254,7 @@ export class WaterDetector extends deviceBase {
|
|
|
234
254
|
async refreshStatus(): Promise<void> {
|
|
235
255
|
if (!this.device.enableCloudService && this.OpenAPI) {
|
|
236
256
|
await this.errorLog(`refreshStatus enableCloudService: ${this.device.enableCloudService}`);
|
|
237
|
-
} else if (this.BLE
|
|
257
|
+
} else if (this.BLE) {
|
|
238
258
|
await this.BLERefreshStatus();
|
|
239
259
|
} else if (this.OpenAPI && this.platform.config.credentials?.token) {
|
|
240
260
|
await this.openAPIRefreshStatus();
|
|
@@ -246,6 +266,29 @@ export class WaterDetector extends deviceBase {
|
|
|
246
266
|
|
|
247
267
|
async BLERefreshStatus(): Promise<void> {
|
|
248
268
|
await this.debugLog('BLERefreshStatus');
|
|
269
|
+
const switchbot = await this.switchbotBLE();
|
|
270
|
+
if (switchbot === undefined) {
|
|
271
|
+
await this.BLERefreshConnection(switchbot);
|
|
272
|
+
} else {
|
|
273
|
+
// Start to monitor advertisement packets
|
|
274
|
+
(async () => {
|
|
275
|
+
// Start to monitor advertisement packets
|
|
276
|
+
const serviceData = await this.monitorAdvertisementPackets(switchbot) as waterLeakDetectorServiceData;
|
|
277
|
+
// Update HomeKit
|
|
278
|
+
if (serviceData.model === SwitchBotBLEModel.Unknown && serviceData.modelName === SwitchBotBLEModelName.Unknown) {
|
|
279
|
+
this.serviceData = serviceData;
|
|
280
|
+
await this.BLEparseStatus();
|
|
281
|
+
await this.updateHomeKitCharacteristics();
|
|
282
|
+
} else {
|
|
283
|
+
await this.errorLog(`failed to get serviceData, serviceData: ${serviceData}`);
|
|
284
|
+
await this.BLERefreshConnection(switchbot);
|
|
285
|
+
}
|
|
286
|
+
})();
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
async registerPlatformBLE(): Promise<void> {
|
|
291
|
+
await this.debugLog('registerPlatformBLE');
|
|
249
292
|
if (this.config.options?.BLE) {
|
|
250
293
|
await this.debugLog('is listening to Platform BLE.');
|
|
251
294
|
this.device.bleMac = this.device.deviceId!.match(/.{1,2}/g)!.join(':').toLowerCase();
|
|
@@ -261,26 +304,7 @@ export class WaterDetector extends deviceBase {
|
|
|
261
304
|
}
|
|
262
305
|
};
|
|
263
306
|
} 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
|
-
}
|
|
307
|
+
await this.debugLog('is not listening to Platform BLE');
|
|
284
308
|
}
|
|
285
309
|
}
|
|
286
310
|
|
package/src/platform.ts
CHANGED
|
@@ -51,6 +51,10 @@ import type { blindTilt, curtain, curtain3, device } from './types/devicelist.js
|
|
|
51
51
|
import type { API, DynamicPlatformPlugin, Logging, PlatformAccessory } from 'homebridge';
|
|
52
52
|
import type { SwitchBotPlatformConfig, devicesConfig, irDevicesConfig } from './settings.js';
|
|
53
53
|
import type { IncomingMessage, Server, ServerResponse } from 'http';
|
|
54
|
+
/*
|
|
55
|
+
* For Testing Locally:
|
|
56
|
+
* import { SwitchBotModel } from '/Users/Shared/GitHub/OpenWonderLabs/node-switchbot/dist/index.js';
|
|
57
|
+
*/
|
|
54
58
|
import { SwitchBotModel } from 'node-switchbot';
|
|
55
59
|
|
|
56
60
|
/**
|
|
@@ -147,9 +151,21 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
147
151
|
}
|
|
148
152
|
});
|
|
149
153
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
154
|
+
try {
|
|
155
|
+
this.setupMqtt();
|
|
156
|
+
} catch (e: any) {
|
|
157
|
+
this.errorLog(`Setup MQTT, Error Message: ${e.message}, Submit Bugs Here: ` + 'https://tinyurl.com/SwitchBotBug');
|
|
158
|
+
}
|
|
159
|
+
try {
|
|
160
|
+
this.setupwebhook();
|
|
161
|
+
} catch (e: any) {
|
|
162
|
+
this.errorLog(`Setup Webhook, Error Message: ${e.message}, Submit Bugs Here: ` + 'https://tinyurl.com/SwitchBotBug');
|
|
163
|
+
}
|
|
164
|
+
try {
|
|
165
|
+
this.setupBlE();
|
|
166
|
+
} catch (e: any) {
|
|
167
|
+
this.errorLog(`Setup Platform BLE, Error Message: ${e.message}, Submit Bugs Here: ` + 'https://tinyurl.com/SwitchBotBug');
|
|
168
|
+
}
|
|
153
169
|
}
|
|
154
170
|
|
|
155
171
|
async setupMqtt(): Promise<void> {
|