@switchbot/homebridge-switchbot 2.0.1-beta.0 → 2.1.0-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 (50) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/config.schema.json +2 -2
  3. package/dist/irdevice/airconditioner.d.ts.map +1 -1
  4. package/dist/irdevice/airconditioner.js.map +1 -1
  5. package/dist/irdevice/airpurifier.d.ts +3 -0
  6. package/dist/irdevice/airpurifier.d.ts.map +1 -1
  7. package/dist/irdevice/airpurifier.js +38 -4
  8. package/dist/irdevice/airpurifier.js.map +1 -1
  9. package/dist/irdevice/camera.d.ts +3 -0
  10. package/dist/irdevice/camera.d.ts.map +1 -1
  11. package/dist/irdevice/camera.js +38 -4
  12. package/dist/irdevice/camera.js.map +1 -1
  13. package/dist/irdevice/fan.d.ts +3 -0
  14. package/dist/irdevice/fan.d.ts.map +1 -1
  15. package/dist/irdevice/fan.js +38 -4
  16. package/dist/irdevice/fan.js.map +1 -1
  17. package/dist/irdevice/light.d.ts +3 -0
  18. package/dist/irdevice/light.d.ts.map +1 -1
  19. package/dist/irdevice/light.js +38 -4
  20. package/dist/irdevice/light.js.map +1 -1
  21. package/dist/irdevice/other.d.ts +3 -0
  22. package/dist/irdevice/other.d.ts.map +1 -1
  23. package/dist/irdevice/other.js +50 -36
  24. package/dist/irdevice/other.js.map +1 -1
  25. package/dist/irdevice/tv.d.ts +3 -0
  26. package/dist/irdevice/tv.d.ts.map +1 -1
  27. package/dist/irdevice/tv.js +38 -4
  28. package/dist/irdevice/tv.js.map +1 -1
  29. package/dist/irdevice/vacuumcleaner.d.ts +3 -0
  30. package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
  31. package/dist/irdevice/vacuumcleaner.js +38 -4
  32. package/dist/irdevice/vacuumcleaner.js.map +1 -1
  33. package/dist/irdevice/waterheater.d.ts +3 -0
  34. package/dist/irdevice/waterheater.d.ts.map +1 -1
  35. package/dist/irdevice/waterheater.js +38 -4
  36. package/dist/irdevice/waterheater.js.map +1 -1
  37. package/dist/settings.d.ts +0 -2
  38. package/dist/settings.d.ts.map +1 -1
  39. package/dist/settings.js.map +1 -1
  40. package/package.json +1 -1
  41. package/src/irdevice/airconditioner.ts +0 -2
  42. package/src/irdevice/airpurifier.ts +38 -4
  43. package/src/irdevice/camera.ts +38 -4
  44. package/src/irdevice/fan.ts +38 -4
  45. package/src/irdevice/light.ts +38 -4
  46. package/src/irdevice/other.ts +50 -32
  47. package/src/irdevice/tv.ts +38 -4
  48. package/src/irdevice/vacuumcleaner.ts +38 -4
  49. package/src/irdevice/waterheater.ts +38 -4
  50. package/src/settings.ts +0 -2
@@ -167,20 +167,24 @@ export class Fan {
167
167
  */
168
168
  async pushFanOnChanges(): Promise<void> {
169
169
  if (this.Active !== 1) {
170
+ const commandType: string = await this.commandType();
171
+ const command: string = await this.commandOn();
170
172
  const body = superStringify({
171
- 'command': 'turnOn',
173
+ 'command': command,
172
174
  'parameter': 'default',
173
- 'commandType': 'command',
175
+ 'commandType': commandType,
174
176
  });
175
177
  await this.pushTVChanges(body);
176
178
  }
177
179
  }
178
180
 
179
181
  async pushFanOffChanges(): Promise<void> {
182
+ const commandType: string = await this.commandType();
183
+ const command: string = await this.commandOff();
180
184
  const body = superStringify({
181
- 'command': 'turnOff',
185
+ 'command': command,
182
186
  'parameter': 'default',
183
- 'commandType': 'command',
187
+ 'commandType': commandType,
184
188
  });
185
189
  await this.pushTVChanges(body);
186
190
  }
@@ -289,6 +293,36 @@ export class Fan {
289
293
  }
290
294
  }
291
295
 
