@switchbot/homebridge-switchbot 2.8.0-beta.0 → 2.8.0-beta.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 (118) hide show
  1. package/.prettierrc +1 -1
  2. package/.vscode/settings.json +1 -1
  3. package/CHANGELOG.md +10 -0
  4. package/config.schema.json +8 -0
  5. package/dist/device/blindtilt.d.ts.map +1 -1
  6. package/dist/device/blindtilt.js +49 -59
  7. package/dist/device/blindtilt.js.map +1 -1
  8. package/dist/device/bot.d.ts.map +1 -1
  9. package/dist/device/bot.js +44 -50
  10. package/dist/device/bot.js.map +1 -1
  11. package/dist/device/ceilinglight.d.ts.map +1 -1
  12. package/dist/device/ceilinglight.js +60 -63
  13. package/dist/device/ceilinglight.js.map +1 -1
  14. package/dist/device/colorbulb.d.ts.map +1 -1
  15. package/dist/device/colorbulb.js +68 -70
  16. package/dist/device/colorbulb.js.map +1 -1
  17. package/dist/device/contact.d.ts.map +1 -1
  18. package/dist/device/contact.js +22 -25
  19. package/dist/device/contact.js.map +1 -1
  20. package/dist/device/curtain.d.ts.map +1 -1
  21. package/dist/device/curtain.js +50 -58
  22. package/dist/device/curtain.js.map +1 -1
  23. package/dist/device/hub.d.ts +6 -0
  24. package/dist/device/hub.d.ts.map +1 -1
  25. package/dist/device/hub.js +168 -26
  26. package/dist/device/hub.js.map +1 -1
  27. package/dist/device/humidifier.d.ts.map +1 -1
  28. package/dist/device/humidifier.js +49 -56
  29. package/dist/device/humidifier.js.map +1 -1
  30. package/dist/device/iosensor.d.ts.map +1 -1
  31. package/dist/device/iosensor.js +18 -20
  32. package/dist/device/iosensor.js.map +1 -1
  33. package/dist/device/lightstrip.d.ts.map +1 -1
  34. package/dist/device/lightstrip.js +59 -61
  35. package/dist/device/lightstrip.js.map +1 -1
  36. package/dist/device/lock.d.ts.map +1 -1
  37. package/dist/device/lock.js +40 -41
  38. package/dist/device/lock.js.map +1 -1
  39. package/dist/device/meter.d.ts +3 -3
  40. package/dist/device/meter.d.ts.map +1 -1
  41. package/dist/device/meter.js +65 -68
  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 +18 -20
  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 +20 -23
  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 +30 -33
  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 +48 -51
  54. package/dist/device/robotvacuumcleaner.js.map +1 -1
  55. package/dist/irdevice/airconditioner.d.ts.map +1 -1
  56. package/dist/irdevice/airconditioner.js +58 -62
  57. package/dist/irdevice/airconditioner.js.map +1 -1
  58. package/dist/irdevice/airpurifier.d.ts.map +1 -1
  59. package/dist/irdevice/airpurifier.js +29 -31
  60. package/dist/irdevice/airpurifier.js.map +1 -1
  61. package/dist/irdevice/camera.d.ts.map +1 -1
  62. package/dist/irdevice/camera.js +17 -20
  63. package/dist/irdevice/camera.js.map +1 -1
  64. package/dist/irdevice/fan.d.ts.map +1 -1
  65. package/dist/irdevice/fan.js +27 -29
  66. package/dist/irdevice/fan.js.map +1 -1
  67. package/dist/irdevice/light.d.ts.map +1 -1
  68. package/dist/irdevice/light.js +23 -26
  69. package/dist/irdevice/light.js.map +1 -1
  70. package/dist/irdevice/other.d.ts.map +1 -1
  71. package/dist/irdevice/other.js +19 -20
  72. package/dist/irdevice/other.js.map +1 -1
  73. package/dist/irdevice/tv.d.ts.map +1 -1
  74. package/dist/irdevice/tv.js +44 -47
  75. package/dist/irdevice/tv.js.map +1 -1
  76. package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
  77. package/dist/irdevice/vacuumcleaner.js +17 -20
  78. package/dist/irdevice/vacuumcleaner.js.map +1 -1
  79. package/dist/irdevice/waterheater.d.ts.map +1 -1
  80. package/dist/irdevice/waterheater.js +19 -20
  81. package/dist/irdevice/waterheater.js.map +1 -1
  82. package/dist/platform.d.ts.map +1 -1
  83. package/dist/platform.js +44 -43
  84. package/dist/platform.js.map +1 -1
  85. package/dist/settings.d.ts +1 -0
  86. package/dist/settings.d.ts.map +1 -1
  87. package/dist/settings.js.map +1 -1
  88. package/dist/utils.js +1 -1
  89. package/dist/utils.js.map +1 -1
  90. package/package.json +1 -1
  91. package/src/device/blindtilt.ts +106 -72
  92. package/src/device/bot.ts +94 -58
  93. package/src/device/ceilinglight.ts +102 -68
  94. package/src/device/colorbulb.ts +134 -82
  95. package/src/device/contact.ts +54 -33
  96. package/src/device/curtain.ts +130 -101
  97. package/src/device/hub.ts +198 -35
  98. package/src/device/humidifier.ts +128 -80
  99. package/src/device/iosensor.ts +43 -27
  100. package/src/device/lightstrip.ts +108 -67
  101. package/src/device/lock.ts +73 -45
  102. package/src/device/meter.ts +94 -75
  103. package/src/device/meterplus.ts +43 -27
  104. package/src/device/motion.ts +50 -32
  105. package/src/device/plug.ts +62 -39
  106. package/src/device/robotvacuumcleaner.ts +78 -54
  107. package/src/irdevice/airconditioner.ts +112 -84
  108. package/src/irdevice/airpurifier.ts +55 -34
  109. package/src/irdevice/camera.ts +35 -23
  110. package/src/irdevice/fan.ts +47 -33
  111. package/src/irdevice/light.ts +43 -29
  112. package/src/irdevice/other.ts +39 -23
  113. package/src/irdevice/tv.ts +65 -51
  114. package/src/irdevice/vacuumcleaner.ts +35 -23
  115. package/src/irdevice/waterheater.ts +43 -27
  116. package/src/platform.ts +85 -55
  117. package/src/settings.ts +41 -40
  118. package/src/utils.ts +1 -1
