@switchbot/homebridge-switchbot 3.5.0-beta.34 → 3.5.0-beta.36

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.
@@ -179,91 +179,108 @@ export abstract class deviceBase {
179
179
  }
180
180
 
181
181
  async getDeviceConfigSettings(device: device & devicesConfig): Promise<void> {
182
- let config = {};
183
- if (device.logging !== undefined) {
184
- config['logging'] = device.logging;
182
+ const deviceConfig = {};
183
+ if (device.logging !== 'standard') {
184
+ deviceConfig['logging'] = device.logging;
185
185
  }
186
- if (device.refreshRate !== undefined) {
187
- config['refreshRate'] = device.refreshRate;
186
+ if (device.refreshRate !== 0) {
187
+ deviceConfig['refreshRate'] = device.refreshRate;
188
188
  }
189
- if (device.updateRate !== undefined) {
190
- config['updateRate'] = device.updateRate;
189
+ if (device.updateRate !== 0) {
190
+ deviceConfig['updateRate'] = device.updateRate;
191
191
  }
192
- if (device.scanDuration !== undefined) {
193
- config['scanDuration'] = device.scanDuration;
192
+ if (device.scanDuration !== 0) {
193
+ deviceConfig['scanDuration'] = device.scanDuration;
194
194
  }
195
- if (device.offline !== undefined) {
196
- config['offline'] = device.offline;
195
+ if (device.offline === true) {
196
+ deviceConfig['offline'] = device.offline;
197
197
  }
198
- if (device.maxRetry !== 0 ) {
199
- config['maxRetry'] = device.maxRetry;
198
+ if (device.maxRetry !== 0) {
199
+ deviceConfig['maxRetry'] = device.maxRetry;
200
200
  }
201
201
  if (device.webhook === true) {
202
- config['webhook'] = device.webhook;
202
+ deviceConfig['webhook'] = device.webhook;
203
203
  }
204
- if (device.connectionType) {
205
- config['connectionType'] = device.connectionType;
204
+ if (device.connectionType !== '') {
205
+ deviceConfig['connectionType'] = device.connectionType;
206
206
  }
207
- if (device.external !== undefined) {
208
- config['external'] = device.external;
207
+ if (device.external === true) {
208
+ deviceConfig['external'] = device.external;
209
209
  }
210
- if (device.mqttURL !== undefined) {
211
- config['mqttURL'] = device.mqttURL;
210
+ if (device.mqttURL !== '') {
211
+ deviceConfig['mqttURL'] = device.mqttURL;
212
212
  }
213
- if (device.maxRetries !== undefined) {
214
- config['maxRetries'] = device.maxRetries;
213
+ if (device.maxRetries !== 0) {
214
+ deviceConfig['maxRetries'] = device.maxRetries;
215
215
  }
216
- if (device.delayBetweenRetries !== undefined) {
217
- config['delayBetweenRetries'] = device.delayBetweenRetries;
216
+ if (device.delayBetweenRetries !== 0) {
217
+ deviceConfig['delayBetweenRetries'] = device.delayBetweenRetries;
218
218
  }
219
+ let botConfig = {};
219
220
  if (device.bot) {
220
- config = device.bot;
221
+ botConfig = device.bot;
221
222
  }
223
+ let lockConfig = {};
222
224
  if (device.lock) {
223
- config = device.lock;
225
+ lockConfig = device.lock;
224
226
  }
227
+ let ceilinglightConfig = {};
225
228
  if (device.ceilinglight) {
226
- config = device.ceilinglight;
229
+ ceilinglightConfig = device.ceilinglight;
227
230
  }
231
+ let colorbulbConfig = {};
228
232
  if (device.colorbulb) {
229
- config = device.colorbulb;
233
+ colorbulbConfig = device.colorbulb;
230
234
  }
235
+ let contactConfig = {};
231
236
  if (device.contact) {
232
- config = device.contact;
237
+ contactConfig = device.contact;
233
238
  }
239
+ let motionConfig = {};
234
240
  if (device.motion) {
235
- config = device.motion;
241
+ motionConfig = device.motion;
236
242
  }
243
+ let curtainConfig = {};
237
244
  if (device.curtain) {
238
- config = device.curtain;
245
+ curtainConfig = device.curtain;
239
246
  }
247
+ let hubConfig = {};
240
248
  if (device.hub) {
241
- config = device.hub;
249
+ hubConfig = device.hub;
242
250
  }
251
+ let waterdetectorConfig = {};
243
252
  if (device.waterdetector) {
244
- config = device.waterdetector;
253
+ waterdetectorConfig = device.waterdetector;
245
254
  }
255
+ let humidifierConfig = {};
246
256
  if (device.humidifier) {
247
- config = device.humidifier;
257
+ humidifierConfig = device.humidifier;
248
258
  }
259
+ let meterConfig = {};
249
260
  if (device.meter) {
250
- config = device.meter;
261
+ meterConfig = device.meter;
251
262
  }
263
+ let iosensorConfig = {};
264
+ if (device.iosensor) {
265
+ iosensorConfig = device.iosensor;
266
+ }
267
+ let striplightConfig = {};
252
268
  if (device.striplight) {
253
- config = device.striplight;
269
+ striplightConfig = device.striplight;
254
270
  }
271
+ let plugConfig = {};
255
272
  if (device.plug) {
256
- config = device.plug;
273
+ plugConfig = device.plug;
257
274
  }
275
+ let blindTiltConfig = {};
258
276
  if (device.blindTilt) {
259
277
  if (device.blindTilt?.mode === undefined) {
260
- config['mode'] = BlindTiltMappingMode.OnlyUp;
261
- } else {
262
- config['mode'] = device.blindTilt?.mode;
263
-
264
- config = device.blindTilt;
278
+ blindTiltConfig['mode'] = BlindTiltMappingMode.OnlyUp;
265
279
  }
280
+ blindTiltConfig = device.blindTilt;
266
281
  }
282
+ const config = Object.assign({}, deviceConfig, botConfig, curtainConfig, waterdetectorConfig, striplightConfig, plugConfig, iosensorConfig,
283
+ meterConfig, humidifierConfig, hubConfig, lockConfig, ceilinglightConfig, colorbulbConfig, contactConfig, motionConfig, blindTiltConfig);
267
284
  if (Object.entries(config).length !== 0) {
268
285
  this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
269
286
  }
@@ -531,9 +548,9 @@ export abstract class deviceBase {
531
548
 
532
549
  if (device.firmware) {
533
550
  accessory.context.FirmwareRevision = device.firmware;
534
- } else if ((device.firmware === undefined && device.version === undefined) || accessory.context.FirmwareRevision === undefined) {
551
+ } else if (device.firmware === undefined && device.version === undefined && accessory.context.FirmwareRevision === undefined) {
535
552
  device.version = this.platform.version;
536
- accessory.context.FirmwareRevision = device.version;
553
+ accessory.context.FirmwareRevision = this.platform.version;
537
554
  } else {
538
555
  accessory.context.FirmwareRevision = device.version;
539
556
  }
@@ -613,7 +630,7 @@ export abstract class deviceBase {
613
630
  break;
614
631
  default:
615
632
  this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Unknown statusCode: `
616
- + `${statusCode}, Submit Bugs Here: ' + 'https://tinyurl.com/SwitchBotBug`);
633
+ + `${statusCode}, Submit Bugs Here: ' + 'https://tinyurl.com/SwitchBotBug`);
617
634
  }
618
635
  }
619
636