@switchbot/homebridge-switchbot 3.5.0-beta.35 → 3.5.0-beta.37

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.
Files changed (77) hide show
  1. package/dist/device/blindtilt.d.ts.map +1 -1
  2. package/dist/device/blindtilt.js +8 -6
  3. package/dist/device/blindtilt.js.map +1 -1
  4. package/dist/device/bot.d.ts.map +1 -1
  5. package/dist/device/bot.js +8 -6
  6. package/dist/device/bot.js.map +1 -1
  7. package/dist/device/ceilinglight.d.ts.map +1 -1
  8. package/dist/device/ceilinglight.js +8 -6
  9. package/dist/device/ceilinglight.js.map +1 -1
  10. package/dist/device/colorbulb.d.ts.map +1 -1
  11. package/dist/device/colorbulb.js +8 -6
  12. package/dist/device/colorbulb.js.map +1 -1
  13. package/dist/device/contact.d.ts.map +1 -1
  14. package/dist/device/contact.js +8 -6
  15. package/dist/device/contact.js.map +1 -1
  16. package/dist/device/curtain.d.ts.map +1 -1
  17. package/dist/device/curtain.js +8 -6
  18. package/dist/device/curtain.js.map +1 -1
  19. package/dist/device/device.d.ts.map +1 -1
  20. package/dist/device/device.js +57 -43
  21. package/dist/device/device.js.map +1 -1
  22. package/dist/device/fan.d.ts.map +1 -1
  23. package/dist/device/fan.js +16 -12
  24. package/dist/device/fan.js.map +1 -1
  25. package/dist/device/hub.d.ts.map +1 -1
  26. package/dist/device/hub.js +8 -6
  27. package/dist/device/hub.js.map +1 -1
  28. package/dist/device/humidifier.d.ts.map +1 -1
  29. package/dist/device/humidifier.js +8 -6
  30. package/dist/device/humidifier.js.map +1 -1
  31. package/dist/device/iosensor.d.ts.map +1 -1
  32. package/dist/device/iosensor.js +8 -6
  33. package/dist/device/iosensor.js.map +1 -1
  34. package/dist/device/lightstrip.d.ts.map +1 -1
  35. package/dist/device/lightstrip.js +8 -6
  36. package/dist/device/lightstrip.js.map +1 -1
  37. package/dist/device/lock.d.ts.map +1 -1
  38. package/dist/device/lock.js +8 -6
  39. package/dist/device/lock.js.map +1 -1
  40. package/dist/device/meter.d.ts.map +1 -1
  41. package/dist/device/meter.js +8 -6
  42. package/dist/device/meter.js.map +1 -1
  43. package/dist/device/meterplus.d.ts.map +1 -1
  44. package/dist/device/meterplus.js +8 -6
  45. package/dist/device/meterplus.js.map +1 -1
  46. package/dist/device/motion.d.ts.map +1 -1
  47. package/dist/device/motion.js +8 -6
  48. package/dist/device/motion.js.map +1 -1
  49. package/dist/device/plug.d.ts.map +1 -1
  50. package/dist/device/plug.js +8 -6
  51. package/dist/device/plug.js.map +1 -1
  52. package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
  53. package/dist/device/robotvacuumcleaner.js +8 -6
  54. package/dist/device/robotvacuumcleaner.js.map +1 -1
  55. package/dist/device/waterdetector.d.ts.map +1 -1
  56. package/dist/device/waterdetector.js +8 -6
  57. package/dist/device/waterdetector.js.map +1 -1
  58. package/package.json +1 -1
  59. package/src/device/blindtilt.ts +4 -2
  60. package/src/device/bot.ts +32 -30
  61. package/src/device/ceilinglight.ts +8 -6
  62. package/src/device/colorbulb.ts +8 -6
  63. package/src/device/contact.ts +8 -6
  64. package/src/device/curtain.ts +8 -6
  65. package/src/device/device.ts +60 -45
  66. package/src/device/fan.ts +16 -12
  67. package/src/device/hub.ts +10 -8
  68. package/src/device/humidifier.ts +8 -6
  69. package/src/device/iosensor.ts +8 -6
  70. package/src/device/lightstrip.ts +8 -6
  71. package/src/device/lock.ts +8 -6
  72. package/src/device/meter.ts +8 -6
  73. package/src/device/meterplus.ts +8 -6
  74. package/src/device/motion.ts +8 -6
  75. package/src/device/plug.ts +8 -6
  76. package/src/device/robotvacuumcleaner.ts +8 -6
  77. package/src/device/waterdetector.ts +8 -6