@@ -20,7 +20,11 @@ export class Camera {
20
20
  disablePushOff?: boolean;
21
21
  deviceLogging!: string;
22
22
 
23
- constructor(private readonly platform: SwitchBotPlatform, private accessory: PlatformAccessory, public device: irdevice & irDevicesConfig) {
23
+ constructor(
24
+ private readonly platform: SwitchBotPlatform,
25
+ private accessory: PlatformAccessory,
26
+ public device: irdevice & irDevicesConfig,
27
+ ) {
24
28
  // default placeholders
25
29
  this.logs(device);
26
30
  this.config(device);
@@ -80,30 +84,30 @@ export class Camera {
80
84
  * Camera - "command" "channelSub" "default" = previous channel
81
85
  */
82
86
  async pushOnChanges(): Promise<void> {
83
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushOnChanges On: ${this.On},`
84
- + ` disablePushOn: ${this.disablePushOn}`);
87
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushOnChanges On: ${this.On},` + ` disablePushOn: ${this.disablePushOn}`);
85
88
  if (this.On && !this.disablePushOn) {
86
89
  const commandType: string = await this.commandType();
87
90
  const command: string = await this.commandOn();
88
91
  const bodyChange = JSON.stringify({
89
- 'command': command,
90
- 'parameter': 'default',
91
- 'commandType': commandType,
92
+ command: command,
93
+ parameter: 'default',
94
+ commandType: commandType,
92
95
  });
93
96
  await this.pushChanges(bodyChange);
94
97
  }
95
98
  }
96
99
 
97
100
  async pushOffChanges(): Promise<void> {
98
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushOffChanges On: ${this.On},`
99
- + ` disablePushOff: ${this.disablePushOff}`);
101
+ this.debugLog(
102
+ `${this.device.remoteType}: ${this.accessory.displayName} pushOffChanges On: ${this.On},` + ` disablePushOff: ${this.disablePushOff}`,
103
+ );
100
104
  if (!this.On && !this.disablePushOff) {
101
105
  const commandType: string = await this.commandType();
102
106
  const command: string = await this.commandOff();
103
107
  const bodyChange = JSON.stringify({
104
- 'command': command,
105
- 'parameter': 'default',
106
- 'commandType': commandType,
108
+ command: command,
109
+ parameter: 'default',
110
+ commandType: commandType,
107
111
  });
108
112
  await this.pushChanges(bodyChange);
109
113
  }
@@ -126,13 +130,16 @@ export class Camera {
126
130
  this.updateHomeKitCharacteristics();
127
131
  } catch (e: any) {
128
132
  this.apiError(e);
129
- this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} failed pushChanges with ${this.device.connectionType}`
130
- + ` Connection, Error Message: ${JSON.stringify(e.message)}`,
133
+ this.errorLog(
134
+ `${this.device.remoteType}: ${this.accessory.displayName} failed pushChanges with ${this.device.connectionType}` +
135
+ ` Connection, Error Message: ${JSON.stringify(e.message)}`,
131
136
  );
132
137
  }
133
138
  } else {
134
- this.warnLog(`${this.device.remoteType}: ${this.accessory.displayName}`
135
- + ` Connection Type: ${this.device.connectionType}, commands will not be sent to OpenAPI`);
139
+ this.warnLog(
140
+ `${this.device.remoteType}: ${this.accessory.displayName}` +
141
+ ` Connection Type: ${this.device.connectionType}, commands will not be sent to OpenAPI`,
142
+ );
136
143
  }
137
144
  }
138
145
 
@@ -146,7 +153,7 @@ export class Camera {
146
153
  }
147
154
  }
