@switchbot/homebridge-switchbot 2.2.2-beta.9 → 2.2.3-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 (107) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/config.schema.json +18 -42
  3. package/dist/device/bot.d.ts +1 -3
  4. package/dist/device/bot.d.ts.map +1 -1
  5. package/dist/device/bot.js +1 -1
  6. package/dist/device/bot.js.map +1 -1
  7. package/dist/device/ceilinglight.d.ts +1 -3
  8. package/dist/device/ceilinglight.d.ts.map +1 -1
  9. package/dist/device/ceilinglight.js +1 -1
  10. package/dist/device/ceilinglight.js.map +1 -1
  11. package/dist/device/colorbulb.d.ts +1 -3
  12. package/dist/device/colorbulb.d.ts.map +1 -1
  13. package/dist/device/colorbulb.js +3 -3
  14. package/dist/device/colorbulb.js.map +1 -1
  15. package/dist/device/contact.d.ts +6 -7
  16. package/dist/device/contact.d.ts.map +1 -1
  17. package/dist/device/contact.js +17 -2
  18. package/dist/device/contact.js.map +1 -1
  19. package/dist/device/humidifier.d.ts +7 -9
  20. package/dist/device/humidifier.d.ts.map +1 -1
  21. package/dist/device/humidifier.js +13 -15
  22. package/dist/device/humidifier.js.map +1 -1
  23. package/dist/device/meter.d.ts +1 -3
  24. package/dist/device/meter.d.ts.map +1 -1
  25. package/dist/device/meter.js +1 -1
  26. package/dist/device/meter.js.map +1 -1
  27. package/dist/device/meterplus.d.ts +1 -3
  28. package/dist/device/meterplus.d.ts.map +1 -1
  29. package/dist/device/meterplus.js +1 -1
  30. package/dist/device/meterplus.js.map +1 -1
  31. package/dist/device/motion.d.ts +2 -3
  32. package/dist/device/motion.d.ts.map +1 -1
  33. package/dist/device/motion.js +15 -3
  34. package/dist/device/motion.js.map +1 -1
  35. package/dist/device/plug.d.ts +1 -3
  36. package/dist/device/plug.d.ts.map +1 -1
  37. package/dist/device/plug.js +1 -1
  38. package/dist/device/plug.js.map +1 -1
  39. package/dist/device/striplight.d.ts +1 -3
  40. package/dist/device/striplight.d.ts.map +1 -1
  41. package/dist/device/striplight.js +9 -7
  42. package/dist/device/striplight.js.map +1 -1
  43. package/dist/irdevice/airconditioner.d.ts +10 -6
  44. package/dist/irdevice/airconditioner.d.ts.map +1 -1
  45. package/dist/irdevice/airconditioner.js +65 -54
  46. package/dist/irdevice/airconditioner.js.map +1 -1
  47. package/dist/irdevice/airpurifier.d.ts +8 -8
  48. package/dist/irdevice/airpurifier.d.ts.map +1 -1
  49. package/dist/irdevice/airpurifier.js +29 -29
  50. package/dist/irdevice/airpurifier.js.map +1 -1
  51. package/dist/irdevice/camera.d.ts +4 -4
  52. package/dist/irdevice/camera.d.ts.map +1 -1
  53. package/dist/irdevice/camera.js +20 -24
  54. package/dist/irdevice/camera.js.map +1 -1
  55. package/dist/irdevice/fan.d.ts +4 -4
  56. package/dist/irdevice/fan.d.ts.map +1 -1
  57. package/dist/irdevice/fan.js +22 -26
  58. package/dist/irdevice/fan.js.map +1 -1
  59. package/dist/irdevice/light.d.ts +4 -4
  60. package/dist/irdevice/light.d.ts.map +1 -1
  61. package/dist/irdevice/light.js +20 -20
  62. package/dist/irdevice/light.js.map +1 -1
  63. package/dist/irdevice/other.d.ts +4 -4
  64. package/dist/irdevice/other.d.ts.map +1 -1
  65. package/dist/irdevice/other.js +20 -24
  66. package/dist/irdevice/other.js.map +1 -1
  67. package/dist/irdevice/tv.d.ts +10 -6
  68. package/dist/irdevice/tv.d.ts.map +1 -1
  69. package/dist/irdevice/tv.js +128 -90
  70. package/dist/irdevice/tv.js.map +1 -1
  71. package/dist/irdevice/vacuumcleaner.d.ts +4 -4
  72. package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
  73. package/dist/irdevice/vacuumcleaner.js +20 -24
  74. package/dist/irdevice/vacuumcleaner.js.map +1 -1
  75. package/dist/irdevice/waterheater.d.ts +4 -4
  76. package/dist/irdevice/waterheater.d.ts.map +1 -1
  77. package/dist/irdevice/waterheater.js +26 -31
  78. package/dist/irdevice/waterheater.js.map +1 -1
  79. package/dist/platform.d.ts +0 -1
  80. package/dist/platform.d.ts.map +1 -1
  81. package/dist/platform.js +29 -35
  82. package/dist/platform.js.map +1 -1
  83. package/dist/settings.d.ts +10 -19
  84. package/dist/settings.d.ts.map +1 -1
  85. package/dist/settings.js.map +1 -1
  86. package/package.json +9 -9
  87. package/src/device/bot.ts +1 -1
  88. package/src/device/ceilinglight.ts +1 -1
  89. package/src/device/colorbulb.ts +3 -3
  90. package/src/device/contact.ts +24 -10
  91. package/src/device/humidifier.ts +11 -15
  92. package/src/device/meter.ts +1 -1
  93. package/src/device/meterplus.ts +1 -1
  94. package/src/device/motion.ts +18 -7
  95. package/src/device/plug.ts +1 -1
  96. package/src/device/striplight.ts +5 -5
  97. package/src/irdevice/airconditioner.ts +71 -58
  98. package/src/irdevice/airpurifier.ts +34 -33
  99. package/src/irdevice/camera.ts +23 -26
  100. package/src/irdevice/fan.ts +25 -28
  101. package/src/irdevice/light.ts +23 -22
  102. package/src/irdevice/other.ts +23 -26
  103. package/src/irdevice/tv.ts +132 -93
  104. package/src/irdevice/vacuumcleaner.ts +23 -26
  105. package/src/irdevice/waterheater.ts +28 -32
  106. package/src/platform.ts +28 -34
  107. package/src/settings.ts +13 -28
