@switchbot/homebridge-switchbot 1.11.0 → 1.12.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.
Files changed (93) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/config.schema.json +18 -3
  3. package/dist/device/bot.d.ts +8 -0
  4. package/dist/device/bot.d.ts.map +1 -1
  5. package/dist/device/bot.js +40 -21
  6. package/dist/device/bot.js.map +1 -1
  7. package/dist/device/colorbulb.d.ts.map +1 -1
  8. package/dist/device/colorbulb.js +22 -32
  9. package/dist/device/colorbulb.js.map +1 -1
  10. package/dist/device/contact.d.ts.map +1 -1
  11. package/dist/device/contact.js +4 -10
  12. package/dist/device/contact.js.map +1 -1
  13. package/dist/device/curtain.d.ts.map +1 -1
  14. package/dist/device/curtain.js +13 -28
  15. package/dist/device/curtain.js.map +1 -1
  16. package/dist/device/humidifier.d.ts.map +1 -1
  17. package/dist/device/humidifier.js +9 -30
  18. package/dist/device/humidifier.js.map +1 -1
  19. package/dist/device/lock.d.ts.map +1 -1
  20. package/dist/device/lock.js +4 -10
  21. package/dist/device/lock.js.map +1 -1
  22. package/dist/device/meter.d.ts.map +1 -1
  23. package/dist/device/meter.js +4 -10
  24. package/dist/device/meter.js.map +1 -1
  25. package/dist/device/motion.d.ts.map +1 -1
  26. package/dist/device/motion.js +4 -10
  27. package/dist/device/motion.js.map +1 -1
  28. package/dist/device/plug.d.ts.map +1 -1
  29. package/dist/device/plug.js +4 -10
  30. package/dist/device/plug.js.map +1 -1
  31. package/dist/irdevice/airconditioner.d.ts +22 -22
  32. package/dist/irdevice/airconditioner.d.ts.map +1 -1
  33. package/dist/irdevice/airconditioner.js +47 -50
  34. package/dist/irdevice/airconditioner.js.map +1 -1
  35. package/dist/irdevice/airpurifier.d.ts +12 -9
  36. package/dist/irdevice/airpurifier.d.ts.map +1 -1
  37. package/dist/irdevice/airpurifier.js +23 -26
  38. package/dist/irdevice/airpurifier.js.map +1 -1
  39. package/dist/irdevice/camera.d.ts +10 -7
  40. package/dist/irdevice/camera.d.ts.map +1 -1
  41. package/dist/irdevice/camera.js +14 -17
  42. package/dist/irdevice/camera.js.map +1 -1
  43. package/dist/irdevice/fan.d.ts +12 -9
  44. package/dist/irdevice/fan.d.ts.map +1 -1
  45. package/dist/irdevice/fan.js +32 -35
  46. package/dist/irdevice/fan.js.map +1 -1
  47. package/dist/irdevice/light.d.ts +10 -7
  48. package/dist/irdevice/light.d.ts.map +1 -1
  49. package/dist/irdevice/light.js +16 -19
  50. package/dist/irdevice/light.js.map +1 -1
  51. package/dist/irdevice/other.d.ts +12 -9
  52. package/dist/irdevice/other.d.ts.map +1 -1
  53. package/dist/irdevice/other.js +21 -24
  54. package/dist/irdevice/other.js.map +1 -1
  55. package/dist/irdevice/tv.d.ts +13 -10
  56. package/dist/irdevice/tv.d.ts.map +1 -1
  57. package/dist/irdevice/tv.js +28 -31
  58. package/dist/irdevice/tv.js.map +1 -1
  59. package/dist/irdevice/vacuumcleaner.d.ts +10 -7
  60. package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
  61. package/dist/irdevice/vacuumcleaner.js +16 -19
  62. package/dist/irdevice/vacuumcleaner.js.map +1 -1
  63. package/dist/irdevice/waterheater.d.ts +10 -7
  64. package/dist/irdevice/waterheater.d.ts.map +1 -1
  65. package/dist/irdevice/waterheater.js +19 -22
  66. package/dist/irdevice/waterheater.js.map +1 -1
  67. package/dist/platform.d.ts.map +1 -1
  68. package/dist/platform.js +5 -5
  69. package/dist/platform.js.map +1 -1
  70. package/dist/settings.d.ts +1 -0
  71. package/dist/settings.d.ts.map +1 -1
  72. package/dist/settings.js.map +1 -1
  73. package/package.json +4 -4
  74. package/src/device/bot.ts +40 -20
  75. package/src/device/colorbulb.ts +22 -44
  76. package/src/device/contact.ts +4 -12
  77. package/src/device/curtain.ts +13 -28
  78. package/src/device/humidifier.ts +9 -30
  79. package/src/device/lock.ts +4 -10
  80. package/src/device/meter.ts +4 -10
  81. package/src/device/motion.ts +4 -12
  82. package/src/device/plug.ts +4 -10
  83. package/src/irdevice/airconditioner.ts +57 -60
  84. package/src/irdevice/airpurifier.ts +33 -36
  85. package/src/irdevice/camera.ts +22 -25
  86. package/src/irdevice/fan.ts +43 -46
  87. package/src/irdevice/light.ts +26 -29
  88. package/src/irdevice/other.ts +29 -32
  89. package/src/irdevice/tv.ts +45 -50
  90. package/src/irdevice/vacuumcleaner.ts +24 -27
  91. package/src/irdevice/waterheater.ts +27 -30
  92. package/src/platform.ts +9 -9
  93. package/src/settings.ts +1 -0