148
155
 
149
- async disablePushOnChanges({ device }: { device: irdevice & irDevicesConfig; }): Promise<void> {
156
+ async disablePushOnChanges({ device }: { device: irdevice & irDevicesConfig }): Promise<void> {
150
157
  if (device.disablePushOn === undefined) {
151
158
  this.disablePushOn = false;
152
159
  } else {
@@ -154,7 +161,7 @@ export class Camera {
154
161
  }
155
162
  }
156
163
 
157
- async disablePushOffChanges({ device }: { device: irdevice & irDevicesConfig; }): Promise<void> {
164
+ async disablePushOffChanges({ device }: { device: irdevice & irDevicesConfig }): Promise<void> {
158
165
  if (device.disablePushOff === undefined) {
159
166
  this.disablePushOff = false;
160
167
  } else {
@@ -207,8 +214,10 @@ export class Camera {
207
214
  this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Device is offline, statusCode: ${statusCode}`);
208
215
  break;
209
216
  case 171:
210
- this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Hub Device is offline, statusCode: ${statusCode}. `
211
- + `Hub: ${this.device.hubDeviceId}`);
217
+ this.errorLog(
218
+ `${this.device.remoteType}: ${this.accessory.displayName} Hub Device is offline, statusCode: ${statusCode}. ` +
219
+ `Hub: ${this.device.hubDeviceId}`,
220
+ );
212
221
  break;
213
222
  case 190:
214
223
  this.errorLog(
@@ -223,8 +232,10 @@ export class Camera {
223
232
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Request successful, statusCode: ${statusCode}`);
224
233
  break;
225
234
  default:
226
- this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Unknown statusCode: `
227
- + `${statusCode}, Submit Bugs Here: ' + 'https://tinyurl.com/SwitchBotBug`);
235
+ this.infoLog(
236
+ `${this.device.remoteType}: ${this.accessory.displayName} Unknown statusCode: ` +
237
+ `${statusCode}, Submit Bugs Here: ' + 'https://tinyurl.com/SwitchBotBug`,
238
+ );
228
239
  }
229
240
  }
230
241
 
@@ -234,8 +245,9 @@ export class Camera {
234
245
 
235
246
  FirmwareRevision(accessory: PlatformAccessory, device: irdevice & irDevicesConfig): string {
236
247
  let FirmwareRevision: string;
237
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName}`
238
- + ` accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}`);
248
+ this.debugLog(
249
+ `${this.device.remoteType}: ${this.accessory.displayName}` + ` accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}`,
250
+ );
239
251
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} device.firmware: ${device.firmware}`);
240
252
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} this.platform.version: ${this.platform.version}`);
241
253
  if (accessory.context.FirmwareRevision) {
@@ -30,7 +30,11 @@ export class Fan {
30
30
  disablePushOff?: boolean;
31
31
  deviceLogging!: string;
32
32
 
33
- constructor(private readonly platform: SwitchBotPlatform, private accessory: PlatformAccessory, public device: irdevice & irDevicesConfig) {
33
+ constructor(
34
+ private readonly platform: SwitchBotPlatform,
35
+ private accessory: PlatformAccessory,
36
+ public device: irdevice & irDevicesConfig,
37
+ ) {
34
38
  // default placeholders
35
39
  this.logs(device);
36
40
  this.config(device);
@@ -170,30 +174,33 @@ export class Fan {
170
174
  * Fan - "command" "highSpeed" "default" = fan speed to high
171
175
  */
172
176
  async pushFanOnChanges(): Promise<void> {
173
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushFanOnChanges Active: ${this.Active},`
174
- + ` disablePushOn: ${this.disablePushOn}`);
177
+ this.debugLog(
178
+ `${this.device.remoteType}: ${this.accessory.displayName} pushFanOnChanges Active: ${this.Active},` + ` disablePushOn: ${this.disablePushOn}`,
179
+ );
175
180
  if (this.Active === this.platform.Characteristic.Active.ACTIVE && !this.disablePushOn) {
176
181
  const commandType: string = await this.commandType();
177
182
  const command: string = await this.commandOn();
178
183
  const bodyChange = JSON.stringify({
179
- 'command': command,
180
- 'parameter': 'default',
181
- 'commandType': commandType,
184
+ command: command,
185
+ parameter: 'default',
186
+ commandType: commandType,
182
187
  });
183
188
  await this.pushChanges(bodyChange);
184
189
  }
