@switchbot/homebridge-switchbot 2.6.1 → 2.6.2-beta.0

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/.github/npm-version-script.js +81 -0
  2. package/dist/device/blindtilt.d.ts.map +1 -1
  3. package/dist/device/blindtilt.js +7 -6
  4. package/dist/device/blindtilt.js.map +1 -1
  5. package/dist/device/bot.d.ts.map +1 -1
  6. package/dist/device/bot.js +4 -3
  7. package/dist/device/bot.js.map +1 -1
  8. package/dist/device/ceilinglight.d.ts.map +1 -1
  9. package/dist/device/ceilinglight.js +13 -9
  10. package/dist/device/ceilinglight.js.map +1 -1
  11. package/dist/device/colorbulb.d.ts.map +1 -1
  12. package/dist/device/colorbulb.js +12 -8
  13. package/dist/device/colorbulb.js.map +1 -1
  14. package/dist/device/curtain.d.ts.map +1 -1
  15. package/dist/device/curtain.js +4 -3
  16. package/dist/device/curtain.js.map +1 -1
  17. package/dist/device/humidifier.d.ts.map +1 -1
  18. package/dist/device/humidifier.js +9 -6
  19. package/dist/device/humidifier.js.map +1 -1
  20. package/dist/device/lightstrip.d.ts.map +1 -1
  21. package/dist/device/lightstrip.js +9 -6
  22. package/dist/device/lightstrip.js.map +1 -1
  23. package/dist/device/lock.d.ts.map +1 -1
  24. package/dist/device/lock.js +3 -2
  25. package/dist/device/lock.js.map +1 -1
  26. package/dist/device/plug.d.ts.map +1 -1
  27. package/dist/device/plug.js +3 -2
  28. package/dist/device/plug.js.map +1 -1
  29. package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
  30. package/dist/device/robotvacuumcleaner.js +3 -2
  31. package/dist/device/robotvacuumcleaner.js.map +1 -1
  32. package/dist/irdevice/airconditioner.d.ts +1 -1
  33. package/dist/irdevice/airconditioner.d.ts.map +1 -1
  34. package/dist/irdevice/airconditioner.js +9 -8
  35. package/dist/irdevice/airconditioner.js.map +1 -1
  36. package/dist/irdevice/airpurifier.d.ts +1 -1
  37. package/dist/irdevice/airpurifier.d.ts.map +1 -1
  38. package/dist/irdevice/airpurifier.js +9 -8
  39. package/dist/irdevice/airpurifier.js.map +1 -1
  40. package/dist/irdevice/camera.d.ts +1 -1
  41. package/dist/irdevice/camera.d.ts.map +1 -1
  42. package/dist/irdevice/camera.js +7 -6
  43. package/dist/irdevice/camera.js.map +1 -1
  44. package/dist/irdevice/fan.d.ts +1 -1
  45. package/dist/irdevice/fan.d.ts.map +1 -1
  46. package/dist/irdevice/fan.js +13 -12
  47. package/dist/irdevice/fan.js.map +1 -1
  48. package/dist/irdevice/light.d.ts +1 -1
  49. package/dist/irdevice/light.d.ts.map +1 -1
  50. package/dist/irdevice/light.js +11 -10
  51. package/dist/irdevice/light.js.map +1 -1
  52. package/dist/irdevice/other.d.ts +1 -1
  53. package/dist/irdevice/other.d.ts.map +1 -1
  54. package/dist/irdevice/other.js +7 -6
  55. package/dist/irdevice/other.js.map +1 -1
  56. package/dist/irdevice/tv.d.ts +1 -1
  57. package/dist/irdevice/tv.d.ts.map +1 -1
  58. package/dist/irdevice/tv.js +25 -24
  59. package/dist/irdevice/tv.js.map +1 -1
  60. package/dist/irdevice/vacuumcleaner.d.ts +1 -1
  61. package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
  62. package/dist/irdevice/vacuumcleaner.js +7 -6
  63. package/dist/irdevice/vacuumcleaner.js.map +1 -1
  64. package/dist/irdevice/waterheater.d.ts +1 -1
  65. package/dist/irdevice/waterheater.d.ts.map +1 -1
  66. package/dist/irdevice/waterheater.js +7 -6
  67. package/dist/irdevice/waterheater.js.map +1 -1
  68. package/dist/settings.d.ts +0 -8
  69. package/dist/settings.d.ts.map +1 -1
  70. package/dist/settings.js +1 -9
  71. package/dist/settings.js.map +1 -1
  72. package/nodemon.json +1 -1
  73. package/package.json +1 -1
  74. package/src/device/blindtilt.ts +7 -6
  75. package/src/device/bot.ts +4 -3
  76. package/src/device/ceilinglight.ts +13 -9
  77. package/src/device/colorbulb.ts +12 -8
  78. package/src/device/curtain.ts +4 -3
  79. package/src/device/humidifier.ts +9 -6
  80. package/src/device/lightstrip.ts +9 -6
  81. package/src/device/lock.ts +3 -2
  82. package/src/device/plug.ts +3 -2
  83. package/src/device/robotvacuumcleaner.ts +3 -2
  84. package/src/irdevice/airconditioner.ts +9 -8
  85. package/src/irdevice/airpurifier.ts +9 -8
  86. package/src/irdevice/camera.ts +7 -6
  87. package/src/irdevice/fan.ts +13 -12
  88. package/src/irdevice/light.ts +11 -10
  89. package/src/irdevice/other.ts +7 -6
  90. package/src/irdevice/tv.ts +25 -24
  91. package/src/irdevice/vacuumcleaner.ts +7 -6
  92. package/src/irdevice/waterheater.ts +7 -6
  93. package/src/settings.ts +0 -10
