@switchbot/homebridge-switchbot 0.2.0-alpha.2 → 1.0.1-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/nodejs-beta.yml +1 -1
- package/.github/workflows/nodejs.yml +1 -1
- package/.github/workflows/{prerelease.js → prerelease-beta.js} +0 -0
- package/CHANGELOG.md +1 -1
- package/README.md +9 -5
- package/config.schema.json +370 -142
- package/dist/devices/bots.d.ts +18 -34
- package/dist/devices/bots.d.ts.map +1 -1
- package/dist/devices/bots.js +166 -171
- package/dist/devices/bots.js.map +1 -1
- package/dist/devices/{bulb.d.ts → colorbulb.d.ts} +12 -19
- package/dist/devices/colorbulb.d.ts.map +1 -0
- package/dist/devices/{bulb.js → colorbulb.js} +34 -32
- package/dist/devices/colorbulb.js.map +1 -0
- package/dist/devices/contact.d.ts +18 -16
- package/dist/devices/contact.d.ts.map +1 -1
- package/dist/devices/contact.js +101 -44
- package/dist/devices/contact.js.map +1 -1
- package/dist/devices/curtains.d.ts +17 -51
- package/dist/devices/curtains.d.ts.map +1 -1
- package/dist/devices/curtains.js +170 -248
- package/dist/devices/curtains.js.map +1 -1
- package/dist/devices/humidifiers.d.ts +13 -4
- package/dist/devices/humidifiers.d.ts.map +1 -1
- package/dist/devices/humidifiers.js +81 -8
- package/dist/devices/humidifiers.js.map +1 -1
- package/dist/devices/indoorcam.d.ts +6 -13
- package/dist/devices/indoorcam.d.ts.map +1 -1
- package/dist/devices/indoorcam.js.map +1 -1
- package/dist/devices/meters.d.ts +12 -15
- package/dist/devices/meters.d.ts.map +1 -1
- package/dist/devices/meters.js +38 -44
- package/dist/devices/meters.js.map +1 -1
- package/dist/devices/motion.d.ts +17 -15
- package/dist/devices/motion.d.ts.map +1 -1
- package/dist/devices/motion.js +87 -40
- package/dist/devices/motion.js.map +1 -1
- package/dist/devices/plugs.d.ts +6 -13
- package/dist/devices/plugs.d.ts.map +1 -1
- package/dist/devices/plugs.js.map +1 -1
- package/dist/irdevices/airconditioners.d.ts +10 -10
- package/dist/irdevices/airconditioners.d.ts.map +1 -1
- package/dist/irdevices/airconditioners.js +29 -9
- package/dist/irdevices/airconditioners.js.map +1 -1
- package/dist/irdevices/airpurifiers.d.ts +11 -11
- package/dist/irdevices/airpurifiers.d.ts.map +1 -1
- package/dist/irdevices/airpurifiers.js.map +1 -1
- package/dist/irdevices/cameras.d.ts +3 -3
- package/dist/irdevices/cameras.d.ts.map +1 -1
- package/dist/irdevices/cameras.js.map +1 -1
- package/dist/irdevices/fans.d.ts +6 -6
- package/dist/irdevices/fans.d.ts.map +1 -1
- package/dist/irdevices/fans.js +10 -10
- package/dist/irdevices/fans.js.map +1 -1
- package/dist/irdevices/lights.d.ts +3 -3
- package/dist/irdevices/lights.d.ts.map +1 -1
- package/dist/irdevices/lights.js.map +1 -1
- package/dist/irdevices/others.d.ts +3 -3
- package/dist/irdevices/others.d.ts.map +1 -1
- package/dist/irdevices/others.js.map +1 -1
- package/dist/irdevices/tvs.d.ts +3 -3
- package/dist/irdevices/tvs.d.ts.map +1 -1
- package/dist/irdevices/tvs.js +7 -5
- package/dist/irdevices/tvs.js.map +1 -1
- package/dist/irdevices/vacuumcleaners.d.ts +3 -3
- package/dist/irdevices/vacuumcleaners.d.ts.map +1 -1
- package/dist/irdevices/vacuumcleaners.js.map +1 -1
- package/dist/irdevices/waterheaters.d.ts +3 -3
- package/dist/irdevices/waterheaters.d.ts.map +1 -1
- package/dist/irdevices/waterheaters.js.map +1 -1
- package/dist/platform.d.ts +3 -2
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +136 -46
- package/dist/platform.js.map +1 -1
- package/dist/settings.d.ts +51 -8
- package/dist/settings.d.ts.map +1 -1
- package/package.json +65 -65
- package/src/devices/bots.ts +188 -193
- package/src/devices/{bulb.ts → colorbulb.ts} +46 -51
- package/src/devices/contact.ts +124 -68
- package/src/devices/curtains.ts +192 -300
- package/src/devices/humidifiers.ts +97 -14
- package/src/devices/indoorcam.ts +10 -20
- package/src/devices/meters.ts +57 -69
- package/src/devices/motion.ts +108 -62
- package/src/devices/plugs.ts +8 -19
- package/src/irdevices/airconditioners.ts +43 -20
- package/src/irdevices/airpurifiers.ts +15 -11
- package/src/irdevices/cameras.ts +5 -3
- package/src/irdevices/fans.ts +22 -16
- package/src/irdevices/lights.ts +5 -3
- package/src/irdevices/others.ts +5 -3
- package/src/irdevices/tvs.ts +13 -7
- package/src/irdevices/vacuumcleaners.ts +5 -3
- package/src/irdevices/waterheaters.ts +5 -3
- package/src/platform.ts +148 -49
- package/src/settings.ts +80 -8
- package/dist/devices/bulb.d.ts.map +0 -1
- package/dist/devices/bulb.js.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
|
|
2
2
|
import { SwitchBotPlatform } from '../platform';
|
|
3
|
-
import {
|
|
3
|
+
import { irDevicesConfig, irdevice } from '../settings';
|
|
4
4
|
/**
|
|
5
5
|
* Platform Accessory
|
|
6
6
|
* An instance of this class is created for each accessory your platform registers
|
|
@@ -9,10 +9,10 @@ import { devicesConfig, irdevice } from '../settings';
|
|
|
9
9
|
export declare class VacuumCleaner {
|
|
10
10
|
private readonly platform;
|
|
11
11
|
private accessory;
|
|
12
|
-
device: irdevice &
|
|
12
|
+
device: irdevice & irDevicesConfig;
|
|
13
13
|
service: Service;
|
|
14
14
|
On: CharacteristicValue;
|
|
15
|
-
constructor(platform: SwitchBotPlatform, accessory: PlatformAccessory, device: irdevice &
|
|
15
|
+
constructor(platform: SwitchBotPlatform, accessory: PlatformAccessory, device: irdevice & irDevicesConfig);
|
|
16
16
|
private OnSet;
|
|
17
17
|
/**
|
|
18
18
|
* Pushes the requested changes to the SwitchBot API
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vacuumcleaners.d.ts","sourceRoot":"","sources":["../../src/irdevices/vacuumcleaners.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAC7E,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"vacuumcleaners.d.ts","sourceRoot":"","sources":["../../src/irdevices/vacuumcleaners.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAC7E,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,eAAe,EAAa,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEnE;;;;GAIG;AACH,qBAAa,aAAa;IAQtB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,SAAS;IACV,MAAM,EAAE,QAAQ,GAAG,eAAe;IAR3C,OAAO,EAAG,OAAO,CAAC;IAGlB,EAAE,EAAG,mBAAmB,CAAC;gBAGN,QAAQ,EAAE,iBAAiB,EACpC,SAAS,EAAE,iBAAiB,EAC7B,MAAM,EAAE,QAAQ,GAAG,eAAe;IA2B3C,OAAO,CAAC,KAAK;IAUb;;;;;;;;;OASG;IACG,aAAa;IAWb,cAAc;IAWP,WAAW,CAAC,OAAO,EAAE,GAAG;IAwBrC,OAAO,CAAC,UAAU;IA4BX,QAAQ,CAAC,CAAC,EAAE,GAAG;CAGvB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vacuumcleaners.js","sourceRoot":"","sources":["../../src/irdevices/vacuumcleaners.ts"],"names":[],"mappings":";;;AAGA,
|
|
1
|
+
{"version":3,"file":"vacuumcleaners.js","sourceRoot":"","sources":["../../src/irdevices/vacuumcleaners.ts"],"names":[],"mappings":";;;AAGA,0CAAmE;AAEnE;;;;GAIG;AACH,MAAa,aAAa;IAOxB,YACmB,QAA2B,EACpC,SAA4B,EAC7B,MAAkC;QAFxB,aAAQ,GAAR,QAAQ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SAC9C;IACH,CAAC;IAEM,QAAQ,CAAC,CAAM;QACpB,IAAI,CAAC,OAAO,CAAC,oBAAoB,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;IACxE,CAAC;CACF;AAtID,sCAsIC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
|
|
2
2
|
import { SwitchBotPlatform } from '../platform';
|
|
3
|
-
import {
|
|
3
|
+
import { irDevicesConfig, irdevice } from '../settings';
|
|
4
4
|
/**
|
|
5
5
|
* Platform Accessory
|
|
6
6
|
* An instance of this class is created for each accessory your platform registers
|
|
@@ -9,10 +9,10 @@ import { devicesConfig, irdevice } from '../settings';
|
|
|
9
9
|
export declare class WaterHeater {
|
|
10
10
|
private readonly platform;
|
|
11
11
|
private accessory;
|
|
12
|
-
device: irdevice &
|
|
12
|
+
device: irdevice & irDevicesConfig;
|
|
13
13
|
service: Service;
|
|
14
14
|
Active: CharacteristicValue;
|
|
15
|
-
constructor(platform: SwitchBotPlatform, accessory: PlatformAccessory, device: irdevice &
|
|
15
|
+
constructor(platform: SwitchBotPlatform, accessory: PlatformAccessory, device: irdevice & irDevicesConfig);
|
|
16
16
|
private ActiveSet;
|
|
17
17
|
/**
|
|
18
18
|
* Pushes the requested changes to the SwitchBot API
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"waterheaters.d.ts","sourceRoot":"","sources":["../../src/irdevices/waterheaters.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAC7E,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"waterheaters.d.ts","sourceRoot":"","sources":["../../src/irdevices/waterheaters.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAC7E,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,eAAe,EAAa,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEnE;;;;GAIG;AACH,qBAAa,WAAW;IAQpB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,SAAS;IACV,MAAM,EAAE,QAAQ,GAAG,eAAe;IAR3C,OAAO,EAAG,OAAO,CAAC;IAGlB,MAAM,EAAG,mBAAmB,CAAC;gBAGV,QAAQ,EAAE,iBAAiB,EACpC,SAAS,EAAE,iBAAiB,EAC7B,MAAM,EAAE,QAAQ,GAAG,eAAe;IAoC3C,OAAO,CAAC,SAAS;IAkBjB;;;;;;;;;OASG;IACG,wBAAwB;IAWxB,yBAAyB;IAWlB,WAAW,CAAC,OAAO,EAAE,GAAG;IAwBrC,OAAO,CAAC,UAAU;IA4BX,QAAQ,CAAC,CAAC,EAAE,GAAG;CAKvB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"waterheaters.js","sourceRoot":"","sources":["../../src/irdevices/waterheaters.ts"],"names":[],"mappings":";;;AAGA,
|
|
1
|
+
{"version":3,"file":"waterheaters.js","sourceRoot":"","sources":["../../src/irdevices/waterheaters.ts"],"names":[],"mappings":";;;AAGA,0CAAmE;AAEnE;;;;GAIG;AACH,MAAa,WAAW;IAOtB,YACmB,QAA2B,EACpC,SAA4B,EAC7B,MAAkC;QAFxB,aAAQ,GAAR,QAAQ,CAAmB;QACpC,cAAS,GAAT,SAAS,CAAmB;QAC7B,WAAM,GAAN,MAAM,CAA4B;QAEzC,4BAA4B;QAC5B,SAAS;aACN,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,oBAAoB,CAAE;aACvD,iBAAiB,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,YAAY,EAAE,WAAW,CAAC;aACzE,iBAA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CAAC,CAAC;gBACrD,MAAM;YACR,KAAK,GAAG;gBACN,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,oBAAoB,CAAC,CAAC;gBAC9C,MAAM;YACR,KAAK,GAAG;gBACN,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,wBAAwB,CAAC,CAAC;gBAClD,MAAM;YACR,KAAK,GAAG;gBACN,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,wGAAwG,CAAC,CAAC;gBAClI,MAAM;YACR,KAAK,GAAG;gBACN,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,4BAA4B,CAAC,CAAC;gBAClD,MAAM;YACR;gBACE,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,qBAAqB,CAAC,CAAC;SAC9C;IACH,CAAC;IAEM,QAAQ,CAAC,CAAM;QACpB,IAAI,CAAC,OAAO,CAAC,oBAAoB,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC;QAC7E,IAAI,CAAC,OAAO,CAAC,oBAAoB,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;QAC1E,IAAI,CAAC,OAAO,CAAC,oBAAoB,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;IAC3E,CAAC;CACF;AAzJD,kCAyJC"}
|
package/dist/platform.d.ts
CHANGED
|
@@ -40,6 +40,7 @@ export declare class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
40
40
|
private createCurtain;
|
|
41
41
|
private isCurtainGrouped;
|
|
42
42
|
private createPlug;
|
|
43
|
+
private createColorBulb;
|
|
43
44
|
private createIndoorCam;
|
|
44
45
|
private createTV;
|
|
45
46
|
private createFan;
|
|
@@ -50,8 +51,8 @@ export declare class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
50
51
|
private createVacuumCleaner;
|
|
51
52
|
private createCamera;
|
|
52
53
|
private createOthers;
|
|
53
|
-
connectionTypeNewAccessory(device:
|
|
54
|
-
connectionTypeExistingAccessory(device:
|
|
54
|
+
connectionTypeNewAccessory(device: device & devicesConfig, accessory: PlatformAccessory): Promise<void>;
|
|
55
|
+
connectionTypeExistingAccessory(device: device & devicesConfig, existingAccessory: PlatformAccessory): Promise<void>;
|
|
55
56
|
unregisterPlatformAccessories(existingAccessory: PlatformAccessory): void;
|
|
56
57
|
deviceListInfo(devices: deviceResponses): void;
|
|
57
58
|
deviceInfo(device: irdevice & devicesConfig | device & devicesConfig): Promise<void>;
|
package/dist/platform.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platform.d.ts","sourceRoot":"","sources":["../src/platform.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,qBAAqB,EAAE,MAAM,EAAE,iBAAiB,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5G,OAAc,EAAE,aAAa,EAAsB,MAAM,OAAO,CAAC;AACjE,OAAO,EAIL,QAAQ,EACR,MAAM,EACN,uBAAuB,EACvB,eAAe,EACf,aAAa,EACd,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"platform.d.ts","sourceRoot":"","sources":["../src/platform.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,qBAAqB,EAAE,MAAM,EAAE,iBAAiB,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5G,OAAc,EAAE,aAAa,EAAsB,MAAM,OAAO,CAAC;AACjE,OAAO,EAIL,QAAQ,EACR,MAAM,EACN,uBAAuB,EACvB,eAAe,EACf,aAAa,EACd,MAAM,YAAY,CAAC;AAoBpB;;;;GAIG;AACH,qBAAa,iBAAkB,YAAW,qBAAqB;aAejC,GAAG,EAAE,MAAM;aAAkB,MAAM,EAAE,uBAAuB;aAAk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
CHANGED
|
@@ -12,17 +12,18 @@ const meters_1 = require("./devices/meters");
|
|
|
12
12
|
const motion_1 = require("./devices/motion");
|
|
13
13
|
const contact_1 = require("./devices/contact");
|
|
14
14
|
const curtains_1 = require("./devices/curtains");
|
|
15
|
+
const colorbulb_1 = require("./devices/colorbulb");
|
|
15
16
|
const indoorcam_1 = require("./devices/indoorcam");
|
|
16
17
|
const humidifiers_1 = require("./devices/humidifiers");
|
|
17
18
|
const tvs_1 = require("./irdevices/tvs");
|
|
18
19
|
const fans_1 = require("./irdevices/fans");
|
|
19
20
|
const lights_1 = require("./irdevices/lights");
|
|
20
|
-
const cameras_1 = require("./irdevices/cameras");
|
|
21
21
|
const others_1 = require("./irdevices/others");
|
|
22
|
+
const cameras_1 = require("./irdevices/cameras");
|
|
23
|
+
const airpurifiers_1 = require("./irdevices/airpurifiers");
|
|
22
24
|
const waterheaters_1 = require("./irdevices/waterheaters");
|
|
23
25
|
const vacuumcleaners_1 = require("./irdevices/vacuumcleaners");
|
|
24
26
|
const airconditioners_1 = require("./irdevices/airconditioners");
|
|
25
|
-
const airpurifiers_1 = require("./irdevices/airpurifiers");
|
|
26
27
|
/**
|
|
27
28
|
* HomebridgePlatform
|
|
28
29
|
* This class is the main constructor for your plugin, this is where you should
|
|
@@ -107,14 +108,25 @@ class SwitchBotPlatform {
|
|
|
107
108
|
// Device Config
|
|
108
109
|
if (this.config.options.devices) {
|
|
109
110
|
for (const deviceConfig of this.config.options.devices) {
|
|
110
|
-
if (!deviceConfig.
|
|
111
|
-
this.log.error('The devices config section is missing the "Type" in the config, Check Your Conifg.');
|
|
111
|
+
if (!deviceConfig.hide_device && !deviceConfig.deviceType) {
|
|
112
|
+
this.log.error('The devices config section is missing the "Device Type" in the config, Check Your Conifg.');
|
|
112
113
|
}
|
|
113
114
|
if (!deviceConfig.deviceId) {
|
|
114
115
|
this.log.error('The devices config section is missing the "Device ID" in the config, Check Your Conifg.');
|
|
115
116
|
}
|
|
116
117
|
}
|
|
117
118
|
}
|
|
119
|
+
// IR Device Config
|
|
120
|
+
if (this.config.options.irdevices) {
|
|
121
|
+
for (const irDeviceConfig of this.config.options.irdevices) {
|
|
122
|
+
if (!irDeviceConfig.hide_device && !irDeviceConfig.remoteType) {
|
|
123
|
+
this.log.error('The devices config section is missing the "Device Type" in the config, Check Your Conifg.');
|
|
124
|
+
}
|
|
125
|
+
if (!irDeviceConfig.deviceId) {
|
|
126
|
+
this.log.error('The devices config section is missing the "Device ID" in the config, Check Your Conifg.');
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
118
130
|
if (this.config.options.refreshRate < 30) {
|
|
119
131
|
throw new Error('Refresh Rate must be above 30 (30 seconds).');
|
|
120
132
|
}
|
|
@@ -143,35 +155,56 @@ class SwitchBotPlatform {
|
|
|
143
155
|
const devicesAPI = (await this.axios.get(settings_1.DeviceURL)).data;
|
|
144
156
|
this.deviceListInfo(devicesAPI);
|
|
145
157
|
this.debug(JSON.stringify(devicesAPI));
|
|
158
|
+
// SwitchBot Devices
|
|
146
159
|
this.log.info('Total SwitchBot Devices Found:', devicesAPI.body.deviceList.length);
|
|
147
|
-
this.log.info('Total IR Devices Found:', devicesAPI.body.infraredRemoteList.length);
|
|
148
160
|
const deviceLists = devicesAPI.body.deviceList;
|
|
149
161
|
if (!this.config.options?.devices) {
|
|
150
|
-
this.debug(`Config Not Set: ${JSON.stringify(this.config.options?.devices)}`);
|
|
162
|
+
this.debug(`SwitchBot Device Config Not Set: ${JSON.stringify(this.config.options?.devices)}`);
|
|
151
163
|
const devices = deviceLists.map((v) => v);
|
|
152
164
|
for (const device of devices) {
|
|
153
165
|
if (device.deviceType) {
|
|
154
166
|
this.createDevice(device);
|
|
155
167
|
}
|
|
156
|
-
else {
|
|
157
|
-
this.createIRDevice(device);
|
|
158
|
-
}
|
|
159
168
|
}
|
|
160
169
|
}
|
|
161
170
|
else {
|
|
162
|
-
this.debug(`Config Set: ${JSON.stringify(this.config.options?.devices)}`);
|
|
171
|
+
this.debug(`SwitchBot Device Config Set: ${JSON.stringify(this.config.options?.devices)}`);
|
|
163
172
|
const deviceConfigs = this.config.options?.devices;
|
|
164
173
|
const mergeBydeviceId = (a1, a2) => a1.map((itm) => ({
|
|
165
174
|
...a2.find((item) => (item.deviceId.toUpperCase().replace(/[^A-Z0-9]+/g, '') === itm.deviceId) && item),
|
|
166
175
|
...itm,
|
|
167
176
|
}));
|
|
168
177
|
const devices = mergeBydeviceId(deviceLists, deviceConfigs);
|
|
169
|
-
this.debug(JSON.stringify(devices));
|
|
178
|
+
this.debug(`SwitchBot Devices: ${JSON.stringify(devices)}`);
|
|
170
179
|
for (const device of devices) {
|
|
171
180
|
if (device.deviceType) {
|
|
172
181
|
this.createDevice(device);
|
|
173
182
|
}
|
|
174
|
-
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
// IR Devices
|
|
186
|
+
this.log.info('Total IR Devices Found:', devicesAPI.body.infraredRemoteList.length);
|
|
187
|
+
const irDeviceLists = devicesAPI.body.infraredRemoteList;
|
|
188
|
+
if (!this.config.options?.irdevices) {
|
|
189
|
+
this.debug(`IR Device Config Not Set: ${JSON.stringify(this.config.options?.irdevices)}`);
|
|
190
|
+
const devices = irDeviceLists.map((v) => v);
|
|
191
|
+
for (const device of devices) {
|
|
192
|
+
if (device.remoteType) {
|
|
193
|
+
this.createIRDevice(device);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
else {
|
|
198
|
+
this.debug(`IR Device Config Set: ${JSON.stringify(this.config.options?.irdevices)}`);
|
|
199
|
+
const irDeviceConfig = this.config.options?.irdevices;
|
|
200
|
+
const mergeIRBydeviceId = (a1, a2) => a1.map((itm) => ({
|
|
201
|
+
...a2.find((item) => (item.deviceId === itm.deviceId) && item),
|
|
202
|
+
...itm,
|
|
203
|
+
}));
|
|
204
|
+
const devices = mergeIRBydeviceId(irDeviceLists, irDeviceConfig);
|
|
205
|
+
this.debug(`IR Devices: ${JSON.stringify(devices)}`);
|
|
206
|
+
for (const device of devices) {
|
|
207
|
+
if (device.remoteType) {
|
|
175
208
|
this.createIRDevice(device);
|
|
176
209
|
}
|
|
177
210
|
}
|
|
@@ -218,6 +251,10 @@ class SwitchBotPlatform {
|
|
|
218
251
|
this.debug(`Discovered ${device.deviceType}: ${device.deviceId}`);
|
|
219
252
|
this.createPlug(device);
|
|
220
253
|
break;
|
|
254
|
+
case 'Color Bulb':
|
|
255
|
+
this.debug(`Discovered ${device.deviceType}: ${device.deviceId}`);
|
|
256
|
+
this.createColorBulb(device);
|
|
257
|
+
break;
|
|
221
258
|
case 'IndoorCam':
|
|
222
259
|
this.debug(`Discovered ${device.deviceType}: ${device.deviceId}`);
|
|
223
260
|
this.createIndoorCam(device);
|
|
@@ -350,7 +387,7 @@ class SwitchBotPlatform {
|
|
|
350
387
|
// the accessory already exists
|
|
351
388
|
if (!device.hide_device && device.enableCloudService) {
|
|
352
389
|
this.log.info(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
|
|
353
|
-
this.
|
|
390
|
+
this.debug(JSON.stringify(device.bot?.mode));
|
|
354
391
|
if (!device.bot?.mode) {
|
|
355
392
|
this.log.error('You must set your Bot to Press or Switch Mode');
|
|
356
393
|
}
|
|
@@ -373,7 +410,7 @@ class SwitchBotPlatform {
|
|
|
373
410
|
else if (!device.hide_device && device.enableCloudService) {
|
|
374
411
|
// the accessory does not yet exist, so we need to create it
|
|
375
412
|
this.log.info(`Adding new accessory: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
|
|
376
|
-
this.
|
|
413
|
+
this.debug(JSON.stringify(device.bot?.mode));
|
|
377
414
|
if (!device.bot?.mode) {
|
|
378
415
|
this.log.error('You must set your Bot to Press or Switch Mode');
|
|
379
416
|
}
|
|
@@ -604,10 +641,14 @@ class SwitchBotPlatform {
|
|
|
604
641
|
}
|
|
605
642
|
}
|
|
606
643
|
isCurtainGrouped(device) {
|
|
644
|
+
this.debug(`deviceId: ${device.deviceId}, curtainDevicesIds: ${device.curtainDevicesIds},`
|
|
645
|
+
+ ` master: ${device.master}, group: ${device.group}, disable_group: ${device.curtain?.disable_group}`);
|
|
607
646
|
if (device.group && !device.curtain?.disable_group) {
|
|
647
|
+
this.debug(`[Curtain Config] disable_group: ${device.curtain?.disable_group}`);
|
|
608
648
|
return device.master && !device.hide_device && device.enableCloudService;
|
|
609
649
|
}
|
|
610
650
|
else {
|
|
651
|
+
this.debug(`[Curtain Config] disable_group: ${device.curtain?.disable_group}, UnGrouping ${device.master}`);
|
|
611
652
|
return !device.hide_device && device.enableCloudService;
|
|
612
653
|
}
|
|
613
654
|
}
|
|
@@ -660,6 +701,55 @@ class SwitchBotPlatform {
|
|
|
660
701
|
this.device(`Unable to Register new device: ${device.deviceName} ${device.deviceType} - ${device.deviceId}`);
|
|
661
702
|
}
|
|
662
703
|
}
|
|
704
|
+
async createColorBulb(device) {
|
|
705
|
+
const uuid = this.api.hap.uuid.generate(`${device.deviceId}-${device.deviceType}`);
|
|
706
|
+
// see if an accessory with the same uuid has already been registered and restored from
|
|
707
|
+
// the cached devices we stored in the `configureAccessory` method above
|
|
708
|
+
const existingAccessory = this.accessories.find((accessory) => accessory.UUID === uuid);
|
|
709
|
+
if (existingAccessory) {
|
|
710
|
+
// the accessory already exists
|
|
711
|
+
if (!device.hide_device && device.enableCloudService) {
|
|
712
|
+
this.log.info(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
|
|
713
|
+
// if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
|
|
714
|
+
existingAccessory.context.model = device.deviceType;
|
|
715
|
+
existingAccessory.context.deviceID = device.deviceId;
|
|
716
|
+
existingAccessory.displayName = device.deviceName;
|
|
717
|
+
existingAccessory.context.firmwareRevision = this.version;
|
|
718
|
+
await this.connectionTypeExistingAccessory(device, existingAccessory);
|
|
719
|
+
this.api.updatePlatformAccessories([existingAccessory]);
|
|
720
|
+
// create the accessory handler for the restored accessory
|
|
721
|
+
// this is imported from `platformAccessory.ts`
|
|
722
|
+
new colorbulb_1.ColorBulb(this, existingAccessory, device);
|
|
723
|
+
this.debug(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
|
|
724
|
+
}
|
|
725
|
+
else {
|
|
726
|
+
this.unregisterPlatformAccessories(existingAccessory);
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
else if (!device.hide_device && device.enableCloudService) {
|
|
730
|
+
// the accessory does not yet exist, so we need to create it
|
|
731
|
+
this.log.info(`Adding new accessory: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
|
|
732
|
+
// create a new accessory
|
|
733
|
+
const accessory = new this.api.platformAccessory(device.deviceName, uuid);
|
|
734
|
+
// store a copy of the device object in the `accessory.context`
|
|
735
|
+
// the `context` property can be used to store any data about the accessory you may need
|
|
736
|
+
accessory.context.device = device;
|
|
737
|
+
accessory.context.model = device.deviceType;
|
|
738
|
+
accessory.context.deviceID = device.deviceId;
|
|
739
|
+
accessory.context.firmwareRevision = this.version;
|
|
740
|
+
await this.connectionTypeExistingAccessory(device, accessory);
|
|
741
|
+
// create the accessory handler for the newly create accessory
|
|
742
|
+
// this is imported from `platformAccessory.ts`
|
|
743
|
+
new colorbulb_1.ColorBulb(this, accessory, device);
|
|
744
|
+
this.debug(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
|
|
745
|
+
// link the accessory to your platform
|
|
746
|
+
this.api.registerPlatformAccessories(settings_1.PLUGIN_NAME, settings_1.PLATFORM_NAME, [accessory]);
|
|
747
|
+
this.accessories.push(accessory);
|
|
748
|
+
}
|
|
749
|
+
else {
|
|
750
|
+
this.device(`Unable to Register new device: ${device.deviceName} ${device.deviceType} - ${device.deviceId}`);
|
|
751
|
+
}
|
|
752
|
+
}
|
|
663
753
|
async createIndoorCam(device) {
|
|
664
754
|
const uuid = this.api.hap.uuid.generate(`${device.deviceId}-${device.deviceType}`);
|
|
665
755
|
// see if an accessory with the same uuid has already been registered and restored from
|
|
@@ -721,7 +811,7 @@ class SwitchBotPlatform {
|
|
|
721
811
|
existingAccessory.context.deviceID = device.deviceId;
|
|
722
812
|
existingAccessory.displayName = device.deviceName;
|
|
723
813
|
existingAccessory.context.firmwareRevision = this.version;
|
|
724
|
-
|
|
814
|
+
existingAccessory.context.connectionType = 'OpenAPI';
|
|
725
815
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
726
816
|
// create the accessory handler for the restored accessory
|
|
727
817
|
// this is imported from `platformAccessory.ts`
|
|
@@ -739,7 +829,7 @@ class SwitchBotPlatform {
|
|
|
739
829
|
accessory.context.model = device.remoteType;
|
|
740
830
|
accessory.context.deviceID = device.deviceId;
|
|
741
831
|
accessory.context.firmwareRevision = this.version;
|
|
742
|
-
|
|
832
|
+
accessory.context.connectionType = 'OpenAPI';
|
|
743
833
|
// create the accessory handler for the newly create accessory
|
|
744
834
|
// this is imported from `platformAccessory.ts`
|
|
745
835
|
new tvs_1.TV(this, accessory, device);
|
|
@@ -770,7 +860,7 @@ class SwitchBotPlatform {
|
|
|
770
860
|
existingAccessory.context.deviceID = device.deviceId;
|
|
771
861
|
existingAccessory.displayName = device.deviceName;
|
|
772
862
|
existingAccessory.context.firmwareRevision = this.version;
|
|
773
|
-
|
|
863
|
+
existingAccessory.context.connectionType = 'OpenAPI';
|
|
774
864
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
775
865
|
// create the accessory handler for the restored accessory
|
|
776
866
|
// this is imported from `platformAccessory.ts`
|
|
@@ -792,7 +882,7 @@ class SwitchBotPlatform {
|
|
|
792
882
|
accessory.context.model = device.remoteType;
|
|
793
883
|
accessory.context.deviceID = device.deviceId;
|
|
794
884
|
accessory.context.firmwareRevision = this.version;
|
|
795
|
-
|
|
885
|
+
accessory.context.connectionType = 'OpenAPI';
|
|
796
886
|
// create the accessory handler for the newly create accessory
|
|
797
887
|
// this is imported from `platformAccessory.ts`
|
|
798
888
|
new fans_1.Fan(this, accessory, device);
|
|
@@ -812,14 +902,14 @@ class SwitchBotPlatform {
|
|
|
812
902
|
const existingAccessory = this.accessories.find((accessory) => accessory.UUID === uuid);
|
|
813
903
|
if (existingAccessory) {
|
|
814
904
|
// the accessory already exists
|
|
815
|
-
if (device.hubDeviceId) {
|
|
905
|
+
if (!device.hide_device && device.hubDeviceId) {
|
|
816
906
|
this.log.info(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
|
|
817
907
|
// if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
|
|
818
908
|
existingAccessory.context.model = device.remoteType;
|
|
819
909
|
existingAccessory.context.deviceID = device.deviceId;
|
|
820
910
|
existingAccessory.displayName = device.deviceName;
|
|
821
911
|
existingAccessory.context.firmwareRevision = this.version;
|
|
822
|
-
|
|
912
|
+
existingAccessory.context.connectionType = 'OpenAPI';
|
|
823
913
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
824
914
|
// create the accessory handler for the restored accessory
|
|
825
915
|
// this is imported from `platformAccessory.ts`
|
|
@@ -830,7 +920,7 @@ class SwitchBotPlatform {
|
|
|
830
920
|
this.unregisterPlatformAccessories(existingAccessory);
|
|
831
921
|
}
|
|
832
922
|
}
|
|
833
|
-
else if (device.hubDeviceId) {
|
|
923
|
+
else if (!device.hide_device && device.hubDeviceId) {
|
|
834
924
|
// the accessory does not yet exist, so we need to create it
|
|
835
925
|
this.log.info(`Adding new accessory: ${device.deviceName} ${device.remoteType} DeviceID: ${device.deviceId}`);
|
|
836
926
|
// create a new accessory
|
|
@@ -841,7 +931,7 @@ class SwitchBotPlatform {
|
|
|
841
931
|
accessory.context.model = device.remoteType;
|
|
842
932
|
accessory.context.deviceID = device.deviceId;
|
|
843
933
|
accessory.context.firmwareRevision = this.version;
|
|
844
|
-
|
|
934
|
+
accessory.context.connectionType = 'OpenAPI';
|
|
845
935
|
// create the accessory handler for the newly create accessory
|
|
846
936
|
// this is imported from `platformAccessory.ts`
|
|
847
937
|
new lights_1.Light(this, accessory, device);
|
|
@@ -861,14 +951,14 @@ class SwitchBotPlatform {
|
|
|
861
951
|
const existingAccessory = this.accessories.find((accessory) => accessory.UUID === uuid);
|
|
862
952
|
if (existingAccessory) {
|
|
863
953
|
// the accessory already exists
|
|
864
|
-
if (device.hubDeviceId) {
|
|
954
|
+
if (!device.hide_device && device.hubDeviceId) {
|
|
865
955
|
this.log.info(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
|
|
866
956
|
// if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
|
|
867
957
|
existingAccessory.context.model = device.remoteType;
|
|
868
958
|
existingAccessory.context.deviceID = device.deviceId;
|
|
869
959
|
existingAccessory.displayName = device.deviceName;
|
|
870
960
|
existingAccessory.context.firmwareRevision = this.version;
|
|
871
|
-
|
|
961
|
+
existingAccessory.context.connectionType = 'OpenAPI';
|
|
872
962
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
873
963
|
// create the accessory handler for the restored accessory
|
|
874
964
|
// this is imported from `platformAccessory.ts`
|
|
@@ -879,7 +969,7 @@ class SwitchBotPlatform {
|
|
|
879
969
|
this.unregisterPlatformAccessories(existingAccessory);
|
|
880
970
|
}
|
|
881
971
|
}
|
|
882
|
-
else if (device.hubDeviceId) {
|
|
972
|
+
else if (!device.hide_device && device.hubDeviceId) {
|
|
883
973
|
// the accessory does not yet exist, so we need to create it
|
|
884
974
|
this.log.info(`Adding new accessory: ${device.deviceName} ${device.remoteType} DeviceID: ${device.deviceId}`);
|
|
885
975
|
// create a new accessory
|
|
@@ -890,7 +980,7 @@ class SwitchBotPlatform {
|
|
|
890
980
|
accessory.context.model = device.remoteType;
|
|
891
981
|
accessory.context.deviceID = device.deviceId;
|
|
892
982
|
accessory.context.firmwareRevision = this.version;
|
|
893
|
-
|
|
983
|
+
accessory.context.connectionType = 'OpenAPI';
|
|
894
984
|
// create the accessory handler for the newly create accessory
|
|
895
985
|
// this is imported from `platformAccessory.ts`
|
|
896
986
|
new airconditioners_1.AirConditioner(this, accessory, device);
|
|
@@ -910,14 +1000,14 @@ class SwitchBotPlatform {
|
|
|
910
1000
|
const existingAccessory = this.accessories.find((accessory) => accessory.UUID === uuid);
|
|
911
1001
|
if (existingAccessory) {
|
|
912
1002
|
// the accessory already exists
|
|
913
|
-
if (device.hubDeviceId) {
|
|
1003
|
+
if (!device.hide_device && device.hubDeviceId) {
|
|
914
1004
|
this.log.info(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
|
|
915
1005
|
// if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
|
|
916
1006
|
existingAccessory.context.model = device.remoteType;
|
|
917
1007
|
existingAccessory.context.deviceID = device.deviceId;
|
|
918
1008
|
existingAccessory.displayName = device.deviceName;
|
|
919
1009
|
existingAccessory.context.firmwareRevision = this.version;
|
|
920
|
-
|
|
1010
|
+
existingAccessory.context.connectionType = 'OpenAPI';
|
|
921
1011
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
922
1012
|
// create the accessory handler for the restored accessory
|
|
923
1013
|
// this is imported from `platformAccessory.ts`
|
|
@@ -928,7 +1018,7 @@ class SwitchBotPlatform {
|
|
|
928
1018
|
this.unregisterPlatformAccessories(existingAccessory);
|
|
929
1019
|
}
|
|
930
1020
|
}
|
|
931
|
-
else if (device.hubDeviceId) {
|
|
1021
|
+
else if (!device.hide_device && device.hubDeviceId) {
|
|
932
1022
|
// the accessory does not yet exist, so we need to create it
|
|
933
1023
|
this.log.info(`Adding new accessory: ${device.deviceName} ${device.remoteType} DeviceID: ${device.deviceId}`);
|
|
934
1024
|
// create a new accessory
|
|
@@ -939,7 +1029,7 @@ class SwitchBotPlatform {
|
|
|
939
1029
|
accessory.context.model = device.remoteType;
|
|
940
1030
|
accessory.context.deviceID = device.deviceId;
|
|
941
1031
|
accessory.context.firmwareRevision = this.version;
|
|
942
|
-
|
|
1032
|
+
accessory.context.connectionType = 'OpenAPI';
|
|
943
1033
|
// create the accessory handler for the newly create accessory
|
|
944
1034
|
// this is imported from `platformAccessory.ts`
|
|
945
1035
|
new airpurifiers_1.AirPurifier(this, accessory, device);
|
|
@@ -959,14 +1049,14 @@ class SwitchBotPlatform {
|
|
|
959
1049
|
const existingAccessory = this.accessories.find((accessory) => accessory.UUID === uuid);
|
|
960
1050
|
if (existingAccessory) {
|
|
961
1051
|
// the accessory already exists
|
|
962
|
-
if (device.hubDeviceId) {
|
|
1052
|
+
if (!device.hide_device && device.hubDeviceId) {
|
|
963
1053
|
this.log.info(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
|
|
964
1054
|
// if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
|
|
965
1055
|
existingAccessory.context.model = device.remoteType;
|
|
966
1056
|
existingAccessory.context.deviceID = device.deviceId;
|
|
967
1057
|
existingAccessory.displayName = device.deviceName;
|
|
968
1058
|
existingAccessory.context.firmwareRevision = this.version;
|
|
969
|
-
|
|
1059
|
+
existingAccessory.context.connectionType = 'OpenAPI';
|
|
970
1060
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
971
1061
|
// create the accessory handler for the restored accessory
|
|
972
1062
|
// this is imported from `platformAccessory.ts`
|
|
@@ -977,7 +1067,7 @@ class SwitchBotPlatform {
|
|
|
977
1067
|
this.unregisterPlatformAccessories(existingAccessory);
|
|
978
1068
|
}
|
|
979
1069
|
}
|
|
980
|
-
else if (device.hubDeviceId) {
|
|
1070
|
+
else if (!device.hide_device && device.hubDeviceId) {
|
|
981
1071
|
// the accessory does not yet exist, so we need to create it
|
|
982
1072
|
this.log.info(`Adding new accessory: ${device.deviceName} ${device.remoteType} DeviceID: ${device.deviceId}`);
|
|
983
1073
|
// create a new accessory
|
|
@@ -988,7 +1078,7 @@ class SwitchBotPlatform {
|
|
|
988
1078
|
accessory.context.model = device.remoteType;
|
|
989
1079
|
accessory.context.deviceID = device.deviceId;
|
|
990
1080
|
accessory.context.firmwareRevision = this.version;
|
|
991
|
-
|
|
1081
|
+
accessory.context.connectionType = 'OpenAPI';
|
|
992
1082
|
// create the accessory handler for the newly create accessory
|
|
993
1083
|
// this is imported from `platformAccessory.ts`
|
|
994
1084
|
new waterheaters_1.WaterHeater(this, accessory, device);
|
|
@@ -1008,14 +1098,14 @@ class SwitchBotPlatform {
|
|
|
1008
1098
|
const existingAccessory = this.accessories.find((accessory) => accessory.UUID === uuid);
|
|
1009
1099
|
if (existingAccessory) {
|
|
1010
1100
|
// the accessory already exists
|
|
1011
|
-
if (device.hubDeviceId) {
|
|
1101
|
+
if (!device.hide_device && device.hubDeviceId) {
|
|
1012
1102
|
this.log.info(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
|
|
1013
1103
|
// if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
|
|
1014
1104
|
existingAccessory.context.model = device.remoteType;
|
|
1015
1105
|
existingAccessory.context.deviceID = device.deviceId;
|
|
1016
1106
|
existingAccessory.displayName = device.deviceName;
|
|
1017
1107
|
existingAccessory.context.firmwareRevision = this.version;
|
|
1018
|
-
|
|
1108
|
+
existingAccessory.context.connectionType = 'OpenAPI';
|
|
1019
1109
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
1020
1110
|
// create the accessory handler for the restored accessory
|
|
1021
1111
|
// this is imported from `platformAccessory.ts`
|
|
@@ -1026,7 +1116,7 @@ class SwitchBotPlatform {
|
|
|
1026
1116
|
this.unregisterPlatformAccessories(existingAccessory);
|
|
1027
1117
|
}
|
|
1028
1118
|
}
|
|
1029
|
-
else if (device.hubDeviceId) {
|
|
1119
|
+
else if (!device.hide_device && device.hubDeviceId) {
|
|
1030
1120
|
// the accessory does not yet exist, so we need to create it
|
|
1031
1121
|
this.log.info(`Adding new accessory: ${device.deviceName} ${device.remoteType} DeviceID: ${device.deviceId}`);
|
|
1032
1122
|
// create a new accessory
|
|
@@ -1037,7 +1127,7 @@ class SwitchBotPlatform {
|
|
|
1037
1127
|
accessory.context.model = device.remoteType;
|
|
1038
1128
|
accessory.context.deviceID = device.deviceId;
|
|
1039
1129
|
accessory.context.firmwareRevision = this.version;
|
|
1040
|
-
|
|
1130
|
+
accessory.context.connectionType = 'OpenAPI';
|
|
1041
1131
|
// create the accessory handler for the newly create accessory
|
|
1042
1132
|
// this is imported from `platformAccessory.ts`
|
|
1043
1133
|
new vacuumcleaners_1.VacuumCleaner(this, accessory, device);
|
|
@@ -1057,14 +1147,14 @@ class SwitchBotPlatform {
|
|
|
1057
1147
|
const existingAccessory = this.accessories.find((accessory) => accessory.UUID === uuid);
|
|
1058
1148
|
if (existingAccessory) {
|
|
1059
1149
|
// the accessory already exists
|
|
1060
|
-
if (device.hubDeviceId) {
|
|
1150
|
+
if (!device.hide_device && device.hubDeviceId) {
|
|
1061
1151
|
this.log.info(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
|
|
1062
1152
|
// if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
|
|
1063
1153
|
existingAccessory.context.model = device.remoteType;
|
|
1064
1154
|
existingAccessory.context.deviceID = device.deviceId;
|
|
1065
1155
|
existingAccessory.displayName = device.deviceName;
|
|
1066
1156
|
existingAccessory.context.firmwareRevision = this.version;
|
|
1067
|
-
|
|
1157
|
+
existingAccessory.context.connectionType = 'OpenAPI';
|
|
1068
1158
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
1069
1159
|
// create the accessory handler for the restored accessory
|
|
1070
1160
|
// this is imported from `platformAccessory.ts`
|
|
@@ -1075,7 +1165,7 @@ class SwitchBotPlatform {
|
|
|
1075
1165
|
this.unregisterPlatformAccessories(existingAccessory);
|
|
1076
1166
|
}
|
|
1077
1167
|
}
|
|
1078
|
-
else if (device.hubDeviceId) {
|
|
1168
|
+
else if (!device.hide_device && device.hubDeviceId) {
|
|
1079
1169
|
// the accessory does not yet exist, so we need to create it
|
|
1080
1170
|
this.log.info(`Adding new accessory: ${device.deviceName} ${device.remoteType} DeviceID: ${device.deviceId}`);
|
|
1081
1171
|
// create a new accessory
|
|
@@ -1086,7 +1176,7 @@ class SwitchBotPlatform {
|
|
|
1086
1176
|
accessory.context.model = device.remoteType;
|
|
1087
1177
|
accessory.context.deviceID = device.deviceId;
|
|
1088
1178
|
accessory.context.firmwareRevision = this.version;
|
|
1089
|
-
|
|
1179
|
+
accessory.context.connectionType = 'OpenAPI';
|
|
1090
1180
|
// create the accessory handler for the newly create accessory
|
|
1091
1181
|
// this is imported from `platformAccessory.ts`
|
|
1092
1182
|
new cameras_1.Camera(this, accessory, device);
|
|
@@ -1106,14 +1196,14 @@ class SwitchBotPlatform {
|
|
|
1106
1196
|
const existingAccessory = this.accessories.find((accessory) => accessory.UUID === uuid);
|
|
1107
1197
|
if (existingAccessory) {
|
|
1108
1198
|
// the accessory already exists
|
|
1109
|
-
if (device.hubDeviceId) {
|
|
1199
|
+
if (!device.hide_device && device.hubDeviceId) {
|
|
1110
1200
|
this.log.info(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
|
|
1111
1201
|
// if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
|
|
1112
1202
|
existingAccessory.context.model = device.remoteType;
|
|
1113
1203
|
existingAccessory.context.deviceID = device.deviceId;
|
|
1114
1204
|
existingAccessory.displayName = device.deviceName;
|
|
1115
1205
|
existingAccessory.context.firmwareRevision = this.version;
|
|
1116
|
-
|
|
1206
|
+
existingAccessory.context.connectionType = 'OpenAPI';
|
|
1117
1207
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
1118
1208
|
// create the accessory handler for the restored accessory
|
|
1119
1209
|
// this is imported from `platformAccessory.ts`
|
|
@@ -1124,7 +1214,7 @@ class SwitchBotPlatform {
|
|
|
1124
1214
|
this.unregisterPlatformAccessories(existingAccessory);
|
|
1125
1215
|
}
|
|
1126
1216
|
}
|
|
1127
|
-
else if (device.hubDeviceId) {
|
|
1217
|
+
else if (!device.hide_device && device.hubDeviceId) {
|
|
1128
1218
|
// the accessory does not yet exist, so we need to create it
|
|
1129
1219
|
this.log.info(`Adding new accessory: ${device.deviceName} ${device.remoteType} DeviceID: ${device.deviceId}`);
|
|
1130
1220
|
// create a new accessory
|
|
@@ -1135,7 +1225,7 @@ class SwitchBotPlatform {
|
|
|
1135
1225
|
accessory.context.model = device.remoteType;
|
|
1136
1226
|
accessory.context.deviceID = device.deviceId;
|
|
1137
1227
|
accessory.context.firmwareRevision = this.version;
|
|
1138
|
-
|
|
1228
|
+
accessory.context.connectionType = 'OpenAPI';
|
|
1139
1229
|
// create the accessory handler for the newly create accessory
|
|
1140
1230
|
// this is imported from `platformAccessory.ts`
|
|
1141
1231
|
new others_1.Others(this, accessory, device);
|