@switchbot/homebridge-switchbot 3.5.1-beta.13 → 3.5.1-beta.14
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.js +1 -1
- package/dist/device/blindtilt.js.map +1 -1
- package/dist/device/bot.js +1 -1
- package/dist/device/bot.js.map +1 -1
- package/dist/device/ceilinglight.js +1 -1
- package/dist/device/ceilinglight.js.map +1 -1
- package/dist/device/colorbulb.js +1 -1
- package/dist/device/colorbulb.js.map +1 -1
- package/dist/device/contact.js +1 -1
- package/dist/device/contact.js.map +1 -1
- package/dist/device/curtain.js +1 -1
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/device.d.ts +0 -8
- package/dist/device/device.d.ts.map +1 -1
- package/dist/device/device.js +9 -195
- package/dist/device/device.js.map +1 -1
- package/dist/device/fan.js +1 -1
- package/dist/device/fan.js.map +1 -1
- package/dist/device/hub.js +1 -1
- package/dist/device/hub.js.map +1 -1
- package/dist/device/humidifier.js +1 -1
- package/dist/device/humidifier.js.map +1 -1
- package/dist/device/iosensor.js +1 -1
- package/dist/device/iosensor.js.map +1 -1
- package/dist/device/lightstrip.js +1 -1
- package/dist/device/lightstrip.js.map +1 -1
- package/dist/device/lock.js +1 -1
- package/dist/device/lock.js.map +1 -1
- package/dist/device/meter.js +1 -1
- package/dist/device/meter.js.map +1 -1
- package/dist/device/meterplus.js +1 -1
- package/dist/device/meterplus.js.map +1 -1
- package/dist/device/motion.js +1 -1
- package/dist/device/motion.js.map +1 -1
- package/dist/device/plug.js +1 -1
- package/dist/device/plug.js.map +1 -1
- package/dist/device/robotvacuumcleaner.js +1 -1
- package/dist/device/robotvacuumcleaner.js.map +1 -1
- package/dist/device/waterdetector.js +1 -1
- package/dist/device/waterdetector.js.map +1 -1
- package/dist/irdevice/irdevice.js +1 -1
- package/dist/irdevice/irdevice.js.map +1 -1
- package/dist/platform.d.ts +10 -1
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +175 -2
- package/dist/platform.js.map +1 -1
- package/package.json +1 -1
- package/src/device/blindtilt.ts +1 -1
- package/src/device/bot.ts +1 -1
- package/src/device/ceilinglight.ts +1 -1
- package/src/device/colorbulb.ts +1 -1
- package/src/device/contact.ts +1 -1
- package/src/device/curtain.ts +1 -1
- package/src/device/device.ts +9 -195
- package/src/device/fan.ts +1 -1
- package/src/device/hub.ts +1 -1
- package/src/device/humidifier.ts +1 -1
- package/src/device/iosensor.ts +1 -1
- package/src/device/lightstrip.ts +1 -1
- package/src/device/lock.ts +1 -1
- package/src/device/meter.ts +1 -1
- package/src/device/meterplus.ts +1 -1
- package/src/device/motion.ts +1 -1
- package/src/device/plug.ts +1 -1
- package/src/device/robotvacuumcleaner.ts +1 -1
- package/src/device/waterdetector.ts +1 -1
- package/src/irdevice/irdevice.ts +1 -1
- package/src/platform.ts +175 -2
package/dist/platform.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import type { UrlObject } from 'url';
|
|
2
|
+
import type { MqttClient } from 'mqtt';
|
|
2
3
|
import type { Dispatcher } from 'undici';
|
|
3
4
|
import type { blindTilt, curtain, curtain3, device } from './types/devicelist.js';
|
|
4
5
|
import type { API, DynamicPlatformPlugin, Logging, PlatformAccessory } from 'homebridge';
|
|
5
6
|
import type { SwitchBotPlatformConfig, devicesConfig, irDevicesConfig } from './settings.js';
|
|
7
|
+
import type { Server } from 'http';
|
|
6
8
|
/**
|
|
7
9
|
* HomebridgePlatform
|
|
8
10
|
* This class is the main constructor for your plugin, this is where you should
|
|
@@ -20,9 +22,16 @@ export declare class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
20
22
|
platformConfig: SwitchBotPlatformConfig['options'];
|
|
21
23
|
platformLogging: SwitchBotPlatformConfig['logging'];
|
|
22
24
|
config: SwitchBotPlatformConfig;
|
|
23
|
-
|
|
25
|
+
mqttClient: MqttClient | null;
|
|
26
|
+
webhookEventListener: Server | null;
|
|
24
27
|
readonly eve: any;
|
|
28
|
+
readonly fakegatoAPI: any;
|
|
29
|
+
readonly webhookEventHandler: {
|
|
30
|
+
[x: string]: (context: any) => void;
|
|
31
|
+
};
|
|
25
32
|
constructor(log: Logging, config: SwitchBotPlatformConfig, api: API);
|
|
33
|
+
setupMqtt(): Promise<void>;
|
|
34
|
+
setupwebhook(): Promise<void>;
|
|
26
35
|
/**
|
|
27
36
|
* This function is invoked when homebridge restores cached accessories from disk at startup.
|
|
28
37
|
* It should be used to setup event handlers for characteristics and update respective values.
|
package/dist/platform.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platform.d.ts","sourceRoot":"","sources":["../src/platform.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"platform.d.ts","sourceRoot":"","sources":["../src/platform.ts"],"names":[],"mappings":"AA6CA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,KAAK,CAAC;AACrC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AACvC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAEzC,OAAO,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAClF,OAAO,KAAK,EAAE,GAAG,EAAE,qBAAqB,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AACzF,OAAO,KAAK,EAAE,uBAAuB,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAC7F,OAAO,KAAK,EAAmB,MAAM,EAAkB,MAAM,MAAM,CAAC;AAEpE;;;;GAIG;AACH,qBAAa,iBAAkB,YAAW,qBAAqB;IACtD,WAAW,EAAE,iBAAiB,EAAE,CAAC;IACxC,SAAgB,GAAG,EAAE,GAAG,CAAC;IACzB,SAAgB,GAAG,EAAE,OAAO,CAAC;IAE7B,OAAO,EAAG,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE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AGG;IACG,OAAO,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAMrC,UAAU,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAMxC,eAAe,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAQ7C,OAAO,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAMrC,YAAY,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAQ1C,QAAQ,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAMtC,aAAa,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAQ3C,QAAQ,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAUtC,uBAAuB,IAAI,OAAO,CAAC,OAAO,CAAC;CAGlD"}
|
package/dist/platform.js
CHANGED
|
@@ -31,12 +31,14 @@ import { VacuumCleaner } from './irdevice/vacuumcleaner.js';
|
|
|
31
31
|
import { AirConditioner } from './irdevice/airconditioner.js';
|
|
32
32
|
import { Buffer } from 'buffer';
|
|
33
33
|
import { request } from 'undici';
|
|
34
|
+
import asyncmqtt from 'async-mqtt';
|
|
35
|
+
import { createServer } from 'http';
|
|
34
36
|
import { queueScheduler } from 'rxjs';
|
|
35
37
|
import fakegato from 'fakegato-history';
|
|
36
38
|
import crypto, { randomUUID } from 'crypto';
|
|
37
39
|
import { readFileSync, writeFileSync } from 'fs';
|
|
38
40
|
import { EveHomeKitTypes } from 'homebridge-lib/EveHomeKitTypes';
|
|
39
|
-
import { PLATFORM_NAME, PLUGIN_NAME, Devices } from './settings.js';
|
|
41
|
+
import { PLATFORM_NAME, PLUGIN_NAME, Devices, deleteWebhook, queryWebhook, setupWebhook, updateWebhook } from './settings.js';
|
|
40
42
|
import { isBlindTiltDevice, isCurtainDevice, sleep } from './utils.js';
|
|
41
43
|
/**
|
|
42
44
|
* HomebridgePlatform
|
|
@@ -55,8 +57,11 @@ export class SwitchBotPlatform {
|
|
|
55
57
|
platformConfig;
|
|
56
58
|
platformLogging;
|
|
57
59
|
config;
|
|
58
|
-
|
|
60
|
+
mqttClient = null;
|
|
61
|
+
webhookEventListener = null;
|
|
59
62
|
eve;
|
|
63
|
+
fakegatoAPI;
|
|
64
|
+
webhookEventHandler = {};
|
|
60
65
|
constructor(log, config, api) {
|
|
61
66
|
// initialize
|
|
62
67
|
this.accessories = [];
|
|
@@ -115,6 +120,174 @@ export class SwitchBotPlatform {
|
|
|
115
120
|
await this.debugErrorLog(`Failed to Discover, Error: ${e}`);
|
|
116
121
|
}
|
|
117
122
|
});
|
|
123
|
+
this.setupMqtt();
|
|
124
|
+
this.setupwebhook();
|
|
125
|
+
}
|
|
126
|
+
async setupMqtt() {
|
|
127
|
+
if (this.config.options?.mqttURL) {
|
|
128
|
+
try {
|
|
129
|
+
const { connectAsync } = asyncmqtt;
|
|
130
|
+
this.mqttClient = await connectAsync(this.config.options?.mqttURL, this.config.options.mqttOptions || {});
|
|
131
|
+
await this.debugLog('MQTT connection has been established successfully.');
|
|
132
|
+
this.mqttClient.on('error', async (e) => {
|
|
133
|
+
await this.errorLog(`Failed to publish MQTT messages. ${e}`);
|
|
134
|
+
});
|
|
135
|
+
if (!this.config.options?.webhookURL) {
|
|
136
|
+
// receive webhook events via MQTT
|
|
137
|
+
await this.infoLog(`Webhook is configured to be received through ${this.config.options.mqttURL}/homebridge-switchbot/webhook.`);
|
|
138
|
+
this.mqttClient.subscribe('homebridge-switchbot/webhook/+');
|
|
139
|
+
this.mqttClient.on('message', async (topic, message) => {
|
|
140
|
+
try {
|
|
141
|
+
await await this.debugLog(`Received Webhook via MQTT: ${topic}=${message}`);
|
|
142
|
+
const context = JSON.parse(message.toString());
|
|
143
|
+
this.webhookEventHandler[context.deviceMac]?.(context);
|
|
144
|
+
}
|
|
145
|
+
catch (e) {
|
|
146
|
+
await this.errorLog(`Failed to handle webhook event. Error:${e}`);
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
catch (e) {
|
|
152
|
+
this.mqttClient = null;
|
|
153
|
+
await this.errorLog(`Failed to establish MQTT connection. ${e}`);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
async setupwebhook() {
|
|
158
|
+
//webhook configuration
|
|
159
|
+
if (this.config.options?.webhookURL) {
|
|
160
|
+
const url = this.config.options?.webhookURL;
|
|
161
|
+
try {
|
|
162
|
+
const xurl = new URL(url);
|
|
163
|
+
const port = Number(xurl.port);
|
|
164
|
+
const path = xurl.pathname;
|
|
165
|
+
this.webhookEventListener = createServer((request, response) => {
|
|
166
|
+
try {
|
|
167
|
+
if (request.url === path && request.method === 'POST') {
|
|
168
|
+
request.on('data', async (data) => {
|
|
169
|
+
try {
|
|
170
|
+
const body = JSON.parse(data);
|
|
171
|
+
await this.debugLog(`Received Webhook: ${JSON.stringify(body)}`);
|
|
172
|
+
if (this.config.options?.mqttURL) {
|
|
173
|
+
const mac = body.context.deviceMac
|
|
174
|
+
?.toLowerCase()
|
|
175
|
+
.match(/[\s\S]{1,2}/g)
|
|
176
|
+
?.join(':');
|
|
177
|
+
const options = this.config.options?.mqttPubOptions || {};
|
|
178
|
+
this.mqttClient?.publish(`homebridge-switchbot/webhook/${mac}`, `${JSON.stringify(body.context)}`, options);
|
|
179
|
+
}
|
|
180
|
+
this.webhookEventHandler[body.context.deviceMac]?.(body.context);
|
|
181
|
+
}
|
|
182
|
+
catch (e) {
|
|
183
|
+
this.errorLog(`Failed to handle webhook event. Error:${e}`);
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
response.writeHead(200, { 'Content-Type': 'text/plain' });
|
|
187
|
+
response.end('OK');
|
|
188
|
+
}
|
|
189
|
+
// else {
|
|
190
|
+
// response.writeHead(403, {'Content-Type': 'text/plain'});
|
|
191
|
+
// response.end(`NG`);
|
|
192
|
+
// }
|
|
193
|
+
}
|
|
194
|
+
catch (e) {
|
|
195
|
+
this.errorLog(`Failed to handle webhook event. Error:${e}`);
|
|
196
|
+
}
|
|
197
|
+
}).listen(port ? port : 80);
|
|
198
|
+
}
|
|
199
|
+
catch (e) {
|
|
200
|
+
this.errorLog(`Failed to create webhook listener. Error:${e.message}`);
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
try {
|
|
204
|
+
const { body, statusCode } = await request(setupWebhook, {
|
|
205
|
+
method: 'POST',
|
|
206
|
+
headers: this.generateHeaders(),
|
|
207
|
+
body: JSON.stringify({
|
|
208
|
+
'action': 'setupWebhook',
|
|
209
|
+
'url': url,
|
|
210
|
+
'deviceList': 'ALL',
|
|
211
|
+
}),
|
|
212
|
+
});
|
|
213
|
+
const response = await body.json();
|
|
214
|
+
await this.debugLog(`setupWebhook: url:${url}`);
|
|
215
|
+
await this.debugLog(`setupWebhook: body:${JSON.stringify(response)}`);
|
|
216
|
+
await this.debugLog(`setupWebhook: statusCode:${statusCode}`);
|
|
217
|
+
if (statusCode !== 200 || response?.statusCode !== 100) {
|
|
218
|
+
this.errorLog(`Failed to configure webhook. Existing webhook well be overridden. HTTP:${statusCode} API:${response?.statusCode} `
|
|
219
|
+
+ `message:${response?.message}`);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
catch (e) {
|
|
223
|
+
this.errorLog(`Failed to configure webhook. Error: ${e.message}`);
|
|
224
|
+
}
|
|
225
|
+
try {
|
|
226
|
+
const { body, statusCode } = await request(updateWebhook, {
|
|
227
|
+
method: 'POST', headers: this.generateHeaders(), body: JSON.stringify({
|
|
228
|
+
'action': 'updateWebhook',
|
|
229
|
+
'config': {
|
|
230
|
+
'url': url,
|
|
231
|
+
'enable': true,
|
|
232
|
+
},
|
|
233
|
+
}),
|
|
234
|
+
});
|
|
235
|
+
const response = await body.json();
|
|
236
|
+
await this.debugLog(`updateWebhook: url:${url}`);
|
|
237
|
+
await this.debugLog(`updateWebhook: body:${JSON.stringify(response)}`);
|
|
238
|
+
await this.debugLog(`updateWebhook: statusCode:${statusCode}`);
|
|
239
|
+
if (statusCode !== 200 || response?.statusCode !== 100) {
|
|
240
|
+
this.errorLog(`Failed to update webhook. HTTP:${statusCode} API:${response?.statusCode} message:${response?.message}`);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
catch (e) {
|
|
244
|
+
this.errorLog(`Failed to update webhook. Error:${e.message}`);
|
|
245
|
+
}
|
|
246
|
+
try {
|
|
247
|
+
const { body, statusCode } = await request(queryWebhook, {
|
|
248
|
+
method: 'POST',
|
|
249
|
+
headers: this.generateHeaders(),
|
|
250
|
+
body: JSON.stringify({
|
|
251
|
+
'action': 'queryUrl',
|
|
252
|
+
}),
|
|
253
|
+
});
|
|
254
|
+
const response = await body.json();
|
|
255
|
+
await this.debugLog(`queryWebhook: body:${JSON.stringify(response)}`);
|
|
256
|
+
await this.debugLog(`queryWebhook: statusCode:${statusCode}`);
|
|
257
|
+
if (statusCode !== 200 || response?.statusCode !== 100) {
|
|
258
|
+
this.errorLog(`Failed to query webhook. HTTP:${statusCode} API:${response?.statusCode} message:${response?.message}`);
|
|
259
|
+
}
|
|
260
|
+
else {
|
|
261
|
+
this.infoLog(`Listening webhook on ${response?.body?.urls[0]}`);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
catch (e) {
|
|
265
|
+
this.errorLog(`Failed to query webhook. Error:${e}`);
|
|
266
|
+
}
|
|
267
|
+
this.api.on('shutdown', async () => {
|
|
268
|
+
try {
|
|
269
|
+
const { body, statusCode } = await request(deleteWebhook, {
|
|
270
|
+
method: 'POST',
|
|
271
|
+
headers: this.generateHeaders(),
|
|
272
|
+
body: JSON.stringify({
|
|
273
|
+
'action': 'deleteWebhook',
|
|
274
|
+
'url': url,
|
|
275
|
+
}),
|
|
276
|
+
});
|
|
277
|
+
const response = await body.json();
|
|
278
|
+
await this.debugLog(`deleteWebhook: url:${url}, body:${JSON.stringify(response)}, statusCode:${statusCode}`);
|
|
279
|
+
if (statusCode !== 200 || response?.statusCode !== 100) {
|
|
280
|
+
this.errorLog(`Failed to delete webhook. HTTP:${statusCode} API:${response?.statusCode} message:${response?.message}`);
|
|
281
|
+
}
|
|
282
|
+
else {
|
|
283
|
+
this.infoLog('Unregistered webhook to close listening.');
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
catch (e) {
|
|
287
|
+
this.errorLog(`Failed to delete webhook. Error:${e.message}`);
|
|
288
|
+
}
|
|
289
|
+
});
|
|
290
|
+
}
|
|
118
291
|
}
|
|
119
292
|
/**
|
|
120
293
|
* This function is invoked when homebridge restores cached accessories from disk at startup.
|