@switchbot/homebridge-switchbot 1.8.2-beta.1 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.vscode/extensions.json +5 -0
- package/.vscode/settings.json +15 -0
- package/CHANGELOG.md +15 -0
- package/config.schema.json +9 -0
- package/dist/devices/bots.d.ts +2 -0
- package/dist/devices/bots.d.ts.map +1 -1
- package/dist/devices/bots.js +12 -2
- package/dist/devices/bots.js.map +1 -1
- package/dist/platform.d.ts +1 -1
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +44 -28
- package/dist/platform.js.map +1 -1
- package/dist/settings.d.ts +1 -0
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js.map +1 -1
- package/package.json +71 -71
- package/src/devices/bots.ts +13 -2
- package/src/platform.ts +45 -30
- package/src/settings.ts +1 -0
package/src/platform.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
import { Bot } from './devices/bots';
|
|
3
2
|
import { Plug } from './devices/plugs';
|
|
4
3
|
import { Meter } from './devices/meters';
|
|
@@ -97,17 +96,19 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
97
96
|
this.debugMode = process.argv.includes('-D') || process.argv.includes('--debug');
|
|
98
97
|
if (this.config.options?.logging === 'debug' || this.config.options?.logging === 'standard' || this.config.options?.logging === 'none') {
|
|
99
98
|
this.platformLogging = this.config.options!.logging;
|
|
100
|
-
if (this.
|
|
99
|
+
if (this.platformLogging.includes('debug')) {
|
|
101
100
|
this.log.warn(`Using Config Logging: ${this.platformLogging}`);
|
|
102
101
|
}
|
|
103
102
|
} else if (this.debugMode) {
|
|
104
|
-
if (this.debugMode) {
|
|
105
|
-
this.log.warn('Using debugMode Logging');
|
|
106
|
-
}
|
|
107
103
|
this.platformLogging = 'debugMode';
|
|
104
|
+
if (this.platformLogging?.includes('debug')) {
|
|
105
|
+
this.log.warn(`Using ${this.platformLogging} Logging`);
|
|
106
|
+
}
|
|
108
107
|
} else {
|
|
109
|
-
this.log.warn('Using Standard Logging');
|
|
110
108
|
this.platformLogging = 'standard';
|
|
109
|
+
if (this.platformLogging?.includes('debug')) {
|
|
110
|
+
this.log.warn(`Using ${this.platformLogging} Logging`);
|
|
111
|
+
}
|
|
111
112
|
}
|
|
112
113
|
}
|
|
113
114
|
|
|
@@ -126,14 +127,23 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
126
127
|
* Verify the config passed to the plugin is valid
|
|
127
128
|
*/
|
|
128
129
|
verifyConfig() {
|
|
129
|
-
/**
|
|
130
|
-
* Hidden Device Discovery Option
|
|
131
|
-
* This will disable adding any device and will just output info.
|
|
132
|
-
*/
|
|
133
130
|
this.config.options = this.config.options || {};
|
|
134
131
|
|
|
135
|
-
|
|
132
|
+
const platformConfig = {};
|
|
133
|
+
if (this.config.options.logging) {
|
|
134
|
+
platformConfig['logging'] = this.config.options.logging;
|
|
135
|
+
}
|
|
136
|
+
if (this.config.options.logging) {
|
|
137
|
+
platformConfig['refreshRate'] = this.config.options.refreshRate;
|
|
138
|
+
}
|
|
139
|
+
if (this.config.options.logging) {
|
|
140
|
+
platformConfig['pushRate'] = this.config.options.pushRate;
|
|
141
|
+
}
|
|
142
|
+
if (Object.entries(platformConfig).length !== 0) {
|
|
143
|
+
this.warnLog(`Platform Config: ${JSON.stringify(platformConfig)}`);
|
|
144
|
+
}
|
|
136
145
|
|
|
146
|
+
if (this.config.options) {
|
|
137
147
|
// Device Config
|
|
138
148
|
if (this.config.options.devices) {
|
|
139
149
|
for (const deviceConfig of this.config.options.devices) {
|
|
@@ -170,41 +180,32 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
170
180
|
if (!this.config.options.refreshRate) {
|
|
171
181
|
// default 120 seconds (2 minutes)
|
|
172
182
|
this.config.options!.refreshRate! = 120;
|
|
173
|
-
if (this.
|
|
174
|
-
this.
|
|
183
|
+
if (this.platformLogging?.includes('debug')) {
|
|
184
|
+
this.debugLog('Using Default Refresh Rate (2 minutes).');
|
|
175
185
|
}
|
|
176
186
|
|
|
177
187
|
if (!this.config.options.pushRate) {
|
|
178
188
|
// default 100 milliseconds
|
|
179
189
|
this.config.options!.pushRate! = 0.1;
|
|
180
|
-
if (this.
|
|
190
|
+
if (this.platformLogging?.includes('debug')) {
|
|
181
191
|
this.warnLog('Using Default Push Rate.');
|
|
182
192
|
}
|
|
183
193
|
}
|
|
184
194
|
|
|
185
195
|
if (!this.config.credentials) {
|
|
186
|
-
this.
|
|
196
|
+
if (this.platformLogging?.includes('debug')) {
|
|
197
|
+
this.debugLog('Missing Credentials');
|
|
198
|
+
}
|
|
187
199
|
}
|
|
188
200
|
if (!this.config.credentials?.openToken) {
|
|
189
|
-
this.
|
|
190
|
-
|
|
201
|
+
if (this.platformLogging?.includes('debug')) {
|
|
202
|
+
this.errorLog('Missing openToken');
|
|
203
|
+
this.warnLog('Cloud Enabled SwitchBot Devices & IR Devices will not work');
|
|
204
|
+
}
|
|
191
205
|
}
|
|
192
206
|
}
|
|
193
207
|
}
|
|
194
208
|
|
|
195
|
-
connectBLE() {
|
|
196
|
-
let Switchbot: new () => any;
|
|
197
|
-
let switchbot: any;
|
|
198
|
-
try {
|
|
199
|
-
Switchbot = require('node-switchbot');
|
|
200
|
-
switchbot = new Switchbot();
|
|
201
|
-
} catch (e) {
|
|
202
|
-
switchbot = false;
|
|
203
|
-
this.errorLog(`Was 'node-switchbot' found: ${switchbot}`);
|
|
204
|
-
}
|
|
205
|
-
return switchbot;
|
|
206
|
-
}
|
|
207
|
-
|
|
208
209
|
/**
|
|
209
210
|
* this method discovers devices
|
|
210
211
|
*/
|
|
@@ -1499,6 +1500,20 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1499
1500
|
}
|
|
1500
1501
|
}
|
|
1501
1502
|
|
|
1503
|
+
// BLE Connection
|
|
1504
|
+
connectBLE() {
|
|
1505
|
+
let Switchbot: new () => any;
|
|
1506
|
+
let switchbot: any;
|
|
1507
|
+
try {
|
|
1508
|
+
Switchbot = require('node-switchbot');
|
|
1509
|
+
switchbot = new Switchbot();
|
|
1510
|
+
} catch (e) {
|
|
1511
|
+
switchbot = false;
|
|
1512
|
+
this.errorLog(`Was 'node-switchbot' found: ${switchbot}`);
|
|
1513
|
+
}
|
|
1514
|
+
return switchbot;
|
|
1515
|
+
}
|
|
1516
|
+
|
|
1502
1517
|
/**
|
|
1503
1518
|
* If device level logging is turned on, log to log.warn
|
|
1504
1519
|
* Otherwise send debug logs to log.debug
|