@switchbot/homebridge-switchbot 2.2.2-beta.9 → 2.2.2
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 +13 -0
- package/config.schema.json +9 -42
- package/dist/device/bot.d.ts +1 -3
- package/dist/device/bot.d.ts.map +1 -1
- package/dist/device/bot.js +1 -1
- package/dist/device/bot.js.map +1 -1
- package/dist/device/ceilinglight.d.ts +1 -3
- package/dist/device/ceilinglight.d.ts.map +1 -1
- package/dist/device/ceilinglight.js +1 -1
- package/dist/device/ceilinglight.js.map +1 -1
- package/dist/device/colorbulb.d.ts +1 -3
- package/dist/device/colorbulb.d.ts.map +1 -1
- package/dist/device/colorbulb.js +3 -3
- package/dist/device/colorbulb.js.map +1 -1
- package/dist/device/contact.d.ts +6 -7
- package/dist/device/contact.d.ts.map +1 -1
- package/dist/device/contact.js +17 -2
- package/dist/device/contact.js.map +1 -1
- package/dist/device/humidifier.d.ts +7 -9
- package/dist/device/humidifier.d.ts.map +1 -1
- package/dist/device/humidifier.js +13 -15
- package/dist/device/humidifier.js.map +1 -1
- package/dist/device/meter.d.ts +1 -3
- package/dist/device/meter.d.ts.map +1 -1
- package/dist/device/meter.js +1 -1
- package/dist/device/meter.js.map +1 -1
- package/dist/device/meterplus.d.ts +1 -3
- package/dist/device/meterplus.d.ts.map +1 -1
- package/dist/device/meterplus.js +1 -1
- package/dist/device/meterplus.js.map +1 -1
- package/dist/device/motion.d.ts +2 -3
- package/dist/device/motion.d.ts.map +1 -1
- package/dist/device/motion.js +15 -3
- package/dist/device/motion.js.map +1 -1
- package/dist/device/plug.d.ts +1 -3
- package/dist/device/plug.d.ts.map +1 -1
- package/dist/device/plug.js +1 -1
- package/dist/device/plug.js.map +1 -1
- package/dist/device/striplight.d.ts +1 -3
- package/dist/device/striplight.d.ts.map +1 -1
- package/dist/device/striplight.js +9 -7
- package/dist/device/striplight.js.map +1 -1
- 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 +35 -36
- 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 +9 -19
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js.map +1 -1
- package/package.json +5 -5
- package/src/device/bot.ts +1 -1
- package/src/device/ceilinglight.ts +1 -1
- package/src/device/colorbulb.ts +3 -3
- package/src/device/contact.ts +24 -10
- package/src/device/humidifier.ts +11 -15
- package/src/device/meter.ts +1 -1
- package/src/device/meterplus.ts +1 -1
- package/src/device/motion.ts +18 -7
- package/src/device/plug.ts +1 -1
- package/src/device/striplight.ts +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 +38 -39
- package/src/irdevice/vacuumcleaner.ts +23 -26
- package/src/irdevice/waterheater.ts +28 -32
- package/src/platform.ts +28 -34
- package/src/settings.ts +12 -28
- package/.github/npm-version-script.js +0 -81
|
@@ -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
|
-
|
|
41
|
-
|
|
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.
|
|
50
|
-
this.
|
|
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
|
-
|
|
88
|
-
|
|
89
|
-
|
|
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
|
-
+ `
|
|
138
|
-
if (this.Active === this.platform.Characteristic.Active.
|
|
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
|
-
+ `
|
|
153
|
-
if (this.Active === this.platform.Characteristic.Active.
|
|
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
|
|
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.
|
|
172
|
+
this.Timeout = setTimeout(this.pushAirPurifierDetailsChanges.bind(this), 1500);
|
|
174
173
|
}
|
|
175
174
|
|
|
176
|
-
async
|
|
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
|
|
282
|
-
if (device.
|
|
283
|
-
this.
|
|
282
|
+
async disablePushOnChanges({ device }: { device: irdevice & irDevicesConfig; }): Promise<void> {
|
|
283
|
+
if (device.disablePushOn === undefined) {
|
|
284
|
+
this.disablePushOn = false;
|
|
284
285
|
} else {
|
|
285
|
-
this.
|
|
286
|
+
this.disablePushOn = device.disablePushOn;
|
|
286
287
|
}
|
|
287
288
|
}
|
|
288
289
|
|
|
289
|
-
async
|
|
290
|
-
if (device.
|
|
291
|
-
this.
|
|
290
|
+
async disablePushOffChanges({ device }: { device: irdevice & irDevicesConfig; }): Promise<void> {
|
|
291
|
+
if (device.disablePushOff === undefined) {
|
|
292
|
+
this.disablePushOff = false;
|
|
292
293
|
} else {
|
|
293
|
-
this.
|
|
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.
|
|
418
|
-
config['
|
|
418
|
+
if (device.disablePushOn !== undefined) {
|
|
419
|
+
config['disablePushOn'] = device.disablePushOn;
|
|
419
420
|
}
|
|
420
|
-
if (device.
|
|
421
|
-
config['
|
|
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)}`);
|
package/src/irdevice/camera.ts
CHANGED
|
@@ -19,8 +19,8 @@ export class Camera {
|
|
|
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 Camera {
|
|
|
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 Camera {
|
|
|
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
|
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
|
-
+ `
|
|
88
|
-
if (this.On
|
|
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
|
-
+ `
|
|
103
|
-
if (!this.On
|
|
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
|
|
179
|
-
if (device.
|
|
180
|
-
this.
|
|
175
|
+
async disablePushOnChanges({ device }: { device: irdevice & irDevicesConfig; }): Promise<void> {
|
|
176
|
+
if (device.disablePushOn === undefined) {
|
|
177
|
+
this.disablePushOn = false;
|
|
181
178
|
} else {
|
|
182
|
-
this.
|
|
179
|
+
this.disablePushOn = device.disablePushOn;
|
|
183
180
|
}
|
|
184
181
|
}
|
|
185
182
|
|
|
186
|
-
async
|
|
187
|
-
if (device.
|
|
188
|
-
this.
|
|
183
|
+
async disablePushOffChanges({ device }: { device: irdevice & irDevicesConfig; }): Promise<void> {
|
|
184
|
+
if (device.disablePushOff === undefined) {
|
|
185
|
+
this.disablePushOff = false;
|
|
189
186
|
} else {
|
|
190
|
-
this.
|
|
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.
|
|
307
|
-
config['
|
|
303
|
+
if (device.disablePushOn !== undefined) {
|
|
304
|
+
config['disablePushOn'] = device.disablePushOn;
|
|
308
305
|
}
|
|
309
|
-
if (device.
|
|
310
|
-
config['
|
|
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)}`);
|
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)}`);
|