185
190
  }
186
191
 
187
192
  async pushFanOffChanges(): Promise<void> {
188
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushLightOffChanges Active: ${this.Active},`
189
- + ` disablePushOff: ${this.disablePushOff}`);
193
+ this.debugLog(
194
+ `${this.device.remoteType}: ${this.accessory.displayName} pushLightOffChanges Active: ${this.Active},` +
195
+ ` disablePushOff: ${this.disablePushOff}`,
196
+ );
190
197
  if (this.Active === this.platform.Characteristic.Active.INACTIVE && !this.disablePushOff) {
191
198
  const commandType: string = await this.commandType();
192
199
  const command: string = await this.commandOff();
193
200
  const bodyChange = JSON.stringify({
194
- 'command': command,
195
- 'parameter': 'default',
196
- 'commandType': commandType,
201
+ command: command,
202
+ parameter: 'default',
203
+ commandType: commandType,
197
204
  });
198
205
  await this.pushChanges(bodyChange);
199
206
  }
@@ -201,27 +208,27 @@ export class Fan {
201
208
 
202
209
  async pushFanSpeedUpChanges(): Promise<void> {
203
210
  const bodyChange = JSON.stringify({
204
- 'command': 'highSpeed',
205
- 'parameter': 'default',
206
- 'commandType': 'command',
211
+ command: 'highSpeed',
212
+ parameter: 'default',
213
+ commandType: 'command',
207
214
  });
208
215
  await this.pushChanges(bodyChange);
209
216
  }
210
217
 
211
218
  async pushFanSpeedDownChanges(): Promise<void> {
212
219
  const bodyChange = JSON.stringify({
213
- 'command': 'lowSpeed',
214
- 'parameter': 'default',
215
- 'commandType': 'command',
220
+ command: 'lowSpeed',
221
+ parameter: 'default',
222
+ commandType: 'command',
216
223
  });
217
224
  await this.pushChanges(bodyChange);
218
225
  }
219
226
 
220
227
  async pushFanSwingChanges(): Promise<void> {
221
228
  const bodyChange = JSON.stringify({
222
- 'command': 'swing',
223
- 'parameter': 'default',
224
- 'commandType': 'command',
229
+ command: 'swing',
230
+ parameter: 'default',
231
+ commandType: 'command',
225
232
  });
226
233
  await this.pushChanges(bodyChange);
227
234
  }
@@ -243,13 +250,16 @@ export class Fan {
243
250
  this.updateHomeKitCharacteristics();
244
251
  } catch (e: any) {
245
252
  this.apiError(e);
246
- this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} failed pushChanges with ${this.device.connectionType}`
247
- + ` Connection, Error Message: ${JSON.stringify(e.message)}`,
253
+ this.errorLog(
254
+ `${this.device.remoteType}: ${this.accessory.displayName} failed pushChanges with ${this.device.connectionType}` +
255
+ ` Connection, Error Message: ${JSON.stringify(e.message)}`,
248
256
  );
249
257
  }
250
258
  } else {
251
- this.warnLog(`${this.device.remoteType}: ${this.accessory.displayName}`
252
- + ` Connection Type: ${this.device.connectionType}, commands will not be sent to OpenAPI`);
259
+ this.warnLog(
260
+ `${this.device.remoteType}: ${this.accessory.displayName}` +
261
+ ` Connection Type: ${this.device.connectionType}, commands will not be sent to OpenAPI`,
262
+ );
253
263
  }
