@switchbot/homebridge-switchbot 2.14.0 → 3.0.0-beta.0
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/npm-version-script.cjs +81 -0
- package/.github/workflows/dependabot.yml +10 -11
- package/CHANGELOG.md +11 -2
- package/LICENSE +1 -1
- package/config.schema.json +1 -0
- package/dist/device/blindtilt.d.ts +9 -5
- package/dist/device/blindtilt.d.ts.map +1 -1
- package/dist/device/blindtilt.js +151 -91
- package/dist/device/blindtilt.js.map +1 -1
- package/dist/device/bot.d.ts +9 -5
- package/dist/device/bot.d.ts.map +1 -1
- package/dist/device/bot.js +234 -184
- package/dist/device/bot.js.map +1 -1
- package/dist/device/ceilinglight.d.ts +9 -5
- package/dist/device/ceilinglight.d.ts.map +1 -1
- package/dist/device/ceilinglight.js +110 -64
- package/dist/device/ceilinglight.js.map +1 -1
- package/dist/device/colorbulb.d.ts +9 -5
- package/dist/device/colorbulb.d.ts.map +1 -1
- package/dist/device/colorbulb.js +121 -69
- package/dist/device/colorbulb.js.map +1 -1
- package/dist/device/contact.d.ts +9 -5
- package/dist/device/contact.d.ts.map +1 -1
- package/dist/device/contact.js +111 -66
- package/dist/device/contact.js.map +1 -1
- package/dist/device/curtain.d.ts +9 -5
- package/dist/device/curtain.d.ts.map +1 -1
- package/dist/device/curtain.js +164 -107
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/hub.d.ts +9 -5
- package/dist/device/hub.d.ts.map +1 -1
- package/dist/device/hub.js +87 -51
- package/dist/device/hub.js.map +1 -1
- package/dist/device/humidifier.d.ts +9 -5
- package/dist/device/humidifier.d.ts.map +1 -1
- package/dist/device/humidifier.js +133 -90
- package/dist/device/humidifier.js.map +1 -1
- package/dist/device/iosensor.d.ts +9 -5
- package/dist/device/iosensor.d.ts.map +1 -1
- package/dist/device/iosensor.js +108 -66
- package/dist/device/iosensor.js.map +1 -1
- package/dist/device/lightstrip.d.ts +9 -5
- package/dist/device/lightstrip.d.ts.map +1 -1
- package/dist/device/lightstrip.js +110 -65
- package/dist/device/lightstrip.js.map +1 -1
- package/dist/device/lock.d.ts +10 -6
- package/dist/device/lock.d.ts.map +1 -1
- package/dist/device/lock.js +125 -84
- package/dist/device/lock.js.map +1 -1
- package/dist/device/meter.d.ts +9 -5
- package/dist/device/meter.d.ts.map +1 -1
- package/dist/device/meter.js +102 -63
- package/dist/device/meter.js.map +1 -1
- package/dist/device/meterplus.d.ts +9 -5
- package/dist/device/meterplus.d.ts.map +1 -1
- package/dist/device/meterplus.js +102 -63
- package/dist/device/meterplus.js.map +1 -1
- package/dist/device/motion.d.ts +9 -5
- package/dist/device/motion.d.ts.map +1 -1
- package/dist/device/motion.js +95 -54
- package/dist/device/motion.js.map +1 -1
- package/dist/device/plug.d.ts +9 -5
- package/dist/device/plug.d.ts.map +1 -1
- package/dist/device/plug.js +68 -40
- package/dist/device/plug.js.map +1 -1
- package/dist/device/robotvacuumcleaner.d.ts +9 -5
- package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
- package/dist/device/robotvacuumcleaner.js +86 -52
- package/dist/device/robotvacuumcleaner.js.map +1 -1
- package/dist/homebridge-ui/server.d.ts +2 -0
- package/dist/homebridge-ui/server.d.ts.map +1 -0
- package/dist/homebridge-ui/server.js +44 -0
- package/dist/homebridge-ui/server.js.map +1 -0
- package/dist/index.d.ts +1 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -5
- package/dist/index.js.map +1 -1
- package/dist/irdevice/airconditioner.d.ts +8 -4
- package/dist/irdevice/airconditioner.d.ts.map +1 -1
- package/dist/irdevice/airconditioner.js +105 -71
- package/dist/irdevice/airconditioner.js.map +1 -1
- package/dist/irdevice/airpurifier.d.ts +8 -4
- package/dist/irdevice/airpurifier.d.ts.map +1 -1
- package/dist/irdevice/airpurifier.js +78 -46
- package/dist/irdevice/airpurifier.js.map +1 -1
- package/dist/irdevice/camera.d.ts +8 -4
- package/dist/irdevice/camera.d.ts.map +1 -1
- package/dist/irdevice/camera.js +41 -25
- package/dist/irdevice/camera.js.map +1 -1
- package/dist/irdevice/fan.d.ts +8 -4
- package/dist/irdevice/fan.d.ts.map +1 -1
- package/dist/irdevice/fan.js +62 -39
- package/dist/irdevice/fan.js.map +1 -1
- package/dist/irdevice/light.d.ts +8 -4
- package/dist/irdevice/light.d.ts.map +1 -1
- package/dist/irdevice/light.js +67 -45
- package/dist/irdevice/light.js.map +1 -1
- package/dist/irdevice/other.d.ts +8 -4
- package/dist/irdevice/other.d.ts.map +1 -1
- package/dist/irdevice/other.js +176 -150
- package/dist/irdevice/other.js.map +1 -1
- package/dist/irdevice/tv.d.ts +8 -4
- package/dist/irdevice/tv.d.ts.map +1 -1
- package/dist/irdevice/tv.js +81 -62
- package/dist/irdevice/tv.js.map +1 -1
- package/dist/irdevice/vacuumcleaner.d.ts +8 -4
- package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
- package/dist/irdevice/vacuumcleaner.js +41 -25
- package/dist/irdevice/vacuumcleaner.js.map +1 -1
- package/dist/irdevice/waterheater.d.ts +8 -4
- package/dist/irdevice/waterheater.d.ts.map +1 -1
- package/dist/irdevice/waterheater.js +48 -32
- package/dist/irdevice/waterheater.js.map +1 -1
- package/dist/platform.d.ts +8 -9
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +147 -162
- package/dist/platform.js.map +1 -1
- package/dist/settings.js +7 -14
- package/dist/settings.js.map +1 -1
- package/dist/utils.js +1 -5
- package/dist/utils.js.map +1 -1
- package/package.json +28 -16
- package/src/device/blindtilt.ts +80 -69
- package/src/device/bot.ts +189 -178
- package/src/device/ceilinglight.ts +55 -42
- package/src/device/colorbulb.ts +51 -38
- package/src/device/contact.ts +69 -58
- package/src/device/curtain.ts +94 -83
- package/src/device/hub.ts +54 -43
- package/src/device/humidifier.ts +86 -75
- package/src/device/iosensor.ts +63 -52
- package/src/device/lightstrip.ts +54 -41
- package/src/device/lock.ts +89 -79
- package/src/device/meter.ts +59 -48
- package/src/device/meterplus.ts +63 -52
- package/src/device/motion.ts +56 -45
- package/src/device/plug.ts +36 -25
- package/src/device/robotvacuumcleaner.ts +47 -36
- package/src/homebridge-ui/public/index.html +240 -0
- package/src/homebridge-ui/server.ts +48 -0
- package/src/index.ts +10 -7
- package/src/irdevice/airconditioner.ts +70 -62
- package/src/irdevice/airpurifier.ts +47 -39
- package/src/irdevice/camera.ts +27 -19
- package/src/irdevice/fan.ts +41 -33
- package/src/irdevice/light.ts +47 -39
- package/src/irdevice/other.ts +163 -155
- package/src/irdevice/tv.ts +65 -57
- package/src/irdevice/vacuumcleaner.ts +27 -19
- package/src/irdevice/waterheater.ts +34 -26
- package/src/platform.ts +35 -21
- package/tsconfig.json +11 -13
- package/homebridge-ui/server.js +0 -50
- /package/{homebridge-ui → dist/homebridge-ui}/public/index.html +0 -0
package/dist/platform.js
CHANGED
|
@@ -1,108 +1,77 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
const contact_1 = require("./device/contact");
|
|
37
|
-
const curtain_1 = require("./device/curtain");
|
|
38
|
-
const iosensor_1 = require("./device/iosensor");
|
|
39
|
-
const meterplus_1 = require("./device/meterplus");
|
|
40
|
-
const colorbulb_1 = require("./device/colorbulb");
|
|
41
|
-
const ceilinglight_1 = require("./device/ceilinglight");
|
|
42
|
-
const lightstrip_1 = require("./device/lightstrip");
|
|
43
|
-
const humidifier_1 = require("./device/humidifier");
|
|
44
|
-
const robotvacuumcleaner_1 = require("./device/robotvacuumcleaner");
|
|
45
|
-
const tv_1 = require("./irdevice/tv");
|
|
46
|
-
const fan_1 = require("./irdevice/fan");
|
|
47
|
-
const light_1 = require("./irdevice/light");
|
|
48
|
-
const other_1 = require("./irdevice/other");
|
|
49
|
-
const camera_1 = require("./irdevice/camera");
|
|
50
|
-
const blindtilt_1 = require("./device/blindtilt");
|
|
51
|
-
const airpurifier_1 = require("./irdevice/airpurifier");
|
|
52
|
-
const waterheater_1 = require("./irdevice/waterheater");
|
|
53
|
-
const vacuumcleaner_1 = require("./irdevice/vacuumcleaner");
|
|
54
|
-
const airconditioner_1 = require("./irdevice/airconditioner");
|
|
55
|
-
const undici_1 = require("undici");
|
|
56
|
-
const crypto_1 = __importStar(require("crypto"));
|
|
57
|
-
const buffer_1 = require("buffer");
|
|
58
|
-
const rxjs_1 = require("rxjs");
|
|
59
|
-
const fakegato_history_1 = __importDefault(require("fakegato-history"));
|
|
60
|
-
const homebridge_lib_1 = require("homebridge-lib");
|
|
61
|
-
const async_mqtt_1 = require("async-mqtt");
|
|
62
|
-
const http = __importStar(require("http"));
|
|
63
|
-
const fs_1 = require("fs");
|
|
64
|
-
const settings_1 = require("./settings");
|
|
1
|
+
import { PLATFORM_NAME, PLUGIN_NAME, Devices } from './settings.js';
|
|
2
|
+
import { Bot } from './device/bot';
|
|
3
|
+
import { Plug } from './device/plug';
|
|
4
|
+
import { Lock } from './device/lock';
|
|
5
|
+
import { Meter } from './device/meter';
|
|
6
|
+
import { Motion } from './device/motion';
|
|
7
|
+
import { Hub } from './device/hub';
|
|
8
|
+
import { Contact } from './device/contact';
|
|
9
|
+
import { Curtain } from './device/curtain';
|
|
10
|
+
import { IOSensor } from './device/iosensor';
|
|
11
|
+
import { MeterPlus } from './device/meterplus';
|
|
12
|
+
import { ColorBulb } from './device/colorbulb';
|
|
13
|
+
import { CeilingLight } from './device/ceilinglight';
|
|
14
|
+
import { StripLight } from './device/lightstrip';
|
|
15
|
+
import { Humidifier } from './device/humidifier';
|
|
16
|
+
import { RobotVacuumCleaner } from './device/robotvacuumcleaner';
|
|
17
|
+
import { TV } from './irdevice/tv';
|
|
18
|
+
import { Fan } from './irdevice/fan';
|
|
19
|
+
import { Light } from './irdevice/light';
|
|
20
|
+
import { Others } from './irdevice/other';
|
|
21
|
+
import { Camera } from './irdevice/camera';
|
|
22
|
+
import { BlindTilt } from './device/blindtilt';
|
|
23
|
+
import { AirPurifier } from './irdevice/airpurifier';
|
|
24
|
+
import { WaterHeater } from './irdevice/waterheater';
|
|
25
|
+
import { VacuumCleaner } from './irdevice/vacuumcleaner';
|
|
26
|
+
import { AirConditioner } from './irdevice/airconditioner';
|
|
27
|
+
import * as http from 'http';
|
|
28
|
+
import { Buffer } from 'buffer';
|
|
29
|
+
import { request } from 'undici';
|
|
30
|
+
import { queueScheduler } from 'rxjs';
|
|
31
|
+
import fakegato from 'fakegato-history';
|
|
32
|
+
import { connectAsync } from 'async-mqtt';
|
|
33
|
+
import crypto, { randomUUID } from 'crypto';
|
|
34
|
+
import { readFileSync, writeFileSync } from 'fs';
|
|
35
|
+
import { EveHomeKitTypes } from 'homebridge-lib';
|
|
65
36
|
/**
|
|
66
37
|
* HomebridgePlatform
|
|
67
38
|
* This class is the main constructor for your plugin, this is where you should
|
|
68
39
|
* parse the user config and discover/register accessories with Homebridge.
|
|
69
40
|
*/
|
|
70
|
-
class SwitchBotPlatform {
|
|
41
|
+
export class SwitchBotPlatform {
|
|
42
|
+
accessories;
|
|
43
|
+
api;
|
|
44
|
+
log;
|
|
45
|
+
version = process.env.npm_package_version || '2.13.0';
|
|
46
|
+
Logging;
|
|
47
|
+
debugMode;
|
|
48
|
+
platformLogging;
|
|
49
|
+
config;
|
|
50
|
+
webhookEventListener = null;
|
|
51
|
+
mqttClient = null;
|
|
52
|
+
fakegatoAPI;
|
|
53
|
+
eve;
|
|
54
|
+
webhookEventHandler = {};
|
|
71
55
|
constructor(log, config, api) {
|
|
72
|
-
this.log = log;
|
|
73
|
-
this.config = config;
|
|
74
|
-
this.api = api;
|
|
75
|
-
this.Service = this.api.hap.Service;
|
|
76
|
-
this.Characteristic = this.api.hap.Characteristic;
|
|
77
|
-
// this is used to track restored cached accessories
|
|
78
56
|
this.accessories = [];
|
|
79
|
-
this.
|
|
80
|
-
this.
|
|
81
|
-
this.mqttClient = null;
|
|
82
|
-
this.webhookEventHandler = {};
|
|
83
|
-
this.generateHeaders = () => {
|
|
84
|
-
const t = `${Date.now()}`;
|
|
85
|
-
const nonce = (0, crypto_1.randomUUID)();
|
|
86
|
-
const data = this.config.credentials?.token + t + nonce;
|
|
87
|
-
const signTerm = crypto_1.default
|
|
88
|
-
.createHmac('sha256', this.config.credentials?.secret)
|
|
89
|
-
.update(buffer_1.Buffer.from(data, 'utf-8'))
|
|
90
|
-
.digest();
|
|
91
|
-
const sign = signTerm.toString('base64');
|
|
92
|
-
return {
|
|
93
|
-
Authorization: this.config.credentials?.token,
|
|
94
|
-
sign: sign,
|
|
95
|
-
nonce: nonce,
|
|
96
|
-
t: t,
|
|
97
|
-
'Content-Type': 'application/json',
|
|
98
|
-
};
|
|
99
|
-
};
|
|
100
|
-
this.logs();
|
|
101
|
-
this.debugLog('Finished initializing platform:', this.config.name);
|
|
57
|
+
this.api = api;
|
|
58
|
+
this.log = log;
|
|
102
59
|
// only load if configured
|
|
103
60
|
if (!this.config) {
|
|
104
61
|
return;
|
|
105
62
|
}
|
|
63
|
+
// Plugin options into our config variables.
|
|
64
|
+
this.config = {
|
|
65
|
+
platform: 'SwitchBotPlatform',
|
|
66
|
+
url: config.url,
|
|
67
|
+
port: config.port,
|
|
68
|
+
hostname: config.hostname,
|
|
69
|
+
protocol: config.protocol,
|
|
70
|
+
verifyTLS: config.verifyTLS,
|
|
71
|
+
logging: config.logging,
|
|
72
|
+
};
|
|
73
|
+
this.logs();
|
|
74
|
+
this.debugLog(`Finished initializing platform: ${config.name}`);
|
|
106
75
|
// HOOBS notice
|
|
107
76
|
if (__dirname.includes('hoobs')) {
|
|
108
77
|
this.warnLog('This plugin has not been tested under HOOBS, it is highly recommended that you switch to Homebridge: ' +
|
|
@@ -119,8 +88,8 @@ class SwitchBotPlatform {
|
|
|
119
88
|
return;
|
|
120
89
|
}
|
|
121
90
|
// import fakegato-history module and EVE characteristics
|
|
122
|
-
this.fakegatoAPI = (
|
|
123
|
-
this.eve = new
|
|
91
|
+
this.fakegatoAPI = fakegato(api);
|
|
92
|
+
this.eve = new EveHomeKitTypes(api);
|
|
124
93
|
// When this event is fired it means Homebridge has restored all cached accessories from disk.
|
|
125
94
|
// Dynamic Platform plugins should only register new accessories after this event was fired,
|
|
126
95
|
// in order to ensure they weren't added to homebridge already. This event can also be used
|
|
@@ -151,7 +120,7 @@ class SwitchBotPlatform {
|
|
|
151
120
|
async setupMqtt() {
|
|
152
121
|
if (this.config.options?.mqttURL) {
|
|
153
122
|
try {
|
|
154
|
-
this.mqttClient = await
|
|
123
|
+
this.mqttClient = await connectAsync(this.config.options?.mqttURL, this.config.options.mqttOptions || {});
|
|
155
124
|
this.debugLog('MQTT connection has been established successfully.');
|
|
156
125
|
this.mqttClient.on('error', (e) => {
|
|
157
126
|
this.errorLog(`Failed to publish MQTT messages. ${e}`);
|
|
@@ -225,7 +194,7 @@ class SwitchBotPlatform {
|
|
|
225
194
|
return;
|
|
226
195
|
}
|
|
227
196
|
try {
|
|
228
|
-
const { body, statusCode, headers } = await
|
|
197
|
+
const { body, statusCode, headers } = await request('https://api.switch-bot.com/v1.1/webhook/setupWebhook', {
|
|
229
198
|
method: 'POST',
|
|
230
199
|
headers: this.generateHeaders(),
|
|
231
200
|
body: JSON.stringify({
|
|
@@ -248,7 +217,7 @@ class SwitchBotPlatform {
|
|
|
248
217
|
this.errorLog(`Failed to configure webhook. Error: ${e.message}`);
|
|
249
218
|
}
|
|
250
219
|
try {
|
|
251
|
-
const { body, statusCode, headers } = await
|
|
220
|
+
const { body, statusCode, headers } = await request('https://api.switch-bot.com/v1.1/webhook/updateWebhook', {
|
|
252
221
|
method: 'POST',
|
|
253
222
|
headers: this.generateHeaders(),
|
|
254
223
|
body: JSON.stringify({
|
|
@@ -272,7 +241,7 @@ class SwitchBotPlatform {
|
|
|
272
241
|
this.errorLog(`Failed to update webhook. Error:${e.message}`);
|
|
273
242
|
}
|
|
274
243
|
try {
|
|
275
|
-
const { body, statusCode, headers } = await
|
|
244
|
+
const { body, statusCode, headers } = await request('https://api.switch-bot.com/v1.1/webhook/queryWebhook', {
|
|
276
245
|
method: 'POST',
|
|
277
246
|
headers: this.generateHeaders(),
|
|
278
247
|
body: JSON.stringify({
|
|
@@ -295,7 +264,7 @@ class SwitchBotPlatform {
|
|
|
295
264
|
}
|
|
296
265
|
this.api.on('shutdown', async () => {
|
|
297
266
|
try {
|
|
298
|
-
const { body, statusCode, headers } = await
|
|
267
|
+
const { body, statusCode, headers } = await request('https://api.switch-bot.com/v1.1/webhook/deleteWebhook', {
|
|
299
268
|
method: 'POST',
|
|
300
269
|
headers: this.generateHeaders(),
|
|
301
270
|
body: JSON.stringify({
|
|
@@ -417,15 +386,15 @@ class SwitchBotPlatform {
|
|
|
417
386
|
throw new Error('New token not provided');
|
|
418
387
|
}
|
|
419
388
|
// load in the current config
|
|
420
|
-
const currentConfig = JSON.parse(
|
|
389
|
+
const currentConfig = JSON.parse(readFileSync(this.api.user.configPath(), 'utf8'));
|
|
421
390
|
// check the platforms section is an array before we do array things on it
|
|
422
391
|
if (!Array.isArray(currentConfig.platforms)) {
|
|
423
392
|
throw new Error('Cannot find platforms array in config');
|
|
424
393
|
}
|
|
425
394
|
// find this plugins current config
|
|
426
|
-
const pluginConfig = currentConfig.platforms.find((x) => x.platform ===
|
|
395
|
+
const pluginConfig = currentConfig.platforms.find((x) => x.platform === PLATFORM_NAME);
|
|
427
396
|
if (!pluginConfig) {
|
|
428
|
-
throw new Error(`Cannot find config for ${
|
|
397
|
+
throw new Error(`Cannot find config for ${PLATFORM_NAME} in platforms array`);
|
|
429
398
|
}
|
|
430
399
|
// check the .credentials is an object before doing object things with it
|
|
431
400
|
if (typeof pluginConfig.credentials !== 'object') {
|
|
@@ -450,13 +419,30 @@ class SwitchBotPlatform {
|
|
|
450
419
|
}
|
|
451
420
|
this.debugWarnLog(`token: ${pluginConfig.credentials.token}`);
|
|
452
421
|
// save the config, ensuring we maintain pretty json
|
|
453
|
-
|
|
422
|
+
writeFileSync(this.api.user.configPath(), JSON.stringify(currentConfig, null, 4));
|
|
454
423
|
this.verifyConfig();
|
|
455
424
|
}
|
|
456
425
|
catch (e) {
|
|
457
426
|
this.errorLog(`Update Token: ${e}`);
|
|
458
427
|
}
|
|
459
428
|
}
|
|
429
|
+
generateHeaders = () => {
|
|
430
|
+
const t = `${Date.now()}`;
|
|
431
|
+
const nonce = randomUUID();
|
|
432
|
+
const data = this.config.credentials?.token + t + nonce;
|
|
433
|
+
const signTerm = crypto
|
|
434
|
+
.createHmac('sha256', this.config.credentials?.secret)
|
|
435
|
+
.update(Buffer.from(data, 'utf-8'))
|
|
436
|
+
.digest();
|
|
437
|
+
const sign = signTerm.toString('base64');
|
|
438
|
+
return {
|
|
439
|
+
Authorization: this.config.credentials?.token,
|
|
440
|
+
sign: sign,
|
|
441
|
+
nonce: nonce,
|
|
442
|
+
t: t,
|
|
443
|
+
'Content-Type': 'application/json',
|
|
444
|
+
};
|
|
445
|
+
};
|
|
460
446
|
/**
|
|
461
447
|
* this method discovers devices
|
|
462
448
|
*
|
|
@@ -469,7 +455,7 @@ class SwitchBotPlatform {
|
|
|
469
455
|
async discoverDevices() {
|
|
470
456
|
if (this.config.credentials?.token) {
|
|
471
457
|
try {
|
|
472
|
-
const { body, statusCode, headers } = await
|
|
458
|
+
const { body, statusCode, headers } = await request(Devices, {
|
|
473
459
|
headers: this.generateHeaders(),
|
|
474
460
|
});
|
|
475
461
|
this.debugWarnLog(`body: ${JSON.stringify(body)}`);
|
|
@@ -778,7 +764,7 @@ class SwitchBotPlatform {
|
|
|
778
764
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
779
765
|
// create the accessory handler for the restored accessory
|
|
780
766
|
// this is imported from `platformAccessory.ts`
|
|
781
|
-
new
|
|
767
|
+
new Humidifier(this, existingAccessory, device);
|
|
782
768
|
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
|
|
783
769
|
}
|
|
784
770
|
else {
|
|
@@ -804,7 +790,7 @@ class SwitchBotPlatform {
|
|
|
804
790
|
accessory.context.connectionType = await this.connectionType(device);
|
|
805
791
|
// create the accessory handler for the newly create accessory
|
|
806
792
|
// this is imported from `platformAccessory.ts`
|
|
807
|
-
new
|
|
793
|
+
new Humidifier(this, accessory, device);
|
|
808
794
|
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
|
|
809
795
|
// publish device externally or link the accessory to your platform
|
|
810
796
|
this.externalOrPlatform(device, accessory);
|
|
@@ -835,7 +821,7 @@ class SwitchBotPlatform {
|
|
|
835
821
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
836
822
|
// create the accessory handler for the restored accessory
|
|
837
823
|
// this is imported from `platformAccessory.ts`
|
|
838
|
-
new
|
|
824
|
+
new Bot(this, existingAccessory, device);
|
|
839
825
|
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
|
|
840
826
|
}
|
|
841
827
|
else {
|
|
@@ -862,7 +848,7 @@ class SwitchBotPlatform {
|
|
|
862
848
|
// accessory.context.FirmwareRevision = findaccessories.accessoryAttribute.softwareRevision;
|
|
863
849
|
// create the accessory handler for the newly create accessory
|
|
864
850
|
// this is imported from `platformAccessory.ts`
|
|
865
|
-
new
|
|
851
|
+
new Bot(this, accessory, device);
|
|
866
852
|
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
|
|
867
853
|
// publish device externally or link the accessory to your platform
|
|
868
854
|
this.externalOrPlatform(device, accessory);
|
|
@@ -893,7 +879,7 @@ class SwitchBotPlatform {
|
|
|
893
879
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
894
880
|
// create the accessory handler for the restored accessory
|
|
895
881
|
// this is imported from `platformAccessory.ts`
|
|
896
|
-
new
|
|
882
|
+
new Meter(this, existingAccessory, device);
|
|
897
883
|
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
|
|
898
884
|
}
|
|
899
885
|
else {
|
|
@@ -919,7 +905,7 @@ class SwitchBotPlatform {
|
|
|
919
905
|
accessory.context.connectionType = await this.connectionType(device);
|
|
920
906
|
// create the accessory handler for the newly create accessory
|
|
921
907
|
// this is imported from `platformAccessory.ts`
|
|
922
|
-
new
|
|
908
|
+
new Meter(this, accessory, device);
|
|
923
909
|
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
|
|
924
910
|
// publish device externally or link the accessory to your platform
|
|
925
911
|
this.externalOrPlatform(device, accessory);
|
|
@@ -951,7 +937,7 @@ class SwitchBotPlatform {
|
|
|
951
937
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
952
938
|
// create the accessory handler for the restored accessory
|
|
953
939
|
// this is imported from `platformAccessory.ts`
|
|
954
|
-
new
|
|
940
|
+
new MeterPlus(this, existingAccessory, device);
|
|
955
941
|
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
|
|
956
942
|
}
|
|
957
943
|
else {
|
|
@@ -977,7 +963,7 @@ class SwitchBotPlatform {
|
|
|
977
963
|
accessory.context.connectionType = await this.connectionType(device);
|
|
978
964
|
// create the accessory handler for the newly create accessory
|
|
979
965
|
// this is imported from `platformAccessory.ts`
|
|
980
|
-
new
|
|
966
|
+
new MeterPlus(this, accessory, device);
|
|
981
967
|
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
|
|
982
968
|
// publish device externally or link the accessory to your platform
|
|
983
969
|
this.externalOrPlatform(device, accessory);
|
|
@@ -1009,7 +995,7 @@ class SwitchBotPlatform {
|
|
|
1009
995
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
1010
996
|
// create the accessory handler for the restored accessory
|
|
1011
997
|
// this is imported from `platformAccessory.ts`
|
|
1012
|
-
new
|
|
998
|
+
new Hub(this, existingAccessory, device);
|
|
1013
999
|
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
|
|
1014
1000
|
}
|
|
1015
1001
|
else {
|
|
@@ -1035,7 +1021,7 @@ class SwitchBotPlatform {
|
|
|
1035
1021
|
accessory.context.connectionType = await this.connectionType(device);
|
|
1036
1022
|
// create the accessory handler for the newly create accessory
|
|
1037
1023
|
// this is imported from `platformAccessory.ts`
|
|
1038
|
-
new
|
|
1024
|
+
new Hub(this, accessory, device);
|
|
1039
1025
|
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
|
|
1040
1026
|
// publish device externally or link the accessory to your platform
|
|
1041
1027
|
this.externalOrPlatform(device, accessory);
|
|
@@ -1066,7 +1052,7 @@ class SwitchBotPlatform {
|
|
|
1066
1052
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
1067
1053
|
// create the accessory handler for the restored accessory
|
|
1068
1054
|
// this is imported from `platformAccessory.ts`
|
|
1069
|
-
new
|
|
1055
|
+
new IOSensor(this, existingAccessory, device);
|
|
1070
1056
|
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
|
|
1071
1057
|
}
|
|
1072
1058
|
else {
|
|
@@ -1092,7 +1078,7 @@ class SwitchBotPlatform {
|
|
|
1092
1078
|
accessory.context.connectionType = await this.connectionType(device);
|
|
1093
1079
|
// create the accessory handler for the newly create accessory
|
|
1094
1080
|
// this is imported from `platformAccessory.ts`
|
|
1095
|
-
new
|
|
1081
|
+
new IOSensor(this, accessory, device);
|
|
1096
1082
|
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
|
|
1097
1083
|
// publish device externally or link the accessory to your platform
|
|
1098
1084
|
this.externalOrPlatform(device, accessory);
|
|
@@ -1123,7 +1109,7 @@ class SwitchBotPlatform {
|
|
|
1123
1109
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
1124
1110
|
// create the accessory handler for the restored accessory
|
|
1125
1111
|
// this is imported from `platformAccessory.ts`
|
|
1126
|
-
new
|
|
1112
|
+
new Motion(this, existingAccessory, device);
|
|
1127
1113
|
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
|
|
1128
1114
|
}
|
|
1129
1115
|
else {
|
|
@@ -1149,7 +1135,7 @@ class SwitchBotPlatform {
|
|
|
1149
1135
|
accessory.context.connectionType = await this.connectionType(device);
|
|
1150
1136
|
// create the accessory handler for the newly create accessory
|
|
1151
1137
|
// this is imported from `platformAccessory.ts`
|
|
1152
|
-
new
|
|
1138
|
+
new Motion(this, accessory, device);
|
|
1153
1139
|
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
|
|
1154
1140
|
// publish device externally or link the accessory to your platform
|
|
1155
1141
|
this.externalOrPlatform(device, accessory);
|
|
@@ -1180,7 +1166,7 @@ class SwitchBotPlatform {
|
|
|
1180
1166
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
1181
1167
|
// create the accessory handler for the restored accessory
|
|
1182
1168
|
// this is imported from `platformAccessory.ts`
|
|
1183
|
-
new
|
|
1169
|
+
new Contact(this, existingAccessory, device);
|
|
1184
1170
|
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
|
|
1185
1171
|
}
|
|
1186
1172
|
else {
|
|
@@ -1206,7 +1192,7 @@ class SwitchBotPlatform {
|
|
|
1206
1192
|
accessory.context.connectionType = await this.connectionType(device);
|
|
1207
1193
|
// create the accessory handler for the newly create accessory
|
|
1208
1194
|
// this is imported from `platformAccessory.ts`
|
|
1209
|
-
new
|
|
1195
|
+
new Contact(this, accessory, device);
|
|
1210
1196
|
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
|
|
1211
1197
|
// publish device externally or link the accessory to your platform
|
|
1212
1198
|
this.externalOrPlatform(device, accessory);
|
|
@@ -1237,7 +1223,7 @@ class SwitchBotPlatform {
|
|
|
1237
1223
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
1238
1224
|
// create the accessory handler for the restored accessory
|
|
1239
1225
|
// this is imported from `platformAccessory.ts`
|
|
1240
|
-
new
|
|
1226
|
+
new BlindTilt(this, existingAccessory, device);
|
|
1241
1227
|
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
|
|
1242
1228
|
}
|
|
1243
1229
|
else {
|
|
@@ -1275,7 +1261,7 @@ class SwitchBotPlatform {
|
|
|
1275
1261
|
accessory.context.connectionType = await this.connectionType(device);
|
|
1276
1262
|
// create the accessory handler for the newly create accessory
|
|
1277
1263
|
// this is imported from `platformAccessory.ts`
|
|
1278
|
-
new
|
|
1264
|
+
new BlindTilt(this, accessory, device);
|
|
1279
1265
|
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
|
|
1280
1266
|
// publish device externally or link the accessory to your platform
|
|
1281
1267
|
this.externalOrPlatform(device, accessory);
|
|
@@ -1306,7 +1292,7 @@ class SwitchBotPlatform {
|
|
|
1306
1292
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
1307
1293
|
// create the accessory handler for the restored accessory
|
|
1308
1294
|
// this is imported from `platformAccessory.ts`
|
|
1309
|
-
new
|
|
1295
|
+
new Curtain(this, existingAccessory, device);
|
|
1310
1296
|
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
|
|
1311
1297
|
}
|
|
1312
1298
|
else {
|
|
@@ -1344,7 +1330,7 @@ class SwitchBotPlatform {
|
|
|
1344
1330
|
accessory.context.connectionType = await this.connectionType(device);
|
|
1345
1331
|
// create the accessory handler for the newly create accessory
|
|
1346
1332
|
// this is imported from `platformAccessory.ts`
|
|
1347
|
-
new
|
|
1333
|
+
new Curtain(this, accessory, device);
|
|
1348
1334
|
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
|
|
1349
1335
|
// publish device externally or link the accessory to your platform
|
|
1350
1336
|
this.externalOrPlatform(device, accessory);
|
|
@@ -1375,7 +1361,7 @@ class SwitchBotPlatform {
|
|
|
1375
1361
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
1376
1362
|
// create the accessory handler for the restored accessory
|
|
1377
1363
|
// this is imported from `platformAccessory.ts`
|
|
1378
|
-
new
|
|
1364
|
+
new Plug(this, existingAccessory, device);
|
|
1379
1365
|
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
|
|
1380
1366
|
}
|
|
1381
1367
|
else {
|
|
@@ -1401,7 +1387,7 @@ class SwitchBotPlatform {
|
|
|
1401
1387
|
accessory.context.connectionType = await this.connectionType(device);
|
|
1402
1388
|
// create the accessory handler for the newly create accessory
|
|
1403
1389
|
// this is imported from `platformAccessory.ts`
|
|
1404
|
-
new
|
|
1390
|
+
new Plug(this, accessory, device);
|
|
1405
1391
|
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
|
|
1406
1392
|
// publish device externally or link the accessory to your platform
|
|
1407
1393
|
this.externalOrPlatform(device, accessory);
|
|
@@ -1432,7 +1418,7 @@ class SwitchBotPlatform {
|
|
|
1432
1418
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
1433
1419
|
// create the accessory handler for the restored accessory
|
|
1434
1420
|
// this is imported from `platformAccessory.ts`
|
|
1435
|
-
new
|
|
1421
|
+
new Lock(this, existingAccessory, device);
|
|
1436
1422
|
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
|
|
1437
1423
|
}
|
|
1438
1424
|
else {
|
|
@@ -1458,7 +1444,7 @@ class SwitchBotPlatform {
|
|
|
1458
1444
|
accessory.context.connectionType = await this.connectionType(device);
|
|
1459
1445
|
// create the accessory handler for the newly create accessory
|
|
1460
1446
|
// this is imported from `platformAccessory.ts`
|
|
1461
|
-
new
|
|
1447
|
+
new Lock(this, accessory, device);
|
|
1462
1448
|
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
|
|
1463
1449
|
// publish device externally or link the accessory to your platform
|
|
1464
1450
|
this.externalOrPlatform(device, accessory);
|
|
@@ -1489,7 +1475,7 @@ class SwitchBotPlatform {
|
|
|
1489
1475
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
1490
1476
|
// create the accessory handler for the restored accessory
|
|
1491
1477
|
// this is imported from `platformAccessory.ts`
|
|
1492
|
-
new
|
|
1478
|
+
new ColorBulb(this, existingAccessory, device);
|
|
1493
1479
|
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
|
|
1494
1480
|
}
|
|
1495
1481
|
else {
|
|
@@ -1515,7 +1501,7 @@ class SwitchBotPlatform {
|
|
|
1515
1501
|
accessory.context.connectionType = await this.connectionType(device);
|
|
1516
1502
|
// create the accessory handler for the newly create accessory
|
|
1517
1503
|
// this is imported from `platformAccessory.ts`
|
|
1518
|
-
new
|
|
1504
|
+
new ColorBulb(this, accessory, device);
|
|
1519
1505
|
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
|
|
1520
1506
|
// publish device externally or link the accessory to your platform
|
|
1521
1507
|
this.externalOrPlatform(device, accessory);
|
|
@@ -1546,7 +1532,7 @@ class SwitchBotPlatform {
|
|
|
1546
1532
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
1547
1533
|
// create the accessory handler for the restored accessory
|
|
1548
1534
|
// this is imported from `platformAccessory.ts`
|
|
1549
|
-
new
|
|
1535
|
+
new CeilingLight(this, existingAccessory, device);
|
|
1550
1536
|
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
|
|
1551
1537
|
}
|
|
1552
1538
|
else {
|
|
@@ -1572,7 +1558,7 @@ class SwitchBotPlatform {
|
|
|
1572
1558
|
accessory.context.connectionType = await this.connectionType(device);
|
|
1573
1559
|
// create the accessory handler for the newly create accessory
|
|
1574
1560
|
// this is imported from `platformAccessory.ts`
|
|
1575
|
-
new
|
|
1561
|
+
new CeilingLight(this, accessory, device);
|
|
1576
1562
|
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
|
|
1577
1563
|
// publish device externally or link the accessory to your platform
|
|
1578
1564
|
this.externalOrPlatform(device, accessory);
|
|
@@ -1603,7 +1589,7 @@ class SwitchBotPlatform {
|
|
|
1603
1589
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
1604
1590
|
// create the accessory handler for the restored accessory
|
|
1605
1591
|
// this is imported from `platformAccessory.ts`
|
|
1606
|
-
new
|
|
1592
|
+
new StripLight(this, existingAccessory, device);
|
|
1607
1593
|
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
|
|
1608
1594
|
}
|
|
1609
1595
|
else {
|
|
@@ -1629,7 +1615,7 @@ class SwitchBotPlatform {
|
|
|
1629
1615
|
accessory.context.connectionType = await this.connectionType(device);
|
|
1630
1616
|
// create the accessory handler for the newly create accessory
|
|
1631
1617
|
// this is imported from `platformAccessory.ts`
|
|
1632
|
-
new
|
|
1618
|
+
new StripLight(this, accessory, device);
|
|
1633
1619
|
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
|
|
1634
1620
|
// publish device externally or link the accessory to your platform
|
|
1635
1621
|
this.externalOrPlatform(device, accessory);
|
|
@@ -1660,7 +1646,7 @@ class SwitchBotPlatform {
|
|
|
1660
1646
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
1661
1647
|
// create the accessory handler for the restored accessory
|
|
1662
1648
|
// this is imported from `platformAccessory.ts`
|
|
1663
|
-
new
|
|
1649
|
+
new RobotVacuumCleaner(this, existingAccessory, device);
|
|
1664
1650
|
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
|
|
1665
1651
|
}
|
|
1666
1652
|
else {
|
|
@@ -1686,7 +1672,7 @@ class SwitchBotPlatform {
|
|
|
1686
1672
|
accessory.context.connectionType = await this.connectionType(device);
|
|
1687
1673
|
// create the accessory handler for the newly create accessory
|
|
1688
1674
|
// this is imported from `platformAccessory.ts`
|
|
1689
|
-
new
|
|
1675
|
+
new RobotVacuumCleaner(this, accessory, device);
|
|
1690
1676
|
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
|
|
1691
1677
|
// publish device externally or link the accessory to your platform
|
|
1692
1678
|
this.externalOrPlatform(device, accessory);
|
|
@@ -1713,7 +1699,7 @@ class SwitchBotPlatform {
|
|
|
1713
1699
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
1714
1700
|
// create the accessory handler for the restored accessory
|
|
1715
1701
|
// this is imported from `platformAccessory.ts`
|
|
1716
|
-
new
|
|
1702
|
+
new TV(this, existingAccessory, device);
|
|
1717
1703
|
this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${existingAccessory.UUID})`);
|
|
1718
1704
|
}
|
|
1719
1705
|
else if (!device.hide_device && device.hubDeviceId) {
|
|
@@ -1735,7 +1721,7 @@ class SwitchBotPlatform {
|
|
|
1735
1721
|
accessory.context.connectionType = device.connectionType;
|
|
1736
1722
|
// create the accessory handler for the newly create accessory
|
|
1737
1723
|
// this is imported from `platformAccessory.ts`
|
|
1738
|
-
new
|
|
1724
|
+
new TV(this, accessory, device);
|
|
1739
1725
|
this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`);
|
|
1740
1726
|
this.externalOrPlatformIR(device, accessory);
|
|
1741
1727
|
this.accessories.push(accessory);
|
|
@@ -1765,7 +1751,7 @@ class SwitchBotPlatform {
|
|
|
1765
1751
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
1766
1752
|
// create the accessory handler for the restored accessory
|
|
1767
1753
|
// this is imported from `platformAccessory.ts`
|
|
1768
|
-
new
|
|
1754
|
+
new Fan(this, existingAccessory, device);
|
|
1769
1755
|
this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${existingAccessory.UUID})`);
|
|
1770
1756
|
}
|
|
1771
1757
|
else {
|
|
@@ -1791,7 +1777,7 @@ class SwitchBotPlatform {
|
|
|
1791
1777
|
accessory.context.connectionType = device.connectionType;
|
|
1792
1778
|
// create the accessory handler for the newly create accessory
|
|
1793
1779
|
// this is imported from `platformAccessory.ts`
|
|
1794
|
-
new
|
|
1780
|
+
new Fan(this, accessory, device);
|
|
1795
1781
|
this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`);
|
|
1796
1782
|
// publish device externally or link the accessory to your platform
|
|
1797
1783
|
this.externalOrPlatformIR(device, accessory);
|
|
@@ -1822,7 +1808,7 @@ class SwitchBotPlatform {
|
|
|
1822
1808
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
1823
1809
|
// create the accessory handler for the restored accessory
|
|
1824
1810
|
// this is imported from `platformAccessory.ts`
|
|
1825
|
-
new
|
|
1811
|
+
new Light(this, existingAccessory, device);
|
|
1826
1812
|
this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${existingAccessory.UUID})`);
|
|
1827
1813
|
}
|
|
1828
1814
|
else {
|
|
@@ -1848,7 +1834,7 @@ class SwitchBotPlatform {
|
|
|
1848
1834
|
accessory.context.connectionType = device.connectionType;
|
|
1849
1835
|
// create the accessory handler for the newly create accessory
|
|
1850
1836
|
// this is imported from `platformAccessory.ts`
|
|
1851
|
-
new
|
|
1837
|
+
new Light(this, accessory, device);
|
|
1852
1838
|
this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`);
|
|
1853
1839
|
// publish device externally or link the accessory to your platform
|
|
1854
1840
|
this.externalOrPlatformIR(device, accessory);
|
|
@@ -1879,7 +1865,7 @@ class SwitchBotPlatform {
|
|
|
1879
1865
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
1880
1866
|
// create the accessory handler for the restored accessory
|
|
1881
1867
|
// this is imported from `platformAccessory.ts`
|
|
1882
|
-
new
|
|
1868
|
+
new AirConditioner(this, existingAccessory, device);
|
|
1883
1869
|
this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${existingAccessory.UUID})`);
|
|
1884
1870
|
}
|
|
1885
1871
|
else {
|
|
@@ -1905,7 +1891,7 @@ class SwitchBotPlatform {
|
|
|
1905
1891
|
accessory.context.connectionType = device.connectionType;
|
|
1906
1892
|
// create the accessory handler for the newly create accessory
|
|
1907
1893
|
// this is imported from `platformAccessory.ts`
|
|
1908
|
-
new
|
|
1894
|
+
new AirConditioner(this, accessory, device);
|
|
1909
1895
|
this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`);
|
|
1910
1896
|
// publish device externally or link the accessory to your platform
|
|
1911
1897
|
this.externalOrPlatformIR(device, accessory);
|
|
@@ -1936,7 +1922,7 @@ class SwitchBotPlatform {
|
|
|
1936
1922
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
1937
1923
|
// create the accessory handler for the restored accessory
|
|
1938
1924
|
// this is imported from `platformAccessory.ts`
|
|
1939
|
-
new
|
|
1925
|
+
new AirPurifier(this, existingAccessory, device);
|
|
1940
1926
|
this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${existingAccessory.UUID})`);
|
|
1941
1927
|
}
|
|
1942
1928
|
else {
|
|
@@ -1962,7 +1948,7 @@ class SwitchBotPlatform {
|
|
|
1962
1948
|
accessory.context.connectionType = device.connectionType;
|
|
1963
1949
|
// create the accessory handler for the newly create accessory
|
|
1964
1950
|
// this is imported from `platformAccessory.ts`
|
|
1965
|
-
new
|
|
1951
|
+
new AirPurifier(this, accessory, device);
|
|
1966
1952
|
this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`);
|
|
1967
1953
|
// publish device externally or link the accessory to your platform
|
|
1968
1954
|
this.externalOrPlatformIR(device, accessory);
|
|
@@ -1993,7 +1979,7 @@ class SwitchBotPlatform {
|
|
|
1993
1979
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
1994
1980
|
// create the accessory handler for the restored accessory
|
|
1995
1981
|
// this is imported from `platformAccessory.ts`
|
|
1996
|
-
new
|
|
1982
|
+
new WaterHeater(this, existingAccessory, device);
|
|
1997
1983
|
this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${existingAccessory.UUID})`);
|
|
1998
1984
|
}
|
|
1999
1985
|
else {
|
|
@@ -2019,7 +2005,7 @@ class SwitchBotPlatform {
|
|
|
2019
2005
|
accessory.context.connectionType = device.connectionType;
|
|
2020
2006
|
// create the accessory handler for the newly create accessory
|
|
2021
2007
|
// this is imported from `platformAccessory.ts`
|
|
2022
|
-
new
|
|
2008
|
+
new WaterHeater(this, accessory, device);
|
|
2023
2009
|
this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`);
|
|
2024
2010
|
// publish device externally or link the accessory to your platform
|
|
2025
2011
|
this.externalOrPlatformIR(device, accessory);
|
|
@@ -2050,7 +2036,7 @@ class SwitchBotPlatform {
|
|
|
2050
2036
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
2051
2037
|
// create the accessory handler for the restored accessory
|
|
2052
2038
|
// this is imported from `platformAccessory.ts`
|
|
2053
|
-
new
|
|
2039
|
+
new VacuumCleaner(this, existingAccessory, device);
|
|
2054
2040
|
this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${existingAccessory.UUID})`);
|
|
2055
2041
|
}
|
|
2056
2042
|
else {
|
|
@@ -2076,7 +2062,7 @@ class SwitchBotPlatform {
|
|
|
2076
2062
|
accessory.context.connectionType = device.connectionType;
|
|
2077
2063
|
// create the accessory handler for the newly create accessory
|
|
2078
2064
|
// this is imported from `platformAccessory.ts`
|
|
2079
|
-
new
|
|
2065
|
+
new VacuumCleaner(this, accessory, device);
|
|
2080
2066
|
this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`);
|
|
2081
2067
|
// publish device externally or link the accessory to your platform
|
|
2082
2068
|
this.externalOrPlatformIR(device, accessory);
|
|
@@ -2107,7 +2093,7 @@ class SwitchBotPlatform {
|
|
|
2107
2093
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
2108
2094
|
// create the accessory handler for the restored accessory
|
|
2109
2095
|
// this is imported from `platformAccessory.ts`
|
|
2110
|
-
new
|
|
2096
|
+
new Camera(this, existingAccessory, device);
|
|
2111
2097
|
this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${existingAccessory.UUID})`);
|
|
2112
2098
|
}
|
|
2113
2099
|
else {
|
|
@@ -2133,7 +2119,7 @@ class SwitchBotPlatform {
|
|
|
2133
2119
|
accessory.context.connectionType = device.connectionType;
|
|
2134
2120
|
// create the accessory handler for the newly create accessory
|
|
2135
2121
|
// this is imported from `platformAccessory.ts`
|
|
2136
|
-
new
|
|
2122
|
+
new Camera(this, accessory, device);
|
|
2137
2123
|
this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`);
|
|
2138
2124
|
// publish device externally or link the accessory to your platform
|
|
2139
2125
|
this.externalOrPlatformIR(device, accessory);
|
|
@@ -2164,7 +2150,7 @@ class SwitchBotPlatform {
|
|
|
2164
2150
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
2165
2151
|
// create the accessory handler for the restored accessory
|
|
2166
2152
|
// this is imported from `platformAccessory.ts`
|
|
2167
|
-
new
|
|
2153
|
+
new Others(this, existingAccessory, device);
|
|
2168
2154
|
this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${existingAccessory.UUID})`);
|
|
2169
2155
|
}
|
|
2170
2156
|
else {
|
|
@@ -2190,7 +2176,7 @@ class SwitchBotPlatform {
|
|
|
2190
2176
|
accessory.context.connectionType = device.connectionType;
|
|
2191
2177
|
// create the accessory handler for the newly create accessory
|
|
2192
2178
|
// this is imported from `platformAccessory.ts`
|
|
2193
|
-
new
|
|
2179
|
+
new Others(this, accessory, device);
|
|
2194
2180
|
this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`);
|
|
2195
2181
|
// publish device externally or link the accessory to your platform
|
|
2196
2182
|
this.externalOrPlatformIR(device, accessory);
|
|
@@ -2345,7 +2331,7 @@ class SwitchBotPlatform {
|
|
|
2345
2331
|
}
|
|
2346
2332
|
else {
|
|
2347
2333
|
this.debugLog(`${accessory.displayName} External Accessory Mode: ${device.external}`);
|
|
2348
|
-
this.api.registerPlatformAccessories(
|
|
2334
|
+
this.api.registerPlatformAccessories(PLUGIN_NAME, PLATFORM_NAME, [accessory]);
|
|
2349
2335
|
}
|
|
2350
2336
|
}
|
|
2351
2337
|
async externalOrPlatform(device, accessory) {
|
|
@@ -2355,15 +2341,15 @@ class SwitchBotPlatform {
|
|
|
2355
2341
|
}
|
|
2356
2342
|
else {
|
|
2357
2343
|
this.debugLog(`${accessory.displayName} External Accessory Mode: ${device.external}`);
|
|
2358
|
-
this.api.registerPlatformAccessories(
|
|
2344
|
+
this.api.registerPlatformAccessories(PLUGIN_NAME, PLATFORM_NAME, [accessory]);
|
|
2359
2345
|
}
|
|
2360
2346
|
}
|
|
2361
2347
|
async externalAccessory(accessory) {
|
|
2362
|
-
this.api.publishExternalAccessories(
|
|
2348
|
+
this.api.publishExternalAccessories(PLUGIN_NAME, [accessory]);
|
|
2363
2349
|
}
|
|
2364
2350
|
unregisterPlatformAccessories(existingAccessory) {
|
|
2365
2351
|
// remove platform accessories when no longer present
|
|
2366
|
-
this.api.unregisterPlatformAccessories(
|
|
2352
|
+
this.api.unregisterPlatformAccessories(PLUGIN_NAME, PLATFORM_NAME, [existingAccessory]);
|
|
2367
2353
|
this.warnLog(`Removing existing accessory from cache: ${existingAccessory.displayName}`);
|
|
2368
2354
|
}
|
|
2369
2355
|
async statusCode(statusCode) {
|
|
@@ -2403,7 +2389,7 @@ class SwitchBotPlatform {
|
|
|
2403
2389
|
let switchbot;
|
|
2404
2390
|
try {
|
|
2405
2391
|
Switchbot = require('node-switchbot');
|
|
2406
|
-
|
|
2392
|
+
queueScheduler.schedule(() => (switchbot = new Switchbot()));
|
|
2407
2393
|
}
|
|
2408
2394
|
catch (e) {
|
|
2409
2395
|
switchbot = false;
|
|
@@ -2473,5 +2459,4 @@ class SwitchBotPlatform {
|
|
|
2473
2459
|
return this.platformLogging?.includes('debug') || this.platformLogging === 'standard';
|
|
2474
2460
|
}
|
|
2475
2461
|
}
|
|
2476
|
-
exports.SwitchBotPlatform = SwitchBotPlatform;
|
|
2477
2462
|
//# sourceMappingURL=platform.js.map
|