@@ -4,7 +4,7 @@ import { IncomingMessage } from 'http';
4
4
  import superStringify from 'super-stringify';
5
5
  import { SwitchBotPlatform } from '../platform';
6
6
  import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
7
- import { irdevice, irDevicesConfig, HostDomain, DevicePath } from '../settings';
7
+ import { irdevice, irDevicesConfig, HostDomain, DevicePath, body } from '../settings';
8
8
 
9
9
  /**
10
10
  * Platform Accessory
@@ -24,8 +24,9 @@ export class TV {
24
24
  deviceStatus!: any;
25
25
 
26
26
  // Config
27
- allowPushOn?: boolean;
28
- allowPushOff?: boolean;
27
+ disablePushOn?: boolean;
28
+ disablePushOff?: boolean;
29
+ disablePushDetail?: boolean;
29
30
  deviceLogging!: string;
30
31
 
31
32
  constructor(private readonly platform: SwitchBotPlatform, private accessory: PlatformAccessory, public device: irdevice & irDevicesConfig) {
@@ -33,8 +34,9 @@ export class TV {
33
34
  this.logs(device);
34
35
  this.config(device);
35
36
  this.context();
36
- this.allowPushOnChanges({ device });
37
- this.allowPushOffChanges({ device });
37
+ this.disablePushOnChanges({ device });
38
+ this.disablePushOffChanges({ device });
39
+ this.disablePushDetailChanges({ device });
38
40
 
39
41
  // set accessory information
40
42
  accessory
@@ -53,13 +55,13 @@ export class TV {
53
55
  case 'DIY Speaker':
54
56
  accessory.category = this.platform.api.hap.Categories.SPEAKER;
55
57
  (this.tvService = accessory.getService(this.platform.Service.Television) || accessory.addService(this.platform.Service.Television)),
56
- `${accessory.displayName} Speaker`;
58
+ `${accessory.displayName} ${device.remoteType}`;
57
59
  break;
58
60
  case 'IPTV':
59
61
  case 'DIY IPTV':
60
62
  accessory.category = this.platform.api.hap.Categories.TV_STREAMING_STICK;
61
63
  (this.tvService = accessory.getService(this.platform.Service.Television) || accessory.addService(this.platform.Service.Television)),
62
- `${accessory.displayName} Streaming Stick`;
64
+ `${accessory.displayName} ${device.remoteType}`;
63
65
  break;
64
66
  case 'DVD':
65
67
  case 'DIY DVD':
@@ -67,7 +69,7 @@ export class TV {
67
69
  case 'DIY Set Top Box':
68
70
  accessory.category = this.platform.api.hap.Categories.TV_SET_TOP_BOX;
69
71
  (this.tvService = accessory.getService(this.platform.Service.Television) || accessory.addService(this.platform.Service.Television)),
70
- `${accessory.displayName} Set Top Box`;
72
+ `${accessory.displayName} ${device.remoteType}`;
71
73
  break;
72
74
  default:
73
75
  accessory.category = this.platform.api.hap.Categories.TELEVISION;
@@ -75,7 +77,7 @@ export class TV {
75
77
  // get the Television service if it exists, otherwise create a new Television service
76
78
  // you can create multiple services for each accessory
77
79
  (this.tvService = accessory.getService(this.platform.Service.Television) || accessory.addService(this.platform.Service.Television)),
78
- `${accessory.displayName} TV`;
80
+ `${accessory.displayName} ${device.remoteType}`;
79
81
  }
80
82
 
81
83
  // To avoid "Cannot add a Service with the same UUID another Service without also defining a unique 'subtype' property." error,
@@ -197,22 +199,16 @@ export class TV {
197
199
  async ActiveIdentifierSet(value: CharacteristicValue): Promise<void> {
198
200
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} ActiveIdentifier: ${value}`);
199
201
  this.ActiveIdentifier = value;
200
- this.accessory.context.ActiveIdentifier = this.ActiveIdentifier;
201
202
  }
202
203
 
203
204
  async ActiveSet(value: CharacteristicValue): Promise<void> {
204
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Active: ${value}`);
205
- if (!this.device.irtv?.disable_power) {
206
- if (value === this.platform.Characteristic.Active.INACTIVE) {
207
- await this.pushTvOffChanges();
208
- } else {
209
- await this.pushTvOnChanges();
210
- }
211
- /**
212
- * pushTvOnChanges and pushTvOffChanges above assume they are measuring the state of the accessory BEFORE
213
- * they are updated, so we are only updating the accessory state after calling the above.
214
- */
215
- this.Active = value;
205
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Active (value): ${value}`);
206
+
207
+ this.Active = value;
208
+ if (this.Active === this.platform.Characteristic.Active.ACTIVE) {
209
+ await this.pushTvOnChanges();
210
+ } else {
211
+ await this.pushTvOffChanges();
216
212
  }
217
213
  }
218
214
 
@@ -228,8 +224,8 @@ export class TV {
228
224
  */
229
225
  async pushTvOnChanges(): Promise<void> {
230
226
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushTvOnChanges Active: ${this.Active},`
231
- + ` allowPushOn: ${this.allowPushOn}`);
232
- if (this.Active === this.platform.Characteristic.Active.INACTIVE || this.allowPushOn) {
227
+ + ` disablePushOn: ${this.disablePushOn}`);
228
+ if (this.Active === this.platform.Characteristic.Active.ACTIVE && !this.disablePushOn) {
233
229
  const commandType: string = await this.commandType();
234
230
  const command: string = await this.commandOn();
235
231
  const body = superStringify({
@@ -243,8 +239,8 @@ export class TV {
243
239
 
244
240
  async pushTvOffChanges(): Promise<void> {
245
241
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushTvOffChanges Active: ${this.Active},`
246
- + ` allowPushOff: ${this.allowPushOff}`);
247
- if (this.Active === this.platform.Characteristic.Active.ACTIVE || this.allowPushOff) {
242
+ + ` disablePushOff: ${this.disablePushOff}`);
243
+ if (this.Active === this.platform.Characteristic.Active.INACTIVE && !this.disablePushOff) {
248
244
  const commandType: string = await this.commandType();
249
245
  const command: string = await this.commandOff();
250
246
  const body = superStringify({
@@ -257,87 +253,114 @@ export class TV {
257
253
  }
258
254
 
259
255
  async pushOkChanges(): Promise<void> {
260
- const body = superStringify({
261
- 'command': 'Ok',
262
- 'parameter': 'default',
263
- 'commandType': 'command',
264
- });
265
- await this.pushTVChanges(body);
256
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushOkChanges disablePushDetail: ${this.disablePushDetail}`);
257
+ if (!this.disablePushDetail) {
258
+ const body = superStringify({
259
+ 'command': 'Ok',
260
+ 'parameter': 'default',
261
+ 'commandType': 'command',
262
+ });
263
+ await this.pushTVChanges(body);
264
+ }
266
265
  }
267
266
 
268
267
  async pushBackChanges(): Promise<void> {
269
- const body = superStringify({
270
- 'command': 'Back',
271
- 'parameter': 'default',
272
- 'commandType': 'command',
273
- });
274
- await this.pushTVChanges(body);
268
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushBackChanges disablePushDetail: ${this.disablePushDetail}`);
269
+ if (!this.disablePushDetail) {
270
+ const body = superStringify({
271
+ 'command': 'Back',
272
+ 'parameter': 'default',
273
+ 'commandType': 'command',
274
+ });
275
+ await this.pushTVChanges(body);
276
+ }
275
277
  }
276
278
 
277
279
  async pushMenuChanges(): Promise<void> {
278
- const body = superStringify({
279
- 'command': 'Menu',
280
- 'parameter': 'default',
281
- 'commandType': 'command',
282
- });
283
- await this.pushTVChanges(body);
280
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushMenuChanges disablePushDetail: ${this.disablePushDetail}`);
281
+ if (!this.disablePushDetail) {
282
+ const body = superStringify({
283
+ 'command': 'Menu',
284
+ 'parameter': 'default',
285
+ 'commandType': 'command',
286
+ });
287
+ await this.pushTVChanges(body);
288
+ }
284
289
  }
285
290
 
286
291
  async pushUpChanges(): Promise<void> {
287
- const body = superStringify({
288
- 'command': 'Up',
289
- 'parameter': 'default',
290
- 'commandType': 'command',
291
- });
292
- await this.pushTVChanges(body);
292
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushUpChanges disablePushDetail: ${this.disablePushDetail}`);
293
+ if (!this.disablePushDetail) {
294
+ const body = superStringify({
295
+ 'command': 'Up',
296
+ 'parameter': 'default',
297
+ 'commandType': 'command',
298
+ });
299
+ await this.pushTVChanges(body);
300
+ }
293
301
  }
294
302
 
295
303
  async pushDownChanges(): Promise<void> {
296
- const body = superStringify({
297
- 'command': 'Down',
298
- 'parameter': 'default',
299
- 'commandType': 'command',
300
- });
301
- await this.pushTVChanges(body);
304
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushDownChanges disablePushDetail: ${this.disablePushDetail}`);
305
+ if (!this.disablePushDetail) {
306
+ const body = superStringify({
307
+ 'command': 'Down',
308
+ 'parameter': 'default',
309
+ 'commandType': 'command',
310
+ });
311
+ await this.pushTVChanges(body);
312
+ }
302
313
  }
303
314
 
304
315
  async pushRightChanges(): Promise<void> {
305
- const body = superStringify({
306
- 'command': 'Right',
307
- 'parameter': 'default',
308
- 'commandType': 'command',
309
- });
310
- await this.pushTVChanges(body);
316
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushRightChanges disablePushDetail: ${this.disablePushDetail}`);
317
+ if (!this.disablePushDetail) {
318
+ const body = superStringify({
319
+ 'command': 'Right',
320
+ 'parameter': 'default',
321
+ 'commandType': 'command',
322
+ });
323
+ await this.pushTVChanges(body);
324
+ }
311
325
  }
312
326
 
313
327
  async pushLeftChanges(): Promise<void> {
314
- const body = superStringify({
315
- 'command': 'Left',
316
- 'parameter': 'default',
317
- 'commandType': 'command',
318
- });
319
- await this.pushTVChanges(body);
328
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushLeftChanges disablePushDetail: ${this.disablePushDetail}`);
329
+ if (!this.disablePushDetail) {
330
+ const body = superStringify({
331
+ 'command': 'Left',
332
+ 'parameter': 'default',
333
+ 'commandType': 'command',
334
+ });
335
+ await this.pushTVChanges(body);
336
+ }
320
337
  }