254
264
  }
255
265
 
@@ -277,7 +287,7 @@ export class Fan {
277
287
  }
278
288
  }
279
289
 
280
- async disablePushOnChanges({ device }: { device: irdevice & irDevicesConfig; }): Promise<void> {
290
+ async disablePushOnChanges({ device }: { device: irdevice & irDevicesConfig }): Promise<void> {
281
291
  if (device.disablePushOn === undefined) {
282
292
  this.disablePushOn = false;
283
293
  } else {
@@ -285,7 +295,7 @@ export class Fan {
285
295
  }
286
296
  }
287
297
 
288
- async disablePushOffChanges({ device }: { device: irdevice & irDevicesConfig; }): Promise<void> {
298
+ async disablePushOffChanges({ device }: { device: irdevice & irDevicesConfig }): Promise<void> {
289
299
  if (device.disablePushOff === undefined) {
290
300
  this.disablePushOff = false;
291
301
  } else {
@@ -338,8 +348,10 @@ export class Fan {
338
348
  this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Device is offline, statusCode: ${statusCode}`);
339
349
  break;
340
350
  case 171:
341
- this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Hub Device is offline, statusCode: ${statusCode}. `
342
- + `Hub: ${this.device.hubDeviceId}`);
351
+ this.errorLog(
352
+ `${this.device.remoteType}: ${this.accessory.displayName} Hub Device is offline, statusCode: ${statusCode}. ` +
353
+ `Hub: ${this.device.hubDeviceId}`,
354
+ );
343
355
  break;
344
356
  case 190:
345
357
  this.errorLog(
@@ -354,8 +366,10 @@ export class Fan {
354
366
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Request successful, statusCode: ${statusCode}`);
355
367
  break;
356
368
  default:
357
- this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Unknown statusCode: `
358
- + `${statusCode}, Submit Bugs Here: ' + 'https://tinyurl.com/SwitchBotBug`);
369
+ this.infoLog(
370
+ `${this.device.remoteType}: ${this.accessory.displayName} Unknown statusCode: ` +
371
+ `${statusCode}, Submit Bugs Here: ' + 'https://tinyurl.com/SwitchBotBug`,
372
+ );
359
373
  }
360
374
  }
361
375
 
@@ -367,8 +381,9 @@ export class Fan {
367
381
 
368
382
  FirmwareRevision(accessory: PlatformAccessory, device: irdevice & irDevicesConfig): string {
369
383
  let FirmwareRevision: string;
370
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName}`
371
- + ` accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}`);
384
+ this.debugLog(
385
+ `${this.device.remoteType}: ${this.accessory.displayName}` + ` accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}`,
386
+ );
372
387
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} device.firmware: ${device.firmware}`);
373
388
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} this.platform.version: ${this.platform.version}`);
374
389
  if (accessory.context.FirmwareRevision) {
@@ -389,7 +404,6 @@ export class Fan {
389
404
  }
390
405
  }
391
406
 
392
-
393
407
  async config(device: irdevice & irDevicesConfig): Promise<void> {
394
408
  let config = {};
395
409
  if (device.irfan) {
@@ -20,7 +20,11 @@ export class Light {
20
20
  disablePushOff?: boolean;
21
21
  deviceLogging!: string;
22
22
 
23
- constructor(private readonly platform: SwitchBotPlatform, private accessory: PlatformAccessory, public device: irdevice & irDevicesConfig) {
23
+ constructor(
24
+ private readonly platform: SwitchBotPlatform,
25
+ private accessory: PlatformAccessory,
26
+ public device: irdevice & irDevicesConfig,
27
+ ) {
24
28
  // default placeholders
25
29
  this.logs(device);
26
30
  this.config(device);
@@ -84,30 +88,32 @@ export class Light {
84
88
  * Light - "command" "channelSub" "default" = previous channel
85
89
  */
86
90
  async pushLightOnChanges(): Promise<void> {
87
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushLightOnChanges On: ${this.On},`
88
- + ` disablePushOn: ${this.disablePushOn}`);
91
+ this.debugLog(
92
+ `${this.device.remoteType}: ${this.accessory.displayName} pushLightOnChanges On: ${this.On},` + ` disablePushOn: ${this.disablePushOn}`,
93
+ );
89
94
  if (this.On && !this.disablePushOn) {
90
95
  const commandType: string = await this.commandType();
91
96
  const command: string = await this.commandOn();
92
97
  const bodyChange = JSON.stringify({
93
- 'command': command,
94
- 'parameter': 'default',
95
- 'commandType': commandType,
98
+ command: command,
99
+ parameter: 'default',
100
+ commandType: commandType,
96
101
  });
97
102
  await this.pushChanges(bodyChange);
98
103
  }
