@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
@@ -3,7 +3,7 @@ import crypto from 'crypto';
3
3
  import { IncomingMessage } from 'http';
4
4
  import superStringify from 'super-stringify';
5
5
  import { SwitchBotPlatform } from '../platform';
6
- import { irDevicesConfig, irdevice, HostDomain, DevicePath } from '../settings';
6
+ import { irDevicesConfig, irdevice, HostDomain, DevicePath, body } from '../settings';
7
7
  import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
8
8
 
9
9
  /**
@@ -37,8 +37,8 @@ export class AirPurifier {
37
37
  static PURIFYING_AIR: number;
38
38
 
39
39
  // Config
40
- allowPushOn?: boolean;
41
- allowPushOff?: boolean;
40
+ disablePushOn?: boolean;
41
+ disablePushOff?: boolean;
42
42
  deviceLogging!: string;
43
43
 
44
44
  constructor(private readonly platform: SwitchBotPlatform, private accessory: PlatformAccessory, public device: irdevice & irDevicesConfig) {
@@ -46,8 +46,8 @@ export class AirPurifier {
46
46
  this.logs(device);
47
47
  this.config(device);
48
48
  this.context();
49
- this.allowPushOnChanges({ device });
50
- this.allowPushOffChanges({ device });
49
+ this.disablePushOnChanges({ device });
50
+ this.disablePushOffChanges({ device });
51
51
 
52
52
  // set accessory information
53
53
  accessory
@@ -84,16 +84,13 @@ export class AirPurifier {
84
84
 
85
85
  async ActiveSet(value: CharacteristicValue): Promise<void> {
86
86
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Set Active: ${value}`);
87
- if (value === this.platform.Characteristic.Active.INACTIVE) {
88
- this.pushAirPurifierOffChanges();
89
- } else {
87
+
88
+ this.Active = value;
89
+ if (this.Active === this.platform.Characteristic.Active.ACTIVE) {
90
90
  this.pushAirPurifierOnChanges();
91
+ } else {
92
+ this.pushAirPurifierOffChanges();
91
93
  }
92
- /**
93
- * pushAirPurifierOnChanges and pushAirPurifierOffChanges above assume they are measuring the state of the accessory BEFORE
94
- * they are updated, so we are only updating the accessory state after calling the above.
95
- */
96
- this.Active = value;
97
94
  }
98
95
 