321
338
 
322
339
  async pushVolumeUpChanges(): Promise<void> {
323
- const body = superStringify({
324
- 'command': 'volumeAdd',
325
- 'parameter': 'default',
326
- 'commandType': 'command',
327
- });
328
- await this.pushTVChanges(body);
340
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushVolumeUpChanges disablePushDetail: ${this.disablePushDetail}`);
341
+ if (!this.disablePushDetail) {
342
+ const body = superStringify({
343
+ 'command': 'volumeAdd',
344
+ 'parameter': 'default',
345
+ 'commandType': 'command',
346
+ });
347
+ await this.pushTVChanges(body);
348
+ }
329
349
  }
330
350
 
331
351
  async pushVolumeDownChanges(): Promise<void> {
332
- const body = superStringify({
333
- 'command': 'volumeSub',
334
- 'parameter': 'default',
335
- 'commandType': 'command',
336
- });
337
- await this.pushTVChanges(body);
352
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushVolumeDownChanges disablePushDetail: ${this.disablePushDetail}`);
353
+ if (!this.disablePushDetail) {
354
+ const body = superStringify({
355
+ 'command': 'volumeSub',
356
+ 'parameter': 'default',
357
+ 'commandType': 'command',
358
+ });
359
+ await this.pushTVChanges(body);
360
+ }
338
361
  }