@@ -263,7 +263,7 @@ export class BlindTilt extends deviceBase {
263
263
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Stopped`);
264
264
  }
265
265
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} CurrentPosition: ${this.WindowCovering.CurrentPosition},`
266
- + ` TargetPosition: ${this.WindowCovering.TargetPosition}, PositionState: ${this.WindowCovering.PositionState},`);
266
+ + ` TargetPosition: ${this.WindowCovering.TargetPosition}, PositionState: ${this.WindowCovering.PositionState},`);
267
267
 
268
268
  if (!this.device.blindTilt?.hide_lightsensor) {
269
269
  const set_minLux = await this.minLux();
@@ -436,12 +436,14 @@ export class BlindTilt extends deviceBase {
436
436
  + ` StatusLowBattery: ${this.Battery.StatusLowBattery}`);
437
437
 
438
438
  // FirmwareRevision
439
- this.accessory.context.FirmwareRevision = deviceStatus.body.version;
439
+ if (deviceStatus.body.version) {
440
+ this.accessory.context.FirmwareRevision = deviceStatus.body.version;
440
441
  this.accessory
441
442
  .getService(this.hap.Service.AccessoryInformation)!
442
443
  .setCharacteristic(this.hap.Characteristic.FirmwareRevision, this.accessory.context.FirmwareRevision)
443
444
  .getCharacteristic(this.hap.Characteristic.FirmwareRevision)
444
445
  .updateValue(this.accessory.context.FirmwareRevision);
446
+ }
445
447
  }
446
448
 
447
449
  async refreshStatus(): Promise<void> {
package/src/device/bot.ts CHANGED
@@ -519,12 +519,14 @@ export class Bot extends deviceBase {
519
519
  + ` StatusLowBattery: ${this.Battery.StatusLowBattery}`);
520
520
 
521
521
  // FirmwareRevision
522
- this.accessory.context.FirmwareRevision = deviceStatus.body.version;
523
- this.accessory
524
- .getService(this.hap.Service.AccessoryInformation)!
525
- .setCharacteristic(this.hap.Characteristic.FirmwareRevision, this.accessory.context.FirmwareRevision)
526
- .getCharacteristic(this.hap.Characteristic.FirmwareRevision)
527
- .updateValue(this.accessory.context.FirmwareRevision);
522
+ if (deviceStatus.body.version) {
523
+ this.accessory.context.FirmwareRevision = deviceStatus.body.version;
524
+ this.accessory
525
+ .getService(this.hap.Service.AccessoryInformation)!
526
+ .setCharacteristic(this.hap.Characteristic.FirmwareRevision, this.accessory.context.FirmwareRevision)
527
+ .getCharacteristic(this.hap.Characteristic.FirmwareRevision)
528
+ .updateValue(this.accessory.context.FirmwareRevision);
529
+ }
528
530
  }
529
531
 
