@switchbot/homebridge-switchbot 3.8.3-beta.30 → 3.8.3-beta.32
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/.github/workflows/release.yml +1 -1
- package/CHANGELOG.md +2 -1
- package/config.schema.json +24 -0
- package/dist/device/blindtilt.d.ts.map +1 -1
- package/dist/device/blindtilt.js +26 -23
- package/dist/device/blindtilt.js.map +1 -1
- package/dist/device/bot.d.ts.map +1 -1
- package/dist/device/bot.js +30 -22
- package/dist/device/bot.js.map +1 -1
- package/dist/device/ceilinglight.d.ts.map +1 -1
- package/dist/device/ceilinglight.js +18 -17
- package/dist/device/ceilinglight.js.map +1 -1
- package/dist/device/colorbulb.d.ts.map +1 -1
- package/dist/device/colorbulb.js +35 -32
- package/dist/device/colorbulb.js.map +1 -1
- package/dist/device/contact.js +11 -11
- package/dist/device/contact.js.map +1 -1
- package/dist/device/curtain.d.ts.map +1 -1
- package/dist/device/curtain.js +21 -20
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/device.js +8 -8
- package/dist/device/device.js.map +1 -1
- package/dist/device/fan.d.ts.map +1 -1
- package/dist/device/fan.js +18 -17
- package/dist/device/fan.js.map +1 -1
- package/dist/device/hub.js +11 -11
- package/dist/device/hub.js.map +1 -1
- package/dist/device/humidifier.d.ts.map +1 -1
- package/dist/device/humidifier.js +17 -16
- package/dist/device/humidifier.js.map +1 -1
- package/dist/device/iosensor.js +11 -11
- package/dist/device/iosensor.js.map +1 -1
- package/dist/device/lightstrip.d.ts.map +1 -1
- package/dist/device/lightstrip.js +26 -25
- package/dist/device/lightstrip.js.map +1 -1
- package/dist/device/lock.d.ts.map +1 -1
- package/dist/device/lock.js +16 -16
- package/dist/device/lock.js.map +1 -1
- package/dist/device/meter.js +11 -11
- package/dist/device/meter.js.map +1 -1
- package/dist/device/meterplus.js +11 -11
- package/dist/device/meterplus.js.map +1 -1
- package/dist/device/motion.js +11 -11
- package/dist/device/motion.js.map +1 -1
- package/dist/device/plug.d.ts.map +1 -1
- package/dist/device/plug.js +18 -17
- package/dist/device/plug.js.map +1 -1
- package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
- package/dist/device/robotvacuumcleaner.js +18 -17
- package/dist/device/robotvacuumcleaner.js.map +1 -1
- package/dist/device/waterdetector.js +11 -11
- package/dist/device/waterdetector.js.map +1 -1
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +80 -76
- package/dist/platform.js.map +1 -1
- package/dist/settings.d.ts +3 -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 +29 -26
- package/src/device/bot.ts +34 -26
- package/src/device/ceilinglight.ts +20 -19
- package/src/device/colorbulb.ts +40 -37
- package/src/device/contact.ts +11 -11
- package/src/device/curtain.ts +25 -23
- package/src/device/device.ts +8 -8
- package/src/device/fan.ts +20 -19
- package/src/device/hub.ts +11 -11
- package/src/device/humidifier.ts +19 -18
- package/src/device/iosensor.ts +11 -11
- package/src/device/lightstrip.ts +30 -29
- package/src/device/lock.ts +18 -18
- package/src/device/meter.ts +11 -11
- package/src/device/meterplus.ts +11 -11
- package/src/device/motion.ts +11 -11
- package/src/device/plug.ts +20 -19
- package/src/device/robotvacuumcleaner.ts +20 -19
- package/src/device/waterdetector.ts +11 -11
- package/src/platform.ts +82 -78
- package/src/settings.ts +3 -0
package/dist/platform.js
CHANGED
|
@@ -91,41 +91,43 @@ export class SwitchBotPlatform {
|
|
|
91
91
|
this.debugLog('Config OK');
|
|
92
92
|
}
|
|
93
93
|
catch (e) {
|
|
94
|
-
this.errorLog(`Verify Config, Error Message: ${e.message}, Submit Bugs Here: ` + 'https://tinyurl.com/SwitchBotBug');
|
|
95
|
-
this.debugErrorLog(`Verify Config, Error: ${e}`);
|
|
94
|
+
this.errorLog(`Verify Config, Error Message: ${e.message ?? e}, Submit Bugs Here: ` + 'https://tinyurl.com/SwitchBotBug');
|
|
95
|
+
this.debugErrorLog(`Verify Config, Error: ${e.message ?? e}`);
|
|
96
96
|
return;
|
|
97
97
|
}
|
|
98
98
|
// SwitchBot OpenAPI
|
|
99
99
|
this.switchBotAPI = new SwitchBotOpenAPI(this.config.credentials?.token, this.config.credentials?.secret);
|
|
100
100
|
// Listen for log events
|
|
101
|
-
this.
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
101
|
+
if (!this.config.options?.disableLogsforOpenAPI) {
|
|
102
|
+
this.switchBotAPI.on('log', (log) => {
|
|
103
|
+
switch (log.level) {
|
|
104
|
+
case LogLevel.SUCCESS:
|
|
105
|
+
this.successLog(log.message);
|
|
106
|
+
break;
|
|
107
|
+
case LogLevel.DEBUGSUCCESS:
|
|
108
|
+
this.debugSuccessLog(log.message);
|
|
109
|
+
break;
|
|
110
|
+
case LogLevel.WARN:
|
|
111
|
+
this.warnLog(log.message);
|
|
112
|
+
break;
|
|
113
|
+
case LogLevel.DEBUGWARN:
|
|
114
|
+
this.debugWarnLog(log.message);
|
|
115
|
+
break;
|
|
116
|
+
case LogLevel.ERROR:
|
|
117
|
+
this.errorLog(log.message);
|
|
118
|
+
break;
|
|
119
|
+
case LogLevel.DEBUGERROR:
|
|
120
|
+
this.debugErrorLog(log.message);
|
|
121
|
+
break;
|
|
122
|
+
case LogLevel.DEBUG:
|
|
123
|
+
this.debugLog(log.message);
|
|
124
|
+
break;
|
|
125
|
+
case LogLevel.INFO:
|
|
126
|
+
default:
|
|
127
|
+
this.infoLog(log.message);
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
}
|
|
129
131
|
// import fakegato-history module and EVE characteristics
|
|
130
132
|
this.fakegatoAPI = fakegato(api);
|
|
131
133
|
this.eve = new EveHomeKitTypes(api);
|
|
@@ -148,27 +150,27 @@ export class SwitchBotPlatform {
|
|
|
148
150
|
}
|
|
149
151
|
}
|
|
150
152
|
catch (e) {
|
|
151
|
-
await this.errorLog(`Failed to Discover, Error Message: ${e.message}, Submit Bugs Here: ` + 'https://tinyurl.com/SwitchBotBug');
|
|
152
|
-
await this.debugErrorLog(`Failed to Discover, Error: ${e}`);
|
|
153
|
+
await this.errorLog(`Failed to Discover, Error Message: ${e.message ?? e}, Submit Bugs Here: ` + 'https://tinyurl.com/SwitchBotBug');
|
|
154
|
+
await this.debugErrorLog(`Failed to Discover, Error: ${e.message ?? e}`);
|
|
153
155
|
}
|
|
154
156
|
});
|
|
155
157
|
try {
|
|
156
158
|
this.setupMqtt();
|
|
157
159
|
}
|
|
158
160
|
catch (e) {
|
|
159
|
-
this.errorLog(`Setup MQTT, Error Message: ${e.message}, Submit Bugs Here: ` + 'https://tinyurl.com/SwitchBotBug');
|
|
161
|
+
this.errorLog(`Setup MQTT, Error Message: ${e.message ?? e}, Submit Bugs Here: ` + 'https://tinyurl.com/SwitchBotBug');
|
|
160
162
|
}
|
|
161
163
|
try {
|
|
162
164
|
this.setupwebhook();
|
|
163
165
|
}
|
|
164
166
|
catch (e) {
|
|
165
|
-
this.errorLog(`Setup Webhook, Error Message: ${e.message}, Submit Bugs Here: ` + 'https://tinyurl.com/SwitchBotBug');
|
|
167
|
+
this.errorLog(`Setup Webhook, Error Message: ${e.message ?? e}, Submit Bugs Here: ` + 'https://tinyurl.com/SwitchBotBug');
|
|
166
168
|
}
|
|
167
169
|
try {
|
|
168
170
|
this.setupBlE();
|
|
169
171
|
}
|
|
170
172
|
catch (e) {
|
|
171
|
-
this.errorLog(`Setup Platform BLE, Error Message: ${e.message}, Submit Bugs Here: ` + 'https://tinyurl.com/SwitchBotBug');
|
|
173
|
+
this.errorLog(`Setup Platform BLE, Error Message: ${e.message ?? e}, Submit Bugs Here: ` + 'https://tinyurl.com/SwitchBotBug');
|
|
172
174
|
}
|
|
173
175
|
}
|
|
174
176
|
async setupMqtt() {
|
|
@@ -178,7 +180,7 @@ export class SwitchBotPlatform {
|
|
|
178
180
|
this.mqttClient = await connectAsync(this.config.options?.mqttURL, this.config.options.mqttOptions || {});
|
|
179
181
|
await this.debugLog('MQTT connection has been established successfully.');
|
|
180
182
|
this.mqttClient.on('error', async (e) => {
|
|
181
|
-
await this.errorLog(`Failed to publish MQTT messages. ${e}`);
|
|
183
|
+
await this.errorLog(`Failed to publish MQTT messages. ${e.message ?? e}`);
|
|
182
184
|
});
|
|
183
185
|
if (!this.config.options?.webhookURL) {
|
|
184
186
|
// receive webhook events via MQTT
|
|
@@ -191,14 +193,14 @@ export class SwitchBotPlatform {
|
|
|
191
193
|
this.webhookEventHandler[context.deviceMac]?.(context);
|
|
192
194
|
}
|
|
193
195
|
catch (e) {
|
|
194
|
-
await this.errorLog(`Failed to handle webhook event. Error:${e}`);
|
|
196
|
+
await this.errorLog(`Failed to handle webhook event. Error:${e.message ?? e}`);
|
|
195
197
|
}
|
|
196
198
|
});
|
|
197
199
|
}
|
|
198
200
|
}
|
|
199
201
|
catch (e) {
|
|
200
202
|
this.mqttClient = null;
|
|
201
|
-
await this.errorLog(`Failed to establish MQTT connection. ${e}`);
|
|
203
|
+
await this.errorLog(`Failed to establish MQTT connection. ${e.message ?? e}`);
|
|
202
204
|
}
|
|
203
205
|
}
|
|
204
206
|
}
|
|
@@ -219,14 +221,14 @@ export class SwitchBotPlatform {
|
|
|
219
221
|
});
|
|
220
222
|
}
|
|
221
223
|
catch (e) {
|
|
222
|
-
await this.errorLog(`Failed to setup webhook. Error:${e.message}`);
|
|
224
|
+
await this.errorLog(`Failed to setup webhook. Error:${e.message ?? e}`);
|
|
223
225
|
}
|
|
224
226
|
this.api.on('shutdown', async () => {
|
|
225
227
|
try {
|
|
226
228
|
this.switchBotAPI.deleteWebhook(url);
|
|
227
229
|
}
|
|
228
230
|
catch (e) {
|
|
229
|
-
await this.errorLog(`Failed to delete webhook. Error:${e.message}`);
|
|
231
|
+
await this.errorLog(`Failed to delete webhook. Error:${e.message ?? e}`);
|
|
230
232
|
}
|
|
231
233
|
});
|
|
232
234
|
}
|
|
@@ -234,38 +236,40 @@ export class SwitchBotPlatform {
|
|
|
234
236
|
async setupBlE() {
|
|
235
237
|
this.switchBotBLE = new SwitchBotBLE();
|
|
236
238
|
// Listen for log events
|
|
237
|
-
this.
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
239
|
+
if (!this.config.options?.disableLogsforBLE) {
|
|
240
|
+
this.switchBotBLE.on('log', (log) => {
|
|
241
|
+
switch (log.level) {
|
|
242
|
+
case LogLevel.SUCCESS:
|
|
243
|
+
this.successLog(log.message);
|
|
244
|
+
break;
|
|
245
|
+
case LogLevel.DEBUGSUCCESS:
|
|
246
|
+
this.debugSuccessLog(log.message);
|
|
247
|
+
break;
|
|
248
|
+
case LogLevel.WARN:
|
|
249
|
+
this.warnLog(log.message);
|
|
250
|
+
break;
|
|
251
|
+
case LogLevel.DEBUGWARN:
|
|
252
|
+
this.debugWarnLog(log.message);
|
|
253
|
+
break;
|
|
254
|
+
case LogLevel.ERROR:
|
|
255
|
+
this.errorLog(log.message);
|
|
256
|
+
break;
|
|
257
|
+
case LogLevel.DEBUGERROR:
|
|
258
|
+
this.debugErrorLog(log.message);
|
|
259
|
+
break;
|
|
260
|
+
case LogLevel.DEBUG:
|
|
261
|
+
this.debugLog(log.message);
|
|
262
|
+
break;
|
|
263
|
+
case LogLevel.INFO:
|
|
264
|
+
default:
|
|
265
|
+
this.infoLog(log.message);
|
|
266
|
+
}
|
|
267
|
+
});
|
|
268
|
+
}
|
|
265
269
|
if (this.config.options?.BLE) {
|
|
266
270
|
await this.debugLog('setupBLE');
|
|
267
271
|
if (this.switchBotBLE === undefined) {
|
|
268
|
-
await this.errorLog(`wasn't able to establish BLE Connection, node-switchbot: ${this.switchBotBLE}`);
|
|
272
|
+
await this.errorLog(`wasn't able to establish BLE Connection, node-switchbot: ${JSON.stringify(this.switchBotBLE)}`);
|
|
269
273
|
}
|
|
270
274
|
else {
|
|
271
275
|
// Start to monitor advertisement packets
|
|
@@ -276,7 +280,7 @@ export class SwitchBotPlatform {
|
|
|
276
280
|
await this.switchBotBLE.startScan();
|
|
277
281
|
}
|
|
278
282
|
catch (e) {
|
|
279
|
-
await this.errorLog(`Failed to start BLE scanning. Error:${e}`);
|
|
283
|
+
await this.errorLog(`Failed to start BLE scanning. Error:${e.message ?? e}`);
|
|
280
284
|
}
|
|
281
285
|
// Set an event handler to monitor advertisement packets
|
|
282
286
|
this.switchBotBLE.onadvertisement = async (ad) => {
|
|
@@ -284,17 +288,17 @@ export class SwitchBotPlatform {
|
|
|
284
288
|
this.bleEventHandler[ad.address]?.(ad.serviceData);
|
|
285
289
|
}
|
|
286
290
|
catch (e) {
|
|
287
|
-
await this.errorLog(`Failed to handle BLE event. Error:${e}`);
|
|
291
|
+
await this.errorLog(`Failed to handle BLE event. Error:${e.message ?? e}`);
|
|
288
292
|
}
|
|
289
293
|
};
|
|
290
294
|
})();
|
|
291
295
|
this.api.on('shutdown', async () => {
|
|
292
296
|
try {
|
|
293
|
-
this.switchBotBLE.stopScan()
|
|
297
|
+
// this.switchBotBLE.stopScan()
|
|
294
298
|
await this.infoLog('Stopped BLE scanning to close listening.');
|
|
295
299
|
}
|
|
296
300
|
catch (e) {
|
|
297
|
-
await this.errorLog(`Failed to stop Platform BLE scanning. Error:${e.message}`);
|
|
301
|
+
await this.errorLog(`Failed to stop Platform BLE scanning. Error:${e.message ?? e}`);
|
|
298
302
|
}
|
|
299
303
|
});
|
|
300
304
|
}
|
|
@@ -449,7 +453,7 @@ export class SwitchBotPlatform {
|
|
|
449
453
|
await this.verifyConfig();
|
|
450
454
|
}
|
|
451
455
|
catch (e) {
|
|
452
|
-
await this.errorLog(`Update Token: ${e}`);
|
|
456
|
+
await this.errorLog(`Update Token: ${e.message ?? e}`);
|
|
453
457
|
}
|
|
454
458
|
}
|
|
455
459
|
async discoverDevices() {
|
|
@@ -479,7 +483,7 @@ export class SwitchBotPlatform {
|
|
|
479
483
|
catch (e) {
|
|
480
484
|
retryCount++;
|
|
481
485
|
await this.debugErrorLog(`Failed to Discover Devices, Error Message: ${JSON.stringify(e.message)}, Submit Bugs Here: https://tinyurl.com/SwitchBotBug`);
|
|
482
|
-
await this.debugErrorLog(`Failed to Discover Devices, Error: ${e}`);
|
|
486
|
+
await this.debugErrorLog(`Failed to Discover Devices, Error: ${e.message ?? e}`);
|
|
483
487
|
}
|
|
484
488
|
}
|
|
485
489
|
}
|
|
@@ -2498,7 +2502,7 @@ export class SwitchBotPlatform {
|
|
|
2498
2502
|
return this.switchBotBLE;
|
|
2499
2503
|
}
|
|
2500
2504
|
catch (e) {
|
|
2501
|
-
await this.errorLog(`${device.deviceType}: ${accessory.displayName} 'node-switchbot' not found, Error: ${e}`);
|
|
2505
|
+
await this.errorLog(`${device.deviceType}: ${accessory.displayName} 'node-switchbot' not found, Error: ${e.message ?? e}`);
|
|
2502
2506
|
return false;
|
|
2503
2507
|
}
|
|
2504
2508
|
}
|