@switchbot/homebridge-switchbot 1.10.2-beta.7 → 1.11.2

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 (99) hide show
  1. package/CHANGELOG.md +20 -3
  2. package/config.schema.json +49 -0
  3. package/dist/device/bot.d.ts +43 -40
  4. package/dist/device/bot.d.ts.map +1 -1
  5. package/dist/device/bot.js +26 -26
  6. package/dist/device/bot.js.map +1 -1
  7. package/dist/device/colorbulb.d.ts +25 -21
  8. package/dist/device/colorbulb.d.ts.map +1 -1
  9. package/dist/device/colorbulb.js +176 -140
  10. package/dist/device/colorbulb.js.map +1 -1
  11. package/dist/device/contact.d.ts +15 -15
  12. package/dist/device/contact.d.ts.map +1 -1
  13. package/dist/device/contact.js +14 -13
  14. package/dist/device/contact.js.map +1 -1
  15. package/dist/device/curtain.d.ts +25 -22
  16. package/dist/device/curtain.d.ts.map +1 -1
  17. package/dist/device/curtain.js +50 -37
  18. package/dist/device/curtain.js.map +1 -1
  19. package/dist/device/humidifier.d.ts +23 -20
  20. package/dist/device/humidifier.d.ts.map +1 -1
  21. package/dist/device/humidifier.js +38 -38
  22. package/dist/device/humidifier.js.map +1 -1
  23. package/dist/device/lock.d.ts +16 -13
  24. package/dist/device/lock.d.ts.map +1 -1
  25. package/dist/device/lock.js +17 -17
  26. package/dist/device/lock.js.map +1 -1
  27. package/dist/device/meter.d.ts +15 -15
  28. package/dist/device/meter.d.ts.map +1 -1
  29. package/dist/device/meter.js +11 -11
  30. package/dist/device/meter.js.map +1 -1
  31. package/dist/device/motion.d.ts +14 -14
  32. package/dist/device/motion.d.ts.map +1 -1
  33. package/dist/device/motion.js +13 -13
  34. package/dist/device/motion.js.map +1 -1
  35. package/dist/device/plug.d.ts +10 -7
  36. package/dist/device/plug.d.ts.map +1 -1
  37. package/dist/device/plug.js +19 -19
  38. package/dist/device/plug.js.map +1 -1
  39. package/dist/irdevice/airconditioner.d.ts +22 -22
  40. package/dist/irdevice/airconditioner.d.ts.map +1 -1
  41. package/dist/irdevice/airconditioner.js +44 -44
  42. package/dist/irdevice/airconditioner.js.map +1 -1
  43. package/dist/irdevice/airpurifier.d.ts +12 -9
  44. package/dist/irdevice/airpurifier.d.ts.map +1 -1
  45. package/dist/irdevice/airpurifier.js +20 -20
  46. package/dist/irdevice/airpurifier.js.map +1 -1
  47. package/dist/irdevice/camera.d.ts +10 -7
  48. package/dist/irdevice/camera.d.ts.map +1 -1
  49. package/dist/irdevice/camera.js +11 -11
  50. package/dist/irdevice/camera.js.map +1 -1
  51. package/dist/irdevice/fan.d.ts +12 -9
  52. package/dist/irdevice/fan.d.ts.map +1 -1
  53. package/dist/irdevice/fan.js +29 -29
  54. package/dist/irdevice/fan.js.map +1 -1
  55. package/dist/irdevice/light.d.ts +10 -7
  56. package/dist/irdevice/light.d.ts.map +1 -1
  57. package/dist/irdevice/light.js +13 -13
  58. package/dist/irdevice/light.js.map +1 -1
  59. package/dist/irdevice/other.d.ts +12 -9
  60. package/dist/irdevice/other.d.ts.map +1 -1
  61. package/dist/irdevice/other.js +17 -17
  62. package/dist/irdevice/other.js.map +1 -1
  63. package/dist/irdevice/tv.d.ts +13 -10
  64. package/dist/irdevice/tv.d.ts.map +1 -1
  65. package/dist/irdevice/tv.js +25 -25
  66. package/dist/irdevice/tv.js.map +1 -1
  67. package/dist/irdevice/vacuumcleaner.d.ts +10 -7
  68. package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
  69. package/dist/irdevice/vacuumcleaner.js +13 -13
  70. package/dist/irdevice/vacuumcleaner.js.map +1 -1
  71. package/dist/irdevice/waterheater.d.ts +10 -7
  72. package/dist/irdevice/waterheater.d.ts.map +1 -1
  73. package/dist/irdevice/waterheater.js +16 -16
  74. package/dist/irdevice/waterheater.js.map +1 -1
  75. package/dist/platform.d.ts.map +1 -1
  76. package/dist/settings.d.ts +4 -1
  77. package/dist/settings.d.ts.map +1 -1
  78. package/dist/settings.js.map +1 -1
  79. package/package.json +76 -76
  80. package/src/device/bot.ts +50 -50
  81. package/src/device/colorbulb.ts +206 -157
  82. package/src/device/contact.ts +31 -30
  83. package/src/device/curtain.ts +68 -57
  84. package/src/device/humidifier.ts +65 -53
  85. package/src/device/lock.ts +25 -25
  86. package/src/device/meter.ts +25 -25
  87. package/src/device/motion.ts +27 -27
  88. package/src/device/plug.ts +22 -22
  89. package/src/irdevice/airconditioner.ts +54 -54
  90. package/src/irdevice/airpurifier.ts +30 -30
  91. package/src/irdevice/camera.ts +19 -19
  92. package/src/irdevice/fan.ts +40 -40
  93. package/src/irdevice/light.ts +23 -23
  94. package/src/irdevice/other.ts +25 -25
  95. package/src/irdevice/tv.ts +42 -42
  96. package/src/irdevice/vacuumcleaner.ts +21 -21
  97. package/src/irdevice/waterheater.ts +24 -24
  98. package/src/platform.ts +4 -4
  99. package/src/settings.ts +5 -1