339
362
 
340
- async pushTVChanges(body): Promise<void> {
363
+ async pushTVChanges(body: Array<body>): Promise<void> {
341
364
  if (this.device.connectionType === 'OpenAPI') {
342
365
  {
343
366
  try {
@@ -409,19 +432,27 @@ export class TV {
409
432
  }
410
433
  }
411
434
 
412
- async allowPushOnChanges({ device }: { device: irdevice & irDevicesConfig; }): Promise<void> {
413
- if (device.allowPushOn) {
414
- this.allowPushOn = true;
435
+ async disablePushOnChanges({ device }: { device: irdevice & irDevicesConfig; }): Promise<void> {
436
+ if (device.disablePushOn === undefined) {
437
+ this.disablePushOn = false;
438
+ } else {
439
+ this.disablePushOn = device.disablePushOn;
440
+ }
441
+ }
442
+
443
+ async disablePushOffChanges({ device }: { device: irdevice & irDevicesConfig; }): Promise<void> {
444
+ if (device.disablePushOff === undefined) {
445
+ this.disablePushOff = false;
415
446
  } else {
416
- this.allowPushOn = false;
447
+ this.disablePushOff = device.disablePushOff;
417
448
  }
418
449
  }
419
450
 
420
- async allowPushOffChanges({ device }: { device: irdevice & irDevicesConfig; }): Promise<void> {
421
- if (device.allowPushOff) {
422
- this.allowPushOff = true;
451
+ async disablePushDetailChanges({ device }: { device: irdevice & irDevicesConfig; }): Promise<void> {
452
+ if (device.disablePushDetail === undefined) {
453
+ this.disablePushDetail = false;
423
454
  } else {
424
- this.allowPushOff = false;
455
+ this.disablePushDetail = device.disablePushDetail;
425
456
  }
426
457
  }
427
458
 
@@ -514,6 +545,11 @@ export class TV {
514
545
  } else {
515
546
  this.Active = this.accessory.context.Active;
516
547
  }
548
+ if (this.ActiveIdentifier === undefined) {
549
+ this.ActiveIdentifier = 1;
550
+ } else {
551
+ this.ActiveIdentifier = this.accessory.context.ActiveIdentifier;
552
+ }
517
553
  }
518
554
 
519
555
  async config(device: irdevice & irDevicesConfig): Promise<void> {
@@ -539,11 +575,14 @@ export class TV {
539
575
  if (device.customize !== undefined) {
540
576
  config['customize'] = device.customize;
541
577
  }
542
- if (device.allowPushOn !== undefined) {
543
- config['allowPushOn'] = device.allowPushOn;
578
+ if (device.disablePushOn !== undefined) {
579
+ config['disablePushOn'] = device.disablePushOn;
580
+ }
581
+ if (device.disablePushOff !== undefined) {
582
+ config['disablePushOff'] = device.disablePushOff;
544
583
  }
545
- if (device.allowPushOff !== undefined) {
546
- config['allowPushOff'] = device.allowPushOff;
584
+ if (device.disablePushDetail !== undefined) {
585
+ config['disablePushDetail'] = device.disablePushDetail;
547
586
  }
548
587
  if (Object.entries(config).length !== 0) {
549
588
  this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Config: ${superStringify(config)}`);
@@ -19,8 +19,8 @@ export class VacuumCleaner {
19
19
  On!: CharacteristicValue;
20
20
 
21
21
  // Config
22
- allowPushOn?: boolean;
23
- allowPushOff?: boolean;
22
+ disablePushOn?: boolean;
23
+ disablePushOff?: boolean;
24
24
  deviceLogging!: string;
25
25
 
26
26
  constructor(private readonly platform: SwitchBotPlatform, private accessory: PlatformAccessory, public device: irdevice & irDevicesConfig) {
@@ -28,8 +28,8 @@ export class VacuumCleaner {
28
28
  this.logs(device);
29
29
  this.config(device);
30
30
  this.context();
31
- this.allowPushOnChanges({ device });
32
- this.allowPushOffChanges({ device });
31
+ this.disablePushOnChanges({ device });
32
+ this.disablePushOffChanges({ device });
33
33
 
34
34
  // set accessory information
35
35
  accessory
@@ -60,16 +60,13 @@ export class VacuumCleaner {
60
60
 
61
61
  async OnSet(value: CharacteristicValue): Promise<void> {
62
62
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} On: ${value}`);
63
- if (value) {
63
+
64
+ this.On = value;
65
+ if (this.On) {
64
66
  await this.pushOnChanges();
65
67
  } else {
66
68
  await this.pushOffChanges();
67
69
  }
68
- /**
69
- * pushOnChanges and pushOffChanges above assume they are measuring the state of the accessory BEFORE
70
- * they are updated, so we are only updating the accessory state after calling the above.
71
- */
72
- this.On = value;
73
70
  }
74
71
 
75
72
  /**
@@ -80,8 +77,8 @@ export class VacuumCleaner {
80
77
  */
81
78
  async pushOnChanges(): Promise<void> {
82
79
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushOnChanges On: ${this.On},`
83
- + ` allowPushOn: ${this.allowPushOn}`);
84
- if (this.On || this.allowPushOn) {
80
+ + ` disablePushOn: ${this.disablePushOn}`);
81
+ if (this.On && !this.disablePushOn) {
85
82
  const commandType: string = await this.commandType();
86
83
  const command: string = await this.commandOn();
87
84
  const body = superStringify({
@@ -95,8 +92,8 @@ export class VacuumCleaner {
95
92
 
96
93
  async pushOffChanges(): Promise<void> {
97
94
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushOffChanges On: ${this.On},`
98
- + ` allowPushOff: ${this.allowPushOff}`);
99
- if (!this.On || this.allowPushOff) {
95
+ + ` disablePushOff: ${this.disablePushOff}`);
96
+ if (!this.On && !this.disablePushOff) {
100
97
  const commandType: string = await this.commandType();
101
98
  const command: string = await this.commandOff();
102
99
  const body = superStringify({
@@ -172,19 +169,19 @@ export class VacuumCleaner {
172
169
  }
173
170
  }
174
171
 
175
- async allowPushOnChanges({ device }: { device: irdevice & irDevicesConfig; }): Promise<void> {
176
- if (device.allowPushOn) {
177
- this.allowPushOn = true;
172
+ async disablePushOnChanges({ device }: { device: irdevice & irDevicesConfig; }): Promise<void> {
173
+ if (device.disablePushOn === undefined) {
174
+ this.disablePushOn = false;
178
175
  } else {
179
- this.allowPushOn = false;
176
+ this.disablePushOn = device.disablePushOn;
180
177
  }
181
178
  }
182
179
 
183
- async allowPushOffChanges({ device }: { device: irdevice & irDevicesConfig; }): Promise<void> {
184
- if (device.allowPushOff) {
185
- this.allowPushOff = true;
180
+ async disablePushOffChanges({ device }: { device: irdevice & irDevicesConfig; }): Promise<void> {
181
+ if (device.disablePushOff === undefined) {
182
+ this.disablePushOff = false;
186
183
  } else {
187
- this.allowPushOff = false;
184
+ this.disablePushOff = device.disablePushOff;
188
185
  }
189
186
  }
190
187
 
@@ -300,11 +297,11 @@ export class VacuumCleaner {
300
297
  if (device.customize !== undefined) {
301
298
  config['customize'] = device.customize;
302
299
  }
303
- if (device.allowPushOn !== undefined) {
304
- config['allowPushOn'] = device.allowPushOn;
300
+ if (device.disablePushOn !== undefined) {
301
+ config['disablePushOn'] = device.disablePushOn;
305
302
  }
306
- if (device.allowPushOff !== undefined) {
307
- config['allowPushOff'] = device.allowPushOff;
303
+ if (device.disablePushOff !== undefined) {
304
+ config['disablePushOff'] = device.disablePushOff;
308
305
  }
309
306
  if (Object.entries(config).length !== 0) {
310
307
  this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Config: ${superStringify(config)}`);
@@ -5,7 +5,6 @@ import superStringify from 'super-stringify';
5
5
  import { SwitchBotPlatform } from '../platform';
6
6
  import { irDevicesConfig, irdevice, HostDomain, DevicePath } from '../settings';
7
7
  import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
8
- const version = process.env.npm_package_version;
9
8
 
10
9
  /**
11
10
  * Platform Accessory
@@ -20,8 +19,8 @@ export class WaterHeater {
20
19
  Active!: CharacteristicValue;
21
20
 
22
21
  // Config
23
- allowPushOn?: boolean;
24
- allowPushOff?: boolean;
22
+ disablePushOn?: boolean;
23
+ disablePushOff?: boolean;
25
24
  deviceLogging!: string;
26
25
 
27
26
  constructor(private readonly platform: SwitchBotPlatform, private accessory: PlatformAccessory, public device: irdevice & irDevicesConfig) {
@@ -29,8 +28,8 @@ export class WaterHeater {
29
28
  this.logs({ device });
30
29
  this.config({ device });
31
30
  this.context();
32
- this.allowPushOnChanges({ device });
33
- this.allowPushOffChanges({ device });
31
+ this.disablePushOnChanges({ device });
32
+ this.disablePushOffChanges({ device });
34
33
 
35
34
  // set accessory information
36
35
  accessory
@@ -64,18 +63,15 @@ export class WaterHeater {
64
63
 
65
64
  async ActiveSet(value: CharacteristicValue): Promise<void> {
66
65
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Active: ${value}`);
67
- if (value === this.platform.Characteristic.Active.INACTIVE) {
68
- await this.pushWaterHeaterOffChanges();
69
- this.valveService.setCharacteristic(this.platform.Characteristic.InUse, this.platform.Characteristic.InUse.NOT_IN_USE);
70
- } else {
66
+
67
+ this.Active = value;
68
+ if (this.Active === this.platform.Characteristic.Active.ACTIVE) {
71
69
  await this.pushWaterHeaterOnChanges();
72
70
  this.valveService.setCharacteristic(this.platform.Characteristic.InUse, this.platform.Characteristic.InUse.IN_USE);
71
+ } else {
72
+ await this.pushWaterHeaterOffChanges();
73
+ this.valveService.setCharacteristic(this.platform.Characteristic.InUse, this.platform.Characteristic.InUse.NOT_IN_USE);
73
74
  }
74
- /**
75
- * pushWaterHeaterOnChanges and pushWaterHeaterOffChanges above assume they are measuring the state of the accessory BEFORE
76
- * they are updated, so we are only updating the accessory state after calling the above.
77
- */
78
- this.Active = value;
79
75
  }
80
76
 
81
77
  /**
@@ -86,8 +82,8 @@ export class WaterHeater {
86
82
  */
87
83
  async pushWaterHeaterOnChanges(): Promise<void> {
88
84
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushWaterHeaterOnChanges Active: ${this.Active},`
89
- + ` allowPushOn: ${this.allowPushOn}`);
90
- if (this.Active === this.platform.Characteristic.Active.INACTIVE || this.allowPushOn) {
85
+ + ` disablePushOn: ${this.disablePushOn}`);
86
+ if (this.Active === this.platform.Characteristic.Active.ACTIVE && !this.disablePushOn) {
91
87
  const commandType: string = await this.commandType();
92
88
  const command: string = await this.commandOn();
93
89
  const body = superStringify({
@@ -101,8 +97,8 @@ export class WaterHeater {
101
97
 
102
98
  async pushWaterHeaterOffChanges(): Promise<void> {
103
99
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushWaterHeaterOffChanges Active: ${this.Active},`
104
- + ` allowPushOff: ${this.allowPushOff}`);
105
- if (this.Active === this.platform.Characteristic.Active.ACTIVE || this.allowPushOff) {
100
+ + ` disablePushOff: ${this.disablePushOff}`);
101
+ if (this.Active === this.platform.Characteristic.Active.INACTIVE && !this.disablePushOff) {
106
102
  const commandType: string = await this.commandType();
107
103
  const command: string = await this.commandOff();
108
104
  const body = superStringify({
@@ -180,19 +176,19 @@ export class WaterHeater {
180
176
  }
181
177
  }
182
178
 
183
- async allowPushOnChanges({ device }: { device: irdevice & irDevicesConfig; }): Promise<void> {
184
- if (device.allowPushOn) {
185
- this.allowPushOn = true;
179
+ async disablePushOnChanges({ device }: { device: irdevice & irDevicesConfig; }): Promise<void> {
180
+ if (device.disablePushOn === undefined) {
181
+ this.disablePushOn = false;
186
182
  } else {
187
- this.allowPushOn = false;
183
+ this.disablePushOn = device.disablePushOn;
188
184
  }
189
185
  }
190
186
 
191
- async allowPushOffChanges({ device }: { device: irdevice & irDevicesConfig; }): Promise<void> {
192
- if (device.allowPushOff) {
193
- this.allowPushOff = true;
187
+ async disablePushOffChanges({ device }: { device: irdevice & irDevicesConfig; }): Promise<void> {
188
+ if (device.disablePushOff === undefined) {
189
+ this.disablePushOff = false;
194
190
  } else {
195
- this.allowPushOff = false;
191
+ this.disablePushOff = device.disablePushOff;
196
192
  }
197
193
  }
198
194
 
@@ -268,13 +264,13 @@ export class WaterHeater {
268
264
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName}`
269
265
  + ` accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}`);
270
266
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} device.firmware: ${device.firmware}`);
271
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} version: ${version}`);
267
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} this.platform.version: ${this.platform.version}`);
272
268
  if (accessory.context.FirmwareRevision) {
273
269
  FirmwareRevision = accessory.context.FirmwareRevision;
274
270
  } else if (device.firmware) {
275
271
  FirmwareRevision = device.firmware;
276
272
  } else {
277
- FirmwareRevision = version!;
273
+ FirmwareRevision = this.platform.version!;
278
274
  }
279
275
  return FirmwareRevision;
280
276
  }
@@ -310,11 +306,11 @@ export class WaterHeater {
310
306
  if (device.customize !== undefined) {
311
307
  config['customize'] = device.customize;
312
308
  }
313
- if (device.allowPushOn !== undefined) {
314
- config['allowPushOn'] = device.allowPushOn;
309
+ if (device.disablePushOn !== undefined) {
310
+ config['disablePushOn'] = device.disablePushOn;
315
311
  }
316
- if (device.allowPushOff !== undefined) {
317
- config['allowPushOff'] = device.allowPushOff;
312
+ if (device.disablePushOff !== undefined) {
313
+ config['disablePushOff'] = device.disablePushOff;
318
314
  }
319
315
  if (Object.entries(config).length !== 0) {
320
316
  this.infoLog({ log: [`${this.device.remoteType}: ${this.accessory.displayName} Config: ${superStringify(config)}`] });