99
104
  }
100
105
 
101
106
  async pushLightOffChanges(): Promise<void> {
102
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushLightOffChanges On: ${this.On},`
103
- + ` disablePushOff: ${this.disablePushOff}`);
107
+ this.debugLog(
108
+ `${this.device.remoteType}: ${this.accessory.displayName} pushLightOffChanges On: ${this.On},` + ` disablePushOff: ${this.disablePushOff}`,
109
+ );
104
110
  if (!this.On && !this.disablePushOff) {
105
111
  const commandType: string = await this.commandType();
106
112
  const command: string = await this.commandOff();
107
113
  const bodyChange = JSON.stringify({
108
- 'command': command,
109
- 'parameter': 'default',
110
- 'commandType': commandType,
114
+ command: command,
115
+ parameter: 'default',
116
+ commandType: commandType,
111
117
  });
112
118
  await this.pushChanges(bodyChange);
113
119
  }
@@ -115,18 +121,18 @@ export class Light {
115
121
 
116
122
  async pushLightBrightnessUpChanges(): Promise<void> {
117
123
  const bodyChange = JSON.stringify({
118
- 'command': 'brightnessUp',
119
- 'parameter': 'default',
120
- 'commandType': 'command',
124
+ command: 'brightnessUp',
125
+ parameter: 'default',
126
+ commandType: 'command',
121
127
  });
122
128
  await this.pushChanges(bodyChange);
123
129
  }
124
130
 
125
131
  async pushLightBrightnessDownChanges(): Promise<void> {
126
132
  const bodyChange = JSON.stringify({
127
- 'command': 'brightnessDown',
128
- 'parameter': 'default',
129
- 'commandType': 'command',
133
+ command: 'brightnessDown',
134
+ parameter: 'default',
135
+ commandType: 'command',
130
136
  });
131
137
  await this.pushChanges(bodyChange);
132
138
  }
@@ -149,13 +155,16 @@ export class Light {
149
155
  this.updateHomeKitCharacteristics();
150
156
  } catch (e: any) {
151
157
  this.apiError(e);
152
- this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} failed pushChanges with ${this.device.connectionType}`
153
- + ` Connection, Error Message: ${JSON.stringify(e.message)}`,
158
+ this.errorLog(
159
+ `${this.device.remoteType}: ${this.accessory.displayName} failed pushChanges with ${this.device.connectionType}` +
160
+ ` Connection, Error Message: ${JSON.stringify(e.message)}`,
154
161
  );
155
162
  }
156
163
  } else {
157
- this.warnLog(`${this.device.remoteType}: ${this.accessory.displayName}`
158
- + ` Connection Type: ${this.device.connectionType}, commands will not be sent to OpenAPI`);
164
+ this.warnLog(
165
+ `${this.device.remoteType}: ${this.accessory.displayName}` +
166
+ ` Connection Type: ${this.device.connectionType}, commands will not be sent to OpenAPI`,
167
+ );
159
168
  }
160
169
  }
161
170
 
@@ -169,7 +178,7 @@ export class Light {
169
178
  }
170
179
  }
171
180
 
