@switchbot/homebridge-switchbot 2.14.1-beta.0 → 3.0.0-beta.1
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.js → npm-version-script.cjs} +1 -1
- package/.github/workflows/dependabot.yml +10 -11
- package/CHANGELOG.md +11 -2
- package/LICENSE +1 -1
- package/dist/device/blindtilt.d.ts +10 -6
- package/dist/device/blindtilt.d.ts.map +1 -1
- package/dist/device/blindtilt.js +152 -91
- package/dist/device/blindtilt.js.map +1 -1
- package/dist/device/bot.d.ts +10 -6
- 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 +10 -6
- 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 +10 -6
- 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 +10 -6
- 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 +10 -6
- package/dist/device/curtain.d.ts.map +1 -1
- package/dist/device/curtain.js +165 -107
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/hub.d.ts +10 -6
- package/dist/device/hub.d.ts.map +1 -1
- package/dist/device/hub.js +88 -51
- package/dist/device/hub.js.map +1 -1
- package/dist/device/humidifier.d.ts +10 -6
- 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 +10 -6
- package/dist/device/iosensor.d.ts.map +1 -1
- package/dist/device/iosensor.js +109 -66
- package/dist/device/iosensor.js.map +1 -1
- package/dist/device/lightstrip.d.ts +10 -6
- 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 +11 -7
- 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 +10 -6
- package/dist/device/meter.d.ts.map +1 -1
- package/dist/device/meter.js +103 -63
- package/dist/device/meter.js.map +1 -1
- package/dist/device/meterplus.d.ts +10 -6
- package/dist/device/meterplus.d.ts.map +1 -1
- package/dist/device/meterplus.js +103 -63
- package/dist/device/meterplus.js.map +1 -1
- package/dist/device/motion.d.ts +10 -6
- 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 +10 -6
- 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 +10 -6
- 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.js +5 -10
- package/dist/homebridge-ui/server.js.map +1 -1
- 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 +9 -5
- 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 +9 -5
- 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 +9 -5
- 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 +9 -5
- 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 +9 -5
- 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 +9 -5
- 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 +9 -5
- 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 +9 -5
- 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 +9 -5
- 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 +151 -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 +20 -9
- package/src/device/blindtilt.ts +84 -72
- package/src/device/bot.ts +191 -180
- package/src/device/ceilinglight.ts +57 -44
- package/src/device/colorbulb.ts +53 -40
- package/src/device/contact.ts +71 -60
- package/src/device/curtain.ts +98 -86
- package/src/device/hub.ts +57 -45
- package/src/device/humidifier.ts +88 -77
- package/src/device/iosensor.ts +67 -55
- package/src/device/lightstrip.ts +56 -43
- package/src/device/lock.ts +91 -81
- package/src/device/meter.ts +63 -51
- package/src/device/meterplus.ts +67 -55
- package/src/device/motion.ts +58 -47
- package/src/device/plug.ts +38 -27
- package/src/device/robotvacuumcleaner.ts +49 -38
- package/src/index.ts +10 -7
- package/src/irdevice/airconditioner.ts +71 -63
- package/src/irdevice/airpurifier.ts +48 -40
- package/src/irdevice/camera.ts +28 -20
- package/src/irdevice/fan.ts +42 -34
- package/src/irdevice/light.ts +48 -40
- package/src/irdevice/other.ts +164 -156
- package/src/irdevice/tv.ts +66 -58
- package/src/irdevice/vacuumcleaner.ts +28 -20
- package/src/irdevice/waterheater.ts +35 -27
- package/src/platform.ts +65 -47
- package/tsconfig.json +11 -13
package/dist/platform.js
CHANGED
|
@@ -1,108 +1,79 @@
|
|
|
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.js';
|
|
3
|
+
import { Plug } from './device/plug.js';
|
|
4
|
+
import { Lock } from './device/lock.js';
|
|
5
|
+
import { Meter } from './device/meter.js';
|
|
6
|
+
import { Motion } from './device/motion.js';
|
|
7
|
+
import { Hub } from './device/hub.js';
|
|
8
|
+
import { Contact } from './device/contact.js';
|
|
9
|
+
import { Curtain } from './device/curtain.js';
|
|
10
|
+
import { IOSensor } from './device/iosensor.js';
|
|
11
|
+
import { MeterPlus } from './device/meterplus.js';
|
|
12
|
+
import { ColorBulb } from './device/colorbulb.js';
|
|
13
|
+
import { CeilingLight } from './device/ceilinglight.js';
|
|
14
|
+
import { StripLight } from './device/lightstrip.js';
|
|
15
|
+
import { Humidifier } from './device/humidifier.js';
|
|
16
|
+
import { RobotVacuumCleaner } from './device/robotvacuumcleaner.js';
|
|
17
|
+
import { TV } from './irdevice/tv.js';
|
|
18
|
+
import { Fan } from './irdevice/fan.js';
|
|
19
|
+
import { Light } from './irdevice/light.js';
|
|
20
|
+
import { Others } from './irdevice/other.js';
|
|
21
|
+
import { Camera } from './irdevice/camera.js';
|
|
22
|
+
import { BlindTilt } from './device/blindtilt.js';
|
|
23
|
+
import { AirPurifier } from './irdevice/airpurifier.js';
|
|
24
|
+
import { WaterHeater } from './irdevice/waterheater.js';
|
|
25
|
+
import { VacuumCleaner } from './irdevice/vacuumcleaner.js';
|
|
26
|
+
import { AirConditioner } from './irdevice/airconditioner.js';
|
|
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 asyncmqtt from 'async-mqtt';
|
|
33
|
+
import crypto, { randomUUID } from 'crypto';
|
|
34
|
+
import { readFileSync, writeFileSync } from 'fs';
|
|
35
|
+
import hbLib 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
|
+
name: config.name,
|
|
67
|
+
credentials: config.credentials,
|
|
68
|
+
url: config.url,
|
|
69
|
+
port: config.port,
|
|
70
|
+
hostname: config.hostname,
|
|
71
|
+
protocol: config.protocol,
|
|
72
|
+
verifyTLS: config.verifyTLS,
|
|
73
|
+
logging: config.logging,
|
|
74
|
+
};
|
|
75
|
+
this.logs();
|
|
76
|
+
this.debugLog(`Finished initializing platform: ${config.name}`);
|
|
106
77
|
// HOOBS notice
|
|
107
78
|
if (__dirname.includes('hoobs')) {
|
|
108
79
|
this.warnLog('This plugin has not been tested under HOOBS, it is highly recommended that you switch to Homebridge: ' +
|
|
@@ -119,8 +90,9 @@ class SwitchBotPlatform {
|
|
|
119
90
|
return;
|
|
120
91
|
}
|
|
121
92
|
// import fakegato-history module and EVE characteristics
|
|
122
|
-
|
|
123
|
-
this.
|
|
93
|
+
const { EveHomeKitTypes } = hbLib;
|
|
94
|
+
this.fakegatoAPI = fakegato(api);
|
|
95
|
+
this.eve = new EveHomeKitTypes(api);
|
|
124
96
|
// When this event is fired it means Homebridge has restored all cached accessories from disk.
|
|
125
97
|
// Dynamic Platform plugins should only register new accessories after this event was fired,
|
|
126
98
|
// in order to ensure they weren't added to homebridge already. This event can also be used
|
|
@@ -151,7 +123,8 @@ class SwitchBotPlatform {
|
|
|
151
123
|
async setupMqtt() {
|
|
152
124
|
if (this.config.options?.mqttURL) {
|
|
153
125
|
try {
|
|
154
|
-
|
|
126
|
+
const { connectAsync } = asyncmqtt;
|
|
127
|
+
this.mqttClient = await connectAsync(this.config.options?.mqttURL, this.config.options.mqttOptions || {});
|
|
155
128
|
this.debugLog('MQTT connection has been established successfully.');
|
|
156
129
|
this.mqttClient.on('error', (e) => {
|
|
157
130
|
this.errorLog(`Failed to publish MQTT messages. ${e}`);
|
|
@@ -225,7 +198,7 @@ class SwitchBotPlatform {
|
|
|
225
198
|
return;
|
|
226
199
|
}
|
|
227
200
|
try {
|
|
228
|
-
const { body, statusCode, headers } = await
|
|
201
|
+
const { body, statusCode, headers } = await request('https://api.switch-bot.com/v1.1/webhook/setupWebhook', {
|
|
229
202
|
method: 'POST',
|
|
230
203
|
headers: this.generateHeaders(),
|
|
231
204
|
body: JSON.stringify({
|
|
@@ -248,7 +221,7 @@ class SwitchBotPlatform {
|
|
|
248
221
|
this.errorLog(`Failed to configure webhook. Error: ${e.message}`);
|
|
249
222
|
}
|
|
250
223
|
try {
|
|
251
|
-
const { body, statusCode, headers } = await
|
|
224
|
+
const { body, statusCode, headers } = await request('https://api.switch-bot.com/v1.1/webhook/updateWebhook', {
|
|
252
225
|
method: 'POST',
|
|
253
226
|
headers: this.generateHeaders(),
|
|
254
227
|
body: JSON.stringify({
|
|
@@ -272,7 +245,7 @@ class SwitchBotPlatform {
|
|
|
272
245
|
this.errorLog(`Failed to update webhook. Error:${e.message}`);
|
|
273
246
|
}
|
|
274
247
|
try {
|
|
275
|
-
const { body, statusCode, headers } = await
|
|
248
|
+
const { body, statusCode, headers } = await request('https://api.switch-bot.com/v1.1/webhook/queryWebhook', {
|
|
276
249
|
method: 'POST',
|
|
277
250
|
headers: this.generateHeaders(),
|
|
278
251
|
body: JSON.stringify({
|
|
@@ -295,7 +268,7 @@ class SwitchBotPlatform {
|
|
|
295
268
|
}
|
|
296
269
|
this.api.on('shutdown', async () => {
|
|
297
270
|
try {
|
|
298
|
-
const { body, statusCode, headers } = await
|
|
271
|
+
const { body, statusCode, headers } = await request('https://api.switch-bot.com/v1.1/webhook/deleteWebhook', {
|
|
299
272
|
method: 'POST',
|
|
300
273
|
headers: this.generateHeaders(),
|
|
301
274
|
body: JSON.stringify({
|
|
@@ -417,15 +390,15 @@ class SwitchBotPlatform {
|
|
|
417
390
|
throw new Error('New token not provided');
|
|
418
391
|
}
|
|
419
392
|
// load in the current config
|
|
420
|
-
const currentConfig = JSON.parse(
|
|
393
|
+
const currentConfig = JSON.parse(readFileSync(this.api.user.configPath(), 'utf8'));
|
|
421
394
|
// check the platforms section is an array before we do array things on it
|
|
422
395
|
if (!Array.isArray(currentConfig.platforms)) {
|
|
423
396
|
throw new Error('Cannot find platforms array in config');
|
|
424
397
|
}
|
|
425
398
|
// find this plugins current config
|
|
426
|
-
const pluginConfig = currentConfig.platforms.find((x) => x.platform ===
|
|
399
|
+
const pluginConfig = currentConfig.platforms.find((x) => x.platform === PLATFORM_NAME);
|
|
427
400
|
if (!pluginConfig) {
|
|
428
|
-
throw new Error(`Cannot find config for ${
|
|
401
|
+
throw new Error(`Cannot find config for ${PLATFORM_NAME} in platforms array`);
|
|
429
402
|
}
|
|
430
403
|
// check the .credentials is an object before doing object things with it
|
|
431
404
|
if (typeof pluginConfig.credentials !== 'object') {
|
|
@@ -450,13 +423,30 @@ class SwitchBotPlatform {
|
|
|
450
423
|
}
|
|
451
424
|
this.debugWarnLog(`token: ${pluginConfig.credentials.token}`);
|
|
452
425
|
// save the config, ensuring we maintain pretty json
|
|
453
|
-
|
|
426
|
+
writeFileSync(this.api.user.configPath(), JSON.stringify(currentConfig, null, 4));
|
|
454
427
|
this.verifyConfig();
|
|
455
428
|
}
|
|
456
429
|
catch (e) {
|
|
457
430
|
this.errorLog(`Update Token: ${e}`);
|
|
458
431
|
}
|
|
459
432
|
}
|
|
433
|
+
generateHeaders = () => {
|
|
434
|
+
const t = `${Date.now()}`;
|
|
435
|
+
const nonce = randomUUID();
|
|
436
|
+
const data = this.config.credentials?.token + t + nonce;
|
|
437
|
+
const signTerm = crypto
|
|
438
|
+
.createHmac('sha256', this.config.credentials?.secret)
|
|
439
|
+
.update(Buffer.from(data, 'utf-8'))
|
|
440
|
+
.digest();
|
|
441
|
+
const sign = signTerm.toString('base64');
|
|
442
|
+
return {
|
|
443
|
+
Authorization: this.config.credentials?.token,
|
|
444
|
+
sign: sign,
|
|
445
|
+
nonce: nonce,
|
|
446
|
+
t: t,
|
|
447
|
+
'Content-Type': 'application/json',
|
|
448
|
+
};
|
|
449
|
+
};
|
|
460
450
|
/**
|
|
461
451
|
* this method discovers devices
|
|
462
452
|
*
|
|
@@ -469,7 +459,7 @@ class SwitchBotPlatform {
|
|
|
469
459
|
async discoverDevices() {
|
|
470
460
|
if (this.config.credentials?.token) {
|
|
471
461
|
try {
|
|
472
|
-
const { body, statusCode, headers } = await
|
|
462
|
+
const { body, statusCode, headers } = await request(Devices, {
|
|
473
463
|
headers: this.generateHeaders(),
|
|
474
464
|
});
|
|
475
465
|
this.debugWarnLog(`body: ${JSON.stringify(body)}`);
|
|
@@ -778,7 +768,7 @@ class SwitchBotPlatform {
|
|
|
778
768
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
779
769
|
// create the accessory handler for the restored accessory
|
|
780
770
|
// this is imported from `platformAccessory.ts`
|
|
781
|
-
new
|
|
771
|
+
new Humidifier(this, existingAccessory, device);
|
|
782
772
|
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
|
|
783
773
|
}
|
|
784
774
|
else {
|
|
@@ -804,7 +794,7 @@ class SwitchBotPlatform {
|
|
|
804
794
|
accessory.context.connectionType = await this.connectionType(device);
|
|
805
795
|
// create the accessory handler for the newly create accessory
|
|
806
796
|
// this is imported from `platformAccessory.ts`
|
|
807
|
-
new
|
|
797
|
+
new Humidifier(this, accessory, device);
|
|
808
798
|
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
|
|
809
799
|
// publish device externally or link the accessory to your platform
|
|
810
800
|
this.externalOrPlatform(device, accessory);
|
|
@@ -835,7 +825,7 @@ class SwitchBotPlatform {
|
|
|
835
825
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
836
826
|
// create the accessory handler for the restored accessory
|
|
837
827
|
// this is imported from `platformAccessory.ts`
|
|
838
|
-
new
|
|
828
|
+
new Bot(this, existingAccessory, device);
|
|
839
829
|
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
|
|
840
830
|
}
|
|
841
831
|
else {
|
|
@@ -862,7 +852,7 @@ class SwitchBotPlatform {
|
|
|
862
852
|
// accessory.context.FirmwareRevision = findaccessories.accessoryAttribute.softwareRevision;
|
|
863
853
|
// create the accessory handler for the newly create accessory
|
|
864
854
|
// this is imported from `platformAccessory.ts`
|
|
865
|
-
new
|
|
855
|
+
new Bot(this, accessory, device);
|
|
866
856
|
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
|
|
867
857
|
// publish device externally or link the accessory to your platform
|
|
868
858
|
this.externalOrPlatform(device, accessory);
|
|
@@ -893,7 +883,7 @@ class SwitchBotPlatform {
|
|
|
893
883
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
894
884
|
// create the accessory handler for the restored accessory
|
|
895
885
|
// this is imported from `platformAccessory.ts`
|
|
896
|
-
new
|
|
886
|
+
new Meter(this, existingAccessory, device);
|
|
897
887
|
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
|
|
898
888
|
}
|
|
899
889
|
else {
|
|
@@ -919,7 +909,7 @@ class SwitchBotPlatform {
|
|
|
919
909
|
accessory.context.connectionType = await this.connectionType(device);
|
|
920
910
|
// create the accessory handler for the newly create accessory
|
|
921
911
|
// this is imported from `platformAccessory.ts`
|
|
922
|
-
new
|
|
912
|
+
new Meter(this, accessory, device);
|
|
923
913
|
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
|
|
924
914
|
// publish device externally or link the accessory to your platform
|
|
925
915
|
this.externalOrPlatform(device, accessory);
|
|
@@ -951,7 +941,7 @@ class SwitchBotPlatform {
|
|
|
951
941
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
952
942
|
// create the accessory handler for the restored accessory
|
|
953
943
|
// this is imported from `platformAccessory.ts`
|
|
954
|
-
new
|
|
944
|
+
new MeterPlus(this, existingAccessory, device);
|
|
955
945
|
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
|
|
956
946
|
}
|
|
957
947
|
else {
|
|
@@ -977,7 +967,7 @@ class SwitchBotPlatform {
|
|
|
977
967
|
accessory.context.connectionType = await this.connectionType(device);
|
|
978
968
|
// create the accessory handler for the newly create accessory
|
|
979
969
|
// this is imported from `platformAccessory.ts`
|
|
980
|
-
new
|
|
970
|
+
new MeterPlus(this, accessory, device);
|
|
981
971
|
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
|
|
982
972
|
// publish device externally or link the accessory to your platform
|
|
983
973
|
this.externalOrPlatform(device, accessory);
|
|
@@ -1009,7 +999,7 @@ class SwitchBotPlatform {
|
|
|
1009
999
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
1010
1000
|
// create the accessory handler for the restored accessory
|
|
1011
1001
|
// this is imported from `platformAccessory.ts`
|
|
1012
|
-
new
|
|
1002
|
+
new Hub(this, existingAccessory, device);
|
|
1013
1003
|
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
|
|
1014
1004
|
}
|
|
1015
1005
|
else {
|
|
@@ -1035,7 +1025,7 @@ class SwitchBotPlatform {
|
|
|
1035
1025
|
accessory.context.connectionType = await this.connectionType(device);
|
|
1036
1026
|
// create the accessory handler for the newly create accessory
|
|
1037
1027
|
// this is imported from `platformAccessory.ts`
|
|
1038
|
-
new
|
|
1028
|
+
new Hub(this, accessory, device);
|
|
1039
1029
|
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
|
|
1040
1030
|
// publish device externally or link the accessory to your platform
|
|
1041
1031
|
this.externalOrPlatform(device, accessory);
|
|
@@ -1066,7 +1056,7 @@ class SwitchBotPlatform {
|
|
|
1066
1056
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
1067
1057
|
// create the accessory handler for the restored accessory
|
|
1068
1058
|
// this is imported from `platformAccessory.ts`
|
|
1069
|
-
new
|
|
1059
|
+
new IOSensor(this, existingAccessory, device);
|
|
1070
1060
|
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
|
|
1071
1061
|
}
|
|
1072
1062
|
else {
|
|
@@ -1092,7 +1082,7 @@ class SwitchBotPlatform {
|
|
|
1092
1082
|
accessory.context.connectionType = await this.connectionType(device);
|
|
1093
1083
|
// create the accessory handler for the newly create accessory
|
|
1094
1084
|
// this is imported from `platformAccessory.ts`
|
|
1095
|
-
new
|
|
1085
|
+
new IOSensor(this, accessory, device);
|
|
1096
1086
|
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
|
|
1097
1087
|
// publish device externally or link the accessory to your platform
|
|
1098
1088
|
this.externalOrPlatform(device, accessory);
|
|
@@ -1123,7 +1113,7 @@ class SwitchBotPlatform {
|
|
|
1123
1113
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
1124
1114
|
// create the accessory handler for the restored accessory
|
|
1125
1115
|
// this is imported from `platformAccessory.ts`
|
|
1126
|
-
new
|
|
1116
|
+
new Motion(this, existingAccessory, device);
|
|
1127
1117
|
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
|
|
1128
1118
|
}
|
|
1129
1119
|
else {
|
|
@@ -1149,7 +1139,7 @@ class SwitchBotPlatform {
|
|
|
1149
1139
|
accessory.context.connectionType = await this.connectionType(device);
|
|
1150
1140
|
// create the accessory handler for the newly create accessory
|
|
1151
1141
|
// this is imported from `platformAccessory.ts`
|
|
1152
|
-
new
|
|
1142
|
+
new Motion(this, accessory, device);
|
|
1153
1143
|
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
|
|
1154
1144
|
// publish device externally or link the accessory to your platform
|
|
1155
1145
|
this.externalOrPlatform(device, accessory);
|
|
@@ -1180,7 +1170,7 @@ class SwitchBotPlatform {
|
|
|
1180
1170
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
1181
1171
|
// create the accessory handler for the restored accessory
|
|
1182
1172
|
// this is imported from `platformAccessory.ts`
|
|
1183
|
-
new
|
|
1173
|
+
new Contact(this, existingAccessory, device);
|
|
1184
1174
|
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
|
|
1185
1175
|
}
|
|
1186
1176
|
else {
|
|
@@ -1206,7 +1196,7 @@ class SwitchBotPlatform {
|
|
|
1206
1196
|
accessory.context.connectionType = await this.connectionType(device);
|
|
1207
1197
|
// create the accessory handler for the newly create accessory
|
|
1208
1198
|
// this is imported from `platformAccessory.ts`
|
|
1209
|
-
new
|
|
1199
|
+
new Contact(this, accessory, device);
|
|
1210
1200
|
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
|
|
1211
1201
|
// publish device externally or link the accessory to your platform
|
|
1212
1202
|
this.externalOrPlatform(device, accessory);
|
|
@@ -1237,7 +1227,7 @@ class SwitchBotPlatform {
|
|
|
1237
1227
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
1238
1228
|
// create the accessory handler for the restored accessory
|
|
1239
1229
|
// this is imported from `platformAccessory.ts`
|
|
1240
|
-
new
|
|
1230
|
+
new BlindTilt(this, existingAccessory, device);
|
|
1241
1231
|
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
|
|
1242
1232
|
}
|
|
1243
1233
|
else {
|
|
@@ -1275,7 +1265,7 @@ class SwitchBotPlatform {
|
|
|
1275
1265
|
accessory.context.connectionType = await this.connectionType(device);
|
|
1276
1266
|
// create the accessory handler for the newly create accessory
|
|
1277
1267
|
// this is imported from `platformAccessory.ts`
|
|
1278
|
-
new
|
|
1268
|
+
new BlindTilt(this, accessory, device);
|
|
1279
1269
|
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
|
|
1280
1270
|
// publish device externally or link the accessory to your platform
|
|
1281
1271
|
this.externalOrPlatform(device, accessory);
|
|
@@ -1306,7 +1296,7 @@ class SwitchBotPlatform {
|
|
|
1306
1296
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
1307
1297
|
// create the accessory handler for the restored accessory
|
|
1308
1298
|
// this is imported from `platformAccessory.ts`
|
|
1309
|
-
new
|
|
1299
|
+
new Curtain(this, existingAccessory, device);
|
|
1310
1300
|
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
|
|
1311
1301
|
}
|
|
1312
1302
|
else {
|
|
@@ -1344,7 +1334,7 @@ class SwitchBotPlatform {
|
|
|
1344
1334
|
accessory.context.connectionType = await this.connectionType(device);
|
|
1345
1335
|
// create the accessory handler for the newly create accessory
|
|
1346
1336
|
// this is imported from `platformAccessory.ts`
|
|
1347
|
-
new
|
|
1337
|
+
new Curtain(this, accessory, device);
|
|
1348
1338
|
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
|
|
1349
1339
|
// publish device externally or link the accessory to your platform
|
|
1350
1340
|
this.externalOrPlatform(device, accessory);
|
|
@@ -1375,7 +1365,7 @@ class SwitchBotPlatform {
|
|
|
1375
1365
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
1376
1366
|
// create the accessory handler for the restored accessory
|
|
1377
1367
|
// this is imported from `platformAccessory.ts`
|
|
1378
|
-
new
|
|
1368
|
+
new Plug(this, existingAccessory, device);
|
|
1379
1369
|
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
|
|
1380
1370
|
}
|
|
1381
1371
|
else {
|
|
@@ -1401,7 +1391,7 @@ class SwitchBotPlatform {
|
|
|
1401
1391
|
accessory.context.connectionType = await this.connectionType(device);
|
|
1402
1392
|
// create the accessory handler for the newly create accessory
|
|
1403
1393
|
// this is imported from `platformAccessory.ts`
|
|
1404
|
-
new
|
|
1394
|
+
new Plug(this, accessory, device);
|
|
1405
1395
|
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
|
|
1406
1396
|
// publish device externally or link the accessory to your platform
|
|
1407
1397
|
this.externalOrPlatform(device, accessory);
|
|
@@ -1432,7 +1422,7 @@ class SwitchBotPlatform {
|
|
|
1432
1422
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
1433
1423
|
// create the accessory handler for the restored accessory
|
|
1434
1424
|
// this is imported from `platformAccessory.ts`
|
|
1435
|
-
new
|
|
1425
|
+
new Lock(this, existingAccessory, device);
|
|
1436
1426
|
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
|
|
1437
1427
|
}
|
|
1438
1428
|
else {
|
|
@@ -1458,7 +1448,7 @@ class SwitchBotPlatform {
|
|
|
1458
1448
|
accessory.context.connectionType = await this.connectionType(device);
|
|
1459
1449
|
// create the accessory handler for the newly create accessory
|
|
1460
1450
|
// this is imported from `platformAccessory.ts`
|
|
1461
|
-
new
|
|
1451
|
+
new Lock(this, accessory, device);
|
|
1462
1452
|
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
|
|
1463
1453
|
// publish device externally or link the accessory to your platform
|
|
1464
1454
|
this.externalOrPlatform(device, accessory);
|
|
@@ -1489,7 +1479,7 @@ class SwitchBotPlatform {
|
|
|
1489
1479
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
1490
1480
|
// create the accessory handler for the restored accessory
|
|
1491
1481
|
// this is imported from `platformAccessory.ts`
|
|
1492
|
-
new
|
|
1482
|
+
new ColorBulb(this, existingAccessory, device);
|
|
1493
1483
|
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
|
|
1494
1484
|
}
|
|
1495
1485
|
else {
|
|
@@ -1515,7 +1505,7 @@ class SwitchBotPlatform {
|
|
|
1515
1505
|
accessory.context.connectionType = await this.connectionType(device);
|
|
1516
1506
|
// create the accessory handler for the newly create accessory
|
|
1517
1507
|
// this is imported from `platformAccessory.ts`
|
|
1518
|
-
new
|
|
1508
|
+
new ColorBulb(this, accessory, device);
|
|
1519
1509
|
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
|
|
1520
1510
|
// publish device externally or link the accessory to your platform
|
|
1521
1511
|
this.externalOrPlatform(device, accessory);
|
|
@@ -1546,7 +1536,7 @@ class SwitchBotPlatform {
|
|
|
1546
1536
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
1547
1537
|
// create the accessory handler for the restored accessory
|
|
1548
1538
|
// this is imported from `platformAccessory.ts`
|
|
1549
|
-
new
|
|
1539
|
+
new CeilingLight(this, existingAccessory, device);
|
|
1550
1540
|
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
|
|
1551
1541
|
}
|
|
1552
1542
|
else {
|
|
@@ -1572,7 +1562,7 @@ class SwitchBotPlatform {
|
|
|
1572
1562
|
accessory.context.connectionType = await this.connectionType(device);
|
|
1573
1563
|
// create the accessory handler for the newly create accessory
|
|
1574
1564
|
// this is imported from `platformAccessory.ts`
|
|
1575
|
-
new
|
|
1565
|
+
new CeilingLight(this, accessory, device);
|
|
1576
1566
|
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
|
|
1577
1567
|
// publish device externally or link the accessory to your platform
|
|
1578
1568
|
this.externalOrPlatform(device, accessory);
|
|
@@ -1603,7 +1593,7 @@ class SwitchBotPlatform {
|
|
|
1603
1593
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
1604
1594
|
// create the accessory handler for the restored accessory
|
|
1605
1595
|
// this is imported from `platformAccessory.ts`
|
|
1606
|
-
new
|
|
1596
|
+
new StripLight(this, existingAccessory, device);
|
|
1607
1597
|
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
|
|
1608
1598
|
}
|
|
1609
1599
|
else {
|
|
@@ -1629,7 +1619,7 @@ class SwitchBotPlatform {
|
|
|
1629
1619
|
accessory.context.connectionType = await this.connectionType(device);
|
|
1630
1620
|
// create the accessory handler for the newly create accessory
|
|
1631
1621
|
// this is imported from `platformAccessory.ts`
|
|
1632
|
-
new
|
|
1622
|
+
new StripLight(this, accessory, device);
|
|
1633
1623
|
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
|
|
1634
1624
|
// publish device externally or link the accessory to your platform
|
|
1635
1625
|
this.externalOrPlatform(device, accessory);
|
|
@@ -1660,7 +1650,7 @@ class SwitchBotPlatform {
|
|
|
1660
1650
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
1661
1651
|
// create the accessory handler for the restored accessory
|
|
1662
1652
|
// this is imported from `platformAccessory.ts`
|
|
1663
|
-
new
|
|
1653
|
+
new RobotVacuumCleaner(this, existingAccessory, device);
|
|
1664
1654
|
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
|
|
1665
1655
|
}
|
|
1666
1656
|
else {
|
|
@@ -1686,7 +1676,7 @@ class SwitchBotPlatform {
|
|
|
1686
1676
|
accessory.context.connectionType = await this.connectionType(device);
|
|
1687
1677
|
// create the accessory handler for the newly create accessory
|
|
1688
1678
|
// this is imported from `platformAccessory.ts`
|
|
1689
|
-
new
|
|
1679
|
+
new RobotVacuumCleaner(this, accessory, device);
|
|
1690
1680
|
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
|
|
1691
1681
|
// publish device externally or link the accessory to your platform
|
|
1692
1682
|
this.externalOrPlatform(device, accessory);
|
|
@@ -1713,7 +1703,7 @@ class SwitchBotPlatform {
|
|
|
1713
1703
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
1714
1704
|
// create the accessory handler for the restored accessory
|
|
1715
1705
|
// this is imported from `platformAccessory.ts`
|
|
1716
|
-
new
|
|
1706
|
+
new TV(this, existingAccessory, device);
|
|
1717
1707
|
this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${existingAccessory.UUID})`);
|
|
1718
1708
|
}
|
|
1719
1709
|
else if (!device.hide_device && device.hubDeviceId) {
|
|
@@ -1735,7 +1725,7 @@ class SwitchBotPlatform {
|
|
|
1735
1725
|
accessory.context.connectionType = device.connectionType;
|
|
1736
1726
|
// create the accessory handler for the newly create accessory
|
|
1737
1727
|
// this is imported from `platformAccessory.ts`
|
|
1738
|
-
new
|
|
1728
|
+
new TV(this, accessory, device);
|
|
1739
1729
|
this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`);
|
|
1740
1730
|
this.externalOrPlatformIR(device, accessory);
|
|
1741
1731
|
this.accessories.push(accessory);
|
|
@@ -1765,7 +1755,7 @@ class SwitchBotPlatform {
|
|
|
1765
1755
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
1766
1756
|
// create the accessory handler for the restored accessory
|
|
1767
1757
|
// this is imported from `platformAccessory.ts`
|
|
1768
|
-
new
|
|
1758
|
+
new Fan(this, existingAccessory, device);
|
|
1769
1759
|
this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${existingAccessory.UUID})`);
|
|
1770
1760
|
}
|
|
1771
1761
|
else {
|
|
@@ -1791,7 +1781,7 @@ class SwitchBotPlatform {
|
|
|
1791
1781
|
accessory.context.connectionType = device.connectionType;
|
|
1792
1782
|
// create the accessory handler for the newly create accessory
|
|
1793
1783
|
// this is imported from `platformAccessory.ts`
|
|
1794
|
-
new
|
|
1784
|
+
new Fan(this, accessory, device);
|
|
1795
1785
|
this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`);
|
|
1796
1786
|
// publish device externally or link the accessory to your platform
|
|
1797
1787
|
this.externalOrPlatformIR(device, accessory);
|
|
@@ -1822,7 +1812,7 @@ class SwitchBotPlatform {
|
|
|
1822
1812
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
1823
1813
|
// create the accessory handler for the restored accessory
|
|
1824
1814
|
// this is imported from `platformAccessory.ts`
|
|
1825
|
-
new
|
|
1815
|
+
new Light(this, existingAccessory, device);
|
|
1826
1816
|
this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${existingAccessory.UUID})`);
|
|
1827
1817
|
}
|
|
1828
1818
|
else {
|
|
@@ -1848,7 +1838,7 @@ class SwitchBotPlatform {
|
|
|
1848
1838
|
accessory.context.connectionType = device.connectionType;
|
|
1849
1839
|
// create the accessory handler for the newly create accessory
|
|
1850
1840
|
// this is imported from `platformAccessory.ts`
|
|
1851
|
-
new
|
|
1841
|
+
new Light(this, accessory, device);
|
|
1852
1842
|
this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`);
|
|
1853
1843
|
// publish device externally or link the accessory to your platform
|
|
1854
1844
|
this.externalOrPlatformIR(device, accessory);
|
|
@@ -1879,7 +1869,7 @@ class SwitchBotPlatform {
|
|
|
1879
1869
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
1880
1870
|
// create the accessory handler for the restored accessory
|
|
1881
1871
|
// this is imported from `platformAccessory.ts`
|
|
1882
|
-
new
|
|
1872
|
+
new AirConditioner(this, existingAccessory, device);
|
|
1883
1873
|
this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${existingAccessory.UUID})`);
|
|
1884
1874
|
}
|
|
1885
1875
|
else {
|
|
@@ -1905,7 +1895,7 @@ class SwitchBotPlatform {
|
|
|
1905
1895
|
accessory.context.connectionType = device.connectionType;
|
|
1906
1896
|
// create the accessory handler for the newly create accessory
|
|
1907
1897
|
// this is imported from `platformAccessory.ts`
|
|
1908
|
-
new
|
|
1898
|
+
new AirConditioner(this, accessory, device);
|
|
1909
1899
|
this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`);
|
|
1910
1900
|
// publish device externally or link the accessory to your platform
|
|
1911
1901
|
this.externalOrPlatformIR(device, accessory);
|
|
@@ -1936,7 +1926,7 @@ class SwitchBotPlatform {
|
|
|
1936
1926
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
1937
1927
|
// create the accessory handler for the restored accessory
|
|
1938
1928
|
// this is imported from `platformAccessory.ts`
|
|
1939
|
-
new
|
|
1929
|
+
new AirPurifier(this, existingAccessory, device);
|
|
1940
1930
|
this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${existingAccessory.UUID})`);
|
|
1941
1931
|
}
|
|
1942
1932
|
else {
|
|
@@ -1962,7 +1952,7 @@ class SwitchBotPlatform {
|
|
|
1962
1952
|
accessory.context.connectionType = device.connectionType;
|
|
1963
1953
|
// create the accessory handler for the newly create accessory
|
|
1964
1954
|
// this is imported from `platformAccessory.ts`
|
|
1965
|
-
new
|
|
1955
|
+
new AirPurifier(this, accessory, device);
|
|
1966
1956
|
this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`);
|
|
1967
1957
|
// publish device externally or link the accessory to your platform
|
|
1968
1958
|
this.externalOrPlatformIR(device, accessory);
|
|
@@ -1993,7 +1983,7 @@ class SwitchBotPlatform {
|
|
|
1993
1983
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
1994
1984
|
// create the accessory handler for the restored accessory
|
|
1995
1985
|
// this is imported from `platformAccessory.ts`
|
|
1996
|
-
new
|
|
1986
|
+
new WaterHeater(this, existingAccessory, device);
|
|
1997
1987
|
this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${existingAccessory.UUID})`);
|
|
1998
1988
|
}
|
|
1999
1989
|
else {
|
|
@@ -2019,7 +2009,7 @@ class SwitchBotPlatform {
|
|
|
2019
2009
|
accessory.context.connectionType = device.connectionType;
|
|
2020
2010
|
// create the accessory handler for the newly create accessory
|
|
2021
2011
|
// this is imported from `platformAccessory.ts`
|
|
2022
|
-
new
|
|
2012
|
+
new WaterHeater(this, accessory, device);
|
|
2023
2013
|
this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`);
|
|
2024
2014
|
// publish device externally or link the accessory to your platform
|
|
2025
2015
|
this.externalOrPlatformIR(device, accessory);
|
|
@@ -2050,7 +2040,7 @@ class SwitchBotPlatform {
|
|
|
2050
2040
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
2051
2041
|
// create the accessory handler for the restored accessory
|
|
2052
2042
|
// this is imported from `platformAccessory.ts`
|
|
2053
|
-
new
|
|
2043
|
+
new VacuumCleaner(this, existingAccessory, device);
|
|
2054
2044
|
this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${existingAccessory.UUID})`);
|
|
2055
2045
|
}
|
|
2056
2046
|
else {
|
|
@@ -2076,7 +2066,7 @@ class SwitchBotPlatform {
|
|
|
2076
2066
|
accessory.context.connectionType = device.connectionType;
|
|
2077
2067
|
// create the accessory handler for the newly create accessory
|
|
2078
2068
|
// this is imported from `platformAccessory.ts`
|
|
2079
|
-
new
|
|
2069
|
+
new VacuumCleaner(this, accessory, device);
|
|
2080
2070
|
this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`);
|
|
2081
2071
|
// publish device externally or link the accessory to your platform
|
|
2082
2072
|
this.externalOrPlatformIR(device, accessory);
|
|
@@ -2107,7 +2097,7 @@ class SwitchBotPlatform {
|
|
|
2107
2097
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
2108
2098
|
// create the accessory handler for the restored accessory
|
|
2109
2099
|
// this is imported from `platformAccessory.ts`
|
|
2110
|
-
new
|
|
2100
|
+
new Camera(this, existingAccessory, device);
|
|
2111
2101
|
this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${existingAccessory.UUID})`);
|
|
2112
2102
|
}
|
|
2113
2103
|
else {
|
|
@@ -2133,7 +2123,7 @@ class SwitchBotPlatform {
|
|
|
2133
2123
|
accessory.context.connectionType = device.connectionType;
|
|
2134
2124
|
// create the accessory handler for the newly create accessory
|
|
2135
2125
|
// this is imported from `platformAccessory.ts`
|
|
2136
|
-
new
|
|
2126
|
+
new Camera(this, accessory, device);
|
|
2137
2127
|
this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`);
|
|
2138
2128
|
// publish device externally or link the accessory to your platform
|
|
2139
2129
|
this.externalOrPlatformIR(device, accessory);
|
|
@@ -2164,7 +2154,7 @@ class SwitchBotPlatform {
|
|
|
2164
2154
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
2165
2155
|
// create the accessory handler for the restored accessory
|
|
2166
2156
|
// this is imported from `platformAccessory.ts`
|
|
2167
|
-
new
|
|
2157
|
+
new Others(this, existingAccessory, device);
|
|
2168
2158
|
this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${existingAccessory.UUID})`);
|
|
2169
2159
|
}
|
|
2170
2160
|
else {
|
|
@@ -2190,7 +2180,7 @@ class SwitchBotPlatform {
|
|
|
2190
2180
|
accessory.context.connectionType = device.connectionType;
|
|
2191
2181
|
// create the accessory handler for the newly create accessory
|
|
2192
2182
|
// this is imported from `platformAccessory.ts`
|
|
2193
|
-
new
|
|
2183
|
+
new Others(this, accessory, device);
|
|
2194
2184
|
this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`);
|
|
2195
2185
|
// publish device externally or link the accessory to your platform
|
|
2196
2186
|
this.externalOrPlatformIR(device, accessory);
|
|
@@ -2345,7 +2335,7 @@ class SwitchBotPlatform {
|
|
|
2345
2335
|
}
|
|
2346
2336
|
else {
|
|
2347
2337
|
this.debugLog(`${accessory.displayName} External Accessory Mode: ${device.external}`);
|
|
2348
|
-
this.api.registerPlatformAccessories(
|
|
2338
|
+
this.api.registerPlatformAccessories(PLUGIN_NAME, PLATFORM_NAME, [accessory]);
|
|
2349
2339
|
}
|
|
2350
2340
|
}
|
|
2351
2341
|
async externalOrPlatform(device, accessory) {
|
|
@@ -2355,15 +2345,15 @@ class SwitchBotPlatform {
|
|
|
2355
2345
|
}
|
|
2356
2346
|
else {
|
|
2357
2347
|
this.debugLog(`${accessory.displayName} External Accessory Mode: ${device.external}`);
|
|
2358
|
-
this.api.registerPlatformAccessories(
|
|
2348
|
+
this.api.registerPlatformAccessories(PLUGIN_NAME, PLATFORM_NAME, [accessory]);
|
|
2359
2349
|
}
|
|
2360
2350
|
}
|
|
2361
2351
|
async externalAccessory(accessory) {
|
|
2362
|
-
this.api.publishExternalAccessories(
|
|
2352
|
+
this.api.publishExternalAccessories(PLUGIN_NAME, [accessory]);
|
|
2363
2353
|
}
|
|
2364
2354
|
unregisterPlatformAccessories(existingAccessory) {
|
|
2365
2355
|
// remove platform accessories when no longer present
|
|
2366
|
-
this.api.unregisterPlatformAccessories(
|
|
2356
|
+
this.api.unregisterPlatformAccessories(PLUGIN_NAME, PLATFORM_NAME, [existingAccessory]);
|
|
2367
2357
|
this.warnLog(`Removing existing accessory from cache: ${existingAccessory.displayName}`);
|
|
2368
2358
|
}
|
|
2369
2359
|
async statusCode(statusCode) {
|
|
@@ -2403,7 +2393,7 @@ class SwitchBotPlatform {
|
|
|
2403
2393
|
let switchbot;
|
|
2404
2394
|
try {
|
|
2405
2395
|
Switchbot = require('node-switchbot');
|
|
2406
|
-
|
|
2396
|
+
queueScheduler.schedule(() => (switchbot = new Switchbot()));
|
|
2407
2397
|
}
|
|
2408
2398
|
catch (e) {
|
|
2409
2399
|
switchbot = false;
|
|
@@ -2473,5 +2463,4 @@ class SwitchBotPlatform {
|
|
|
2473
2463
|
return this.platformLogging?.includes('debug') || this.platformLogging === 'standard';
|
|
2474
2464
|
}
|
|
2475
2465
|
}
|
|
2476
|
-
exports.SwitchBotPlatform = SwitchBotPlatform;
|
|
2477
2466
|
//# sourceMappingURL=platform.js.map
|