530
532
  /**
@@ -1065,36 +1067,36 @@ export class Bot extends deviceBase {
1065
1067
  async removeOutletService(accessory: PlatformAccessory): Promise<void> {
1066
1068
  // If outletService still present, then remove first
1067
1069
  if (this.Outlet?.Service) {
1068
- this.Outlet!.Service = this.accessory.getService(this.hap.Service.Outlet) as Service;
1069
- this.warnLog(`${this.device.deviceType}: ${accessory.displayName} Removing Leftover Outlet Service`);
1070
- accessory.removeService(this.Outlet!.Service);
1070
+ this.Outlet!.Service = this.accessory.getService(this.hap.Service.Outlet) as Service;
1071
+ this.warnLog(`${this.device.deviceType}: ${accessory.displayName} Removing Leftover Outlet Service`);
1072
+ accessory.removeService(this.Outlet!.Service);
1071
1073
  }
1072
1074
  }
1073
1075
 
1074
1076
  async removeGarageDoorService(accessory: PlatformAccessory): Promise<void> {
1075
1077
  // If garageDoorService still present, then remove first
1076
1078
  if (this.GarageDoor?.Service) {
1077
- this.GarageDoor!.Service = this.accessory.getService(this.hap.Service.GarageDoorOpener) as Service;
1078
- this.warnLog(`${this.device.deviceType}: ${accessory.displayName} Removing Leftover Garage Door Service`);
1079
- accessory.removeService(this.GarageDoor!.Service);
1079
+ this.GarageDoor!.Service = this.accessory.getService(this.hap.Service.GarageDoorOpener) as Service;
1080
+ this.warnLog(`${this.device.deviceType}: ${accessory.displayName} Removing Leftover Garage Door Service`);
1081
+ accessory.removeService(this.GarageDoor!.Service);
1080
1082
  }
1081
1083
  }
1082
1084
 
1083
1085
  async removeDoorService(accessory: PlatformAccessory): Promise<void> {
1084
1086
  // If doorService still present, then remove first
1085
1087
  if (this.Door?.Service) {
1086
- this.Door!.Service = this.accessory.getService(this.hap.Service.Door) as Service;
1087
- this.warnLog(`${this.device.deviceType}: ${accessory.displayName} Removing Leftover Door Service`);
1088
- accessory.removeService(this.Door!.Service);
1088
+ this.Door!.Service = this.accessory.getService(this.hap.Service.Door) as Service;
1089
+ this.warnLog(`${this.device.deviceType}: ${accessory.displayName} Removing Leftover Door Service`);
1090
+ accessory.removeService(this.Door!.Service);
1089
1091
  }
1090
1092
  }
1091
1093
 
1092
1094
  async removeLockService(accessory: PlatformAccessory): Promise<void> {
1093
1095
  // If lockService still present, then remove first
1094
1096
  if (this.Lock?.Service) {
1095
- this.Lock!.Service = this.accessory.getService(this.hap.Service.LockMechanism) as Service;
1096
- this.warnLog(`${this.device.deviceType}: ${accessory.displayName} Removing Leftover Lock Service`);
1097
- accessory.removeService(this.Lock!.Service);
1097
+ this.Lock!.Service = this.accessory.getService(this.hap.Service.LockMechanism) as Service;
1098
+ this.warnLog(`${this.device.deviceType}: ${accessory.displayName} Removing Leftover Lock Service`);
1099
+ accessory.removeService(this.Lock!.Service);
1098
1100
  }
1099
1101
  }
1100
1102
 
@@ -1110,27 +1112,27 @@ export class Bot extends deviceBase {
1110
1112
  async removeFanService(accessory: PlatformAccessory): Promise<void> {
1111
1113
  // If fanService still present, then remove first
1112
1114
  if (this.Fan?.Service) {
1113
- this.Fan!.Service = this.accessory.getService(this.hap.Service.Fanv2) as Service;
1114
- this.warnLog(`${this.device.deviceType}: ${accessory.displayName} Removing Leftover Fan Service`);
1115
- accessory.removeService(this.Fan!.Service);
1115
+ this.Fan!.Service = this.accessory.getService(this.hap.Service.Fanv2) as Service;
1116
+ this.warnLog(`${this.device.deviceType}: ${accessory.displayName} Removing Leftover Fan Service`);
1117
+ accessory.removeService(this.Fan!.Service);
1116
1118
  }
1117
1119
  }
1118
1120
 
1119
1121
  async removeWindowService(accessory: PlatformAccessory): Promise<void> {
1120
1122
  // If windowService still present, then remove first
1121
1123
  if (this.Window?.Service) {
1122
- this.Window!.Service = this.accessory.getService(this.hap.Service.Window) as Service;
1123
- this.warnLog(`${this.device.deviceType}: ${accessory.displayName} Removing Leftover Window Service`);
1124
- accessory.removeService(this.Window!.Service);
1124
+ this.Window!.Service = this.accessory.getService(this.hap.Service.Window) as Service;
1125
+ this.warnLog(`${this.device.deviceType}: ${accessory.displayName} Removing Leftover Window Service`);
1126
+ accessory.removeService(this.Window!.Service);
1125
1127
  }
1126
1128
  }
1127
1129
 
1128
1130
  async removeWindowCoveringService(accessory: PlatformAccessory): Promise<void> {
1129
1131
  // If windowCoveringService still present, then remove first
1130
1132
  if (this.WindowCovering?.Service) {
1131
- this.WindowCovering!.Service = this.accessory.getService(this.hap.Service.WindowCovering) as Service;
1132
- this.warnLog(`${this.device.deviceType}: ${accessory.displayName} Removing Leftover Window Covering Service`);
1133
- accessory.removeService(this.WindowCovering!.Service);
1133
+ this.WindowCovering!.Service = this.accessory.getService(this.hap.Service.WindowCovering) as Service;
1134
+ this.warnLog(`${this.device.deviceType}: ${accessory.displayName} Removing Leftover Window Covering Service`);
1135
+ accessory.removeService(this.WindowCovering!.Service);
1134
1136
  }
1135
1137
  }
1136
1138
 
@@ -1146,9 +1148,9 @@ export class Bot extends deviceBase {
1146
1148
  async removeSwitchService(accessory: PlatformAccessory): Promise<void> {
1147
1149
  // If switchService still present, then remove first
1148
1150
  if (this.Switch?.Service) {
1149
- this.Switch!.Service = this.accessory.getService(this.hap.Service.Switch) as Service;
1150
- this.warnLog(`${this.device.deviceType}: ${accessory.displayName} Removing Leftover Switch Service`);
1151
- accessory.removeService(this.Switch!.Service);
1151
+ this.Switch!.Service = this.accessory.getService(this.hap.Service.Switch) as Service;
1152
+ this.warnLog(`${this.device.deviceType}: ${accessory.displayName} Removing Leftover Switch Service`);
1153
+ accessory.removeService(this.Switch!.Service);
1152
1154
  }
1153
1155
  }
1154
1156
 
@@ -288,12 +288,14 @@ export class CeilingLight extends deviceBase {
288
288
  }
289
289
 
290
290
  // FirmwareRevision
291
- this.accessory.context.FirmwareRevision = deviceStatus.body.version;
292
- this.accessory
293
- .getService(this.hap.Service.AccessoryInformation)!
294
- .setCharacteristic(this.hap.Characteristic.FirmwareRevision, this.accessory.context.FirmwareRevision)
295
- .getCharacteristic(this.hap.Characteristic.FirmwareRevision)
296
- .updateValue(this.accessory.context.FirmwareRevision);
291
+ if (deviceStatus.body.version) {
292
+ this.accessory.context.FirmwareRevision = deviceStatus.body.version;
293
+ this.accessory
294
+ .getService(this.hap.Service.AccessoryInformation)!
295
+ .setCharacteristic(this.hap.Characteristic.FirmwareRevision, this.accessory.context.FirmwareRevision)
296
+ .getCharacteristic(this.hap.Characteristic.FirmwareRevision)
297
+ .updateValue(this.accessory.context.FirmwareRevision);
298
+ }
297
299
  }
298
300
 
299
301
  /**
@@ -349,12 +349,14 @@ export class ColorBulb extends deviceBase {
349
349
  }
350
350
 
351
351
  // FirmwareRevision
352
- this.accessory.context.FirmwareRevision = deviceStatus.body.version;
353
- this.accessory
354
- .getService(this.hap.Service.AccessoryInformation)!
355
- .setCharacteristic(this.hap.Characteristic.FirmwareRevision, this.accessory.context.FirmwareRevision)
356
- .getCharacteristic(this.hap.Characteristic.FirmwareRevision)
357
- .updateValue(this.accessory.context.FirmwareRevision);
352
+ if (deviceStatus.body.version) {
353
+ this.accessory.context.FirmwareRevision = deviceStatus.body.version;
354
+ this.accessory
355
+ .getService(this.hap.Service.AccessoryInformation)!
356
+ .setCharacteristic(this.hap.Characteristic.FirmwareRevision, this.accessory.context.FirmwareRevision)
357
+ .getCharacteristic(this.hap.Characteristic.FirmwareRevision)
358
+ .updateValue(this.accessory.context.FirmwareRevision);
359
+ }
358
360
  }
359
361
 
360
362
  /**
@@ -279,12 +279,14 @@ export class Contact extends deviceBase {
279
279
  + `StatusLowBattery: ${this.Battery.StatusLowBattery}`);
280
280
 
281
281
  // FirmwareRevision
282
- this.accessory.context.FirmwareRevision = deviceStatus.body.version;
283
- this.accessory
284
- .getService(this.hap.Service.AccessoryInformation)!
285
- .setCharacteristic(this.hap.Characteristic.FirmwareRevision, this.accessory.context.FirmwareRevision)
286
- .getCharacteristic(this.hap.Characteristic.FirmwareRevision)
287
- .updateValue(this.accessory.context.FirmwareRevision);
282
+ if (deviceStatus.body.version) {
283
+ this.accessory.context.FirmwareRevision = deviceStatus.body.version;
284
+ this.accessory
285
+ .getService(this.hap.Service.AccessoryInformation)!
286
+ .setCharacteristic(this.hap.Characteristic.FirmwareRevision, this.accessory.context.FirmwareRevision)
287
+ .getCharacteristic(this.hap.Characteristic.FirmwareRevision)
288
+ .updateValue(this.accessory.context.FirmwareRevision);
289
+ }
288
290
  }
289
291
 
290
292
  /**
@@ -464,12 +464,14 @@ export class Curtain extends deviceBase {
464
464
  + ` StatusLowBattery: ${this.Battery.StatusLowBattery}`);
465
465
 
466
466
  // FirmwareRevision
467
- this.accessory.context.FirmwareRevision = deviceStatus.body.version;
468
- this.accessory
469
- .getService(this.hap.Service.AccessoryInformation)!
470
- .setCharacteristic(this.hap.Characteristic.FirmwareRevision, this.accessory.context.FirmwareRevision)
471
- .getCharacteristic(this.hap.Characteristic.FirmwareRevision)
472
- .updateValue(this.accessory.context.FirmwareRevision);
467
+ if (deviceStatus.body.version) {
468
+ this.accessory.context.FirmwareRevision = deviceStatus.body.version;
469
+ this.accessory
470
+ .getService(this.hap.Service.AccessoryInformation)!
471
+ .setCharacteristic(this.hap.Characteristic.FirmwareRevision, this.accessory.context.FirmwareRevision)
472
+ .getCharacteristic(this.hap.Characteristic.FirmwareRevision)
473
+ .updateValue(this.accessory.context.FirmwareRevision);
474
+ }
473
475
  }
474
476
 
475
477
  async refreshStatus(): Promise<void> {
@@ -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
  }
@@ -542,8 +559,6 @@ export abstract class deviceBase {
542
559
  async statusCode(statusCode: number): Promise<void> {
543
560
  switch (this.device.deviceType) {
544
561
  case this.device.hubDeviceId:
545
- statusCode = 161;
546
- break;
547
562
  case '000000000000':
548
563
  statusCode = 161;
549
564
  break;
@@ -613,7 +628,7 @@ export abstract class deviceBase {
613
628
  break;
614
629
  default:
615
630
  this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Unknown statusCode: `
616
- + `${statusCode}, Submit Bugs Here: ' + 'https://tinyurl.com/SwitchBotBug`);
631
+ + `${statusCode}, Submit Bugs Here: ' + 'https://tinyurl.com/SwitchBotBug`);
617
632
  }
618
633
  }
619
634
 
package/src/device/fan.ts CHANGED
@@ -119,12 +119,14 @@ export class Fan extends deviceBase {
119
119
  this.Battery.BatteryLevel = battery;
120
120
 
121
121
  // FirmwareRevision
122
- this.accessory.context.FirmwareRevision = version;
122
+ if (version) {
123
+ this.accessory.context.FirmwareRevision = version;
123
124
  this.accessory
124
125
  .getService(this.hap.Service.AccessoryInformation)!
125
126
  .setCharacteristic(this.hap.Characteristic.FirmwareRevision, this.accessory.context.FirmwareRevision)
126
127
  .getCharacteristic(this.hap.Characteristic.FirmwareRevision)
127
128
  .updateValue(this.accessory.context.FirmwareRevision);
129
+ }
128
130
  this.updateHomeKitCharacteristics();
129
131
  } catch (e: any) {
130
132
  this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} `
@@ -202,12 +204,14 @@ export class Fan extends deviceBase {
202
204
  + ` StatusLowBattery: ${this.Battery.StatusLowBattery}`);
203
205
 
204
206
  // FirmwareRevision
205
- this.accessory.context.FirmwareRevision = deviceStatus.body.version;
206
- this.accessory
207
- .getService(this.hap.Service.AccessoryInformation)!
208
- .setCharacteristic(this.hap.Characteristic.FirmwareRevision, this.accessory.context.FirmwareRevision)
209
- .getCharacteristic(this.hap.Characteristic.FirmwareRevision)
210
- .updateValue(this.accessory.context.FirmwareRevision);
207
+ if (deviceStatus.body.version) {
208
+ this.accessory.context.FirmwareRevision = deviceStatus.body.version;
209
+ this.accessory
210
+ .getService(this.hap.Service.AccessoryInformation)!
211
+ .setCharacteristic(this.hap.Characteristic.FirmwareRevision, this.accessory.context.FirmwareRevision)
212
+ .getCharacteristic(this.hap.Characteristic.FirmwareRevision)
213
+ .updateValue(this.accessory.context.FirmwareRevision);
214
+ }
211
215
  }
212
216
 
213
217
 
@@ -475,7 +479,7 @@ export class Fan extends deviceBase {
475
479
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic Active: ${this.Fan.Active}`);
476
480
  }
477
481
  // RotationSpeed
478
- if(this.Fan.RotationSpeed === undefined) {
482
+ if (this.Fan.RotationSpeed === undefined) {
479
483
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} RotationSpeed: ${this.Fan.RotationSpeed}`);
480
484
  } else {
481
485
  this.accessory.context.RotationSpeed = this.Fan.RotationSpeed;
@@ -483,7 +487,7 @@ export class Fan extends deviceBase {
483
487
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic RotationSpeed: ${this.Fan.RotationSpeed}`);
484
488
  }
485
489
  // SwingMode
486
- if(this.Fan.SwingMode === undefined) {
490
+ if (this.Fan.SwingMode === undefined) {
487
491
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} SwingMode: ${this.Fan.SwingMode}`);
488
492
  } else {
489
493
  this.accessory.context.SwingMode = this.Fan.SwingMode;
@@ -491,7 +495,7 @@ export class Fan extends deviceBase {
491
495
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic SwingMode: ${this.Fan.SwingMode}`);
492
496
  }
493
497
  // BateryLevel
494
- if(this.Battery.BatteryLevel === undefined) {
498
+ if (this.Battery.BatteryLevel === undefined) {
495
499
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} BatteryLevel: ${this.Battery.BatteryLevel}`);
496
500
  } else {
497
501
  this.accessory.context.BatteryLevel = this.Battery.BatteryLevel;
@@ -499,7 +503,7 @@ export class Fan extends deviceBase {
499
503
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic BatteryLevel: ${this.Battery.BatteryLevel}`);
500
504
  }
501
505
  // ChargingState
502
- if(this.Battery.ChargingState === undefined) {
506
+ if (this.Battery.ChargingState === undefined) {
503
507
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} ChargingState: ${this.Battery.ChargingState}`);
504
508
  } else {
505
509
  this.accessory.context.ChargingState = this.Battery.ChargingState;
@@ -507,7 +511,7 @@ export class Fan extends deviceBase {
507
511
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic ChargingState: ${this.Battery.ChargingState}`);
508
512
  }
509
513
  // StatusLowBattery
510
- if(this.Battery.StatusLowBattery === undefined) {
514
+ if (this.Battery.StatusLowBattery === undefined) {
511
515
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} StatusLowBattery: ${this.Battery.StatusLowBattery}`);
512
516
  } else {
513
517
  this.accessory.context.StatusLowBattery = this.Battery.StatusLowBattery;
package/src/device/hub.ts CHANGED
@@ -157,12 +157,12 @@ export class Hub extends deviceBase {
157
157
  const { CurrentRelativeHumidity } = this.HumiditySensor || { CurrentRelativeHumidity: undefined };
158
158
  if (context.scale !== 'CELCIUS' && device.hub?.convertUnitTo === undefined) {
159
159
  this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} received a non-CELCIUS Webhook scale: `
160
- + `${context.scale}, Use the *convertUnitsTo* config under Hub settings, if displaying incorrectly in HomeKit.`);
160
+ + `${context.scale}, Use the *convertUnitsTo* config under Hub settings, if displaying incorrectly in HomeKit.`);
161
161
  }
162
162
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} ` +
163
- '(scale, temperature, humidity, lightLevel) = ' +
164
- `Webhook:(${context.scale}, ${convertUnits(temperature, context.scale, device.hub?.convertUnitTo)}, ${humidity}, ${lightLevel}), ` +
165
- `current:(${CurrentTemperature}, ${CurrentRelativeHumidity}, ${CurrentAmbientLightLevel})`);
163
+ '(scale, temperature, humidity, lightLevel) = ' +
164
+ `Webhook:(${context.scale}, ${convertUnits(temperature, context.scale, device.hub?.convertUnitTo)}, ${humidity}, ${lightLevel}), ` +
165
+ `current:(${CurrentTemperature}, ${CurrentRelativeHumidity}, ${CurrentAmbientLightLevel})`);
166
166
  if (!this.device.hub?.hide_humidity) {
167
167
  this.HumiditySensor!.CurrentRelativeHumidity = humidity;
168
168
  }
@@ -217,12 +217,14 @@ export class Hub extends deviceBase {
217
217
  }
218
218
 
219
219
  // FirmwareRevision
220
- this.accessory.context.FirmwareRevision = deviceStatus.body.version;
220
+ if (deviceStatus.body.version) {
221
+ this.accessory.context.FirmwareRevision = deviceStatus.body.version;
221
222
  this.accessory
222
223
  .getService(this.hap.Service.AccessoryInformation)!
223
224
  .setCharacteristic(this.hap.Characteristic.FirmwareRevision, this.accessory.context.FirmwareRevision)
224
225
  .getCharacteristic(this.hap.Characteristic.FirmwareRevision)
225
226
  .updateValue(this.accessory.context.FirmwareRevision);
227
+ }
226
228
  }
227
229
 
228
230
  async refreshStatus(): Promise<void> {
@@ -278,7 +280,7 @@ export class Hub extends deviceBase {
278
280
  if (!this.device.hub?.hide_humidity) {
279
281
  if (this.HumiditySensor!.CurrentRelativeHumidity === undefined) {
280
282
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName}`
281
- +` CurrentRelativeHumidity: ${this.HumiditySensor!.CurrentRelativeHumidity}`);
283
+ + ` CurrentRelativeHumidity: ${this.HumiditySensor!.CurrentRelativeHumidity}`);
282
284
  } else {
283
285
  if (this.device.mqttURL) {
284
286
  mqttmessage.push(`"humidity": ${this.HumiditySensor!.CurrentRelativeHumidity}`);
@@ -308,7 +310,7 @@ export class Hub extends deviceBase {
308
310
  this.accessory.context.CurrentTemperature = this.TemperatureSensor!.CurrentTemperature;
309
311
  this.TemperatureSensor!.Service.updateCharacteristic(this.hap.Characteristic.CurrentTemperature, this.TemperatureSensor!.CurrentTemperature);
310
312
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic`
311
- + ` CurrentTemperature: ${this.TemperatureSensor!.CurrentTemperature}`);
313
+ + ` CurrentTemperature: ${this.TemperatureSensor!.CurrentTemperature}`);
312
314
  }
313
315
  }
314
316
 
@@ -316,7 +318,7 @@ export class Hub extends deviceBase {
316
318
  if (!this.device.hub?.hide_lightsensor) {
317
319
  if (this.LightSensor!.CurrentAmbientLightLevel === undefined) {
318
320
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName}`
319
- + ` CurrentAmbientLightLevel: ${this.LightSensor!.CurrentAmbientLightLevel}`);
321
+ + ` CurrentAmbientLightLevel: ${this.LightSensor!.CurrentAmbientLightLevel}`);
320
322
  } else {
321
323
  if (this.device.mqttURL) {
322
324
  mqttmessage.push(`"light": ${this.LightSensor!.CurrentAmbientLightLevel}`);
@@ -269,12 +269,14 @@ export class Humidifier extends deviceBase {
269
269
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} WaterLevel: ${this.HumidifierDehumidifier.WaterLevel}`);
270
270
 
271
271
  // FirmwareRevision
272
- this.accessory.context.FirmwareRevision = deviceStatus.body.version;
273
- this.accessory
274
- .getService(this.hap.Service.AccessoryInformation)!
275
- .setCharacteristic(this.hap.Characteristic.FirmwareRevision, this.accessory.context.FirmwareRevision)
276
- .getCharacteristic(this.hap.Characteristic.FirmwareRevision)
277
- .updateValue(this.accessory.context.FirmwareRevision);
272
+ if (deviceStatus.body.version) {
273
+ this.accessory.context.FirmwareRevision = deviceStatus.body.version;
274
+ this.accessory
275
+ .getService(this.hap.Service.AccessoryInformation)!
276
+ .setCharacteristic(this.hap.Characteristic.FirmwareRevision, this.accessory.context.FirmwareRevision)
277
+ .getCharacteristic(this.hap.Characteristic.FirmwareRevision)
278
+ .updateValue(this.accessory.context.FirmwareRevision);
279
+ }
278
280
  }
279
281
 
280
282
  async refreshStatus(): Promise<void> {
@@ -228,12 +228,14 @@ export class IOSensor extends deviceBase {
228
228
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Temperature: ${this.TemperatureSensor!.CurrentTemperature}°c`);
229
229
  }
230
230
  // FirmwareRevision
231
- this.accessory.context.FirmwareRevision = deviceStatus.body.version;
232
- this.accessory
233
- .getService(this.hap.Service.AccessoryInformation)!
234
- .setCharacteristic(this.hap.Characteristic.FirmwareRevision, this.accessory.context.FirmwareRevision)
235
- .getCharacteristic(this.hap.Characteristic.FirmwareRevision)
236
- .updateValue(this.accessory.context.FirmwareRevision);
231
+ if (deviceStatus.body.version) {
232
+ this.accessory.context.FirmwareRevision = deviceStatus.body.version;
233
+ this.accessory
234
+ .getService(this.hap.Service.AccessoryInformation)!
235
+ .setCharacteristic(this.hap.Characteristic.FirmwareRevision, this.accessory.context.FirmwareRevision)
236
+ .getCharacteristic(this.hap.Characteristic.FirmwareRevision)
237
+ .updateValue(this.accessory.context.FirmwareRevision);
238
+ }
237
239
  }
238
240
 
239
241
  /**
@@ -326,12 +326,14 @@ export class StripLight extends deviceBase {
326
326
  }
327
327
 
328
328
  // FirmwareRevision
329
- this.accessory.context.FirmwareRevision = deviceStatus.body.version;
330
- this.accessory
331
- .getService(this.hap.Service.AccessoryInformation)!
332
- .setCharacteristic(this.hap.Characteristic.FirmwareRevision, this.accessory.context.FirmwareRevision)
333
- .getCharacteristic(this.hap.Characteristic.FirmwareRevision)
334
- .updateValue(this.accessory.context.FirmwareRevision);
329
+ if (deviceStatus.body.version) {
330
+ this.accessory.context.FirmwareRevision = deviceStatus.body.version;
331
+ this.accessory
332
+ .getService(this.hap.Service.AccessoryInformation)!
333
+ .setCharacteristic(this.hap.Characteristic.FirmwareRevision, this.accessory.context.FirmwareRevision)
334
+ .getCharacteristic(this.hap.Characteristic.FirmwareRevision)
335
+ .updateValue(this.accessory.context.FirmwareRevision);
336
+ }
335
337
  }
336
338
 
337
339
  /**
@@ -256,12 +256,14 @@ export class Lock extends deviceBase {
256
256
  + ` StatusLowBattery: ${this.Battery.StatusLowBattery}`);
257
257
 
258
258
  // FirmwareRevision
259
- this.accessory.context.FirmwareRevision = deviceStatus.body.version;
260
- this.accessory
261
- .getService(this.hap.Service.AccessoryInformation)!
262
- .setCharacteristic(this.hap.Characteristic.FirmwareRevision, this.accessory.context.FirmwareRevision)
263
- .getCharacteristic(this.hap.Characteristic.FirmwareRevision)
264
- .updateValue(this.accessory.context.FirmwareRevision);
259
+ if (deviceStatus.body.version) {
260
+ this.accessory.context.FirmwareRevision = deviceStatus.body.version;
261
+ this.accessory
262
+ .getService(this.hap.Service.AccessoryInformation)!
263
+ .setCharacteristic(this.hap.Characteristic.FirmwareRevision, this.accessory.context.FirmwareRevision)
264
+ .getCharacteristic(this.hap.Characteristic.FirmwareRevision)
265
+ .updateValue(this.accessory.context.FirmwareRevision);
266
+ }
265
267
  }
266
268
 
267
269
  /**