@@ -10,7 +10,7 @@ import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
10
10
  */
11
11
  export class Others {
12
12
  // Services
13
- private service?: Service;
13
+ fanService?: Service;
14
14
 
15
15
  // Characteristic Values
16
16
  Active!: CharacteristicValue;
@@ -46,38 +46,38 @@ export class Others {
46
46
  if (this.otherDeviceType === undefined) {
47
47
  this.errorLog(`Other: ${this.accessory.displayName} No Device Type Set, deviceType: ${device.other?.deviceType}`);
48
48
  }
49
- this.service = this.accessory.getService(this.platform.Service.Fanv2);
50
- accessory.removeService(this.service!);
51
- } else if (!this.service && this.otherDeviceType === 'Fan') {
49
+ this.fanService = this.accessory.getService(this.platform.Service.Fanv2);
50
+ accessory.removeService(this.fanService!);
51
+ } else if (!this.fanService && this.otherDeviceType === 'Fan') {
52
52
  this.debugLog(`Other: ${accessory.displayName} Add Fanv2 Service`);
53
- (this.service = this.accessory.getService(this.platform.Service.Fanv2) || this.accessory.addService(this.platform.Service.Fanv2)),
53
+ (this.fanService = this.accessory.getService(this.platform.Service.Fanv2) || this.accessory.addService(this.platform.Service.Fanv2)),
54
54
  `${accessory.displayName} Fan`;
55
55
 
56
- this.service.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Fan`);
56
+ this.fanService.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Fan`);
57
57
 
58
- this.service.getCharacteristic(this.platform.Characteristic.Active).onSet(this.ActiveSet.bind(this));
58
+ this.fanService.getCharacteristic(this.platform.Characteristic.Active).onSet(this.ActiveSet.bind(this));
59
59
  } else {
60
60
  this.debugLog(`Other: ${accessory.displayName} Fanv2 Service Not Added, deviceType: ${device.other?.deviceType}`);
61
61
  }
62
62
  }
63
63
 