@@ -10,7 +10,7 @@ import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
10
10
  */
11
11
  export class WaterHeater {
12
12
  // Services
13
- service!: Service;
13
+ valveService!: Service;
14
14
 
15
15
  // Characteristic Values
16
16
  Active!: CharacteristicValue;
@@ -38,7 +38,7 @@ export class WaterHeater {
38
38
 
39
39
  // get the Television service if it exists, otherwise create a new Television service
40
40
  // you can create multiple services for each accessory
41
- (this.service = accessory.getService(this.platform.Service.Valve) || accessory.addService(this.platform.Service.Valve)),
41
+ (this.valveService = accessory.getService(this.platform.Service.Valve) || accessory.addService(this.platform.Service.Valve)),
42
42
  `${accessory.displayName} Water Heater`;
43
43
 
44
44
  // To avoid "Cannot add a Service with the same UUID another Service without also defining a unique 'subtype' property." error,
@@ -47,34 +47,34 @@ export class WaterHeater {
47
47
 
48
48
  // set the service name, this is what is displayed as the default name on the Home app
49
49
  // in this example we are using the name we stored in the `accessory.context` in the `discoverDevices` method.
50
- this.service.setCharacteristic(this.platform.Characteristic.Name, `${device.deviceName} ${device.remoteType}`);
50
+ this.valveService.setCharacteristic(this.platform.Characteristic.Name, `${device.deviceName} ${device.remoteType}`);
51
51
 
52
52
  // set sleep discovery characteristic
53
- this.service.setCharacteristic(this.platform.Characteristic.ValveType, this.platform.Characteristic.ValveType.GENERIC_VALVE);
53
+ this.valveService.setCharacteristic(this.platform.Characteristic.ValveType, this.platform.Characteristic.ValveType.GENERIC_VALVE);
54
54
 
55
55
  // handle on / off events using the Active characteristic
56
- this.service.getCharacteristic(this.platform.Characteristic.Active).onSet(this.ActiveSet.bind(this));
56
+ this.valveService.getCharacteristic(this.platform.Characteristic.Active).onSet(this.ActiveSet.bind(this));
57
57
  }
58
58
 
59
- private ActiveSet(value: CharacteristicValue) {
59
+ async ActiveSet(value: CharacteristicValue): Promise<void> {
60
60
  this.debugLog(`Water Heater: ${this.accessory.displayName} Active: ${value}`);
61
61
  if (value === this.platform.Characteristic.Active.INACTIVE) {
62
- this.pushWaterHeaterOffChanges();
63
- this.service.setCharacteristic(this.platform.Characteristic.InUse, this.platform.Characteristic.InUse.NOT_IN_USE);
62
+ await this.pushWaterHeaterOffChanges();
63
+ this.valveService.setCharacteristic(this.platform.Characteristic.InUse, this.platform.Characteristic.InUse.NOT_IN_USE);
64
64
  } else {
65
- this.pushWaterHeaterOnChanges();
66
- this.service.setCharacteristic(this.platform.Characteristic.InUse, this.platform.Characteristic.InUse.IN_USE);
65
+ await this.pushWaterHeaterOnChanges();
66
+ this.valveService.setCharacteristic(this.platform.Characteristic.InUse, this.platform.Characteristic.InUse.IN_USE);
67
67
  }
68
68
  this.Active = value;
69
69
  this.ActiveCached = this.Active;
70
70
  this.accessory.context.Active = this.ActiveCached;
71
71
  }
72
72
 
73
- private updateHomeKitCharacteristics() {
73
+ async updateHomeKitCharacteristics(): Promise<void> {
74
74
  if (this.Active === undefined) {
75
75
  this.debugLog(`Water Heater: ${this.accessory.displayName} Active: ${this.Active}`);
76
76
  } else {
77
- this.service?.updateCharacteristic(this.platform.Characteristic.Active, this.Active);
77
+ this.valveService?.updateCharacteristic(this.platform.Characteristic.Active, this.Active);
78
78
  this.debugLog(`Water Heater: ${this.accessory.displayName} updateCharacteristic Active: ${this.Active}`);
79
79
  }
80
80
  }
@@ -89,7 +89,7 @@ export class WaterHeater {
89
89
  * WaterHeater: "command" "channelAdd" "default" = next channel
90
90
  * WaterHeater: "command" "channelSub" "default" = previous channel
91
91
  */
92
- async pushWaterHeaterOnChanges() {
92
+ async pushWaterHeaterOnChanges(): Promise<void> {
93
93
  if (this.Active !== 1) {
94
94
  const payload = {
95
95
  commandType: 'command',
@@ -100,7 +100,7 @@ export class WaterHeater {
100
100
  }
101
101
  }
102
102
 
103
- async pushWaterHeaterOffChanges() {
103
+ async pushWaterHeaterOffChanges(): Promise<void> {
104
104
  if (this.Active !== 0) {
105
105
  const payload = {
106
106
  commandType: 'command',
@@ -111,7 +111,7 @@ export class WaterHeater {
111
111
  }
112
112
  }
113
113
 
114
- public async pushChanges(payload: payload) {
114
+ async pushChanges(payload: payload): Promise<void> {
115
115
  try {
116
116
  this.infoLog(
117
117
  `Water Heater: ${this.accessory.displayName} Sending request to SwitchBot API. command: ${payload.command},` +
@@ -137,7 +137,7 @@ export class WaterHeater {
137
137
  }
138
138
  }
139
139
 
140
- private statusCode(push: AxiosResponse<{ statusCode: number }>) {
140
+ async statusCode(push: AxiosResponse<{ statusCode: number }>): Promise<void>{
141
141
  switch (push.data.statusCode) {
142
142
  case 151:
143
143
  this.errorLog(`Water Heater: ${this.accessory.displayName} Command not supported by this device type.`);
@@ -168,12 +168,12 @@ export class WaterHeater {
168
168
  }
169
169
  }
170
170
 
171
- public apiError(e: any) {
172
- this.service.updateCharacteristic(this.platform.Characteristic.Active, e);
171
+ async apiError(e: any): Promise<void> {
172
+ this.valveService.updateCharacteristic(this.platform.Characteristic.Active, e);
173
173
  //throw new this.platform.api.hap.HapStatusError(HAPStatus.SERVICE_COMMUNICATION_FAILURE);
174
174
  }
175
175
 
176
- config(device: irdevice & irDevicesConfig) {
176
+ async config(device: irdevice & irDevicesConfig): Promise<void> {
177
177
  let config = {};
178
178
  if (device.irwh) {
179
179
  config = device.irwh;
@@ -186,7 +186,7 @@ export class WaterHeater {
186
186
  }
187
187
  }
188
188
 
189
- logs(device: irdevice & irDevicesConfig) {
189
+ async logs(device: irdevice & irDevicesConfig): Promise<void> {
190
190
  if (this.platform.debugMode) {
191
191
  this.deviceLogging = this.accessory.context.logging = 'debugMode';
192
192
  this.debugLog(`Water Heater: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
@@ -205,25 +205,25 @@ export class WaterHeater {
205
205
  /**
206
206
  * Logging for Device
207
207
  */
208
- infoLog(...log: any[]) {
208
+ infoLog(...log: any[]): void {
209
209
  if (this.enablingDeviceLogging()) {
210
210
  this.platform.log.info(String(...log));
211
211
  }
212
212
  }
213
213
 
214
- warnLog(...log: any[]) {
214
+ warnLog(...log: any[]): void {
215
215
  if (this.enablingDeviceLogging()) {
216
216
  this.platform.log.warn(String(...log));
217
217
  }
218
218
  }
219
219
 
220
- errorLog(...log: any[]) {
220
+ errorLog(...log: any[]): void {
221
221
  if (this.enablingDeviceLogging()) {
222
222
  this.platform.log.error(String(...log));
223
223
  }
224
224
  }
225
225
 
226
- debugLog(...log: any[]) {
226
+ debugLog(...log: any[]): void {
227
227
  if (this.enablingDeviceLogging()) {
228
228
  if (this.deviceLogging === 'debug') {
229
229
  this.platform.log.info('[DEBUG]', String(...log));
package/src/platform.ts CHANGED
@@ -1582,25 +1582,25 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1582
1582
  * If device level logging is turned on, log to log.warn
1583
1583
  * Otherwise send debug logs to log.debug
1584
1584
  */
1585
- infoLog(...log: any[]) {
1585
+ infoLog(...log: any[]): void {
1586
1586
  if (this.enablingPlatfromLogging()) {
1587
1587
  this.log.info(String(...log));
1588
1588
  }
1589
1589
  }
1590
1590
 
1591
- warnLog(...log: any[]) {
1591
+ warnLog(...log: any[]): void {
1592
1592
  if (this.enablingPlatfromLogging()) {
1593
1593
  this.log.warn(String(...log));
1594
1594
  }
1595
1595
  }
1596
1596
 
1597
- errorLog(...log: any[]) {
1597
+ errorLog(...log: any[]): void {
1598
1598
  if (this.enablingPlatfromLogging()) {
1599
1599
  this.log.error(String(...log));
1600
1600
  }
1601
1601
  }
1602
1602
 
1603
- debugLog(...log: any[]) {
1603
+ debugLog(...log: any[]): void {
1604
1604
  if (this.enablingPlatfromLogging()) {
1605
1605
  if (this.platformLogging === 'debugMode') {
1606
1606
  this.log.debug(String(...log));
package/src/settings.ts CHANGED
@@ -51,7 +51,7 @@ export interface devicesConfig extends device {
51
51
  motion?: motion;
52
52
  colorbulb?: colorbulb;
53
53
  plug?: Record<any, any>;
54
- lock?: Record<any, any>;
54
+ lock?: lock;
55
55
  ble?: boolean;
56
56
  scanDuration?: number;
57
57
  hide_device?: boolean;
@@ -104,6 +104,10 @@ export type colorbulb = {
104
104
  adaptiveLightingShift?: number;
105
105
  };
106
106
 
107
+ export type lock = {
108
+ hide_contactsensor?: boolean;
109
+ };
110
+
107
111
  export interface irDevicesConfig extends irdevice {
108
112
  configRemoteType?: string;
109
113
  deviceId: string;