172
- async disablePushOnChanges({ device }: { device: irdevice & irDevicesConfig; }): Promise<void> {
181
+ async disablePushOnChanges({ device }: { device: irdevice & irDevicesConfig }): Promise<void> {
173
182
  if (device.disablePushOn === undefined) {
174
183
  this.disablePushOn = false;
175
184
  } else {
@@ -177,7 +186,7 @@ export class Light {
177
186
  }
178
187
  }
179
188
 
180
- async disablePushOffChanges({ device }: { device: irdevice & irDevicesConfig; }): Promise<void> {
189
+ async disablePushOffChanges({ device }: { device: irdevice & irDevicesConfig }): Promise<void> {
181
190
  if (device.disablePushOff === undefined) {
182
191
  this.disablePushOff = false;
183
192
  } else {
@@ -230,8 +239,10 @@ export class Light {
230
239
  this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Device is offline, statusCode: ${statusCode}`);
231
240
  break;
232
241
  case 171:
233
- this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Hub Device is offline, statusCode: ${statusCode}. `
234
- + `Hub: ${this.device.hubDeviceId}`);
242
+ this.errorLog(
243
+ `${this.device.remoteType}: ${this.accessory.displayName} Hub Device is offline, statusCode: ${statusCode}. ` +
244
+ `Hub: ${this.device.hubDeviceId}`,
245
+ );
235
246
  break;
236
247
  case 190:
237
248
  this.errorLog(
@@ -246,8 +257,10 @@ export class Light {
246
257
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Request successful, statusCode: ${statusCode}`);
247
258
  break;
248
259
  default:
249
- this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Unknown statusCode: `
250
- + `${statusCode}, Submit Bugs Here: ' + 'https://tinyurl.com/SwitchBotBug`);
260
+ this.infoLog(
261
+ `${this.device.remoteType}: ${this.accessory.displayName} Unknown statusCode: ` +
262
+ `${statusCode}, Submit Bugs Here: ' + 'https://tinyurl.com/SwitchBotBug`,
263
+ );
251
264
  }
252
265
  }
253
266
 
@@ -257,8 +270,9 @@ export class Light {
257
270
 
258
271
  FirmwareRevision(accessory: PlatformAccessory, device: irdevice & irDevicesConfig): string {
259
272
  let FirmwareRevision: string;
260
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName}`
261
- + ` accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}`);
273
+ this.debugLog(
274
+ `${this.device.remoteType}: ${this.accessory.displayName}` + ` accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}`,
275
+ );
262
276
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} device.firmware: ${device.firmware}`);
263
277
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} this.platform.version: ${this.platform.version}`);
264
278
  if (accessory.context.FirmwareRevision) {
@@ -21,7 +21,11 @@ export class Others {
21
21
  deviceLogging!: string;
22
22
  otherDeviceType?: string;
23
23
 
24
- constructor(private readonly platform: SwitchBotPlatform, private accessory: PlatformAccessory, public device: irdevice & irDevicesConfig) {
24
+ constructor(
25
+ private readonly platform: SwitchBotPlatform,
26
+ private accessory: PlatformAccessory,
27
+ public device: irdevice & irDevicesConfig,
28
+ ) {
25
29
  // default placeholders
26
30
  this.logs(device);
27
31
  this.deviceType(device);
@@ -87,16 +91,18 @@ export class Others {
87
91
  * Other - "command" "channelSub" "default" = previous channel
88
92
  */
89
93
  async pushOnChanges(): Promise<void> {
90
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushOnChanges Active: ${this.Active},`
91
- + ` disablePushOn: ${this.disablePushOn}, customize: ${this.device.customize}, customOn: ${this.device.customOn}`);
94
+ this.debugLog(
95
+ `${this.device.remoteType}: ${this.accessory.displayName} pushOnChanges Active: ${this.Active},` +
96
+ ` disablePushOn: ${this.disablePushOn}, customize: ${this.device.customize}, customOn: ${this.device.customOn}`,
97
+ );
92
98
  if (this.device.customize) {
93
99
  if (this.Active === this.platform.Characteristic.Active.ACTIVE && !this.disablePushOn) {
94
100
  const commandType: string = await this.commandType();
95
101
  const command: string = await this.commandOn();
96
102
  const bodyChange = JSON.stringify({
97
- 'command': command,
98
- 'parameter': 'default',
99
- 'commandType': commandType,
103
+ command: command,
104
+ parameter: 'default',
105
+ commandType: commandType,
100
106
  });
101
107
  await this.pushChanges(bodyChange);
102
108
  }
@@ -106,16 +112,18 @@ export class Others {
106
112
  }
107
113
 
108
114
  async pushOffChanges(): Promise<void> {
109
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushOffChanges Active: ${this.Active},`
110
- + ` disablePushOff: ${this.disablePushOff}, customize: ${this.device.customize}, customOff: ${this.device.customOff}`);
115
+ this.debugLog(
116
+ `${this.device.remoteType}: ${this.accessory.displayName} pushOffChanges Active: ${this.Active},` +
117
+ ` disablePushOff: ${this.disablePushOff}, customize: ${this.device.customize}, customOff: ${this.device.customOff}`,
118
+ );
111
119
  if (this.device.customize) {
112
120
  if (this.Active === this.platform.Characteristic.Active.INACTIVE && !this.disablePushOff) {
113
121
  const commandType: string = await this.commandType();
114
122
  const command: string = await this.commandOff();
115
123
  const bodyChange = JSON.stringify({
116
- 'command': command,
117
- 'parameter': 'default',
118
- 'commandType': commandType,
124
+ command: command,
125
+ parameter: 'default',
126
+ commandType: commandType,
119
127
  });
120
128
  await this.pushChanges(bodyChange);
121
129
  }
@@ -141,13 +149,16 @@ export class Others {
141
149
  this.updateHomeKitCharacteristics();
142
150
  } catch (e: any) {
143
151
  this.apiError(e);
144
- this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} failed pushChanges with ${this.device.connectionType}`
145
- + ` Connection, Error Message: ${JSON.stringify(e.message)}`,
152
+ this.errorLog(
153
+ `${this.device.remoteType}: ${this.accessory.displayName} failed pushChanges with ${this.device.connectionType}` +
154
+ ` Connection, Error Message: ${JSON.stringify(e.message)}`,
146
155
  );
147
156
  }
148
157
  } else {
149
- this.warnLog(`${this.device.remoteType}: ${this.accessory.displayName}`
150
- + ` Connection Type: ${this.device.connectionType}, commands will not be sent to OpenAPI`);
158
+ this.warnLog(
159
+ `${this.device.remoteType}: ${this.accessory.displayName}` +
160
+ ` Connection Type: ${this.device.connectionType}, commands will not be sent to OpenAPI`,
161
+ );
151
162
  }