64
- private ActiveSet(value: CharacteristicValue) {
64
+ async ActiveSet(value: CharacteristicValue): Promise<void> {
65
65
  this.debugLog(`Other: ${this.accessory.displayName} On: ${value}`);
66
66
  if (this.Active) {
67
- this.pushOnChanges();
67
+ await this.pushOnChanges();
68
68
  } else {
69
- this.pushOffChanges();
69
+ await this.pushOffChanges();
70
70
  }
71
71
  this.Active = value;
72
72
  this.ActiveCached = this.Active;
73
73
  this.accessory.context.Active = this.ActiveCached;
74
74
  }
75
75
 
76
- private updateHomeKitCharacteristics() {
76
+ async updateHomeKitCharacteristics(): Promise<void> {
77
77
  if (this.Active === undefined) {
78
78
  this.debugLog(`Other: ${this.accessory.displayName} Active: ${this.Active}`);
79
79
  } else {
80
- this.service?.updateCharacteristic(this.platform.Characteristic.Active, this.Active);
80
+ this.fanService?.updateCharacteristic(this.platform.Characteristic.Active, this.Active);
81
81
  this.debugLog(`Other: ${this.accessory.displayName} updateCharacteristic Active: ${this.Active}`);
82
82
  }
83
83
  }
@@ -92,7 +92,7 @@ export class Others {
92
92
  * Light: "command" "channelAdd" "default" = next channel
93
93
  * Light: "command" "channelSub" "default" = previous channel
94
94
  */
95
- async pushOnChanges() {
95
+ async pushOnChanges(): Promise<void> {
96
96
  if (this.platform.config.options) {
97
97
  if (this.device.other) {
98
98
  if (this.device.other.commandOn) {
@@ -115,7 +115,7 @@ export class Others {
115
115
  }
116
116
  }
117
117
 
118
- async pushOffChanges() {
118
+ async pushOffChanges(): Promise<void> {
119
119
  if (this.platform.config.options) {
120
120
  if (this.device.other) {
121
121
  if (this.device.other.commandOff) {
@@ -138,7 +138,7 @@ export class Others {
138
138
  }
139
139
  }
140
140
 
141
- public async pushChanges(payload: payload) {
141
+ async pushChanges(payload: payload): Promise<void> {
142
142
  try {
143
143
  this.infoLog(
144
144
  `Other: ${this.accessory.displayName} Sending request to SwitchBot API. command: ${payload.command},` +
@@ -152,19 +152,16 @@ export class Others {
152
152
  this.updateHomeKitCharacteristics();
153
153
  } catch (e: any) {
154
154
  this.errorLog(`Other: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection`);
155
- if (this.deviceLogging === 'debug') {
155
+ if (this.deviceLogging.includes('debug')) {
156
156
  this.errorLog(
157
157
  `Other: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` + ` Error Message: ${JSON.stringify(e.message)}`,
158
158
  );
159
159
  }
160
- if (this.platform.debugMode) {
161
- this.errorLog(`Other: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` + ` Error: ${JSON.stringify(e)}`);
162
- }
163
160
  this.apiError(e);
164
161
  }
165
162
  }
166
163
 
167
- private statusCode(push: AxiosResponse<{ statusCode: number }>) {
164
+ async statusCode(push: AxiosResponse<{ statusCode: number }>): Promise<void>{
168
165
  switch (push.data.statusCode) {
169
166
  case 151:
170
167
  this.errorLog(`Other: ${this.accessory.displayName} Command not supported by this device type.`);
@@ -195,15 +192,15 @@ export class Others {
195
192
  }
196
193
  }
197
194
 
198
- public apiError(e: any) {
199
- this.service?.updateCharacteristic(this.platform.Characteristic.Active, e);
195
+ async apiError(e: any): Promise<void> {
196
+ this.fanService?.updateCharacteristic(this.platform.Characteristic.Active, e);
200
197
  //throw new this.platform.api.hap.HapStatusError(HAPStatus.SERVICE_COMMUNICATION_FAILURE);
201
198
  }
202
199
 
203
- deviceType(device: irdevice & irDevicesConfig) {
200
+ async deviceType(device: irdevice & irDevicesConfig): Promise<void> {
204
201
  if (device.other?.deviceType) {
205
202
  this.otherDeviceType = this.accessory.context.deviceType = device.other.deviceType;
206
- if (this.deviceLogging === 'debug' || this.deviceLogging === 'standard') {
203
+ if (this.deviceLogging.includes('debug') || this.deviceLogging === 'standard') {
207
204
  this.warnLog(`Other: ${this.accessory.displayName} Using Device Type: ${this.otherDeviceType}`);
208
205
  }
209
206
  } else {
@@ -211,7 +208,7 @@ export class Others {
211
208
  }
212
209
  }
213
210
 
214
- config(device: irdevice & irDevicesConfig) {
211
+ async config(device: irdevice & irDevicesConfig): Promise<void> {
215
212
  let config = {};
216
213
  if (device.other) {
217
214
  config = device.other;
@@ -220,11 +217,11 @@ export class Others {
220
217
  config['logging'] = device.logging;
221
218
  }
222
219
  if (Object.entries(config).length !== 0) {
223
- this.warnLog(`Other: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
220
+ this.infoLog(`Other: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
224
221
  }
225
222
  }
226
223
 
227
- logs(device: irdevice & irDevicesConfig) {
224
+ async logs(device: irdevice & irDevicesConfig): Promise<void> {
228
225
  if (this.platform.debugMode) {
229
226
  this.deviceLogging = this.accessory.context.logging = 'debugMode';
230
227
  this.debugLog(`Other: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
@@ -243,25 +240,25 @@ export class Others {
243
240
  /**
244
241
  * Logging for Device
245
242
  */
246
- infoLog(...log: any[]) {
243
+ infoLog(...log: any[]): void {
247
244
  if (this.enablingDeviceLogging()) {
248
245
  this.platform.log.info(String(...log));
249
246
  }
250
247
  }
251
248
 
252
- warnLog(...log: any[]) {
249
+ warnLog(...log: any[]): void {
253
250
  if (this.enablingDeviceLogging()) {
254
251
  this.platform.log.warn(String(...log));
255
252
  }
256
253
  }
257
254
 
258
- errorLog(...log: any[]) {
255
+ errorLog(...log: any[]): void {
259
256
  if (this.enablingDeviceLogging()) {
260
257
  this.platform.log.error(String(...log));
261
258
  }
262
259
  }
263
260
 
264
- debugLog(...log: any[]) {
261
+ debugLog(...log: any[]): void {
265
262
  if (this.enablingDeviceLogging()) {
266
263
  if (this.deviceLogging === 'debug') {
267
264
  this.platform.log.info('[DEBUG]', String(...log));
@@ -272,6 +269,6 @@ export class Others {
272
269
  }
273
270
 
274
271
  enablingDeviceLogging(): boolean {
275
- return this.deviceLogging === 'debug' || this.deviceLogging === 'standard';
272
+ return this.deviceLogging.includes('debug') || this.deviceLogging === 'standard';
276
273
  }
277
274
  }
@@ -10,7 +10,7 @@ import { DeviceURL, irdevice, deviceStatusResponse, irDevicesConfig, payload } f
10
10
  */
11
11
  export class TV {
12
12
  // Services
13
- service!: Service;
13
+ tvService!: Service;
14
14
  speakerService: Service;
15
15
 
16
16
  // Characteristic Values
@@ -47,13 +47,13 @@ export class TV {
47
47
  case 'Speaker':
48
48
  case 'DIY Speaker':
49
49
  accessory.category = this.platform.api.hap.Categories.SPEAKER;
50
- (this.service = accessory.getService(this.platform.Service.Television) || accessory.addService(this.platform.Service.Television)),
50
+ (this.tvService = accessory.getService(this.platform.Service.Television) || accessory.addService(this.platform.Service.Television)),
51
51
  `${accessory.displayName} Speaker`;
52
52
  break;
53
53
  case 'IPTV':
54
54
  case 'DIY IPTV':
55
55
  accessory.category = this.platform.api.hap.Categories.TV_STREAMING_STICK;
56
- (this.service = accessory.getService(this.platform.Service.Television) || accessory.addService(this.platform.Service.Television)),
56
+ (this.tvService = accessory.getService(this.platform.Service.Television) || accessory.addService(this.platform.Service.Television)),
57
57
  `${accessory.displayName} Streaming Stick`;
58
58
  break;
59
59
  case 'DVD':
@@ -61,7 +61,7 @@ export class TV {
61
61
  case 'Set Top Box':
62
62
  case 'DIY Set Top Box':
63
63
  accessory.category = this.platform.api.hap.Categories.TV_SET_TOP_BOX;
64
- (this.service = accessory.getService(this.platform.Service.Television) || accessory.addService(this.platform.Service.Television)),
64
+ (this.tvService = accessory.getService(this.platform.Service.Television) || accessory.addService(this.platform.Service.Television)),
65
65
  `${accessory.displayName} Set Top Box`;
66
66
  break;
67
67
  default:
@@ -69,7 +69,7 @@ export class TV {
69
69
 
70
70
  // get the Television service if it exists, otherwise create a new Television service
71
71
  // you can create multiple services for each accessory
72
- (this.service = accessory.getService(this.platform.Service.Television) || accessory.addService(this.platform.Service.Television)),
72
+ (this.tvService = accessory.getService(this.platform.Service.Television) || accessory.addService(this.platform.Service.Television)),
73
73
  `${accessory.displayName} TV`;
74
74
  }
75
75
 
@@ -79,24 +79,24 @@ export class TV {
79
79
 
80
80
  // set the service name, this is what is displayed as the default name on the Home app
81
81
  // in this example we are using the name we stored in the `accessory.context` in the `discoverDevices` method.
82
- this.service.getCharacteristic(this.platform.Characteristic.ConfiguredName);
82
+ this.tvService.getCharacteristic(this.platform.Characteristic.ConfiguredName);
83
83
 
84
84
  // set sleep discovery characteristic
85
- this.service.setCharacteristic(
85
+ this.tvService.setCharacteristic(
86
86
  this.platform.Characteristic.SleepDiscoveryMode,
87
87
  this.platform.Characteristic.SleepDiscoveryMode.ALWAYS_DISCOVERABLE,
88
88
  );
89
89
 
90
90
  // handle on / off events using the Active characteristic
91
- this.service.getCharacteristic(this.platform.Characteristic.Active).onSet(this.ActiveSet.bind(this));
91
+ this.tvService.getCharacteristic(this.platform.Characteristic.Active).onSet(this.ActiveSet.bind(this));
92
92
 
93
- this.service.setCharacteristic(this.platform.Characteristic.ActiveIdentifier, 1);
93
+ this.tvService.setCharacteristic(this.platform.Characteristic.ActiveIdentifier, 1);
94
94
 
95
95
  // handle input source changes
96
- this.service.getCharacteristic(this.platform.Characteristic.ActiveIdentifier).onSet(this.ActiveIdentifierSet.bind(this));
96
+ this.tvService.getCharacteristic(this.platform.Characteristic.ActiveIdentifier).onSet(this.ActiveIdentifierSet.bind(this));
97
97
 
98
98
  // handle remote control input
99
- this.service.getCharacteristic(this.platform.Characteristic.RemoteKey).onSet(this.RemoteKeySet.bind(this));
99
+ this.tvService.getCharacteristic(this.platform.Characteristic.RemoteKey).onSet(this.RemoteKeySet.bind(this));
100
100
 
101
101
  /**
102
102
  * Create a speaker service to allow volume control
@@ -116,7 +116,7 @@ export class TV {
116
116
  this.speakerService.getCharacteristic(this.platform.Characteristic.VolumeSelector).onSet(this.VolumeSelectorSet.bind(this));
117
117
  }
118
118
 
119
- private VolumeSelectorSet(value: CharacteristicValue) {
119
+ async VolumeSelectorSet(value: CharacteristicValue): Promise<void> {
120
120
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} VolumeSelector: ${value}`);
121
121
  if (value === this.platform.Characteristic.VolumeSelector.INCREMENT) {
122
122
  this.pushVolumeUpChanges();
@@ -125,7 +125,7 @@ export class TV {
125
125
  }
126
126
  }
127
127
 
128
- private RemoteKeySet(value: CharacteristicValue) {
128
+ async RemoteKeySet(value: CharacteristicValue): Promise<void> {
129
129
  switch (value) {
130
130
  case this.platform.Characteristic.RemoteKey.REWIND: {
131
131
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Set Remote Key Pressed: REWIND`);
@@ -189,18 +189,18 @@ export class TV {
189
189
  }
190
190
  }
191
191
 
192
- private ActiveIdentifierSet(value: CharacteristicValue) {
192
+ async ActiveIdentifierSet(value: CharacteristicValue): Promise<void> {
193
193
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} ActiveIdentifier: ${value}`);
194
194
  this.ActiveIdentifier = value;
195
195
  }
196
196
 
197
- private ActiveSet(value: CharacteristicValue) {
197
+ async ActiveSet(value: CharacteristicValue): Promise<void> {
198
198
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Active: ${value}`);
199
199
  if (!this.device.irtv?.disable_power) {
200
200
  if (value === this.platform.Characteristic.Active.INACTIVE) {
201
- this.pushTvOffChanges();
201
+ await this.pushTvOffChanges();
202
202
  } else {
203
- this.pushTvOnChanges();
203
+ await this.pushTvOnChanges();
204
204
  }
205
205
  this.Active = value;
206
206
  this.ActiveCached = this.Active;
@@ -208,17 +208,17 @@ export class TV {
208
208
  }
209
209
  }
210
210
 
211
- private updateHomeKitCharacteristics() {
211
+ async updateHomeKitCharacteristics(): Promise<void> {
212
212
  if (this.Active === undefined) {
213
213
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Active: ${this.Active}`);
214
214
  } else {
215
- this.service?.updateCharacteristic(this.platform.Characteristic.Active, this.Active);
215
+ this.tvService?.updateCharacteristic(this.platform.Characteristic.Active, this.Active);
216
216
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic Active: ${this.Active}`);
217
217
  }
218
218
  if (this.ActiveIdentifier === undefined) {
219
219
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} ActiveIdentifier: ${this.ActiveIdentifier}`);
220
220
  } else {
221
- this.service?.updateCharacteristic(this.platform.Characteristic.ActiveIdentifier, this.ActiveIdentifier);
221
+ this.tvService?.updateCharacteristic(this.platform.Characteristic.ActiveIdentifier, this.ActiveIdentifier);
222
222
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName}` + ` updateCharacteristic ActiveIdentifier: ${this.ActiveIdentifier}`);
223
223
  }
224
224
  }
@@ -233,7 +233,7 @@ export class TV {
233
233
  * TV: "command" "channelAdd" "default" = next channel
234
234
  * TV: "command" "channelSub" "default" = previous channel
235
235
  */
236
- async pushTvOnChanges() {
236
+ async pushTvOnChanges(): Promise<void> {
237
237
  if (this.Active !== 1) {
238
238
  const payload = {
239
239
  commandType: 'command',
@@ -244,7 +244,7 @@ export class TV {
244
244
  }
245
245
  }
246
246
 
247
- async pushTvOffChanges() {
247
+ async pushTvOffChanges(): Promise<void> {
248
248
  const payload = {
249
249
  commandType: 'command',
250
250
  parameter: 'default',
@@ -253,7 +253,7 @@ export class TV {
253
253
  await this.pushTVChanges(payload);
254
254
  }
255
255
 
256
- async pushOkChanges() {
256
+ async pushOkChanges(): Promise<void> {
257
257
  const payload = {
258
258
  commandType: 'command',
259
259
  parameter: 'default',
@@ -262,7 +262,7 @@ export class TV {
262
262
  await this.pushTVChanges(payload);
263
263
  }
264
264
 
265
- async pushBackChanges() {
265
+ async pushBackChanges(): Promise<void> {
266
266
  const payload = {
267
267
  commandType: 'command',
268
268
  parameter: 'default',
@@ -271,7 +271,7 @@ export class TV {
271
271
  await this.pushTVChanges(payload);
272
272
  }
273
273
 
274
- async pushMenuChanges() {
274
+ async pushMenuChanges(): Promise<void> {
275
275
  const payload = {
276
276
  commandType: 'command',
277
277
  parameter: 'default',
@@ -280,7 +280,7 @@ export class TV {
280
280
  await this.pushTVChanges(payload);
281
281
  }
282
282
 
283
- async pushUpChanges() {
283
+ async pushUpChanges(): Promise<void> {
284
284
  const payload = {
285
285
  commandType: 'command',
286
286
  parameter: 'default',
@@ -289,7 +289,7 @@ export class TV {
289
289
  await this.pushTVChanges(payload);
290
290
  }
291
291
 
292
- async pushDownChanges() {
292
+ async pushDownChanges(): Promise<void> {
293
293
  const payload = {
294
294
  commandType: 'command',
295
295
  parameter: 'default',
@@ -298,7 +298,7 @@ export class TV {
298
298
  await this.pushTVChanges(payload);
299
299
  }
300
300
 
301
- async pushRightChanges() {
301
+ async pushRightChanges(): Promise<void> {
302
302
  const payload = {
303
303
  commandType: 'command',
304
304
  parameter: 'default',
@@ -307,7 +307,7 @@ export class TV {
307
307
  await this.pushTVChanges(payload);
308
308
  }
309
309
 
310
- async pushLeftChanges() {
310
+ async pushLeftChanges(): Promise<void> {
311
311
  const payload = {
312
312
  commandType: 'command',
313
313
  parameter: 'default',
@@ -316,7 +316,7 @@ export class TV {
316
316
  await this.pushTVChanges(payload);
317
317
  }
318
318
 
319
- async pushVolumeUpChanges() {
319
+ async pushVolumeUpChanges(): Promise<void> {
320
320
  const payload = {
321
321
  commandType: 'command',
322
322
  parameter: 'default',
@@ -325,7 +325,7 @@ export class TV {
325
325
  await this.pushTVChanges(payload);
326
326
  }
327
327
 
328
- async pushVolumeDownChanges() {
328
+ async pushVolumeDownChanges(): Promise<void> {
329
329
  const payload = {
330
330
  commandType: 'command',
331
331
  parameter: 'default',
@@ -334,7 +334,7 @@ export class TV {
334
334
  await this.pushTVChanges(payload);
335
335
  }
336
336
 
337
- public async pushTVChanges(payload: payload) {
337
+ async pushTVChanges(payload: payload): Promise<void> {
338
338
  try {
339
339
  this.infoLog(
340
340
  `${this.device.remoteType}: ${this.accessory.displayName} Sending request to SwitchBot API. command: ${payload.command},` +
@@ -348,22 +348,17 @@ export class TV {
348
348
  this.updateHomeKitCharacteristics();
349
349
  } catch (e: any) {
350
350
  this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection`);
351
- if (this.deviceLogging === 'debug') {
351
+ if (this.deviceLogging.includes('debug')) {
352
352
  this.errorLog(
353
353
  `${this.device.remoteType}: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` +
354
354
  ` Error Message: ${JSON.stringify(e.message)}`,
355
355
  );
356
356
  }
357
- if (this.platform.debugMode) {
358
- this.errorLog(
359
- `${this.device.remoteType}: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` + ` Error: ${JSON.stringify(e)}`,
360
- );
361
- }
362
357
  this.apiError(e);
363
358
  }
364
359
  }
365
360
 
366
- private statusCode(push: AxiosResponse<{ statusCode: number }>) {
361
+ async statusCode(push: AxiosResponse<{ statusCode: number }>): Promise<void>{
367
362
  switch (push.data.statusCode) {
368
363
  case 151:
369
364
  this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Command not supported by this device type.`);
@@ -395,13 +390,13 @@ export class TV {
395
390
  }
396
391
  }
397
392
 
398
- public apiError(e: any) {
399
- this.service.updateCharacteristic(this.platform.Characteristic.Active, e);
400
- this.service.updateCharacteristic(this.platform.Characteristic.ActiveIdentifier, e);
393
+ async apiError(e: any): Promise<void> {
394
+ this.tvService.updateCharacteristic(this.platform.Characteristic.Active, e);
395
+ this.tvService.updateCharacteristic(this.platform.Characteristic.ActiveIdentifier, e);
401
396
  //throw new this.platform.api.hap.HapStatusError(HAPStatus.SERVICE_COMMUNICATION_FAILURE);
402
397
  }
403
398
 
404
- config(device: irdevice & irDevicesConfig) {
399
+ async config(device: irdevice & irDevicesConfig): Promise<void> {
405
400
  let config = {};
406
401
  if (device.irtv) {
407
402
  config = device.irtv;
@@ -410,11 +405,11 @@ export class TV {
410
405
  config['logging'] = device.logging;
411
406
  }
412
407
  if (Object.entries(config).length !== 0) {
413
- this.warnLog(`${this.device.remoteType}: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
408
+ this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
414
409
  }
415
410
  }
416
411
 
417
- logs(device: irdevice & irDevicesConfig) {
412
+ async logs(device: irdevice & irDevicesConfig): Promise<void> {
418
413
  if (this.platform.debugMode) {
419
414
  this.deviceLogging = this.accessory.context.logging = 'debugMode';
420
415
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
@@ -433,25 +428,25 @@ export class TV {
433
428
  /**
434
429
  * Logging for Device
435
430
  */
436
- infoLog(...log: any[]) {
431
+ infoLog(...log: any[]): void {
437
432
  if (this.enablingDeviceLogging()) {
438
433
  this.platform.log.info(String(...log));
439
434
  }
440
435
  }
441
436
 
442
- warnLog(...log: any[]) {
437
+ warnLog(...log: any[]): void {
443
438
  if (this.enablingDeviceLogging()) {
444
439
  this.platform.log.warn(String(...log));
445
440
  }
446
441
  }
447
442
 
448
- errorLog(...log: any[]) {
443
+ errorLog(...log: any[]): void {
449
444
  if (this.enablingDeviceLogging()) {
450
445
  this.platform.log.error(String(...log));
451
446
  }
452
447
  }
453
448
 
454
- debugLog(...log: any[]) {
449
+ debugLog(...log: any[]): void {
455
450
  if (this.enablingDeviceLogging()) {
456
451
  if (this.deviceLogging === 'debug') {
457
452
  this.platform.log.info('[DEBUG]', String(...log));
@@ -462,6 +457,6 @@ export class TV {
462
457
  }
463
458
 
464
459
  enablingDeviceLogging(): boolean {
465
- return this.deviceLogging === 'debug' || this.deviceLogging === 'standard';
460
+ return this.deviceLogging.includes('debug') || this.deviceLogging === 'standard';
466
461
  }
467
462
  }