@switchbot/homebridge-switchbot 2.1.4-beta.0 → 2.2.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 (58) hide show
  1. package/.github/labeler.yml +2 -2
  2. package/CHANGELOG.md +9 -0
  3. package/config.schema.json +30 -11
  4. package/dist/device/colorbulb.d.ts +6 -0
  5. package/dist/device/colorbulb.d.ts.map +1 -1
  6. package/dist/device/colorbulb.js +12 -10
  7. package/dist/device/colorbulb.js.map +1 -1
  8. package/dist/irdevice/airconditioner.d.ts +8 -4
  9. package/dist/irdevice/airconditioner.d.ts.map +1 -1
  10. package/dist/irdevice/airconditioner.js +45 -19
  11. package/dist/irdevice/airconditioner.js.map +1 -1
  12. package/dist/irdevice/airpurifier.d.ts +8 -1
  13. package/dist/irdevice/airpurifier.d.ts.map +1 -1
  14. package/dist/irdevice/airpurifier.js +35 -2
  15. package/dist/irdevice/airpurifier.js.map +1 -1
  16. package/dist/irdevice/camera.d.ts +8 -1
  17. package/dist/irdevice/camera.d.ts.map +1 -1
  18. package/dist/irdevice/camera.js +35 -2
  19. package/dist/irdevice/camera.js.map +1 -1
  20. package/dist/irdevice/fan.d.ts +8 -1
  21. package/dist/irdevice/fan.d.ts.map +1 -1
  22. package/dist/irdevice/fan.js +42 -11
  23. package/dist/irdevice/fan.js.map +1 -1
  24. package/dist/irdevice/light.d.ts +8 -1
  25. package/dist/irdevice/light.d.ts.map +1 -1
  26. package/dist/irdevice/light.js +35 -2
  27. package/dist/irdevice/light.js.map +1 -1
  28. package/dist/irdevice/other.d.ts +8 -1
  29. package/dist/irdevice/other.d.ts.map +1 -1
  30. package/dist/irdevice/other.js +35 -2
  31. package/dist/irdevice/other.js.map +1 -1
  32. package/dist/irdevice/tv.d.ts +8 -1
  33. package/dist/irdevice/tv.d.ts.map +1 -1
  34. package/dist/irdevice/tv.js +42 -11
  35. package/dist/irdevice/tv.js.map +1 -1
  36. package/dist/irdevice/vacuumcleaner.d.ts +8 -1
  37. package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
  38. package/dist/irdevice/vacuumcleaner.js +35 -2
  39. package/dist/irdevice/vacuumcleaner.js.map +1 -1
  40. package/dist/irdevice/waterheater.d.ts +8 -1
  41. package/dist/irdevice/waterheater.d.ts.map +1 -1
  42. package/dist/irdevice/waterheater.js +35 -2
  43. package/dist/irdevice/waterheater.js.map +1 -1
  44. package/dist/settings.d.ts +7 -6
  45. package/dist/settings.d.ts.map +1 -1
  46. package/dist/settings.js.map +1 -1
  47. package/package.json +3 -3
  48. package/src/device/colorbulb.ts +16 -9
  49. package/src/irdevice/airconditioner.ts +47 -21
  50. package/src/irdevice/airpurifier.ts +37 -3
  51. package/src/irdevice/camera.ts +37 -3
  52. package/src/irdevice/fan.ts +44 -12
  53. package/src/irdevice/light.ts +37 -3
  54. package/src/irdevice/other.ts +37 -3
  55. package/src/irdevice/tv.ts +44 -12
  56. package/src/irdevice/vacuumcleaner.ts +37 -3
  57. package/src/irdevice/waterheater.ts +37 -3
  58. package/src/settings.ts +8 -6
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "displayName": "Homebridge SwitchBot",
3
3
  "name": "@switchbot/homebridge-switchbot",
4
- "version": "2.1.4-beta.0",
4
+ "version": "2.2.0-beta.0",
5
5
  "description": "The [Homebridge](https://homebridge.io) SwitchBot plugin allows you to access your [SwitchBot](https://www.switch-bot.com) device(s) from HomeKit.",
6
6
  "author": "SwitchBot <support@wondertechlabs.com> (https://github.com/SwitchBot)",
7
7
  "license": "ISC",
