@switchbot/homebridge-switchbot 0.1.2-beta.35 → 0.1.2-beta.39

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 (69) hide show
  1. package/.github/ISSUE_TEMPLATE/feature-request.yml +1 -1
  2. package/dist/devices/bots.js +4 -4
  3. package/dist/devices/bots.js.map +1 -1
  4. package/dist/devices/bulb.js +3 -3
  5. package/dist/devices/bulb.js.map +1 -1
  6. package/dist/devices/contact.d.ts.map +1 -1
  7. package/dist/devices/contact.js +5 -4
  8. package/dist/devices/contact.js.map +1 -1
  9. package/dist/devices/curtains.d.ts.map +1 -1
  10. package/dist/devices/curtains.js +3 -4
  11. package/dist/devices/curtains.js.map +1 -1
  12. package/dist/devices/humidifiers.d.ts.map +1 -1
  13. package/dist/devices/humidifiers.js +5 -4
  14. package/dist/devices/humidifiers.js.map +1 -1
  15. package/dist/devices/indoorcam.d.ts.map +1 -1
  16. package/dist/devices/indoorcam.js +3 -4
  17. package/dist/devices/indoorcam.js.map +1 -1
  18. package/dist/devices/meters.d.ts.map +1 -1
  19. package/dist/devices/meters.js +7 -5
  20. package/dist/devices/meters.js.map +1 -1
  21. package/dist/devices/motion.js +3 -3
  22. package/dist/devices/motion.js.map +1 -1
  23. package/dist/devices/plugs.js +2 -2
  24. package/dist/devices/plugs.js.map +1 -1
  25. package/dist/irdevices/airconditioners.js +1 -1
  26. package/dist/irdevices/airconditioners.js.map +1 -1
  27. package/dist/irdevices/airpurifiers.js +1 -1
  28. package/dist/irdevices/airpurifiers.js.map +1 -1
  29. package/dist/irdevices/cameras.js +1 -1
  30. package/dist/irdevices/cameras.js.map +1 -1
  31. package/dist/irdevices/fans.js +1 -1
  32. package/dist/irdevices/fans.js.map +1 -1
  33. package/dist/irdevices/lights.js +1 -1
  34. package/dist/irdevices/lights.js.map +1 -1
  35. package/dist/irdevices/others.d.ts.map +1 -1
  36. package/dist/irdevices/others.js +1 -1
  37. package/dist/irdevices/others.js.map +1 -1
  38. package/dist/irdevices/tvs.d.ts.map +1 -1
  39. package/dist/irdevices/tvs.js +16 -6
  40. package/dist/irdevices/tvs.js.map +1 -1
  41. package/dist/irdevices/vacuumcleaners.d.ts.map +1 -1
  42. package/dist/irdevices/vacuumcleaners.js +2 -3
  43. package/dist/irdevices/vacuumcleaners.js.map +1 -1
  44. package/dist/irdevices/waterheaters.js +2 -2
  45. package/dist/irdevices/waterheaters.js.map +1 -1
  46. package/dist/platform.d.ts +2 -1
  47. package/dist/platform.d.ts.map +1 -1
  48. package/dist/platform.js +25 -25
  49. package/dist/platform.js.map +1 -1
  50. package/package.json +1 -1
  51. package/src/devices/bots.ts +4 -4
  52. package/src/devices/bulb.ts +3 -3
  53. package/src/devices/contact.ts +6 -4
  54. package/src/devices/curtains.ts +3 -4
  55. package/src/devices/humidifiers.ts +10 -8
  56. package/src/devices/indoorcam.ts +3 -4
  57. package/src/devices/meters.ts +9 -5
  58. package/src/devices/motion.ts +3 -3
  59. package/src/devices/plugs.ts +2 -2
  60. package/src/irdevices/airconditioners.ts +1 -1
  61. package/src/irdevices/airpurifiers.ts +1 -1
  62. package/src/irdevices/cameras.ts +1 -1
  63. package/src/irdevices/fans.ts +1 -1
  64. package/src/irdevices/lights.ts +1 -1
  65. package/src/irdevices/others.ts +2 -4
  66. package/src/irdevices/tvs.ts +18 -7
  67. package/src/irdevices/vacuumcleaners.ts +2 -6
  68. package/src/irdevices/waterheaters.ts +2 -2
  69. package/src/platform.ts +25 -25