296
+ async commandType() {
297
+ let commandType: string;
298
+ if (this.device.customize) {
299
+ commandType = 'customize';
300
+ } else {
301
+ commandType = 'command';
302
+ }
303
+ return commandType;
304
+ }
305
+
306
+ async commandOn() {
307
+ let command: string;
308
+ if (this.device.customize && this.device.customOn) {
309
+ command = this.device.customOn;
310
+ } else {
311
+ command = 'turnOn';
312
+ }
313
+ return command;
314
+ }
315
+
316
+ async commandOff() {
317
+ let command: string;
318
+ if (this.device.customize && this.device.customOn) {
319
+ command = this.device.customOn;
320
+ } else {
321
+ command = 'turnOff';
322
+ }
323
+ return command;
324
+ }
325
+
292
326
  async statusCode({ res }: { res: IncomingMessage }): Promise<void> {
293
327
  switch (res.statusCode) {
294
328
  case 151:
@@ -77,10 +77,12 @@ export class Light {
77
77
  */
78
78
  async pushLightOnChanges(): Promise<void> {
79
79
  if (this.On) {
80
+ const commandType: string = await this.commandType();
81
+ const command: string = await this.commandOn();
80
82
  const body = superStringify({
81
- 'command': 'turnOn',
83
+ 'command': command,
82
84
  'parameter': 'default',
83
- 'commandType': 'command',
85
+ 'commandType': commandType,
84
86
  });
85
87
  await this.pushChanges(body);
86
88
  }
@@ -88,10 +90,12 @@ export class Light {
88
90
 
89
91
  async pushLightOffChanges(): Promise<void> {
90
92
  if (!this.On) {
93
+ const commandType: string = await this.commandType();
94
+ const command: string = await this.commandOff();
91
95
  const body = superStringify({
92
- 'command': 'turnOff',
96
+ 'command': command,
93
97
  'parameter': 'default',
94
- 'commandType': 'command',
98
+ 'commandType': commandType,
95
99
  });
96
100
  await this.pushChanges(body);
97
101
  }
@@ -179,6 +183,36 @@ export class Light {
179
183
  }
180
184
  }
181
185
 
186
+ async commandType() {
187
+ let commandType: string;
188
+ if (this.device.customize) {
189
+ commandType = 'customize';
190
+ } else {
191
+ commandType = 'command';
192
+ }
193
+ return commandType;
194
+ }
195
+
196
+ async commandOn() {
197
+ let command: string;
198
+ if (this.device.customize && this.device.customOn) {
199
+ command = this.device.customOn;
200
+ } else {
201
+ command = 'turnOn';
202
+ }
203
+ return command;
204
+ }
205
+
206
+ async commandOff() {
207
+ let command: string;
208
+ if (this.device.customize && this.device.customOn) {
209
+ command = this.device.customOn;
210
+ } else {
211
+ command = 'turnOff';
212
+ }
213
+ return command;
214
+ }
215
+
182
216
  async statusCode({ res }: { res: IncomingMessage }): Promise<void> {
183
217
  switch (res.statusCode) {
184
218
  case 151:
@@ -84,22 +84,16 @@ export class Others {
84
84
  * Other - "command" "channelSub" "default" = previous channel
85
85
  */
86
86
  async pushOnChanges(): Promise<void> {
87
- if (this.platform.config.options) {
88
- if (this.device.other) {
89
- if (this.device.other.commandOn) {
90
- if (!this.Active) {
91
- const body = superStringify({
92
- 'command': `${this.device.other.commandOn}`,
93
- 'parameter': 'default',
94
- 'commandType': 'customize',
95
- });
96
- await this.pushChanges(body);
97
- }
98
- } else {
99
- this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} On Command not set, commandOn: ${this.device.other.commandOn}`);
100
- }
101
- } else {
102
- this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} On Command not set, other: ${this.device.other}`);
87
+ if (this.device.customize) {
88
+ if (!this.Active) {
89
+ const commandType: string = await this.commandType();
90
+ const command: string = await this.commandOn();
91
+ const body = superStringify({
92
+ 'command': command,
93
+ 'parameter': 'default',
94
+ 'commandType': commandType,
95
+ });
96
+ await this.pushChanges(body);
103
97
  }
104
98
  } else {
105
99
  this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} On Command not set`);
@@ -107,22 +101,16 @@ export class Others {
107
101
  }
108
102
 
109
103
  async pushOffChanges(): Promise<void> {
110
- if (this.platform.config.options) {
111
- if (this.device.other) {
112
- if (this.device.other.commandOff) {
113
- if (this.Active) {
114
- const body = superStringify({
115
- 'command': `${this.device.other.commandOff}`,
116
- 'parameter': 'default',
117
- 'commandType': 'customize',
118
- });
119
- await this.pushChanges(body);
120
- }
121
- } else {
122
- this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Off Command not set, commandOff: ${this.device.other.commandOff}`);
123
- }
124
- } else {
125
- this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Off Command not set, other: ${this.device.other}`);
104
+ if (this.device.customize) {
105
+ if (this.Active) {
106
+ const commandType: string = await this.commandType();
107
+ const command: string = await this.commandOff();
108
+ const body = superStringify({
109
+ 'command': command,
110
+ 'parameter': 'default',
111
+ 'commandType': commandType,
112
+ });
113
+ await this.pushChanges(body);
126
114
  }
127
115
  } else {
128
116
  this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Off Command not set.`);
@@ -191,6 +179,36 @@ export class Others {
191
179
  }
192
180
  }
193
181
 
182
+ async commandType() {
183
+ let commandType: string;
184
+ if (this.device.customize) {
185
+ commandType = 'customize';
186
+ } else {
187
+ commandType = 'command';
188
+ }
189
+ return commandType;
190
+ }
191
+
192
+ async commandOn() {
193
+ let command: string;
194
+ if (this.device.customize && this.device.customOn) {
195
+ command = this.device.customOn;
196
+ } else {
197
+ command = 'turnOn';
198
+ }
199
+ return command;
200
+ }
201
+
202
+ async commandOff() {
203
+ let command: string;
204
+ if (this.device.customize && this.device.customOn) {
205
+ command = this.device.customOn;
206
+ } else {
207
+ command = 'turnOff';
208
+ }
209
+ return command;
210
+ }
211
+
194
212
  async statusCode({ res }: { res: IncomingMessage }): Promise<void> {
195
213
  switch (res.statusCode) {
196
214
  case 151:
@@ -221,20 +221,24 @@ export class TV {
221
221
  */
222
222
  async pushTvOnChanges(): Promise<void> {
223
223
  if (this.Active !== 1) {
224
+ const commandType: string = await this.commandType();
225
+ const command: string = await this.commandOn();
224
226
  const body = superStringify({
225
- 'command': 'turnOn',
227
+ 'command': command,
226
228
  'parameter': 'default',
227
- 'commandType': 'command',
229
+ 'commandType': commandType,
228
230
  });
229
231
  await this.pushTVChanges(body);
230
232
  }
231
233
  }
232
234
 
233
235
  async pushTvOffChanges(): Promise<void> {
236
+ const commandType: string = await this.commandType();
237
+ const command: string = await this.commandOff();
234
238
  const body = superStringify({
235
- 'command': 'turnOff',
239
+ 'command': command,
236
240
  'parameter': 'default',
237
- 'commandType': 'command',
241
+ 'commandType': commandType,
238
242
  });
239
243
  await this.pushTVChanges(body);
240
244
  }
@@ -392,6 +396,36 @@ export class TV {
392
396
  }
393
397
  }
394
398
 
399
+ async commandType() {
400
+ let commandType: string;
401
+ if (this.device.customize) {
402
+ commandType = 'customize';
403
+ } else {
404
+ commandType = 'command';
405
+ }
406
+ return commandType;
407
+ }
408
+
409
+ async commandOn() {
410
+ let command: string;
411
+ if (this.device.customize && this.device.customOn) {
412
+ command = this.device.customOn;
413
+ } else {
414
+ command = 'turnOn';
415
+ }
416
+ return command;
417
+ }
418
+
419
+ async commandOff() {
420
+ let command: string;
421
+ if (this.device.customize && this.device.customOn) {
422
+ command = this.device.customOn;
423
+ } else {
424
+ command = 'turnOff';
425
+ }
426
+ return command;
427
+ }
428
+
395
429
  async statusCode({ res }: { res: IncomingMessage }): Promise<void> {
396
430
  switch (res.statusCode) {
397
431
  case 151:
@@ -73,10 +73,12 @@ export class VacuumCleaner {
73
73
  */
74
74
  async pushOnChanges(): Promise<void> {
75
75
  if (this.On) {
76
+ const commandType: string = await this.commandType();
77
+ const command: string = await this.commandOn();
76
78
  const body = superStringify({
77
- 'command': 'turnOn',
79
+ 'command': command,
78
80
  'parameter': 'default',
79
- 'commandType': 'command',
81
+ 'commandType': commandType,
80
82
  });
81
83
  await this.pushChanges(body);
82
84
  }
@@ -84,10 +86,12 @@ export class VacuumCleaner {
84
86
 
85
87
  async pushOffChanges(): Promise<void> {
86
88
  if (!this.On) {
89
+ const commandType: string = await this.commandType();
90
+ const command: string = await this.commandOff();
87
91
  const body = superStringify({
88
- 'command': 'turnOff',
92
+ 'command': command,
89
93
  'parameter': 'default',
90
- 'commandType': 'command',
94
+ 'commandType': commandType,
91
95
  });
92
96
  await this.pushChanges(body);
93
97
  }
@@ -157,6 +161,36 @@ export class VacuumCleaner {
157
161
  }
158
162
  }
159
163
 
164
+ async commandType() {
165
+ let commandType: string;
166
+ if (this.device.customize) {
167
+ commandType = 'customize';
168
+ } else {
169
+ commandType = 'command';
170
+ }
171
+ return commandType;
172
+ }
173
+
174
+ async commandOn() {
175
+ let command: string;
176
+ if (this.device.customize && this.device.customOn) {
177
+ command = this.device.customOn;
178
+ } else {
179
+ command = 'turnOn';
180
+ }
181
+ return command;
182
+ }
183
+
184
+ async commandOff() {
185
+ let command: string;
186
+ if (this.device.customize && this.device.customOn) {
187
+ command = this.device.customOn;
188
+ } else {
189
+ command = 'turnOff';
190
+ }
191
+ return command;
192
+ }
193
+
160
194
  async statusCode({ res }: { res: IncomingMessage }): Promise<void> {
161
195
  switch (res.statusCode) {
162
196
  case 151:
@@ -78,10 +78,12 @@ export class WaterHeater {
78
78
  */
79
79
  async pushWaterHeaterOnChanges(): Promise<void> {
80
80
  if (this.Active !== 1) {
81
+ const commandType: string = await this.commandType();
82
+ const command: string = await this.commandOn();
81
83
  const body = superStringify({
82
- 'command': 'turnOn',
84
+ 'command': command,
83
85
  'parameter': 'default',
84
- 'commandType': 'command',
86
+ 'commandType': commandType,
85
87
  });
86
88
  await this.pushChanges(body);
87
89
  }
@@ -89,10 +91,12 @@ export class WaterHeater {
89
91
 
90
92
  async pushWaterHeaterOffChanges(): Promise<void> {
91
93
  if (this.Active !== 0) {
94
+ const commandType: string = await this.commandType();
95
+ const command: string = await this.commandOff();
92
96
  const body = superStringify({
93
- 'command': 'turnOff',
97
+ 'command': command,
94
98
  'parameter': 'default',
95
- 'commandType': 'command',
99
+ 'commandType': commandType,
96
100
  });
97
101
  await this.pushChanges(body);
98
102
  }
@@ -160,6 +164,36 @@ export class WaterHeater {
160
164
  }
161
165
  }
162
166
 
167
+ async commandType() {
168
+ let commandType: string;
169
+ if (this.device.customize) {
170
+ commandType = 'customize';
171
+ } else {
172
+ commandType = 'command';
173
+ }
174
+ return commandType;
175
+ }
176
+
177
+ async commandOn() {
178
+ let command: string;
179
+ if (this.device.customize && this.device.customOn) {
180
+ command = this.device.customOn;
181
+ } else {
182
+ command = 'turnOn';
183
+ }
184
+ return command;
185
+ }
186
+
187
+ async commandOff() {
188
+ let command: string;
189
+ if (this.device.customize && this.device.customOn) {
190
+ command = this.device.customOn;
191
+ } else {
192
+ command = 'turnOff';
193
+ }
194
+ return command;
195
+ }
196
+
163
197
  async statusCode({ res }: { res: IncomingMessage }): Promise<void> {
164
198
  switch (res.statusCode) {
165
199
  case 151:
package/src/settings.ts CHANGED
@@ -187,8 +187,6 @@ export type irtv = {
187
187
 
188
188
  export type other = {
189
189
  deviceType?: string;
190
- commandOn?: string;
191
- commandOff?: string;
192
190
  };
193
191
 
194
192
  //a list of physical devices.