99
96
  async TargetAirPurifierStateSet(value: CharacteristicValue): Promise<void> {
@@ -134,8 +131,8 @@ export class AirPurifier {
134
131
  */
135
132
  async pushAirPurifierOnChanges(): Promise<void> {
136
133
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushAirPurifierOnChanges Active: ${this.Active},`
137
- + ` allowPushOn: ${this.allowPushOn}`);
138
- if (this.Active === this.platform.Characteristic.Active.INACTIVE || this.allowPushOn) {
134
+ + ` disablePushOn: ${this.disablePushOn}`);
135
+ if (this.Active === this.platform.Characteristic.Active.ACTIVE && !this.disablePushOn) {
139
136
  const commandType: string = await this.commandType();
140
137
  const command: string = await this.commandOn();
141
138
  const body = superStringify({
@@ -149,8 +146,8 @@ export class AirPurifier {
149
146
 
150
147
  async pushAirPurifierOffChanges(): Promise<void> {
151
148
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushAirPurifierOffChanges Active: ${this.Active},`
152
- + ` allowPushOff: ${this.allowPushOff}`);
153
- if (this.Active === this.platform.Characteristic.Active.ACTIVE || this.allowPushOn) {
149
+ + ` disablePushOff: ${this.disablePushOff}`);
150
+ if (this.Active === this.platform.Characteristic.Active.INACTIVE && !this.disablePushOn) {
154
151
  const commandType: string = await this.commandType();
155
152
  const command: string = await this.commandOff();
156
153
  const body = superStringify({
@@ -162,7 +159,9 @@ export class AirPurifier {
162
159
  }
163
160
  }
164
161
 
165
- async pushAirConditionerStatusChanges(): Promise<void> {
162
+ async pushAirPurifierStatusChanges(): Promise<void> {
163
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushAirPurifierStatusChanges Active: ${this.Active},`
164
+ + ` disablePushOff: ${this.disablePushOff}, disablePushOn: ${this.disablePushOn}`);
166
165
  if (!this.Busy) {
167
166
  this.Busy = true;
168
167
  this.CurrentHeaterCoolerState = this.platform.Characteristic.CurrentHeaterCoolerState.IDLE;
@@ -170,10 +169,12 @@ export class AirPurifier {
170
169
  clearTimeout(this.Timeout);
171
170
 
172
171
  // Make a new Timeout set to go off in 1000ms (1 second)
173
- this.Timeout = setTimeout(this.pushAirConditionerDetailsChanges.bind(this), 1500);
172
+ this.Timeout = setTimeout(this.pushAirPurifierDetailsChanges.bind(this), 1500);
174
173
  }
175
174
 
176
- async pushAirConditionerDetailsChanges(): Promise<void> {
175
+ async pushAirPurifierDetailsChanges(): Promise<void> {
176
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushAirPurifierDetailsChanges Active: ${this.Active},`
177
+ + ` disablePushOff: ${this.disablePushOff}, disablePushOn: ${this.disablePushOn}`);
177
178
  this.CurrentAPTemp = this.CurrentTemperature || 24;
178
179
  this.CurrentAPMode = this.CurrentMode || 1;
179
180
  this.CurrentAPFanSpeed = this.CurrentFanSpeed || 1;
@@ -196,7 +197,7 @@ export class AirPurifier {
196
197
  await this.pushChanges(body);
197
198
  }
198
199
 
199
- async pushChanges(body): Promise<void> {
200
+ async pushChanges(body: Array<body>): Promise<void> {
200
201
  if (this.device.connectionType === 'OpenAPI') {
201
202
  try {
202
203
  // Make Push On request to the API
@@ -278,19 +279,19 @@ export class AirPurifier {
278
279
  }
279
280
  }
280
281
 
281
- async allowPushOnChanges({ device }: { device: irdevice & irDevicesConfig; }): Promise<void> {
282
- if (device.allowPushOn) {
283
- this.allowPushOn = true;
282
+ async disablePushOnChanges({ device }: { device: irdevice & irDevicesConfig; }): Promise<void> {
283
+ if (device.disablePushOn === undefined) {
284
+ this.disablePushOn = false;
284
285
  } else {
285
- this.allowPushOn = false;
286
+ this.disablePushOn = device.disablePushOn;
286
287
  }
287
288
  }
288
289
 
289
- async allowPushOffChanges({ device }: { device: irdevice & irDevicesConfig; }): Promise<void> {
290
- if (device.allowPushOff) {
291
- this.allowPushOff = true;
290
+ async disablePushOffChanges({ device }: { device: irdevice & irDevicesConfig; }): Promise<void> {
291
+ if (device.disablePushOff === undefined) {
292
+ this.disablePushOff = false;
292
293
  } else {
293
- this.allowPushOff = false;
294
+ this.disablePushOff = device.disablePushOff;
294
295
  }
295
296
  }
296
297
 
@@ -414,11 +415,11 @@ export class AirPurifier {
414
415
  if (device.customize !== undefined) {
415
416
  config['customize'] = device.customize;
416
417
  }
417
- if (device.allowPushOn !== undefined) {
418
- config['allowPushOn'] = device.allowPushOn;
418
+ if (device.disablePushOn !== undefined) {
419
+ config['disablePushOn'] = device.disablePushOn;
419
420
  }
420
- if (device.allowPushOff !== undefined) {
421
- config['allowPushOff'] = device.allowPushOff;
421
+ if (device.disablePushOff !== undefined) {
422
+ config['disablePushOff'] = device.disablePushOff;
422
423
  }
423
424
  if (Object.entries(config).length !== 0) {
424
425
  this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Config: ${superStringify(config)}`);
@@ -19,8 +19,8 @@ export class Camera {
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 Camera {
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 Camera {
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
  this.pushOnChanges();
65
67
  } else {
66
68
  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
  /**
@@ -84,8 +81,8 @@ export class Camera {
84
81
  */
85
82
  async pushOnChanges(): Promise<void> {
86
83
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushOnChanges On: ${this.On},`
87
- + ` allowPushOn: ${this.allowPushOn}`);
88
- if (this.On || this.allowPushOn) {
84
+ + ` disablePushOn: ${this.disablePushOn}`);
85
+ if (this.On && !this.disablePushOn) {
89
86
  const commandType: string = await this.commandType();
90
87
  const command: string = await this.commandOn();
91
88
  const body = superStringify({
@@ -99,8 +96,8 @@ export class Camera {
99
96
 
100
97
  async pushOffChanges(): Promise<void> {
101
98
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushOffChanges On: ${this.On},`
102
- + ` allowPushOff: ${this.allowPushOff}`);
103
- if (!this.On || this.allowPushOff) {
99
+ + ` disablePushOff: ${this.disablePushOff}`);
100
+ if (!this.On && !this.disablePushOff) {
104
101
  const commandType: string = await this.commandType();
105
102
  const command: string = await this.commandOff();
106
103
  const body = superStringify({
@@ -175,19 +172,19 @@ export class Camera {
175
172
  }
176
173
  }
177
174
 
178
- async allowPushOnChanges({ device }: { device: irdevice & irDevicesConfig; }): Promise<void> {
179
- if (device.allowPushOn) {
180
- this.allowPushOn = true;
175
+ async disablePushOnChanges({ device }: { device: irdevice & irDevicesConfig; }): Promise<void> {
176
+ if (device.disablePushOn === undefined) {
177
+ this.disablePushOn = false;
181
178
  } else {
182
- this.allowPushOn = false;
179
+ this.disablePushOn = device.disablePushOn;
183
180
  }
184
181
  }
185
182
 
186
- async allowPushOffChanges({ device }: { device: irdevice & irDevicesConfig; }): Promise<void> {
187
- if (device.allowPushOff) {
188
- this.allowPushOff = true;
183
+ async disablePushOffChanges({ device }: { device: irdevice & irDevicesConfig; }): Promise<void> {
184
+ if (device.disablePushOff === undefined) {
185
+ this.disablePushOff = false;
189
186
  } else {
190
- this.allowPushOff = false;
187
+ this.disablePushOff = device.disablePushOff;
191
188
  }
192
189
  }
193
190
 
@@ -303,11 +300,11 @@ export class Camera {
303
300
  if (device.customize !== undefined) {
304
301
  config['customize'] = device.customize;
305
302
  }
306
- if (device.allowPushOn !== undefined) {
307
- config['allowPushOn'] = device.allowPushOn;
303
+ if (device.disablePushOn !== undefined) {
304
+ config['disablePushOn'] = device.disablePushOn;
308
305
  }
309
- if (device.allowPushOff !== undefined) {
310
- config['allowPushOff'] = device.allowPushOff;
306
+ if (device.disablePushOff !== undefined) {
307
+ config['disablePushOff'] = device.disablePushOff;
311
308
  }
312
309
  if (Object.entries(config).length !== 0) {
313
310
  this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Config: ${superStringify(config)}`);
@@ -29,8 +29,8 @@ export class Fan {
29
29
  minStep?: number;
30
30
  minValue?: number;
31
31
  maxValue?: number;
32
- allowPushOn?: boolean;
33
- allowPushOff?: boolean;
32
+ disablePushOn?: boolean;
33
+ disablePushOff?: boolean;
34
34
  deviceLogging!: string;
35
35
 
36
36
  constructor(private readonly platform: SwitchBotPlatform, private accessory: PlatformAccessory, public device: irdevice & irDevicesConfig) {
@@ -38,8 +38,8 @@ export class Fan {
38
38
  this.logs(device);
39
39
  this.config(device);
40
40
  this.context();
41
- this.allowPushOnChanges({ device });
42
- this.allowPushOffChanges({ device });
41
+ this.disablePushOnChanges({ device });
42
+ this.disablePushOffChanges({ device });
43
43
 
44
44
  // set accessory information
45
45
  accessory
@@ -151,16 +151,13 @@ export class Fan {
151
151
 
152
152
  async ActiveSet(value: CharacteristicValue): Promise<void> {
153
153
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Active: ${value}`);
154
- if (value === this.platform.Characteristic.Active.INACTIVE) {
155
- this.pushFanOffChanges();
156
- } else {
154
+
155
+ this.Active = value;
156
+ if (this.Active === this.platform.Characteristic.Active.ACTIVE) {
157
157
  this.pushFanOnChanges();
158
+ } else {
159
+ this.pushFanOffChanges();
158
160
  }
159
- /**
160
- * pushFanOnChanges and pushFanOffChanges above assume they are measuring the state of the accessory BEFORE
161
- * they are updated, so we are only updating the accessory state after calling the above.
162
- */
163
- this.Active = value;
164
161
  }
165
162
 
166
163
  /**
@@ -174,8 +171,8 @@ export class Fan {
174
171
  */
175
172
  async pushFanOnChanges(): Promise<void> {
176
173
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushFanOnChanges Active: ${this.Active},`
177
- + ` allowPushOn: ${this.allowPushOn}`);
178
- if (this.Active === this.platform.Characteristic.Active.INACTIVE || this.allowPushOn) {
174
+ + ` disablePushOn: ${this.disablePushOn}`);
175
+ if (this.Active === this.platform.Characteristic.Active.ACTIVE && !this.disablePushOn) {
179
176
  const commandType: string = await this.commandType();
180
177
  const command: string = await this.commandOn();
181
178
  const body = superStringify({
@@ -189,8 +186,8 @@ export class Fan {
189
186
 
190
187
  async pushFanOffChanges(): Promise<void> {
191
188
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushLightOffChanges Active: ${this.Active},`
192
- + ` allowPushOff: ${this.allowPushOff}`);
193
- if (this.Active === this.platform.Characteristic.Active.ACTIVE || this.allowPushOff) {
189
+ + ` disablePushOff: ${this.disablePushOff}`);
190
+ if (this.Active === this.platform.Characteristic.Active.INACTIVE && !this.disablePushOff) {
194
191
  const commandType: string = await this.commandType();
195
192
  const command: string = await this.commandOff();
196
193
  const body = superStringify({
@@ -306,19 +303,19 @@ export class Fan {
306
303
  }
307
304
  }
308
305
 
309
- async allowPushOnChanges({ device }: { device: irdevice & irDevicesConfig; }): Promise<void> {
310
- if (device.allowPushOn) {
311
- this.allowPushOn = true;
306
+ async disablePushOnChanges({ device }: { device: irdevice & irDevicesConfig; }): Promise<void> {
307
+ if (device.disablePushOn === undefined) {
308
+ this.disablePushOn = false;
312
309
  } else {
313
- this.allowPushOn = false;
310
+ this.disablePushOn = device.disablePushOn;
314
311
  }
315
312
  }
316
313
 
317
- async allowPushOffChanges({ device }: { device: irdevice & irDevicesConfig; }): Promise<void> {
318
- if (device.allowPushOff) {
319
- this.allowPushOff = true;
314
+ async disablePushOffChanges({ device }: { device: irdevice & irDevicesConfig; }): Promise<void> {
315
+ if (device.disablePushOff === undefined) {
316
+ this.disablePushOff = false;
320
317
  } else {
321
- this.allowPushOff = false;
318
+ this.disablePushOff = device.disablePushOff;
322
319
  }
323
320
  }
324
321
 
@@ -437,11 +434,11 @@ export class Fan {
437
434
  if (device.customize !== undefined) {
438
435
  config['customize'] = device.customize;
439
436
  }
440
- if (device.allowPushOn !== undefined) {
441
- config['allowPushOn'] = device.allowPushOn;
437
+ if (device.disablePushOn !== undefined) {
438
+ config['disablePushOn'] = device.disablePushOn;
442
439
  }
443
- if (device.allowPushOff !== undefined) {
444
- config['allowPushOff'] = device.allowPushOff;
440
+ if (device.disablePushOff !== undefined) {
441
+ config['disablePushOff'] = device.disablePushOff;
445
442
  }
446
443
  if (Object.entries(config).length !== 0) {
447
444
  this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Config: ${superStringify(config)}`);
@@ -19,8 +19,8 @@ export class Light {
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 Light {
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,7 +60,9 @@ export class Light {
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.pushLightOnChanges();
65
67
  } else {
66
68
  await this.pushLightOffChanges();
@@ -69,7 +71,6 @@ export class Light {
69
71
  * pushLightOnChanges and pushLightOffChanges above assume they are measuring the state of the accessory BEFORE
70
72
  * they are updated, so we are only updating the accessory state after calling the above.
71
73
  */
72
- this.On = value;
73
74
  }
74
75
 
75
76
  /**
@@ -84,8 +85,8 @@ export class Light {
84
85
  */
85
86
  async pushLightOnChanges(): Promise<void> {
86
87
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushLightOnChanges On: ${this.On},`
87
- + ` allowPushOn: ${this.allowPushOn}`);
88
- if (this.On || this.allowPushOn) {
88
+ + ` disablePushOn: ${this.disablePushOn}`);
89
+ if (this.On && !this.disablePushOn) {
89
90
  const commandType: string = await this.commandType();
90
91
  const command: string = await this.commandOn();
91
92
  const body = superStringify({
@@ -99,8 +100,8 @@ export class Light {
99
100
 
100
101
  async pushLightOffChanges(): Promise<void> {
101
102
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushLightOffChanges On: ${this.On},`
102
- + ` allowPushOff: ${this.allowPushOff}`);
103
- if (!this.On || this.allowPushOff) {
103
+ + ` disablePushOff: ${this.disablePushOff}`);
104
+ if (!this.On && !this.disablePushOff) {
104
105
  const commandType: string = await this.commandType();
105
106
  const command: string = await this.commandOff();
106
107
  const body = superStringify({
@@ -194,19 +195,19 @@ export class Light {
194
195
  }
195
196
  }
196
197
 
197
- async allowPushOnChanges({ device }: { device: irdevice & irDevicesConfig; }): Promise<void> {
198
- if (device.allowPushOn) {
199
- this.allowPushOn = true;
198
+ async disablePushOnChanges({ device }: { device: irdevice & irDevicesConfig; }): Promise<void> {
199
+ if (device.disablePushOn === undefined) {
200
+ this.disablePushOn = false;
200
201
  } else {
201
- this.allowPushOn = false;
202
+ this.disablePushOn = device.disablePushOn;
202
203
  }
203
204
  }
204
205
 
205
- async allowPushOffChanges({ device }: { device: irdevice & irDevicesConfig; }): Promise<void> {
206
- if (device.allowPushOff) {
207
- this.allowPushOff = true;
206
+ async disablePushOffChanges({ device }: { device: irdevice & irDevicesConfig; }): Promise<void> {
207
+ if (device.disablePushOff === undefined) {
208
+ this.disablePushOff = false;
208
209
  } else {
209
- this.allowPushOff = false;
210
+ this.disablePushOff = device.disablePushOff;
210
211
  }
211
212
  }
212
213
 
@@ -322,11 +323,11 @@ export class Light {
322
323
  if (device.customize !== undefined) {
323
324
  config['customize'] = device.customize;
324
325
  }
325
- if (device.allowPushOn !== undefined) {
326
- config['allowPushOn'] = device.allowPushOn;
326
+ if (device.disablePushOn !== undefined) {
327
+ config['disablePushOn'] = device.disablePushOn;
327
328
  }
328
- if (device.allowPushOff !== undefined) {
329
- config['allowPushOff'] = device.allowPushOff;
329
+ if (device.disablePushOff !== undefined) {
330
+ config['disablePushOff'] = device.disablePushOff;
330
331
  }
331
332
  if (Object.entries(config).length !== 0) {
332
333
  this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Config: ${superStringify(config)}`);
@@ -19,8 +19,8 @@ export class Others {
19
19
  Active!: CharacteristicValue;
20
20
 
21
21
  // Config
22
- allowPushOn?: boolean;
23
- allowPushOff?: boolean;
22
+ disablePushOn?: boolean;
23
+ disablePushOff?: boolean;
24
24
  deviceLogging!: string;
25
25
  otherDeviceType?: string;
26
26
 
@@ -30,8 +30,8 @@ export class Others {
30
30
  this.deviceType(device);
31
31
  this.config(device);
32
32
  this.context();
33
- this.allowPushOnChanges({ device });
34
- this.allowPushOffChanges({ device });
33
+ this.disablePushOnChanges({ device });
34
+ this.disablePushOffChanges({ device });
35
35
 
36
36
  // set accessory information
37
37
  accessory
@@ -68,16 +68,13 @@ export class Others {
68
68
 
69
69
  async ActiveSet(value: CharacteristicValue): Promise<void> {
70
70
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} On: ${value}`);
71
- if (value) {
71
+
72
+ this.Active = value;
73
+ if (this.Active) {
72
74
  await this.pushOnChanges();
73
75
  } else {
74
76
  await this.pushOffChanges();
75
77
  }
76
- /**
77
- * pushOnChanges and pushOffChanges above assume they are measuring the state of the accessory BEFORE
78
- * they are updated, so we are only updating the accessory state after calling the above.
79
- */
80
- this.Active = value;
81
78
  }
82
79
 
83
80
  /**
@@ -92,9 +89,9 @@ export class Others {
92
89
  */
93
90
  async pushOnChanges(): Promise<void> {
94
91
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushOnChanges Active: ${this.Active},`
95
- + ` allowPushOn: ${this.allowPushOn}, customize: ${this.device.customize}, customOn: ${this.device.customOn}`);
92
+ + ` disablePushOn: ${this.disablePushOn}, customize: ${this.device.customize}, customOn: ${this.device.customOn}`);
96
93
  if (this.device.customize) {
97
- if (this.Active === this.platform.Characteristic.Active.INACTIVE || this.allowPushOn) {
94
+ if (this.Active === this.platform.Characteristic.Active.ACTIVE && !this.disablePushOn) {
98
95
  const commandType: string = await this.commandType();
99
96
  const command: string = await this.commandOn();
100
97
  const body = superStringify({
@@ -111,9 +108,9 @@ export class Others {
111
108
 
112
109
  async pushOffChanges(): Promise<void> {
113
110
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushOffChanges Active: ${this.Active},`
114
- + ` allowPushOff: ${this.allowPushOff}, customize: ${this.device.customize}, customOff: ${this.device.customOff}`);
111
+ + ` disablePushOff: ${this.disablePushOff}, customize: ${this.device.customize}, customOff: ${this.device.customOff}`);
115
112
  if (this.device.customize) {
116
- if (this.Active === this.platform.Characteristic.Active.ACTIVE || this.allowPushOff) {
113
+ if (this.Active === this.platform.Characteristic.Active.INACTIVE && !this.disablePushOff) {
117
114
  const commandType: string = await this.commandType();
118
115
  const command: string = await this.commandOff();
119
116
  const body = superStringify({
@@ -191,19 +188,19 @@ export class Others {
191
188
  }
192
189
  }
193
190
 
194
- async allowPushOnChanges({ device }: { device: irdevice & irDevicesConfig; }): Promise<void> {
195
- if (device.allowPushOn) {
196
- this.allowPushOn = true;
191
+ async disablePushOnChanges({ device }: { device: irdevice & irDevicesConfig; }): Promise<void> {
192
+ if (device.disablePushOn === undefined) {
193
+ this.disablePushOn = false;
197
194
  } else {
198
- this.allowPushOn = false;
195
+ this.disablePushOn = device.disablePushOn;
199
196
  }
200
197
  }
201
198
 
202
- async allowPushOffChanges({ device }: { device: irdevice & irDevicesConfig; }): Promise<void> {
203
- if (device.allowPushOff) {
204
- this.allowPushOff = true;
199
+ async disablePushOffChanges({ device }: { device: irdevice & irDevicesConfig; }): Promise<void> {
200
+ if (device.disablePushOff === undefined) {
201
+ this.disablePushOff = false;
205
202
  } else {
206
- this.allowPushOff = false;
203
+ this.disablePushOff = device.disablePushOff;
207
204
  }
208
205
  }
209
206
 
@@ -331,11 +328,11 @@ export class Others {
331
328
  if (device.customize !== undefined) {
332
329
  config['customize'] = device.customize;
333
330
  }
334
- if (device.allowPushOn !== undefined) {
335
- config['allowPushOn'] = device.allowPushOn;
331
+ if (device.disablePushOn !== undefined) {
332
+ config['disablePushOn'] = device.disablePushOn;
336
333
  }
337
- if (device.allowPushOff !== undefined) {
338
- config['allowPushOff'] = device.allowPushOff;
334
+ if (device.disablePushOff !== undefined) {
335
+ config['disablePushOff'] = device.disablePushOff;
339
336
  }
340
337
  if (Object.entries(config).length !== 0) {
341
338
  this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Config: ${superStringify(config)}`);