@switchbot/homebridge-switchbot 2.2.2-beta.24 → 2.2.2-beta.26
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.
- package/CHANGELOG.md +7 -3
- package/config.schema.json +9 -11
- package/dist/irdevice/airconditioner.d.ts +6 -6
- package/dist/irdevice/airconditioner.d.ts.map +1 -1
- package/dist/irdevice/airconditioner.js +39 -35
- package/dist/irdevice/airconditioner.js.map +1 -1
- package/dist/irdevice/airpurifier.d.ts +8 -8
- package/dist/irdevice/airpurifier.d.ts.map +1 -1
- package/dist/irdevice/airpurifier.js +29 -29
- package/dist/irdevice/airpurifier.js.map +1 -1
- package/dist/irdevice/camera.d.ts +4 -4
- package/dist/irdevice/camera.d.ts.map +1 -1
- package/dist/irdevice/camera.js +20 -24
- package/dist/irdevice/camera.js.map +1 -1
- package/dist/irdevice/fan.d.ts +4 -4
- package/dist/irdevice/fan.d.ts.map +1 -1
- package/dist/irdevice/fan.js +22 -26
- package/dist/irdevice/fan.js.map +1 -1
- package/dist/irdevice/light.d.ts +4 -4
- package/dist/irdevice/light.d.ts.map +1 -1
- package/dist/irdevice/light.js +20 -20
- package/dist/irdevice/light.js.map +1 -1
- package/dist/irdevice/other.d.ts +4 -4
- package/dist/irdevice/other.d.ts.map +1 -1
- package/dist/irdevice/other.js +20 -24
- package/dist/irdevice/other.js.map +1 -1
- package/dist/irdevice/tv.d.ts +6 -6
- package/dist/irdevice/tv.d.ts.map +1 -1
- package/dist/irdevice/tv.js +25 -29
- package/dist/irdevice/tv.js.map +1 -1
- package/dist/irdevice/vacuumcleaner.d.ts +4 -4
- package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
- package/dist/irdevice/vacuumcleaner.js +20 -24
- package/dist/irdevice/vacuumcleaner.js.map +1 -1
- package/dist/irdevice/waterheater.d.ts +4 -4
- package/dist/irdevice/waterheater.d.ts.map +1 -1
- package/dist/irdevice/waterheater.js +26 -31
- package/dist/irdevice/waterheater.js.map +1 -1
- package/dist/platform.d.ts +0 -1
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +29 -35
- package/dist/platform.js.map +1 -1
- package/dist/settings.d.ts +8 -3
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js.map +1 -1
- package/package.json +5 -5
- package/src/irdevice/airconditioner.ts +43 -39
- package/src/irdevice/airpurifier.ts +34 -33
- package/src/irdevice/camera.ts +23 -26
- package/src/irdevice/fan.ts +25 -28
- package/src/irdevice/light.ts +23 -22
- package/src/irdevice/other.ts +23 -26
- package/src/irdevice/tv.ts +30 -33
- package/src/irdevice/vacuumcleaner.ts +23 -26
- package/src/irdevice/waterheater.ts +28 -32
- package/src/platform.ts +28 -34
- package/src/settings.ts +11 -5
package/src/irdevice/fan.ts
CHANGED
|
@@ -29,8 +29,8 @@ export class Fan {
|
|
|
29
29
|
minStep?: number;
|
|
30
30
|
minValue?: number;
|
|
31
31
|
maxValue?: number;
|
|
32
|
-
|
|
33
|
-
|
|
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.
|
|
42
|
-
this.
|
|
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
|
-
|
|
155
|
-
|
|
156
|
-
|
|
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
|
-
+ `
|
|
178
|
-
if (this.Active === this.platform.Characteristic.Active.
|
|
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
|
-
+ `
|
|
193
|
-
if (this.Active === this.platform.Characteristic.Active.
|
|
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
|
|
310
|
-
if (device.
|
|
311
|
-
this.
|
|
306
|
+
async disablePushOnChanges({ device }: { device: irdevice & irDevicesConfig; }): Promise<void> {
|
|
307
|
+
if (device.disablePushOn === undefined) {
|
|
308
|
+
this.disablePushOn = false;
|
|
312
309
|
} else {
|
|
313
|
-
this.
|
|
310
|
+
this.disablePushOn = device.disablePushOn;
|
|
314
311
|
}
|
|
315
312
|
}
|
|
316
313
|
|
|
317
|
-
async
|
|
318
|
-
if (device.
|
|
319
|
-
this.
|
|
314
|
+
async disablePushOffChanges({ device }: { device: irdevice & irDevicesConfig; }): Promise<void> {
|
|
315
|
+
if (device.disablePushOff === undefined) {
|
|
316
|
+
this.disablePushOff = false;
|
|
320
317
|
} else {
|
|
321
|
-
this.
|
|
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.
|
|
441
|
-
config['
|
|
437
|
+
if (device.disablePushOn !== undefined) {
|
|
438
|
+
config['disablePushOn'] = device.disablePushOn;
|
|
442
439
|
}
|
|
443
|
-
if (device.
|
|
444
|
-
config['
|
|
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)}`);
|
package/src/irdevice/light.ts
CHANGED
|
@@ -19,8 +19,8 @@ export class Light {
|
|
|
19
19
|
On!: CharacteristicValue;
|
|
20
20
|
|
|
21
21
|
// Config
|
|
22
|
-
|
|
23
|
-
|
|
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.
|
|
32
|
-
this.
|
|
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
|
-
|
|
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
|
-
+ `
|
|
88
|
-
if (this.On
|
|
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
|
-
+ `
|
|
103
|
-
if (!this.On
|
|
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
|
|
198
|
-
if (device.
|
|
199
|
-
this.
|
|
198
|
+
async disablePushOnChanges({ device }: { device: irdevice & irDevicesConfig; }): Promise<void> {
|
|
199
|
+
if (device.disablePushOn === undefined) {
|
|
200
|
+
this.disablePushOn = false;
|
|
200
201
|
} else {
|
|
201
|
-
this.
|
|
202
|
+
this.disablePushOn = device.disablePushOn;
|
|
202
203
|
}
|
|
203
204
|
}
|
|
204
205
|
|
|
205
|
-
async
|
|
206
|
-
if (device.
|
|
207
|
-
this.
|
|
206
|
+
async disablePushOffChanges({ device }: { device: irdevice & irDevicesConfig; }): Promise<void> {
|
|
207
|
+
if (device.disablePushOff === undefined) {
|
|
208
|
+
this.disablePushOff = false;
|
|
208
209
|
} else {
|
|
209
|
-
this.
|
|
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.
|
|
326
|
-
config['
|
|
326
|
+
if (device.disablePushOn !== undefined) {
|
|
327
|
+
config['disablePushOn'] = device.disablePushOn;
|
|
327
328
|
}
|
|
328
|
-
if (device.
|
|
329
|
-
config['
|
|
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)}`);
|
package/src/irdevice/other.ts
CHANGED
|
@@ -19,8 +19,8 @@ export class Others {
|
|
|
19
19
|
Active!: CharacteristicValue;
|
|
20
20
|
|
|
21
21
|
// Config
|
|
22
|
-
|
|
23
|
-
|
|
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.
|
|
34
|
-
this.
|
|
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
|
-
|
|
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
|
-
+ `
|
|
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.
|
|
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
|
-
+ `
|
|
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.
|
|
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
|
|
195
|
-
if (device.
|
|
196
|
-
this.
|
|
191
|
+
async disablePushOnChanges({ device }: { device: irdevice & irDevicesConfig; }): Promise<void> {
|
|
192
|
+
if (device.disablePushOn === undefined) {
|
|
193
|
+
this.disablePushOn = false;
|
|
197
194
|
} else {
|
|
198
|
-
this.
|
|
195
|
+
this.disablePushOn = device.disablePushOn;
|
|
199
196
|
}
|
|
200
197
|
}
|
|
201
198
|
|
|
202
|
-
async
|
|
203
|
-
if (device.
|
|
204
|
-
this.
|
|
199
|
+
async disablePushOffChanges({ device }: { device: irdevice & irDevicesConfig; }): Promise<void> {
|
|
200
|
+
if (device.disablePushOff === undefined) {
|
|
201
|
+
this.disablePushOff = false;
|
|
205
202
|
} else {
|
|
206
|
-
this.
|
|
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.
|
|
335
|
-
config['
|
|
331
|
+
if (device.disablePushOn !== undefined) {
|
|
332
|
+
config['disablePushOn'] = device.disablePushOn;
|
|
336
333
|
}
|
|
337
|
-
if (device.
|
|
338
|
-
config['
|
|
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)}`);
|
package/src/irdevice/tv.ts
CHANGED
|
@@ -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,8 @@ export class TV {
|
|
|
24
24
|
deviceStatus!: any;
|
|
25
25
|
|
|
26
26
|
// Config
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
disablePushOn?: boolean;
|
|
28
|
+
disablePushOff?: boolean;
|
|
29
29
|
deviceLogging!: string;
|
|
30
30
|
|
|
31
31
|
constructor(private readonly platform: SwitchBotPlatform, private accessory: PlatformAccessory, public device: irdevice & irDevicesConfig) {
|
|
@@ -33,8 +33,8 @@ export class TV {
|
|
|
33
33
|
this.logs(device);
|
|
34
34
|
this.config(device);
|
|
35
35
|
this.context();
|
|
36
|
-
this.
|
|
37
|
-
this.
|
|
36
|
+
this.disablePushOnChanges({ device });
|
|
37
|
+
this.disablePushOffChanges({ device });
|
|
38
38
|
|
|
39
39
|
// set accessory information
|
|
40
40
|
accessory
|
|
@@ -53,13 +53,13 @@ export class TV {
|
|
|
53
53
|
case 'DIY Speaker':
|
|
54
54
|
accessory.category = this.platform.api.hap.Categories.SPEAKER;
|
|
55
55
|
(this.tvService = accessory.getService(this.platform.Service.Television) || accessory.addService(this.platform.Service.Television)),
|
|
56
|
-
`${accessory.displayName}
|
|
56
|
+
`${accessory.displayName} ${device.remoteType}`;
|
|
57
57
|
break;
|
|
58
58
|
case 'IPTV':
|
|
59
59
|
case 'DIY IPTV':
|
|
60
60
|
accessory.category = this.platform.api.hap.Categories.TV_STREAMING_STICK;
|
|
61
61
|
(this.tvService = accessory.getService(this.platform.Service.Television) || accessory.addService(this.platform.Service.Television)),
|
|
62
|
-
`${accessory.displayName}
|
|
62
|
+
`${accessory.displayName} ${device.remoteType}`;
|
|
63
63
|
break;
|
|
64
64
|
case 'DVD':
|
|
65
65
|
case 'DIY DVD':
|
|
@@ -67,7 +67,7 @@ export class TV {
|
|
|
67
67
|
case 'DIY Set Top Box':
|
|
68
68
|
accessory.category = this.platform.api.hap.Categories.TV_SET_TOP_BOX;
|
|
69
69
|
(this.tvService = accessory.getService(this.platform.Service.Television) || accessory.addService(this.platform.Service.Television)),
|
|
70
|
-
`${accessory.displayName}
|
|
70
|
+
`${accessory.displayName} ${device.remoteType}`;
|
|
71
71
|
break;
|
|
72
72
|
default:
|
|
73
73
|
accessory.category = this.platform.api.hap.Categories.TELEVISION;
|
|
@@ -75,7 +75,7 @@ export class TV {
|
|
|
75
75
|
// get the Television service if it exists, otherwise create a new Television service
|
|
76
76
|
// you can create multiple services for each accessory
|
|
77
77
|
(this.tvService = accessory.getService(this.platform.Service.Television) || accessory.addService(this.platform.Service.Television)),
|
|
78
|
-
`${accessory.displayName}
|
|
78
|
+
`${accessory.displayName} ${device.remoteType}`;
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
// To avoid "Cannot add a Service with the same UUID another Service without also defining a unique 'subtype' property." error,
|
|
@@ -200,17 +200,14 @@ export class TV {
|
|
|
200
200
|
}
|
|
201
201
|
|
|
202
202
|
async ActiveSet(value: CharacteristicValue): Promise<void> {
|
|
203
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Active: ${value}`);
|
|
204
|
-
|
|
203
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Active (value): ${value}`);
|
|
204
|
+
|
|
205
|
+
this.Active = value;
|
|
206
|
+
if (this.Active === this.platform.Characteristic.Active.ACTIVE) {
|
|
205
207
|
await this.pushTvOnChanges();
|
|
206
208
|
} else {
|
|
207
209
|
await this.pushTvOffChanges();
|
|
208
210
|
}
|
|
209
|
-
/**
|
|
210
|
-
* pushTvOnChanges and pushTvOffChanges above assume they are measuring the state of the accessory BEFORE
|
|
211
|
-
* they are updated, so we are only updating the accessory state after calling the above.
|
|
212
|
-
*/
|
|
213
|
-
this.Active = value;
|
|
214
211
|
}
|
|
215
212
|
|
|
216
213
|
/**
|
|
@@ -225,8 +222,8 @@ export class TV {
|
|
|
225
222
|
*/
|
|
226
223
|
async pushTvOnChanges(): Promise<void> {
|
|
227
224
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushTvOnChanges Active: ${this.Active},`
|
|
228
|
-
+ `
|
|
229
|
-
if (this.Active === this.platform.Characteristic.Active.
|
|
225
|
+
+ ` disablePushOn: ${this.disablePushOn}`);
|
|
226
|
+
if (this.Active === this.platform.Characteristic.Active.ACTIVE && !this.disablePushOn) {
|
|
230
227
|
const commandType: string = await this.commandType();
|
|
231
228
|
const command: string = await this.commandOn();
|
|
232
229
|
const body = superStringify({
|
|
@@ -240,8 +237,8 @@ export class TV {
|
|
|
240
237
|
|
|
241
238
|
async pushTvOffChanges(): Promise<void> {
|
|
242
239
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushTvOffChanges Active: ${this.Active},`
|
|
243
|
-
+ `
|
|
244
|
-
if (this.Active === this.platform.Characteristic.Active.
|
|
240
|
+
+ ` disablePushOff: ${this.disablePushOff}`);
|
|
241
|
+
if (this.Active === this.platform.Characteristic.Active.INACTIVE && !this.disablePushOff) {
|
|
245
242
|
const commandType: string = await this.commandType();
|
|
246
243
|
const command: string = await this.commandOff();
|
|
247
244
|
const body = superStringify({
|
|
@@ -334,7 +331,7 @@ export class TV {
|
|
|
334
331
|
await this.pushTVChanges(body);
|
|
335
332
|
}
|
|
336
333
|
|
|
337
|
-
async pushTVChanges(body): Promise<void> {
|
|
334
|
+
async pushTVChanges(body: Array<body>): Promise<void> {
|
|
338
335
|
if (this.device.connectionType === 'OpenAPI') {
|
|
339
336
|
{
|
|
340
337
|
try {
|
|
@@ -406,19 +403,19 @@ export class TV {
|
|
|
406
403
|
}
|
|
407
404
|
}
|
|
408
405
|
|
|
409
|
-
async
|
|
410
|
-
if (device.
|
|
411
|
-
this.
|
|
406
|
+
async disablePushOnChanges({ device }: { device: irdevice & irDevicesConfig; }): Promise<void> {
|
|
407
|
+
if (device.disablePushOn === undefined) {
|
|
408
|
+
this.disablePushOn = false;
|
|
412
409
|
} else {
|
|
413
|
-
this.
|
|
410
|
+
this.disablePushOn = device.disablePushOn;
|
|
414
411
|
}
|
|
415
412
|
}
|
|
416
413
|
|
|
417
|
-
async
|
|
418
|
-
if (device.
|
|
419
|
-
this.
|
|
414
|
+
async disablePushOffChanges({ device }: { device: irdevice & irDevicesConfig; }): Promise<void> {
|
|
415
|
+
if (device.disablePushOff === undefined) {
|
|
416
|
+
this.disablePushOff = false;
|
|
420
417
|
} else {
|
|
421
|
-
this.
|
|
418
|
+
this.disablePushOff = device.disablePushOff;
|
|
422
419
|
}
|
|
423
420
|
}
|
|
424
421
|
|
|
@@ -541,11 +538,11 @@ export class TV {
|
|
|
541
538
|
if (device.customize !== undefined) {
|
|
542
539
|
config['customize'] = device.customize;
|
|
543
540
|
}
|
|
544
|
-
if (device.
|
|
545
|
-
config['
|
|
541
|
+
if (device.disablePushOn !== undefined) {
|
|
542
|
+
config['disablePushOn'] = device.disablePushOn;
|
|
546
543
|
}
|
|
547
|
-
if (device.
|
|
548
|
-
config['
|
|
544
|
+
if (device.disablePushOff !== undefined) {
|
|
545
|
+
config['disablePushOff'] = device.disablePushOff;
|
|
549
546
|
}
|
|
550
547
|
if (Object.entries(config).length !== 0) {
|
|
551
548
|
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
|
-
|
|
23
|
-
|
|
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.
|
|
32
|
-
this.
|
|
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
|
-
|
|
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
|
-
+ `
|
|
84
|
-
if (this.On
|
|
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
|
-
+ `
|
|
99
|
-
if (!this.On
|
|
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
|
|
176
|
-
if (device.
|
|
177
|
-
this.
|
|
172
|
+
async disablePushOnChanges({ device }: { device: irdevice & irDevicesConfig; }): Promise<void> {
|
|
173
|
+
if (device.disablePushOn === undefined) {
|
|
174
|
+
this.disablePushOn = false;
|
|
178
175
|
} else {
|
|
179
|
-
this.
|
|
176
|
+
this.disablePushOn = device.disablePushOn;
|
|
180
177
|
}
|
|
181
178
|
}
|
|
182
179
|
|
|
183
|
-
async
|
|
184
|
-
if (device.
|
|
185
|
-
this.
|
|
180
|
+
async disablePushOffChanges({ device }: { device: irdevice & irDevicesConfig; }): Promise<void> {
|
|
181
|
+
if (device.disablePushOff === undefined) {
|
|
182
|
+
this.disablePushOff = false;
|
|
186
183
|
} else {
|
|
187
|
-
this.
|
|
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.
|
|
304
|
-
config['
|
|
300
|
+
if (device.disablePushOn !== undefined) {
|
|
301
|
+
config['disablePushOn'] = device.disablePushOn;
|
|
305
302
|
}
|
|
306
|
-
if (device.
|
|
307
|
-
config['
|
|
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)}`);
|