152
163
  }
153
164
 
@@ -161,7 +172,7 @@ export class Others {
161
172
  }
162
173
  }
163
174
 
164
- async disablePushOnChanges({ device }: { device: irdevice & irDevicesConfig; }): Promise<void> {
175
+ async disablePushOnChanges({ device }: { device: irdevice & irDevicesConfig }): Promise<void> {
165
176
  if (device.disablePushOn === undefined) {
166
177
  this.disablePushOn = false;
167
178
  } else {
@@ -169,7 +180,7 @@ export class Others {
169
180
  }
170
181
  }
171
182
 
172
- async disablePushOffChanges({ device }: { device: irdevice & irDevicesConfig; }): Promise<void> {
183
+ async disablePushOffChanges({ device }: { device: irdevice & irDevicesConfig }): Promise<void> {
173
184
  if (device.disablePushOff === undefined) {
174
185
  this.disablePushOff = false;
175
186
  } else {
@@ -222,8 +233,10 @@ export class Others {
222
233
  this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Device is offline, statusCode: ${statusCode}`);
223
234
  break;
224
235
  case 171:
225
- this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Hub Device is offline, statusCode: ${statusCode}. `
226
- + `Hub: ${this.device.hubDeviceId}`);
236
+ this.errorLog(
237
+ `${this.device.remoteType}: ${this.accessory.displayName} Hub Device is offline, statusCode: ${statusCode}. ` +
238
+ `Hub: ${this.device.hubDeviceId}`,
239
+ );
227
240
  break;
228
241
  case 190:
229
242
  this.errorLog(
@@ -238,8 +251,10 @@ export class Others {
238
251
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Request successful, statusCode: ${statusCode}`);
239
252
  break;
240
253
  default:
241
- this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Unknown statusCode: `
242
- + `${statusCode}, Submit Bugs Here: ' + 'https://tinyurl.com/SwitchBotBug`);
254
+ this.infoLog(
255
+ `${this.device.remoteType}: ${this.accessory.displayName} Unknown statusCode: ` +
256
+ `${statusCode}, Submit Bugs Here: ' + 'https://tinyurl.com/SwitchBotBug`,
257
+ );
243
258
  }
244
259
  }
245
260
 
@@ -261,8 +276,9 @@ export class Others {
261
276
 
262
277
  FirmwareRevision(accessory: PlatformAccessory, device: irdevice & irDevicesConfig): string {
263
278
  let FirmwareRevision: string;
264
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName}`
265
- + ` accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}`);
279
+ this.debugLog(
280
+ `${this.device.remoteType}: ${this.accessory.displayName}` + ` accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}`,
281
+ );
266
282
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} device.firmware: ${device.firmware}`);
267
283
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} this.platform.version: ${this.platform.version}`);
268
284
  if (accessory.context.FirmwareRevision) {