@switchbot/homebridge-switchbot 1.5.1-beta.5 → 1.6.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.
@@ -194,10 +194,25 @@ export class Motion {
194
194
  }
195
195
 
196
196
  private async openAPIparseStatus() {
197
- if (this.platform.config.credentials?.openToken) {
198
- this.debugLog(`Motion Sensor: ${this.accessory.displayName} OpenAPI parseStatus`);
199
- this.MotionDetected = Boolean(this.deviceStatus.body.moveDetected);
200
- this.debugLog(`Motion Sensor: ${this.accessory.displayName} MotionDetected: ${this.MotionDetected}`);
197
+ try {
198
+ if (this.platform.config.credentials?.openToken) {
199
+ this.debugLog(`Motion Sensor: ${this.accessory.displayName} OpenAPI parseStatus`);
200
+ if (typeof this.deviceStatus.body.moveDetected === 'boolean') {
201
+ this.MotionDetected = this.deviceStatus.body.moveDetected;
202
+ }
203
+ this.debugLog(`Motion Sensor: ${this.accessory.displayName} MotionDetected: ${this.MotionDetected}`);
204
+ }
205
+ } catch (e: any) {
206
+ this.errorLog(`Motion Sensor: ${this.accessory.displayName} failed parseStatus with OpenAPI Connection`);
207
+ if (this.deviceLogging === 'debug') {
208
+ this.errorLog(`Motion Sensor: ${this.accessory.displayName} failed parseStatus with OpenAPI Connection,`
209
+ + ` Error Message: ${JSON.stringify(e.message)}`);
210
+ }
211
+ if (this.platform.debugMode) {
212
+ this.errorLog(`Motion Sensor: ${this.accessory.displayName} failed parseStatus with OpenAPI Connection,`
213
+ + ` Error: ${JSON.stringify(e)}`);
214
+ }
215
+ this.apiError(e);
201
216
  }
202
217
  }
203
218
 
package/src/platform.ts CHANGED
@@ -144,11 +144,6 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
144
144
  if (!deviceConfig.configDeviceType && deviceConfig.ble) {
145
145
  throw new Error('The devices config section is missing the *Device Type* in the config, Check Your Conifg.');
146
146
  }
147
- if (deviceConfig.bot) {
148
- if (!deviceConfig.bot?.mode) {
149
- this.errorLog('You must set your Bot to Press or Switch Mode');
150
- }
151
- }
152
147
  }
153
148
  }
154
149
  }