@@ -227,12 +227,12 @@ export class TV {
227
227
  if (this.Active === this.platform.Characteristic.Active.ACTIVE && !this.disablePushOn) {
228
228
  const commandType: string = await this.commandType();
229
229
  const command: string = await this.commandOn();
230
- const body = JSON.stringify({
230
+ const bodyChange = JSON.stringify({
231
231
  'command': command,
232
232
  'parameter': 'default',
233
233
  'commandType': commandType,
234
234
  });
235
- await this.pushTVChanges(body);
235
+ await this.pushTVChanges(bodyChange);
236
236
  }
237
237
  }
238
238
 
@@ -242,129 +242,130 @@ export class TV {
242
242
  if (this.Active === this.platform.Characteristic.Active.INACTIVE && !this.disablePushOff) {
243
243
  const commandType: string = await this.commandType();
244
244
  const command: string = await this.commandOff();
245
- const body = JSON.stringify({
245
+ const bodyChange = JSON.stringify({
246
246
  'command': command,
247
247
  'parameter': 'default',
248
248
  'commandType': commandType,
249
249
  });
250
- await this.pushTVChanges(body);
250
+ await this.pushTVChanges(bodyChange);
251
251
  }
252
252
  }
253
253
 
254
254
  async pushOkChanges(): Promise<void> {
255
255
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushOkChanges disablePushDetail: ${this.disablePushDetail}`);
256
256
  if (!this.disablePushDetail) {
257
- const body = JSON.stringify({
257
+ const bodyChange = JSON.stringify({
258
258
  'command': 'Ok',
259
259
  'parameter': 'default',
260
260
  'commandType': 'command',
261
261
  });
262
- await this.pushTVChanges(body);
262
+ await this.pushTVChanges(bodyChange);
263
263
  }
264
264
  }
265
265
 
266
266
  async pushBackChanges(): Promise<void> {
267
267
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushBackChanges disablePushDetail: ${this.disablePushDetail}`);
268
268
  if (!this.disablePushDetail) {
269
- const body = JSON.stringify({
269
+ const bodyChange = JSON.stringify({
270
270
  'command': 'Back',
271
271
  'parameter': 'default',
272
272
  'commandType': 'command',
273
273
  });
274
- await this.pushTVChanges(body);
274
+ await this.pushTVChanges(bodyChange);
275
275
  }
276
276
  }
277
277
 
278
278
  async pushMenuChanges(): Promise<void> {
279
279
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushMenuChanges disablePushDetail: ${this.disablePushDetail}`);
280
280
  if (!this.disablePushDetail) {
281
- const body = JSON.stringify({
281
+ const bodyChange = JSON.stringify({
282
282
  'command': 'Menu',
283
283
  'parameter': 'default',
284
284
  'commandType': 'command',
285
285
  });
286
- await this.pushTVChanges(body);
286
+ await this.pushTVChanges(bodyChange);
287
287
  }
288
288
  }
289
289
 
290
290
  async pushUpChanges(): Promise<void> {
291
291
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushUpChanges disablePushDetail: ${this.disablePushDetail}`);
292
292
  if (!this.disablePushDetail) {
293
- const body = JSON.stringify({
293
+ const bodyChange = JSON.stringify({
294
294
  'command': 'Up',
295
295
  'parameter': 'default',
296
296
  'commandType': 'command',
297
297
  });
298
- await this.pushTVChanges(body);
298
+ await this.pushTVChanges(bodyChange);
299
299
  }
300
300
  }
301
301
 
302
302
  async pushDownChanges(): Promise<void> {
303
303
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushDownChanges disablePushDetail: ${this.disablePushDetail}`);
304
304
  if (!this.disablePushDetail) {
305
- const body = JSON.stringify({
305
+ const bodyChange = JSON.stringify({
306
306
  'command': 'Down',
307
307
  'parameter': 'default',
308
308
  'commandType': 'command',
309
309
  });
310
- await this.pushTVChanges(body);
310
+ await this.pushTVChanges(bodyChange);
311
311
  }
312
312
  }
313
313
 
314
314
  async pushRightChanges(): Promise<void> {
315
315
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushRightChanges disablePushDetail: ${this.disablePushDetail}`);
316
316
  if (!this.disablePushDetail) {
317
- const body = JSON.stringify({
317
+ const bodyChange = JSON.stringify({
318
318
  'command': 'Right',
319
319
  'parameter': 'default',
320
320
  'commandType': 'command',
321
321
  });
322
- await this.pushTVChanges(body);
322
+ await this.pushTVChanges(bodyChange);
323
323
  }
324
324
  }
325
325
 
326
326
  async pushLeftChanges(): Promise<void> {
327
327
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushLeftChanges disablePushDetail: ${this.disablePushDetail}`);
328
328
  if (!this.disablePushDetail) {
329
- const body = JSON.stringify({
329
+ const bodyChange = JSON.stringify({
330
330
  'command': 'Left',
331
331
  'parameter': 'default',
332
332
  'commandType': 'command',
333
333
  });
334
- await this.pushTVChanges(body);
334
+ await this.pushTVChanges(bodyChange);
335
335
  }
336
336
  }
337
337
 
338
338
  async pushVolumeUpChanges(): Promise<void> {
339
339
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushVolumeUpChanges disablePushDetail: ${this.disablePushDetail}`);
340
340
  if (!this.disablePushDetail) {
341
- const body = JSON.stringify({
341
+ const bodyChange = JSON.stringify({
342
342
  'command': 'volumeAdd',
343
343
  'parameter': 'default',
344
344
  'commandType': 'command',
345
345
  });
346
- await this.pushTVChanges(body);
346
+ await this.pushTVChanges(bodyChange);
347
347
  }
348
348
  }
349
349
 
350
350
  async pushVolumeDownChanges(): Promise<void> {
351
351
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushVolumeDownChanges disablePushDetail: ${this.disablePushDetail}`);
352
352
  if (!this.disablePushDetail) {
353
- const body = JSON.stringify({
353
+ const bodyChange = JSON.stringify({
354
354
  'command': 'volumeSub',
355
355
  'parameter': 'default',
356
356
  'commandType': 'command',
357
357
  });
358
- await this.pushTVChanges(body);
358
+ await this.pushTVChanges(bodyChange);
359
359
  }
360
360
  }
361
361
 
362
- async pushTVChanges(body: any): Promise<void> {
362
+ async pushTVChanges(bodyChange: any): Promise<void> {
363
363
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushTVChanges`);
364
364
  if (this.device.connectionType === 'OpenAPI') {
365
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${body},`);
365
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
366
366
  try {
367
367
  const { body, statusCode, headers } = await request(`${Devices}/${this.device.deviceId}/commands`, {
368
+ body: bodyChange,
368
369
  method: 'POST',
369
370
  headers: this.platform.generateHeaders(),
370
371
  });
@@ -81,12 +81,12 @@ export class VacuumCleaner {
81
81
  if (this.On && !this.disablePushOn) {
82
82
  const commandType: string = await this.commandType();
83
83
  const command: string = await this.commandOn();
84
- const body = JSON.stringify({
84
+ const bodyChange = JSON.stringify({
85
85
  'command': command,
86
86
  'parameter': 'default',
87
87
  'commandType': commandType,
88
88
  });
89
- await this.pushChanges(body);
89
+ await this.pushChanges(bodyChange);
90
90
  }
91
91
  }
92
92
 
@@ -96,21 +96,22 @@ export class VacuumCleaner {
96
96
  if (!this.On && !this.disablePushOff) {
97
97
  const commandType: string = await this.commandType();
98
98
  const command: string = await this.commandOff();
99
- const body = JSON.stringify({
99
+ const bodyChange = JSON.stringify({
100
100
  'command': command,
101
101
  'parameter': 'default',
102
102
  'commandType': commandType,
103
103
  });
104
- await this.pushChanges(body);
104
+ await this.pushChanges(bodyChange);
105
105
  }
106
106
  }
107
107
 
108
- async pushChanges(body: any): Promise<void> {
108
+ async pushChanges(bodyChange: any): Promise<void> {
109
109
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushChanges`);
110
110
  if (this.device.connectionType === 'OpenAPI') {
111
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${body},`);
111
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
112
112
  try {
113
113
  const { body, statusCode, headers } = await request(`${Devices}/${this.device.deviceId}/commands`, {
114
+ body: bodyChange,
114
115
  method: 'POST',
115
116
  headers: this.platform.generateHeaders(),
116
117
  });
@@ -86,12 +86,12 @@ export class WaterHeater {
86
86
  if (this.Active === this.platform.Characteristic.Active.ACTIVE && !this.disablePushOn) {
87
87
  const commandType: string = await this.commandType();
88
88
  const command: string = await this.commandOn();
89
- const body = JSON.stringify({
89
+ const bodyChange = JSON.stringify({
90
90
  'command': command,
91
91
  'parameter': 'default',
92
92
  'commandType': commandType,
93
93
  });
94
- await this.pushChanges(body);
94
+ await this.pushChanges(bodyChange);
95
95
  }
96
96
  }
97
97
 
@@ -101,21 +101,22 @@ export class WaterHeater {
101
101
  if (this.Active === this.platform.Characteristic.Active.INACTIVE && !this.disablePushOff) {
102
102
  const commandType: string = await this.commandType();
103
103
  const command: string = await this.commandOff();
104
- const body = JSON.stringify({
104
+ const bodyChange = JSON.stringify({
105
105
  'command': command,
106
106
  'parameter': 'default',
107
107
  'commandType': commandType,
108
108
  });
109
- await this.pushChanges(body);
109
+ await this.pushChanges(bodyChange);
110
110
  }
111
111
  }
112
112
 
113
- async pushChanges(body: any): Promise<void> {
113
+ async pushChanges(bodyChange: any): Promise<void> {
114
114
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushChanges`);
115
115
  if (this.device.connectionType === 'OpenAPI') {
116
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${body},`);
116
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
117
117
  try {
118
118
  const { body, statusCode, headers } = await request(`${Devices}/${this.device.deviceId}/commands`, {
119
+ body: bodyChange,
119
120
  method: 'POST',
120
121
  headers: this.platform.generateHeaders(),
121
122
  });
package/src/settings.ts CHANGED
@@ -16,16 +16,6 @@ export const PLUGIN_NAME = '@switchbot/homebridge-switchbot';
16
16
  */
17
17
  export const Devices = 'https://api.switch-bot.com/v1.1/devices';
18
18
 
19
- /**
20
- * This is the main url used to access SwitchBot API
21
- */
22
- export const HostDomain = 'api.switch-bot.com';
23
-
24
- /**
25
- * This is the main url used to access SwitchBot API
26
- */
27
- export const DevicePath = '/v1.1/devices';
28
-
29
19
  //Config
30
20
  export interface SwitchBotPlatformConfig extends PlatformConfig {
31
21
  credentials?: credentials;