@@ -34,26 +34,35 @@ export class TV {
34
34
  case 'Speaker':
35
35
  case 'DIY Speaker':
36
36
  accessory.category = this.platform.api.hap.Categories.SPEAKER;
37
+ (this.service =
38
+ accessory.getService(this.platform.Service.Television) ||
39
+ accessory.addService(this.platform.Service.Television)), `${accessory.displayName} Speaker`;
37
40
  break;
38
41
  case 'IPTV':
39
42
  case 'DIY IPTV':
40
43
  accessory.category = this.platform.api.hap.Categories.TV_STREAMING_STICK;
44
+ (this.service =
45
+ accessory.getService(this.platform.Service.Television) ||
46
+ accessory.addService(this.platform.Service.Television)), `${accessory.displayName} Streaming Stick`;
41
47
  break;
42
48
  case 'DVD':
43
49
  case 'DIY DVD':
44
50
  case 'Set Top Box':
45
51
  case 'DIY Set Top Box':
46
52
  accessory.category = this.platform.api.hap.Categories.TV_SET_TOP_BOX;
53
+ (this.service =
54
+ accessory.getService(this.platform.Service.Television) ||
55
+ accessory.addService(this.platform.Service.Television)), `${accessory.displayName} Set Top Box`;
47
56
  break;
48
57
  default:
49
58
  accessory.category = this.platform.api.hap.Categories.TELEVISION;
50
- }
51
59
 
52
- // get the Television service if it exists, otherwise create a new Television service
53
- // you can create multiple services for each accessory
54
- (this.service =
55
- accessory.getService(this.platform.Service.Television) ||
56
- accessory.addService(this.platform.Service.Television)), `${device.deviceName} ${device.remoteType}`;
60
+ // get the Television service if it exists, otherwise create a new Television service
61
+ // you can create multiple services for each accessory
62
+ (this.service =
63
+ accessory.getService(this.platform.Service.Television) ||
64
+ accessory.addService(this.platform.Service.Television)), `${accessory.displayName} TV`;
65
+ }
57
66
 
58
67
  // To avoid "Cannot add a Service with the same UUID another Service without also defining a unique 'subtype' property." error,
59
68
  // when creating multiple services of the same type, you need to use the following syntax to specify a name and subtype id:
