@switchbot/homebridge-switchbot 1.15.1-beta.8 → 1.15.1-beta.9

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 (70) hide show
  1. package/dist/device/bot.d.ts.map +1 -1
  2. package/dist/device/bot.js +32 -28
  3. package/dist/device/bot.js.map +1 -1
  4. package/dist/device/colorbulb.d.ts.map +1 -1
  5. package/dist/device/colorbulb.js +96 -90
  6. package/dist/device/colorbulb.js.map +1 -1
  7. package/dist/device/curtain.d.ts.map +1 -1
  8. package/dist/device/curtain.js +26 -24
  9. package/dist/device/curtain.js.map +1 -1
  10. package/dist/device/humidifier.d.ts.map +1 -1
  11. package/dist/device/humidifier.js +87 -91
  12. package/dist/device/humidifier.js.map +1 -1
  13. package/dist/device/lock.d.ts.map +1 -1
  14. package/dist/device/lock.js +29 -25
  15. package/dist/device/lock.js.map +1 -1
  16. package/dist/device/plug.d.ts.map +1 -1
  17. package/dist/device/plug.js +30 -26
  18. package/dist/device/plug.js.map +1 -1
  19. package/dist/device/striplight.d.ts.map +1 -1
  20. package/dist/device/striplight.js +81 -72
  21. package/dist/device/striplight.js.map +1 -1
  22. package/dist/irdevice/airconditioner.d.ts +2 -2
  23. package/dist/irdevice/airconditioner.d.ts.map +1 -1
  24. package/dist/irdevice/airconditioner.js.map +1 -1
  25. package/dist/irdevice/airpurifier.d.ts +2 -2
  26. package/dist/irdevice/airpurifier.d.ts.map +1 -1
  27. package/dist/irdevice/airpurifier.js +6 -5
  28. package/dist/irdevice/airpurifier.js.map +1 -1
  29. package/dist/irdevice/camera.d.ts +2 -2
  30. package/dist/irdevice/camera.d.ts.map +1 -1
  31. package/dist/irdevice/camera.js.map +1 -1
  32. package/dist/irdevice/fan.d.ts +2 -2
  33. package/dist/irdevice/fan.d.ts.map +1 -1
  34. package/dist/irdevice/fan.js.map +1 -1
  35. package/dist/irdevice/light.d.ts +2 -2
  36. package/dist/irdevice/light.d.ts.map +1 -1
  37. package/dist/irdevice/light.js.map +1 -1
  38. package/dist/irdevice/other.d.ts +2 -2
  39. package/dist/irdevice/other.d.ts.map +1 -1
  40. package/dist/irdevice/other.js.map +1 -1
  41. package/dist/irdevice/tv.d.ts +2 -2
  42. package/dist/irdevice/tv.d.ts.map +1 -1
  43. package/dist/irdevice/tv.js.map +1 -1
  44. package/dist/irdevice/vacuumcleaner.d.ts +2 -2
  45. package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
  46. package/dist/irdevice/vacuumcleaner.js.map +1 -1
  47. package/dist/irdevice/waterheater.d.ts +2 -2
  48. package/dist/irdevice/waterheater.d.ts.map +1 -1
  49. package/dist/irdevice/waterheater.js.map +1 -1
  50. package/dist/settings.d.ts +0 -5
  51. package/dist/settings.d.ts.map +1 -1
  52. package/dist/settings.js.map +1 -1
  53. package/package.json +1 -1
  54. package/src/device/bot.ts +33 -38
  55. package/src/device/colorbulb.ts +97 -110
  56. package/src/device/curtain.ts +27 -33
  57. package/src/device/humidifier.ts +88 -117
  58. package/src/device/lock.ts +29 -34
  59. package/src/device/plug.ts +31 -35
  60. package/src/device/striplight.ts +82 -98
  61. package/src/irdevice/airconditioner.ts +2 -2
  62. package/src/irdevice/airpurifier.ts +10 -10
  63. package/src/irdevice/camera.ts +4 -4
  64. package/src/irdevice/fan.ts +7 -7
  65. package/src/irdevice/light.ts +6 -6
  66. package/src/irdevice/other.ts +4 -4
  67. package/src/irdevice/tv.ts +13 -13
  68. package/src/irdevice/vacuumcleaner.ts +4 -4
  69. package/src/irdevice/waterheater.ts +4 -4
  70. package/src/settings.ts +0 -19