@@ -72,7 +72,7 @@
72
72
  "eslint-plugin-prettier": "4.2.1",
73
73
  "homebridge": "^1.5.0",
74
74
  "nodemon": "^2.0.20",
75
- "npm-check-updates": "^16.3.11",
75
+ "npm-check-updates": "^16.3.13",
76
76
  "prettier": "2.7.1",
77
77
  "rimraf": "^3.0.2",
78
78
  "ts-node": "^10.9.1",
@@ -80,6 +80,6 @@
80
80
  },
81
81
  "optionalDependencies": {
82
82
  "@abandonware/noble": "^1.9.2-15",
83
- "node-switchbot": "^1.5.0"
83
+ "node-switchbot": "^1.6.0-beta.4"
84
84
  }
85
85
  }
@@ -40,6 +40,12 @@ export class ColorBulb {
40
40
  state: serviceData['state'];
41
41
  delay: serviceData['delay'];
42
42
  wifiRssi: serviceData['wifiRssi'];
43
+ brightnessBLE: serviceData['brightness'];
44
+ sequence: any;//serviceData['sequence'];
45
+ preset: any;//serviceData['preset'];
46
+ color_mode: any;//serviceData['color_mode'];
47
+ speed: any;//serviceData['speed'];
48
+ loop_index: any;//serviceData['loop_index'];
43
49
 
44
50
  // Config
45
51
  set_minStep?: number;
@@ -293,9 +299,9 @@ export class ColorBulb {
293
299
  async refreshStatus(): Promise<void> {
294
300
  if (!this.device.enableCloudService && this.OpenAPI) {
295
301
  this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} refreshStatus enableCloudService: ${this.device.enableCloudService}`);
296
- } else/*if (this.BLE) {
302
+ } else if (this.BLE) {
297
303
  await this.BLERefreshStatus();
298
- } else*/ if (this.OpenAPI && this.platform.config.credentials?.token) {
304
+ } else if (this.OpenAPI && this.platform.config.credentials?.token) {
299
305
  await this.openAPIRefreshStatus();
300
306
  } else {
301
307
  await this.offlineOff();
@@ -329,13 +335,14 @@ export class ColorBulb {
329
335
  + ` BLE Address Found: ${this.address}`);
330
336
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} serviceData: ${superStringify(ad.serviceData)}`);
331
337
  this.serviceData = ad.serviceData;
332
- //this.state = ad.serviceData.state;
333
- //this.delay = ad.serviceData.delay;
334
- //this.timer = ad.serviceData.timer;
335
- //this.syncUtcTime = ad.serviceData.syncUtcTime;
336
- //this.wifiRssi = ad.serviceData.wifiRssi;
337
- //this.overload = ad.serviceData.overload;
338
- //this.currentPower = ad.serviceData.currentPower;
338
+ this.state = ad.serviceData.state;
339
+ this.sequence = ad.serviceData.sequence_number;
340
+ this.brightnessBLE = ad.serviceData.brightness;
341
+ this.delay = ad.serviceData.delay;
342
+ this.preset = ad.serviceData.preset;
343
+ this.color_mode = ad.serviceData.color_mode;
344
+ this.speed = ad.serviceData.speed;
345
+ this.loop_index = ad.serviceData.loop_index;
339
346
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} serviceData: ${superStringify(ad.serviceData)}`);
340
347
  /*this.debugLog(
341
348
  `${this.device.deviceType}: ${this.accessory.displayName} state: ${ad.serviceData.state}, ` +
@@ -36,9 +36,10 @@ export class AirConditioner {
36
36
  static MODE_HEAT: number;
37
37
 
38
38
  // Config
39
+ allowPushOn?: boolean;
40
+ allowPushOff?: boolean;
39
41
  deviceLogging!: string;
40
42
  hide_automode?: boolean;
41
- pushOn?: boolean;
42
43
 
43
44
  private readonly valid12 = [1, 2];
44
45
  private readonly valid012 = [0, 1, 2];
@@ -47,8 +48,9 @@ export class AirConditioner {
47
48
  // default placeholders
48
49
  this.logs({ device });
49
50
  this.config({ device });
50
- this.pushOnChanges({ device });
51
51
  this.context({ device });
52
+ this.allowPushOnChanges({ device });
53
+ this.allowPushOffChanges({ device });
52
54
 
53
55
  // set accessory information
54
56
  accessory
@@ -163,7 +165,7 @@ export class AirConditioner {
163
165
  * AirConditioner: "command" "highSpeed" "default" = fan speed to high
164
166
  */
165
167
  async pushAirConditionerOnChanges(): Promise<void> {
166
- if (this.Active !== this.platform.Characteristic.Active.ACTIVE || this.pushOn) {
168
+ if (this.Active === this.platform.Characteristic.Active.INACTIVE || this.allowPushOn) {
167
169
  const commandType: string = await this.commandType();
168
170
  const command: string = await this.commandOn();
169
171
  const body = superStringify({
@@ -176,14 +178,16 @@ export class AirConditioner {
176
178
  }
177
179
 
178
180
  async pushAirConditionerOffChanges(): Promise<void> {
179
- const commandType: string = await this.commandType();
180
- const command: string = await this.commandOff();
181
- const body = superStringify({
182
- 'command': command,
183
- 'parameter': 'default',
184
- 'commandType': commandType,
185
- });
186
- await this.pushChanges(body);
181
+ if (this.Active === this.platform.Characteristic.Active.ACTIVE || this.allowPushOff) {
182
+ const commandType: string = await this.commandType();
183
+ const command: string = await this.commandOff();
184
+ const body = superStringify({
185
+ 'command': command,
186
+ 'parameter': 'default',
187
+ 'commandType': commandType,
188
+ });
189
+ await this.pushChanges(body);
190
+ }
187
191
  }
188
192
 
189
193
  async pushAirConditionerStatusChanges(): Promise<void> {
@@ -339,7 +343,7 @@ export class AirConditioner {
339
343
  this.pushAirConditionerOffChanges();
340
344
  } else {
341
345
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushAirConditionerOnChanges, Active: ${this.Active}`);
342
- if (this.pushOn) {
346
+ if (this.allowPushOn) {
343
347
  this.pushAirConditionerOnChanges();
344
348
  } else {
345
349
  this.pushAirConditionerStatusChanges();
@@ -561,6 +565,22 @@ export class AirConditioner {
561
565
  }
562
566
  }
563
567
 
568
+ async allowPushOnChanges({ device }: { device: irdevice & irDevicesConfig; }): Promise<void> {
569
+ if (device.allowPushOn) {
570
+ this.allowPushOn = true;
571
+ } else {
572
+ this.allowPushOn = false;
573
+ }
574
+ }
575
+
576
+ async allowPushOffChanges({ device }: { device: irdevice & irDevicesConfig; }): Promise<void> {
577
+ if (device.allowPushOff) {
578
+ this.allowPushOn = true;
579
+ } else {
580
+ this.allowPushOn = false;
581
+ }
582
+ }
583
+
564
584
  async commandType(): Promise<string> {
565
585
  let commandType: string;
566
586
  if (this.device.customize) {
@@ -682,6 +702,21 @@ export class AirConditioner {
682
702
  if (device.external !== undefined) {
683
703
  config['external'] = device.external;
684
704
  }
705
+ if (device.customOn !== undefined) {
706
+ config['customOn'] = device.customOn;
707
+ }
708
+ if (device.customOff !== undefined) {
709
+ config['customOff'] = device.customOff;
710
+ }
711
+ if (device.customize !== undefined) {
712
+ config['customize'] = device.customize;
713
+ }
714
+ if (device.allowPushOn !== undefined) {
715
+ config['allowPushOn'] = device.allowPushOn;
716
+ }
717
+ if (device.allowPushOff !== undefined) {
718
+ config['allowPushOff'] = device.allowPushOff;
719
+ }
685
720
  if (Object.entries(config).length !== 0) {
686
721
  this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Config: ${superStringify(config)}`);
687
722
  }
@@ -703,15 +738,6 @@ export class AirConditioner {
703
738
  }
704
739
  }
705
740
 
706
-
707
- async pushOnChanges({ device }: { device: irdevice & irDevicesConfig; }): Promise<void> {
708
- if (device.irair?.pushOn) {
709
- this.pushOn = true;
710
- } else {
711
- this.pushOn = false;
712
- }
713
- }
714
-
715
741
  /**
716
742
  * Logging for Device
717
743
  */
@@ -37,14 +37,17 @@ export class AirPurifier {
37
37
  static PURIFYING_AIR: number;
38
38
 
39
39
  // Config
40
+ allowPushOn?: boolean;
41
+ allowPushOff?: boolean;
40
42
  deviceLogging!: string;
41
- allowPush?: boolean;
42
43
 
43
44
  constructor(private readonly platform: SwitchBotPlatform, private accessory: PlatformAccessory, public device: irdevice & irDevicesConfig) {
44
45
  // default placeholders
45
46
  this.logs(device);
46
47
  this.config(device);
47
48
  this.context();
49
+ this.allowPushOnChanges({ device });
50
+ this.allowPushOffChanges({ device });
48
51
 
49
52
  // set accessory information
50
53
  accessory
@@ -131,7 +134,7 @@ export class AirPurifier {
131
134
  * AirPurifier: "command" "highSpeed" "default" = fan speed to high
132
135
  */
133
136
  async pushAirPurifierOnChanges(): Promise<void> {
134
- if (this.Active !== 1 || this.allowPush) {
137
+ if (this.Active !== 1) {
135
138
  const commandType: string = await this.commandType();
136
139
  const command: string = await this.commandOn();
137
140
  const body = superStringify({
@@ -146,7 +149,7 @@ export class AirPurifier {
146
149
  async pushAirPurifierOffChanges(): Promise<void> {
147
150
  const commandType: string = await this.commandType();
148
151
  const command: string = await this.commandOff();
149
- if (this.Active !== 0 || this.allowPush) {
152
+ if (this.Active !== 0) {
150
153
  const body = superStringify({
151
154
  'command': command,
152
155
  'parameter': 'default',
@@ -272,6 +275,22 @@ export class AirPurifier {
272
275
  }
273
276
  }
274
277
 
278
+ async allowPushOnChanges({ device }: { device: irdevice & irDevicesConfig; }): Promise<void> {
279
+ if (device.allowPushOn) {
280
+ this.allowPushOn = true;
281
+ } else {
282
+ this.allowPushOn = false;
283
+ }
284
+ }
285
+
286
+ async allowPushOffChanges({ device }: { device: irdevice & irDevicesConfig; }): Promise<void> {
287
+ if (device.allowPushOff) {
288
+ this.allowPushOn = true;
289
+ } else {
290
+ this.allowPushOn = false;
291
+ }
292
+ }
293
+
275
294
  async commandType(): Promise<string> {
276
295
  let commandType: string;
277
296
  if (this.device.customize) {
@@ -383,6 +402,21 @@ export class AirPurifier {
383
402
  if (device.external !== undefined) {
384
403
  config['external'] = device.external;
385
404
  }
405
+ if (device.customOn !== undefined) {
406
+ config['customOn'] = device.customOn;
407
+ }
408
+ if (device.customOff !== undefined) {
409
+ config['customOff'] = device.customOff;
410
+ }
411
+ if (device.customize !== undefined) {
412
+ config['customize'] = device.customize;
413
+ }
414
+ if (device.allowPushOn !== undefined) {
415
+ config['allowPushOn'] = device.allowPushOn;
416
+ }
417
+ if (device.allowPushOff !== undefined) {
418
+ config['allowPushOff'] = device.allowPushOff;
419
+ }
386
420
  if (Object.entries(config).length !== 0) {
387
421
  this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Config: ${superStringify(config)}`);
388
422
  }
@@ -19,14 +19,17 @@ export class Camera {
19
19
  On!: CharacteristicValue;
20
20
 
21
21
  // Config
22
+ allowPushOn?: boolean;
23
+ allowPushOff?: boolean;
22
24
  deviceLogging!: string;
23
- allowPush?: boolean;
24
25
 
25
26
  constructor(private readonly platform: SwitchBotPlatform, private accessory: PlatformAccessory, public device: irdevice & irDevicesConfig) {
26
27
  // default placeholders
27
28
  this.logs(device);
28
29
  this.config(device);
29
30
  this.context();
31
+ this.allowPushOnChanges({ device });
32
+ this.allowPushOffChanges({ device });
30
33
 
31
34
  // set accessory information
32
35
  accessory
@@ -81,7 +84,7 @@ export class Camera {
81
84
  * Camera - "command" "channelSub" "default" = previous channel
82
85
  */
83
86
  async pushOnChanges(): Promise<void> {
84
- if (this.On || this.allowPush) {
87
+ if (this.On) {
85
88
  const commandType: string = await this.commandType();
86
89
  const command: string = await this.commandOn();
87
90
  const body = superStringify({
@@ -96,7 +99,7 @@ export class Camera {
96
99
  async pushOffChanges(): Promise<void> {
97
100
  const commandType: string = await this.commandType();
98
101
  const command: string = await this.commandOff();
99
- if (!this.On || this.allowPush) {
102
+ if (!this.On) {
100
103
  const body = superStringify({
101
104
  'command': command,
102
105
  'parameter': 'default',
@@ -169,6 +172,22 @@ export class Camera {
169
172
  }
170
173
  }
171
174
 
175
+ async allowPushOnChanges({ device }: { device: irdevice & irDevicesConfig; }): Promise<void> {
176
+ if (device.allowPushOn) {
177
+ this.allowPushOn = true;
178
+ } else {
179
+ this.allowPushOn = false;
180
+ }
181
+ }
182
+
183
+ async allowPushOffChanges({ device }: { device: irdevice & irDevicesConfig; }): Promise<void> {
184
+ if (device.allowPushOff) {
185
+ this.allowPushOn = true;
186
+ } else {
187
+ this.allowPushOn = false;
188
+ }
189
+ }
190
+
172
191
  async commandType(): Promise<string> {
173
192
  let commandType: string;
174
193
  if (this.device.customize) {
@@ -272,6 +291,21 @@ export class Camera {
272
291
  if (device.external !== undefined) {
273
292
  config['external'] = device.external;
274
293
  }
294
+ if (device.customOn !== undefined) {
295
+ config['customOn'] = device.customOn;
296
+ }
297
+ if (device.customOff !== undefined) {
298
+ config['customOff'] = device.customOff;
299
+ }
300
+ if (device.customize !== undefined) {
301
+ config['customize'] = device.customize;
302
+ }
303
+ if (device.allowPushOn !== undefined) {
304
+ config['allowPushOn'] = device.allowPushOn;
305
+ }
306
+ if (device.allowPushOff !== undefined) {
307
+ config['allowPushOff'] = device.allowPushOff;
308
+ }
275
309
  if (Object.entries(config).length !== 0) {
276
310
  this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Config: ${superStringify(config)}`);
277
311
  }
@@ -29,14 +29,17 @@ export class Fan {
29
29
  minStep?: number;
30
30
  minValue?: number;
31
31
  maxValue?: number;
32
+ allowPushOn?: boolean;
33
+ allowPushOff?: boolean;
32
34
  deviceLogging!: string;
33
- allowPush?: boolean;
34
35
 
35
36
  constructor(private readonly platform: SwitchBotPlatform, private accessory: PlatformAccessory, public device: irdevice & irDevicesConfig) {
36
37
  // default placeholders
37
38
  this.logs(device);
38
39
  this.config(device);
39
40
  this.context();
41
+ this.allowPushOnChanges({ device });
42
+ this.allowPushOffChanges({ device });
40
43
 
41
44
  // set accessory information
42
45
  accessory
@@ -171,7 +174,7 @@ export class Fan {
171
174
  * Fan - "command" "highSpeed" "default" = fan speed to high
172
175
  */
173
176
  async pushFanOnChanges(): Promise<void> {
174
- if (this.Active !== 1 || this.allowPush) {
177
+ if (this.Active !== 1) {
175
178
  const commandType: string = await this.commandType();
176
179
  const command: string = await this.commandOn();
177
180
  const body = superStringify({
@@ -184,16 +187,14 @@ export class Fan {
184
187
  }
185
188
 
186
189
  async pushFanOffChanges(): Promise<void> {
187
- if (this.Active === 1 || this.allowPush) {
188
- const commandType: string = await this.commandType();
189
- const command: string = await this.commandOff();
190
- const body = superStringify({
191
- 'command': command,
192
- 'parameter': 'default',
193
- 'commandType': commandType,
194
- });
195
- await this.pushTVChanges(body);
196
- }
190
+ const commandType: string = await this.commandType();
191
+ const command: string = await this.commandOff();
192
+ const body = superStringify({
193
+ 'command': command,
194
+ 'parameter': 'default',
195
+ 'commandType': commandType,
196
+ });
197
+ await this.pushTVChanges(body);
197
198
  }
198
199
 
199
200
  async pushFanSpeedUpChanges(): Promise<void> {
@@ -300,6 +301,22 @@ export class Fan {
300
301
  }
301
302
  }
302
303
 
304
+ async allowPushOnChanges({ device }: { device: irdevice & irDevicesConfig; }): Promise<void> {
305
+ if (device.allowPushOn) {
306
+ this.allowPushOn = true;
307
+ } else {
308
+ this.allowPushOn = false;
309
+ }
310
+ }
311
+
312
+ async allowPushOffChanges({ device }: { device: irdevice & irDevicesConfig; }): Promise<void> {
313
+ if (device.allowPushOff) {
314
+ this.allowPushOn = true;
315
+ } else {
316
+ this.allowPushOn = false;
317
+ }
318
+ }
319
+
303
320
  async commandType(): Promise<string> {
304
321
  let commandType: string;
305
322
  if (this.device.customize) {
@@ -406,6 +423,21 @@ export class Fan {
406
423
  if (device.external !== undefined) {
407
424
  config['external'] = device.external;
408
425
  }
426
+ if (device.customOn !== undefined) {
427
+ config['customOn'] = device.customOn;
428
+ }
429
+ if (device.customOff !== undefined) {
430
+ config['customOff'] = device.customOff;
431
+ }
432
+ if (device.customize !== undefined) {
433
+ config['customize'] = device.customize;
434
+ }
435
+ if (device.allowPushOn !== undefined) {
436
+ config['allowPushOn'] = device.allowPushOn;
437
+ }
438
+ if (device.allowPushOff !== undefined) {
439
+ config['allowPushOff'] = device.allowPushOff;
440
+ }
409
441
  if (Object.entries(config).length !== 0) {
410
442
  this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Config: ${superStringify(config)}`);
411
443
  }
@@ -19,14 +19,17 @@ export class Light {
19
19
  On!: CharacteristicValue;
20
20
 
21
21
  // Config
22
+ allowPushOn?: boolean;
23
+ allowPushOff?: boolean;
22
24
  deviceLogging!: string;
23
- allowPush?: boolean;
24
25
 
25
26
  constructor(private readonly platform: SwitchBotPlatform, private accessory: PlatformAccessory, public device: irdevice & irDevicesConfig) {
26
27
  // default placeholders
27
28
  this.logs(device);
28
29
  this.config(device);
29
30
  this.context();
31
+ this.allowPushOnChanges({ device });
32
+ this.allowPushOffChanges({ device });
30
33
 
31
34
  // set accessory information
32
35
  accessory
@@ -81,7 +84,7 @@ export class Light {
81
84
  * Light - "command" "channelSub" "default" = previous channel
82
85
  */
83
86
  async pushLightOnChanges(): Promise<void> {
84
- if (this.On || this.allowPush) {
87
+ if (this.On) {
85
88
  const commandType: string = await this.commandType();
86
89
  const command: string = await this.commandOn();
87
90
  const body = superStringify({
@@ -94,7 +97,7 @@ export class Light {
94
97
  }
95
98
 
96
99
  async pushLightOffChanges(): Promise<void> {
97
- if (!this.On || this.allowPush) {
100
+ if (!this.On) {
98
101
  const commandType: string = await this.commandType();
99
102
  const command: string = await this.commandOff();
100
103
  const body = superStringify({
@@ -188,6 +191,22 @@ export class Light {
188
191
  }
189
192
  }
190
193
 
194
+ async allowPushOnChanges({ device }: { device: irdevice & irDevicesConfig; }): Promise<void> {
195
+ if (device.allowPushOn) {
196
+ this.allowPushOn = true;
197
+ } else {
198
+ this.allowPushOn = false;
199
+ }
200
+ }
201
+
202
+ async allowPushOffChanges({ device }: { device: irdevice & irDevicesConfig; }): Promise<void> {
203
+ if (device.allowPushOff) {
204
+ this.allowPushOn = true;
205
+ } else {
206
+ this.allowPushOn = false;
207
+ }
208
+ }
209
+
191
210
  async commandType(): Promise<string> {
192
211
  let commandType: string;
193
212
  if (this.device.customize) {
@@ -291,6 +310,21 @@ export class Light {
291
310
  if (device.external !== undefined) {
292
311
  config['external'] = device.external;
293
312
  }
313
+ if (device.customOn !== undefined) {
314
+ config['customOn'] = device.customOn;
315
+ }
316
+ if (device.customOff !== undefined) {
317
+ config['customOff'] = device.customOff;
318
+ }
319
+ if (device.customize !== undefined) {
320
+ config['customize'] = device.customize;
321
+ }
322
+ if (device.allowPushOn !== undefined) {
323
+ config['allowPushOn'] = device.allowPushOn;
324
+ }
325
+ if (device.allowPushOff !== undefined) {
326
+ config['allowPushOff'] = device.allowPushOff;
327
+ }
294
328
  if (Object.entries(config).length !== 0) {
295
329
  this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Config: ${superStringify(config)}`);
296
330
  }
@@ -19,9 +19,10 @@ export class Others {
19
19
  Active!: CharacteristicValue;
20
20
 
21
21
  // Config
22
+ allowPushOn?: boolean;
23
+ allowPushOff?: boolean;
22
24
  deviceLogging!: string;
23
25
  otherDeviceType?: string;
24
- allowPush?: boolean;
25
26
 
26
27
  constructor(private readonly platform: SwitchBotPlatform, private accessory: PlatformAccessory, public device: irdevice & irDevicesConfig) {
27
28
  // default placeholders
@@ -29,6 +30,8 @@ export class Others {
29
30
  this.deviceType(device);
30
31
  this.config(device);
31
32
  this.context();
33
+ this.allowPushOnChanges({ device });
34
+ this.allowPushOffChanges({ device });
32
35
 
33
36
  // set accessory information
34
37
  accessory
@@ -90,7 +93,7 @@ export class Others {
90
93
  */
91
94
  async pushOnChanges(): Promise<void> {
92
95
  if (this.device.customize) {
93
- if (!this.Active || this.allowPush) {
96
+ if (!this.Active) {
94
97
  const commandType: string = await this.commandType();
95
98
  const command: string = await this.commandOn();
96
99
  const body = superStringify({
@@ -107,7 +110,7 @@ export class Others {
107
110
 
108
111
  async pushOffChanges(): Promise<void> {
109
112
  if (this.device.customize) {
110
- if (this.Active || this.allowPush) {
113
+ if (this.Active) {
111
114
  const commandType: string = await this.commandType();
112
115
  const command: string = await this.commandOff();
113
116
  const body = superStringify({
@@ -184,6 +187,22 @@ export class Others {
184
187
  }
185
188
  }
186
189
 
190
+ async allowPushOnChanges({ device }: { device: irdevice & irDevicesConfig; }): Promise<void> {
191
+ if (device.allowPushOn) {
192
+ this.allowPushOn = true;
193
+ } else {
194
+ this.allowPushOn = false;
195
+ }
196
+ }
197
+
198
+ async allowPushOffChanges({ device }: { device: irdevice & irDevicesConfig; }): Promise<void> {
199
+ if (device.allowPushOff) {
200
+ this.allowPushOn = true;
201
+ } else {
202
+ this.allowPushOn = false;
203
+ }
204
+ }
205
+
187
206
  async commandType(): Promise<string> {
188
207
  let commandType: string;
189
208
  if (this.device.customize) {
@@ -299,6 +318,21 @@ export class Others {
299
318
  if (device.external !== undefined) {
300
319
  config['external'] = device.external;
301
320
  }
321
+ if (device.customOn !== undefined) {
322
+ config['customOn'] = device.customOn;
323
+ }
324
+ if (device.customOff !== undefined) {
325
+ config['customOff'] = device.customOff;
326
+ }
327
+ if (device.customize !== undefined) {
328
+ config['customize'] = device.customize;
329
+ }
330
+ if (device.allowPushOn !== undefined) {
331
+ config['allowPushOn'] = device.allowPushOn;
332
+ }
333
+ if (device.allowPushOff !== undefined) {
334
+ config['allowPushOff'] = device.allowPushOff;
335
+ }
302
336
  if (Object.entries(config).length !== 0) {
303
337
  this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Config: ${superStringify(config)}`);
304
338
  }