@@ -86,7 +95,9 @@ export class TV {
86
95
  // create a new Television Speaker service
87
96
  (this.speakerService =
88
97
  accessory.getService(this.platform.Service.TelevisionSpeaker) ||
89
- accessory.addService(this.platform.Service.TelevisionSpeaker)), `${device.deviceName} ${device.remoteType} Speaker`;
98
+ accessory.addService(this.platform.Service.TelevisionSpeaker)), `${accessory.displayName} Speaker`;
99
+
100
+ this.speakerService.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Speaker`);
90
101
 
91
102
  this.speakerService
92
103
  .setCharacteristic(this.platform.Characteristic.Active, this.platform.Characteristic.Active.ACTIVE)
@@ -29,8 +29,7 @@ export class VacuumCleaner {
29
29
  // you can create multiple services for each accessory
30
30
  (this.service =
31
31
  accessory.getService(this.platform.Service.Switch) ||
32
- accessory.addService(this.platform.Service.Switch)),
33
- `${device.deviceName} ${device.remoteType}`;
32
+ accessory.addService(this.platform.Service.Switch)), `${accessory.displayName} Vacuum`;
34
33
 
35
34
  // To avoid "Cannot add a Service with the same UUID another Service without also defining a unique 'subtype' property." error,
36
35
  // when creating multiple services of the same type, you need to use the following syntax to specify a name and subtype id:
@@ -38,10 +37,7 @@ export class VacuumCleaner {
38
37
 
39
38
  // set the service name, this is what is displayed as the default name on the Home app
40
39
  // in this example we are using the name we stored in the `accessory.context` in the `discoverDevices` method.
41
- this.service.setCharacteristic(
42
- this.platform.Characteristic.Name,
43
- `${device.deviceName} ${device.remoteType}`,
44
- );
40
+ this.service.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
45
41
 
46
42
  // handle on / off events using the On characteristic
47
43
  this.service.getCharacteristic(this.platform.Characteristic.On).onSet(this.OnSet.bind(this));
@@ -28,8 +28,8 @@ export class WaterHeater {
28
28
  // get the Television service if it exists, otherwise create a new Television service
29
29
  // you can create multiple services for each accessory
30
30
  (this.service =
31
- accessory.getService(this.platform.Service.Valve) || accessory.addService(this.platform.Service.Valve)),
32
- `${device.deviceName} ${device.remoteType}`;
31
+ accessory.getService(this.platform.Service.Valve) ||
32
+ accessory.addService(this.platform.Service.Valve)), `${accessory.displayName} Water Heater`;
33
33
 
34
34
  // To avoid "Cannot add a Service with the same UUID another Service without also defining a unique 'subtype' property." error,
35
35
  // when creating multiple services of the same type, you need to use the following syntax to specify a name and subtype id:
package/src/platform.ts CHANGED
@@ -115,6 +115,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
115
115
  * This will disable adding any device and will just output info.
116
116
  */
117
117
  this.config.options = this.config.options || {};
118
+ this.config.options.debug;
118
119
 
119
120
  //Enable BLE for Device
120
121
  this.config.options.ble;
@@ -171,14 +172,14 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
171
172
  this.config.options.other.commandOn;
172
173
  this.config.options.other.commandOff;
173
174
 
174
- if (this.config.options!.refreshRate! < 120) {
175
- throw new Error('Refresh Rate must be above 120 (2 minutes).');
175
+ if (this.config.options!.refreshRate! < 30) {
176
+ throw new Error('Refresh Rate must be above 30 (30 seconds).');
176
177
  }
177
178
 
178
179
  if (!this.config.options.refreshRate) {
179
- // default 600 seconds (15 minutes)
180
- this.config.options!.refreshRate! = 1000;
181
- this.log.warn('Using Default Refresh Rate.');
180
+ // default 120 seconds (2 minutes)
181
+ this.config.options!.refreshRate! = 120;
182
+ this.log.warn('Using Default Refresh Rate (2 minutes).');
182
183
  }
183
184
 
184
185
  if (!this.config.options.pushRate) {
@@ -255,7 +256,6 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
255
256
  this.debug(`Discovered ${device.deviceType}: ${device.deviceId} is Not Supported.`);
256
257
  break;
257
258
  default:
258
- // eslint-disable-next-line max-len
259
259
  this.log.info(`Device: ${device.deviceName} with Device Type: ${device.deviceType}, is currently not supported.`);
260
260
  this.log.info('Submit Feature Requests Here: https://git.io/JL14Z');
261
261
  }
@@ -320,7 +320,6 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
320
320
  this.createOthers(device);
321
321
  break;
322
322
  default:
323
- // eslint-disable-next-line max-len
324
323
  this.log.info(`Device: ${device.deviceName} with Device Type: ${device.remoteType}, is currently not supported.`);
325
324
  this.log.info('Submit Feature Requests Here: https://git.io/JL14Z');
326
325
  }
@@ -363,7 +362,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
363
362
  this.log.info(`Adding new accessory: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
364
363
 
365
364
  // create a new accessory
366
- const accessory = new this.api.platformAccessory(`${device.deviceName} ${device.deviceType}`, uuid);
365
+ const accessory = new this.api.platformAccessory(device.deviceName, uuid);
367
366
 
368
367
  // store a copy of the device object in the `accessory.context`
369
368
  // the `context` property can be used to store any data about the accessory you may need
@@ -419,7 +418,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
419
418
  this.log.error('You must set your Bot to Press or Switch Mode');
420
419
  }
421
420
  // create a new accessory
422
- const accessory = new this.api.platformAccessory(`${device.deviceName} ${device.deviceType}`, uuid);
421
+ const accessory = new this.api.platformAccessory(device.deviceName, uuid);
423
422
 
424
423
  // store a copy of the device object in the `accessory.context`
425
424
  // the `context` property can be used to store any data about the accessory you may need