@@ -6,7 +6,7 @@ import { interval, Subject } from 'rxjs';
6
6
  import { SwitchBotPlatform } from '../platform';
7
7
  import { debounceTime, skipWhile, tap } from 'rxjs/operators';
8
8
  import { Service, PlatformAccessory, CharacteristicValue, ControllerConstructor, Controller, ControllerServiceMap } from 'homebridge';
9
- import { device, devicesConfig, switchbot, payload, hs2rgb, rgb2hs, deviceStatus, HostDomain, DevicePath } from '../settings';
9
+ import { device, devicesConfig, switchbot, hs2rgb, rgb2hs, deviceStatus, HostDomain, DevicePath } from '../settings';
10
10
 
11
11
  /**
12
12
  * Platform Accessory
@@ -280,59 +280,54 @@ export class StripLight {
280
280
  async pushChanges(): Promise<void> {
281
281
  try {
282
282
  if (this.On !== this.OnCached) {
283
- // Push On Update
284
- const payload = {
285
- commandType: 'command',
286
- parameter: 'default',
287
- } as payload;
288
-
289
- if (this.On) {
290
- payload.command = 'turnOn';
291
- } else {
292
- payload.command = 'turnOff';
293
- }
294
-
295
- this.infoLog(
296
- `Strip Light: ${this.accessory.displayName} Sending request to SwitchBot API. command: ${payload.command},` +
297
- ` parameter: ${payload.parameter}, commandType: ${payload.commandType}`,
298
- );
299
-
300
- // Make the API request
283
+ // Make Push On request to the API
301
284
  const t = Date.now();
302
285
  const nonce = 'requestID';
303
286
  const data = this.platform.config.credentials?.token + t + nonce;
304
- const signTerm = crypto.createHmac('sha256', this.platform.config.credentials?.secret).update(Buffer.from(data, 'utf-8')).digest();
287
+ const signTerm = crypto.createHmac('sha256', this.platform.config.credentials?.secret)
288
+ .update(Buffer.from(data, 'utf-8'))
289
+ .digest();
305
290
  const sign = signTerm.toString('base64');
306
291
  this.debugLog(`Strip Light: ${this.accessory.displayName} sign: ${sign}`);
292
+
293
+ let command = '';
294
+ if (this.On) {
295
+ command = 'turnOn';
296
+ } else {
297
+ command = 'turnOff';
298
+ }
299
+ const body = JSON.stringify({
300
+ 'command': `${command}`,
301
+ 'parameter': 'default',
302
+ 'commandType': 'command',
303
+ });
304
+ this.infoLog(`Strip Light: ${this.accessory.displayName} Sending request to SwitchBot API. body: ${body},`);
307
305
  const options = {
308
- hostname: 'api.switch-bot.com',
306
+ hostname: HostDomain,
309
307
  port: 443,
310
- path: `/v1.1/devices/${this.device.deviceId}/commands`,
308
+ path: `${DevicePath}/${this.device.deviceId}/commands`,
311
309
  method: 'POST',
312
310
  headers: {
313
- Authorization: this.platform.config.credentials?.token,
314
- sign: sign,
315
- nonce: nonce,
316
- t: t,
311
+ 'Authorization': this.platform.config.credentials?.token,
312
+ 'sign': sign,
313
+ 'nonce': nonce,
314
+ 't': t,
317
315
  'Content-Type': 'application/json',
316
+ 'Content-Length': body.length,
318
317
  },
319
318
  };
320
-
321
- const req = https.request(options, (res) => {
319
+ const req = https.request(options, res => {
322
320
  this.debugLog(`Strip Light: ${this.accessory.displayName} statusCode: ${res.statusCode}`);
323
321
  this.statusCode({ res });
324
- res.on('data', (d) => {
322
+ res.on('data', d => {
325
323
  this.debugLog(`Strip Light: ${this.accessory.displayName} d: ${d}`);
326
324
  });
327
325
  });
328
-
329
- req.on('error', (error) => {
330
- this.errorLog(`Strip Light: ${this.accessory.displayName} error: ${error}`);
326
+ req.on('error', (e: any) => {
327
+ this.errorLog(`Strip Light: ${this.accessory.displayName} error message: ${e.message}`);
331
328
  });
332
-
333
- req.write(payload);
329
+ req.write(body);
334
330
  req.end();
335
-
336
331
  this.debugLog(`Strip Light: ${this.accessory.displayName} pushchanges: ${JSON.stringify(req)}`);
337
332
  this.OnCached = this.On;
338
333
  this.accessory.context.On = this.OnCached;
@@ -365,55 +360,48 @@ export class StripLight {
365
360
 
366
361
  const [red, green, blue] = hs2rgb(Number(this.Hue), Number(this.Saturation));
367
362
  this.debugLog(`Strip Light: ${this.accessory.displayName} rgb: ${JSON.stringify([red, green, blue])}`);
368
-
369
- const payload = {
370
- commandType: 'command',
371
- command: 'setColor',
372
- parameter: `${red}:${green}:${blue}`,
373
- } as payload;
374
-
375
- this.infoLog(
376
- `Strip Light: ${this.accessory.displayName} Sending request to SwitchBot API. command: ${payload.command},` +
377
- ` parameter: ${payload.parameter}, commandType: ${payload.commandType}`,
378
- );
379
-
380
- // Make the API request
363
+ // Make Push On request to the API
381
364
  const t = Date.now();
382
365
  const nonce = 'requestID';
383
366
  const data = this.platform.config.credentials?.token + t + nonce;
384
- const signTerm = crypto.createHmac('sha256', this.platform.config.credentials?.secret).update(Buffer.from(data, 'utf-8')).digest();
367
+ const signTerm = crypto.createHmac('sha256', this.platform.config.credentials?.secret)
368
+ .update(Buffer.from(data, 'utf-8'))
369
+ .digest();
385
370
  const sign = signTerm.toString('base64');
386
371
  this.debugLog(`Strip Light: ${this.accessory.displayName} sign: ${sign}`);
372
+ const body = JSON.stringify({
373
+ 'command': 'setColor',
374
+ 'parameter': `${red}:${green}:${blue}`,
375
+ 'commandType': 'command',
376
+ });
377
+ this.infoLog(`Strip Light: ${this.accessory.displayName} Sending request to SwitchBot API. body: ${body},`);
387
378
  const options = {
388
- hostname: 'api.switch-bot.com',
379
+ hostname: HostDomain,
389
380
  port: 443,
390
- path: `/v1.1/devices/${this.device.deviceId}/commands`,
381
+ path: `${DevicePath}/${this.device.deviceId}/commands`,
391
382
  method: 'POST',
392
383
  headers: {
393
- Authorization: this.platform.config.credentials?.token,
394
- sign: sign,
395
- nonce: nonce,
396
- t: t,
384
+ 'Authorization': this.platform.config.credentials?.token,
385
+ 'sign': sign,
386
+ 'nonce': nonce,
387
+ 't': t,
397
388
  'Content-Type': 'application/json',
389
+ 'Content-Length': body.length,
398
390
  },
399
391
  };
400
-
401
- const req = https.request(options, (res) => {
392
+ const req = https.request(options, res => {
402
393
  this.debugLog(`Strip Light: ${this.accessory.displayName} statusCode: ${res.statusCode}`);
403
394
  this.statusCode({ res });
404
- res.on('data', (d) => {
395
+ res.on('data', d => {
405
396
  this.debugLog(`Strip Light: ${this.accessory.displayName} d: ${d}`);
406
397
  });
407
398
  });
408
-
409
- req.on('error', (error) => {
410
- this.errorLog(`Strip Light: ${this.accessory.displayName} error: ${error}`);
399
+ req.on('error', (e: any) => {
400
+ this.errorLog(`Strip Light: ${this.accessory.displayName} error message: ${e.message}`);
411
401
  });
412
-
413
- req.write(payload);
402
+ req.write(body);
414
403
  req.end();
415
-
416
- this.debugLog(`Strip Light: ${this.accessory.displayName} pushchanges: ${JSON.stringify(req)}`);
404
+ this.debugLog(`Strip Light: ${this.accessory.displayName} pushHueSaturationChanges: ${JSON.stringify(req)}`);
417
405
  this.HueCached = this.Hue;
418
406
  this.SaturationCached = this.Saturation;
419
407
  } else {
@@ -423,10 +411,11 @@ export class StripLight {
423
411
  );
424
412
  }
425
413
  } catch (e: any) {
426
- this.errorLog(`Strip Light: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection`);
414
+ this.errorLog(`Strip Light: ${this.accessory.displayName} failed pushHueSaturationChanges with OpenAPI Connection`);
427
415
  if (this.deviceLogging.includes('debug')) {
428
416
  this.errorLog(
429
- `Strip Light: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` + ` Error Message: ${JSON.stringify(e.message)}`,
417
+ `Strip Light: ${this.accessory.displayName} failed pushHueSaturationChanges with OpenAPI Connection,`
418
+ + ` Error Message: ${JSON.stringify(e.message)}`,
430
419
  );
431
420
  }
432
421
  this.apiError(e);
@@ -436,54 +425,48 @@ export class StripLight {
436
425
  async pushBrightnessChanges(): Promise<void> {
437
426
  try {
438
427
  if (this.Brightness !== this.BrightnessCached) {
439
- const payload = {
440
- commandType: 'command',
441
- command: 'setBrightness',
442
- parameter: `${this.Brightness}`,
443
- } as payload;
444
-
445
- this.infoLog(
446
- `Strip Light: ${this.accessory.displayName} Sending request to SwitchBot API. command: ${payload.command},` +
447
- ` parameter: ${payload.parameter}, commandType: ${payload.commandType}`,
448
- );
449
-
450
- // Make the API request
428
+ // Make Push On request to the API
451
429
  const t = Date.now();
452
430
  const nonce = 'requestID';
453
431
  const data = this.platform.config.credentials?.token + t + nonce;
454
- const signTerm = crypto.createHmac('sha256', this.platform.config.credentials?.secret).update(Buffer.from(data, 'utf-8')).digest();
432
+ const signTerm = crypto.createHmac('sha256', this.platform.config.credentials?.secret)
433
+ .update(Buffer.from(data, 'utf-8'))
434
+ .digest();
455
435
  const sign = signTerm.toString('base64');
456
436
  this.debugLog(`Strip Light: ${this.accessory.displayName} sign: ${sign}`);
437
+ const body = JSON.stringify({
438
+ 'command': 'setBrightness',
439
+ 'parameter': `${this.Brightness}`,
440
+ 'commandType': 'command',
441
+ });
442
+ this.infoLog(`Strip Light: ${this.accessory.displayName} Sending request to SwitchBot API. body: ${body},`);
457
443
  const options = {
458
- hostname: 'api.switch-bot.com',
444
+ hostname: HostDomain,
459
445
  port: 443,
460
- path: `/v1.1/devices/${this.device.deviceId}/commands`,
446
+ path: `${DevicePath}/${this.device.deviceId}/commands`,
461
447
  method: 'POST',
462
448
  headers: {
463
- Authorization: this.platform.config.credentials?.token,
464
- sign: sign,
465
- nonce: nonce,
466
- t: t,
449
+ 'Authorization': this.platform.config.credentials?.token,
450
+ 'sign': sign,
451
+ 'nonce': nonce,
452
+ 't': t,
467
453
  'Content-Type': 'application/json',
454
+ 'Content-Length': body.length,
468
455
  },
469
456
  };
470
-
471
- const req = https.request(options, (res) => {
457
+ const req = https.request(options, res => {
472
458
  this.debugLog(`Strip Light: ${this.accessory.displayName} statusCode: ${res.statusCode}`);
473
459
  this.statusCode({ res });
474
- res.on('data', (d) => {
460
+ res.on('data', d => {
475
461
  this.debugLog(`Strip Light: ${this.accessory.displayName} d: ${d}`);
476
462
  });
477
463
  });
478
-
479
- req.on('error', (error) => {
480
- this.errorLog(`Strip Light: ${this.accessory.displayName} error: ${error}`);
464
+ req.on('error', (e: any) => {
465
+ this.errorLog(`Strip Light: ${this.accessory.displayName} error message: ${e.message}`);
481
466
  });
482
-
483
- req.write(payload);
467
+ req.write(body);
484
468
  req.end();
485
-
486
- this.debugLog(`Strip Light: ${this.accessory.displayName} pushchanges: ${JSON.stringify(req)}`);
469
+ this.debugLog(`Strip Light: ${this.accessory.displayName} pushBrightnessChanges: ${JSON.stringify(req)}`);
487
470
  this.BrightnessCached = this.Brightness;
488
471
  } else {
489
472
  this.debugLog(
@@ -491,10 +474,11 @@ export class StripLight {
491
474
  );
492
475
  }
493
476
  } catch (e: any) {
494
- this.errorLog(`Strip Light: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection`);
477
+ this.errorLog(`Strip Light: ${this.accessory.displayName} failed pushBrightnessChanges with OpenAPI Connection`);
495
478
  if (this.deviceLogging.includes('debug')) {
496
479
  this.errorLog(
497
- `Strip Light: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` + ` Error Message: ${JSON.stringify(e.message)}`,
480
+ `Strip Light: ${this.accessory.displayName} failed pushBrightnessChanges with OpenAPI Connection,`
481
+ + ` Error Message: ${JSON.stringify(e.message)}`,
498
482
  );
499
483
  }
500
484
  this.apiError(e);
@@ -2,7 +2,7 @@ import https from 'https';
2
2
  import crypto from 'crypto';
3
3
  import { IncomingMessage } from 'http';
4
4
  import { SwitchBotPlatform } from '../platform';
5
- import { irDevicesConfig, irdevice, payload, HostDomain, DevicePath } from '../settings';
5
+ import { irDevicesConfig, irdevice, HostDomain, DevicePath } from '../settings';
6
6
  import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
7
7
 
8
8
  /**
@@ -252,7 +252,7 @@ export class AirConditioner {
252
252
  await this.pushChanges(payload);
253
253
  }
254
254
 
255
- async pushChanges(payload: payload): Promise<void> {
255
+ async pushChanges(payload): Promise<void> {
256
256
  try {
257
257
  this.infoLog(
258
258
  `Air Conditioner: ${this.accessory.displayName} Sending request to SwitchBot API. command: ${payload.command},` +
@@ -2,7 +2,7 @@ import https from 'https';
2
2
  import crypto from 'crypto';
3
3
  import { IncomingMessage } from 'http';
4
4
  import { SwitchBotPlatform } from '../platform';
5
- import { irDevicesConfig, irdevice, payload, HostDomain, DevicePath } from '../settings';
5
+ import { irDevicesConfig, irdevice, HostDomain, DevicePath } from '../settings';
6
6
  import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
7
7
 
8
8
  /**
@@ -162,7 +162,7 @@ export class AirPurifier {
162
162
  commandType: 'command',
163
163
  parameter: 'default',
164
164
  command: 'turnOn',
165
- } as payload;
165
+ };
166
166
  await this.pushChanges(payload);
167
167
  }
168
168
  }
@@ -173,7 +173,7 @@ export class AirPurifier {
173
173
  commandType: 'command',
174
174
  parameter: 'default',
175
175
  command: 'turnOff',
176
- } as payload;
176
+ };
177
177
  await this.pushChanges(payload);
178
178
  }
179
179
  }
@@ -190,16 +190,16 @@ export class AirPurifier {
190
190
  }
191
191
 
192
192
  async pushAirConditionerDetailsChanges(): Promise<void> {
193
- const payload = {
194
- commandType: 'command',
195
- command: 'setAll',
196
- } as payload;
197
-
198
193
  this.CurrentAPTemp = this.CurrentTemperature || 24;
199
194
  this.CurrentAPMode = this.CurrentMode || 1;
200
195
  this.CurrentAPFanSpeed = this.CurrentFanSpeed || 1;
201
196
  this.APActive = this.Active === 1 ? 'on' : 'off';
202
- payload.parameter = `${this.CurrentAPTemp},${this.CurrentAPMode},${this.CurrentAPFanSpeed},${this.APActive}`;
197
+ const parameter = `${this.CurrentAPTemp},${this.CurrentAPMode},${this.CurrentAPFanSpeed},${this.APActive}`;
198
+ const payload = JSON.stringify({
199
+ 'command': 'setAll',
200
+ 'parameter': `${parameter}`,
201
+ 'commandType': 'command',
202
+ });
203
203
 
204
204
  if (this.Active === 1) {
205
205
  if ((this.CurrentTemperature || 24) < (this.LastTemperature || 30)) {
@@ -214,7 +214,7 @@ export class AirPurifier {
214
214
  await this.pushChanges(payload);
215
215
  }
216
216
 
217
- async pushChanges(payload: payload): Promise<void> {
217
+ async pushChanges(payload): Promise<void> {
218
218
  try {
219
219
  this.infoLog(
220
220
  `Air Purifier: ${this.accessory.displayName} Sending request to SwitchBot API. command: ${payload.command},` +
@@ -2,7 +2,7 @@ import https from 'https';
2
2
  import crypto from 'crypto';
3
3
  import { IncomingMessage } from 'http';
4
4
  import { SwitchBotPlatform } from '../platform';
5
- import { irDevicesConfig, irdevice, payload, HostDomain, DevicePath } from '../settings';
5
+ import { irDevicesConfig, irdevice, HostDomain, DevicePath } from '../settings';
6
6
  import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
7
7
 
8
8
  /**
@@ -90,7 +90,7 @@ export class Camera {
90
90
  commandType: 'command',
91
91
  parameter: 'default',
92
92
  command: 'turnOn',
93
- } as payload;
93
+ };
94
94
  await this.pushChanges(payload);
95
95
  }
96
96
  }
@@ -101,12 +101,12 @@ export class Camera {
101
101
  commandType: 'command',
102
102
  parameter: 'default',
103
103
  command: 'turnOff',
104
- } as payload;
104
+ };
105
105
  await this.pushChanges(payload);
106
106
  }
107
107
  }
108
108
 
109
- async pushChanges(payload: payload): Promise<void> {
109
+ async pushChanges(payload): Promise<void> {
110
110
  try {
111
111
  this.infoLog(
112
112
  `Camera: ${this.accessory.displayName} Sending request to SwitchBot API. command: ${payload.command},` +
@@ -3,7 +3,7 @@ import crypto from 'crypto';
3
3
  import { IncomingMessage } from 'http';
4
4
  import { SwitchBotPlatform } from '../platform';
5
5
  import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
6
- import { irdevice, irDevicesConfig, payload, HostDomain, DevicePath } from '../settings';
6
+ import { irdevice, irDevicesConfig, HostDomain, DevicePath } from '../settings';
7
7
 
8
8
  /**
9
9
  * Platform Accessory
@@ -192,7 +192,7 @@ export class Fan {
192
192
  commandType: 'command',
193
193
  parameter: 'default',
194
194
  command: 'turnOn',
195
- } as payload;
195
+ };
196
196
  await this.pushTVChanges(payload);
197
197
  }
198
198
  }
@@ -202,7 +202,7 @@ export class Fan {
202
202
  commandType: 'command',
203
203
  parameter: 'default',
204
204
  command: 'turnOff',
205
- } as payload;
205
+ };
206
206
  await this.pushTVChanges(payload);
207
207
  }
208
208
 
@@ -211,7 +211,7 @@ export class Fan {
211
211
  commandType: 'command',
212
212
  parameter: 'default',
213
213
  command: 'highSpeed',
214
- } as payload;
214
+ };
215
215
  await this.pushTVChanges(payload);
216
216
  }
217
217
 
@@ -220,7 +220,7 @@ export class Fan {
220
220
  commandType: 'command',
221
221
  parameter: 'default',
222
222
  command: 'lowSpeed',
223
- } as payload;
223
+ };
224
224
  await this.pushTVChanges(payload);
225
225
  }
226
226
 
@@ -229,11 +229,11 @@ export class Fan {
229
229
  commandType: 'command',
230
230
  parameter: 'default',
231
231
  command: 'swing',
232
- } as payload;
232
+ };
233
233
  await this.pushTVChanges(payload);
234
234
  }
235
235
 
236
- async pushTVChanges(payload: payload): Promise<void> {
236
+ async pushTVChanges(payload): Promise<void> {
237
237
  try {
238
238
  this.infoLog(
239
239
  `Fan: ${this.accessory.displayName} Sending request to SwitchBot API. command: ${payload.command},` +
@@ -2,7 +2,7 @@ import https from 'https';
2
2
  import crypto from 'crypto';
3
3
  import { IncomingMessage } from 'http';
4
4
  import { SwitchBotPlatform } from '../platform';
5
- import { irDevicesConfig, irdevice, payload, HostDomain, DevicePath } from '../settings';
5
+ import { irDevicesConfig, irdevice, HostDomain, DevicePath } from '../settings';
6
6
  import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
7
7
 
8
8
  /**
@@ -105,7 +105,7 @@ export class Light {
105
105
  commandType: 'command',
106
106
  parameter: 'default',
107
107
  command: 'turnOn',
108
- } as payload;
108
+ };
109
109
  await this.pushChanges(payload);
110
110
  }
111
111
  }
@@ -116,7 +116,7 @@ export class Light {
116
116
  commandType: 'command',
117
117
  parameter: 'default',
118
118
  command: 'turnOff',
119
- } as payload;
119
+ };
120
120
  await this.pushChanges(payload);
121
121
  }
122
122
  }
@@ -126,7 +126,7 @@ export class Light {
126
126
  commandType: 'command',
127
127
  parameter: 'default',
128
128
  command: 'brightnessUp',
129
- } as payload;
129
+ };
130
130
  await this.pushChanges(payload);
131
131
  }
132
132
 
@@ -135,11 +135,11 @@ export class Light {
135
135
  commandType: 'command',
136
136
  parameter: 'default',
137
137
  command: 'brightnessDown',
138
- } as payload;
138
+ };
139
139
  await this.pushChanges(payload);
140
140
  }
141
141
 
142
- async pushChanges(payload: payload): Promise<void> {
142
+ async pushChanges(payload): Promise<void> {
143
143
  try {
144
144
  this.infoLog(
145
145
  `Light: ${this.accessory.displayName} Sending request to SwitchBot API. command: ${payload.command},` +
@@ -2,7 +2,7 @@ import https from 'https';
2
2
  import crypto from 'crypto';
3
3
  import { IncomingMessage } from 'http';
4
4
  import { SwitchBotPlatform } from '../platform';
5
- import { irDevicesConfig, irdevice, payload, HostDomain, DevicePath } from '../settings';
5
+ import { irDevicesConfig, irdevice, HostDomain, DevicePath } from '../settings';
6
6
  import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
7
7
 
8
8
  /**
@@ -103,7 +103,7 @@ export class Others {
103
103
  commandType: 'customize',
104
104
  parameter: 'default',
105
105
  command: `${this.device.other.commandOn}`,
106
- } as payload;
106
+ };
107
107
  await this.pushChanges(payload);
108
108
  }
109
109
  } else {
@@ -126,7 +126,7 @@ export class Others {
126
126
  commandType: 'customize',
127
127
  parameter: 'default',
128
128
  command: `${this.device.other.commandOff}`,
129
- } as payload;
129
+ };
130
130
  await this.pushChanges(payload);
131
131
  }
132
132
  } else {
@@ -140,7 +140,7 @@ export class Others {
140
140
  }
141
141
  }
142
142
 
143
- async pushChanges(payload: payload): Promise<void> {
143
+ async pushChanges(payload): Promise<void> {
144
144
  try {
145
145
  this.infoLog(
146
146
  `Other: ${this.accessory.displayName} Sending request to SwitchBot API. command: ${payload.command},` +
@@ -3,7 +3,7 @@ import crypto from 'crypto';
3
3
  import { IncomingMessage } from 'http';
4
4
  import { SwitchBotPlatform } from '../platform';
5
5
  import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
6
- import { irdevice, irDevicesConfig, payload, HostDomain, DevicePath } from '../settings';
6
+ import { irdevice, irDevicesConfig, HostDomain, DevicePath } from '../settings';
7
7
 
8
8
  /**
9
9
  * Platform Accessory
@@ -241,7 +241,7 @@ export class TV {
241
241
  commandType: 'command',
242
242
  parameter: 'default',
243
243
  command: 'turnOn',
244
- } as payload;
244
+ };
245
245
  await this.pushTVChanges(payload);
246
246
  }
247
247
  }
@@ -251,7 +251,7 @@ export class TV {
251
251
  commandType: 'command',
252
252
  parameter: 'default',
253
253
  command: 'turnOff',
254
- } as payload;
254
+ };
255
255
  await this.pushTVChanges(payload);
256
256
  }
257
257
 
@@ -260,7 +260,7 @@ export class TV {
260
260
  commandType: 'command',
261
261
  parameter: 'default',
262
262
  command: 'Ok',
263
- } as payload;
263
+ };
264
264
  await this.pushTVChanges(payload);
265
265
  }
266
266
 
@@ -269,7 +269,7 @@ export class TV {
269
269
  commandType: 'command',
270
270
  parameter: 'default',
271
271
  command: 'Back',
272
- } as payload;
272
+ };
273
273
  await this.pushTVChanges(payload);
274
274
  }
275
275
 
@@ -278,7 +278,7 @@ export class TV {
278
278
  commandType: 'command',
279
279
  parameter: 'default',
280
280
  command: 'Menu',
281
- } as payload;
281
+ };
282
282
  await this.pushTVChanges(payload);
283
283
  }
284
284
 
@@ -287,7 +287,7 @@ export class TV {
287
287
  commandType: 'command',
288
288
  parameter: 'default',
289
289
  command: 'Up',
290
- } as payload;
290
+ };
291
291
  await this.pushTVChanges(payload);
292
292
  }
293
293
 
@@ -296,7 +296,7 @@ export class TV {
296
296
  commandType: 'command',
297
297
  parameter: 'default',
298
298
  command: 'Down',
299
- } as payload;
299
+ };
300
300
  await this.pushTVChanges(payload);
301
301
  }
302
302
 
@@ -305,7 +305,7 @@ export class TV {
305
305
  commandType: 'command',
306
306
  parameter: 'default',
307
307
  command: 'Right',
308
- } as payload;
308
+ };
309
309
  await this.pushTVChanges(payload);
310
310
  }
311
311
 
@@ -314,7 +314,7 @@ export class TV {
314
314
  commandType: 'command',
315
315
  parameter: 'default',
316
316
  command: 'Left',
317
- } as payload;
317
+ };
318
318
  await this.pushTVChanges(payload);
319
319
  }
320
320
 
@@ -323,7 +323,7 @@ export class TV {
323
323
  commandType: 'command',
324
324
  parameter: 'default',
325
325
  command: 'volumeAdd',
326
- } as payload;
326
+ };
327
327
  await this.pushTVChanges(payload);
328
328
  }
329
329
 
@@ -332,11 +332,11 @@ export class TV {
332
332
  commandType: 'command',
333
333
  parameter: 'default',
334
334
  command: 'volumeSub',
335
- } as payload;
335
+ };
336
336
  await this.pushTVChanges(payload);
337
337
  }
338
338
 
339
- async pushTVChanges(payload: payload): Promise<void> {
339
+ async pushTVChanges(payload): Promise<void> {
340
340
  try {
341
341
  this.infoLog(
342
342
  `${this.device.remoteType}: ${this.accessory.displayName} Sending request to SwitchBot API. command: ${payload.command},` +
@@ -2,7 +2,7 @@ import https from 'https';
2
2
  import crypto from 'crypto';
3
3
  import { IncomingMessage } from 'http';
4
4
  import { SwitchBotPlatform } from '../platform';
5
- import { irDevicesConfig, irdevice, payload, HostDomain, DevicePath } from '../settings';
5
+ import { irDevicesConfig, irdevice, HostDomain, DevicePath } from '../settings';
6
6
  import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
7
7
 
8
8
  /**
@@ -90,7 +90,7 @@ export class VacuumCleaner {
90
90
  commandType: 'command',
91
91
  parameter: 'default',
92
92
  command: 'turnOn',
93
- } as payload;
93
+ };
94
94
  await this.pushChanges(payload);
95
95
  }
96
96
  }
@@ -101,12 +101,12 @@ export class VacuumCleaner {
101
101
  commandType: 'command',
102
102
  parameter: 'default',
103
103
  command: 'turnOff',
104
- } as payload;
104
+ };
105
105
  await this.pushChanges(payload);
106
106
  }
107
107
  }
108
108
 
109
- async pushChanges(payload: payload): Promise<void> {
109
+ async pushChanges(payload): Promise<void> {
110
110
  try {
111
111
  this.infoLog(
112
112
  `Vacuum Cleaner: ${this.accessory.displayName} Sending request to SwitchBot API. command: ${payload.command},` +