@@ -473,7 +472,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
473
472
  this.log.info(`Adding new accessory: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
474
473
 
475
474
  // create a new accessory
476
- const accessory = new this.api.platformAccessory(`${device.deviceName} ${device.deviceType}`, uuid);
475
+ const accessory = new this.api.platformAccessory(device.deviceName, uuid);
477
476
 
478
477
  // store a copy of the device object in the `accessory.context`
479
478
  // the `context` property can be used to store any data about the accessory you may need
@@ -525,7 +524,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
525
524
  this.log.info(`Adding new accessory: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
526
525
 
527
526
  // create a new accessory
528
- const accessory = new this.api.platformAccessory(`${device.deviceName} ${device.deviceType}`, uuid);
527
+ const accessory = new this.api.platformAccessory(device.deviceName, uuid);
529
528
 
530
529
  // store a copy of the device object in the `accessory.context`
531
530
  // the `context` property can be used to store any data about the accessory you may need
@@ -576,7 +575,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
576
575
  this.log.info(`Adding new accessory: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
577
576
 
578
577
  // create a new accessory
579
- const accessory = new this.api.platformAccessory(`${device.deviceName} ${device.deviceType}`, uuid);
578
+ const accessory = new this.api.platformAccessory(device.deviceName, uuid);
580
579
 
581
580
  // store a copy of the device object in the `accessory.context`
582
581
  // the `context` property can be used to store any data about the accessory you may need
@@ -638,7 +637,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
638
637
  }
639
638
 
640
639
  // create a new accessory
641
- const accessory = new this.api.platformAccessory(`${device.deviceName} ${device.deviceType}`, uuid);
640
+ const accessory = new this.api.platformAccessory(device.deviceName, uuid);
642
641
 
643
642
  // store a copy of the device object in the `accessory.context`
644
643
  // the `context` property can be used to store any data about the accessory you may need
@@ -699,7 +698,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
699
698
  this.log.info(`Adding new accessory: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
700
699
 
701
700
  // create a new accessory
702
- const accessory = new this.api.platformAccessory(`${device.deviceName} ${device.deviceType}`, uuid);
701
+ const accessory = new this.api.platformAccessory(device.deviceName, uuid);
703
702
 
704
703
  // store a copy of the device object in the `accessory.context`
705
704
  // the `context` property can be used to store any data about the accessory you may need
@@ -752,7 +751,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
752
751
  this.log.info(`Adding new accessory: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
753
752
 
754
753
  // create a new accessory
755
- const accessory = new this.api.platformAccessory(`${device.deviceName} ${device.deviceType}`, uuid);
754
+ const accessory = new this.api.platformAccessory(device.deviceName, uuid);
756
755
 
757
756
  // store a copy of the device object in the `accessory.context`
758
757
  // the `context` property can be used to store any data about the accessory you may need
@@ -800,7 +799,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
800
799
  this.log.info(`Adding new accessory: ${device.deviceName} ${device.remoteType} DeviceID: ${device.deviceId}`);
801
800
 
802
801
  // create a new accessory
803
- const accessory = new this.api.platformAccessory(`${device.deviceName} ${device.remoteType}`, uuid);
802
+ const accessory = new this.api.platformAccessory(device.deviceName, uuid);
804
803
 
805
804
  // store a copy of the device object in the `accessory.context`
806
805
  // the `context` property can be used to store any data about the accessory you may need
@@ -858,7 +857,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
858
857
  this.log.info(`Adding new accessory: ${device.deviceName} ${device.remoteType} DeviceID: ${device.deviceId}`);
859
858
 
860
859
  // create a new accessory
861
- const accessory = new this.api.platformAccessory(`${device.deviceName} ${device.remoteType}`, uuid);
860
+ const accessory = new this.api.platformAccessory(device.deviceName, uuid);
862
861
 
863
862
  // store a copy of the device object in the `accessory.context`
864
863
  // the `context` property can be used to store any data about the accessory you may need
@@ -911,7 +910,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
911
910
  this.log.info(`Adding new accessory: ${device.deviceName} ${device.remoteType} DeviceID: ${device.deviceId}`);
912
911
 
913
912
  // create a new accessory
914
- const accessory = new this.api.platformAccessory(`${device.deviceName} ${device.remoteType}`, uuid);
913
+ const accessory = new this.api.platformAccessory(device.deviceName, uuid);
915
914
 
916
915
  // store a copy of the device object in the `accessory.context`
917
916
  // the `context` property can be used to store any data about the accessory you may need
@@ -964,7 +963,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
964
963
  this.log.info(`Adding new accessory: ${device.deviceName} ${device.remoteType} DeviceID: ${device.deviceId}`);
965
964
 
966
965
  // create a new accessory
967
- const accessory = new this.api.platformAccessory(`${device.deviceName} ${device.remoteType}`, uuid);
966
+ const accessory = new this.api.platformAccessory(device.deviceName, uuid);
968
967
 
969
968
  // store a copy of the device object in the `accessory.context`
970
969
  // the `context` property can be used to store any data about the accessory you may need
@@ -1017,7 +1016,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1017
1016
  this.log.info(`Adding new accessory: ${device.deviceName} ${device.remoteType} DeviceID: ${device.deviceId}`);
1018
1017
 
1019
1018
  // create a new accessory
1020
- const accessory = new this.api.platformAccessory(`${device.deviceName} ${device.remoteType}`, uuid);
1019
+ const accessory = new this.api.platformAccessory(device.deviceName, uuid);
1021
1020
 
1022
1021
  // store a copy of the device object in the `accessory.context`
1023
1022
  // the `context` property can be used to store any data about the accessory you may need
@@ -1070,7 +1069,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1070
1069
  this.log.info(`Adding new accessory: ${device.deviceName} ${device.remoteType} DeviceID: ${device.deviceId}`);
1071
1070
 
1072
1071
  // create a new accessory
1073
- const accessory = new this.api.platformAccessory(`${device.deviceName} ${device.remoteType}`, uuid);
1072
+ const accessory = new this.api.platformAccessory(device.deviceName, uuid);
1074
1073
 
1075
1074
  // store a copy of the device object in the `accessory.context`
1076
1075
  // the `context` property can be used to store any data about the accessory you may need
@@ -1123,7 +1122,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1123
1122
  this.log.info(`Adding new accessory: ${device.deviceName} ${device.remoteType} DeviceID: ${device.deviceId}`);
1124
1123
 
1125
1124
  // create a new accessory
1126
- const accessory = new this.api.platformAccessory(`${device.deviceName} ${device.remoteType}`, uuid);
1125
+ const accessory = new this.api.platformAccessory(device.deviceName, uuid);
1127
1126
 
1128
1127
  // store a copy of the device object in the `accessory.context`
1129
1128
  // the `context` property can be used to store any data about the accessory you may need
@@ -1176,7 +1175,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1176
1175
  this.log.info(`Adding new accessory: ${device.deviceName} ${device.remoteType} DeviceID: ${device.deviceId}`);
1177
1176
 
1178
1177
  // create a new accessory
1179
- const accessory = new this.api.platformAccessory(`${device.deviceName} ${device.remoteType}`, uuid);
1178
+ const accessory = new this.api.platformAccessory(device.deviceName, uuid);
1180
1179
 
1181
1180
  // store a copy of the device object in the `accessory.context`
1182
1181
  // the `context` property can be used to store any data about the accessory you may need
@@ -1229,7 +1228,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1229
1228
  this.log.info(`Adding new accessory: ${device.deviceName} ${device.remoteType} DeviceID: ${device.deviceId}`);
1230
1229
 
1231
1230
  // create a new accessory
1232
- const accessory = new this.api.platformAccessory(`${device.deviceName} ${device.remoteType}`, uuid);
1231
+ const accessory = new this.api.platformAccessory(device.deviceName, uuid);
1233
1232
 
1234
1233
  // store a copy of the device object in the `accessory.context`
1235
1234
  // the `context` property can be used to store any data about the accessory you may need
@@ -1300,6 +1299,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1300
1299
  /**
1301
1300
  * If debug level logging is turned on, log to log.info
1302
1301
  * Otherwise send debug logs to log.debug
1302
+ * this.debugMode = process.argv.includes('-D') || process.argv.includes('--debug');
1303
1303
  */
1304
1304
  debug(...log: any[]) {
1305
1305
  if (this.config.options!.debug === 'debug') {
@@ -1310,7 +1310,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1310
1310
  }
1311
1311
 
1312
1312
  /**
1313
- * If debug level logging is turned on, log to log.info
1313
+ * If device level logging is turned on, log to log.warn
1314
1314
  * Otherwise send debug logs to log.debug
1315
1315
  */
1316
1316
  device(...log: any[]) {