@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.
- package/CHANGELOG.md +13 -0
- package/config.schema.json +18 -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 +10 -6
- package/dist/irdevice/airconditioner.d.ts.map +1 -1
- package/dist/irdevice/airconditioner.js +65 -54
- 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 +10 -6
- package/dist/irdevice/tv.d.ts.map +1 -1
- package/dist/irdevice/tv.js +128 -90
- 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 +10 -19
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js.map +1 -1
- package/package.json +9 -9
- 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 +71 -58
- 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 +132 -93
- package/src/irdevice/vacuumcleaner.ts +23 -26
- package/src/irdevice/waterheater.ts +28 -32
- package/src/platform.ts +28 -34
- package/src/settings.ts +13 -28
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,9 @@ export class TV {
|
|
|
24
24
|
deviceStatus!: any;
|
|
25
25
|
|
|
26
26
|
// Config
|
|
27
|
-
|
|
28
|
-
|
|
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.
|
|
37
|
-
this.
|
|
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}
|
|
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}
|
|
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}
|
|
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}
|
|
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
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
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
|
-
+ `
|
|
232
|
-
if (this.Active === this.platform.Characteristic.Active.
|
|
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
|
-
+ `
|
|
247
|
-
if (this.Active === this.platform.Characteristic.Active.
|
|
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
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
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
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
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
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
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
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
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
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
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
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
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
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
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
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
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
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
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
|
|
413
|
-
if (device.
|
|
414
|
-
this.
|
|
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.
|
|
447
|
+
this.disablePushOff = device.disablePushOff;
|
|
417
448
|
}
|
|
418
449
|
}
|
|
419
450
|
|
|
420
|
-
async
|
|
421
|
-
if (device.
|
|
422
|
-
this.
|
|
451
|
+
async disablePushDetailChanges({ device }: { device: irdevice & irDevicesConfig; }): Promise<void> {
|
|
452
|
+
if (device.disablePushDetail === undefined) {
|
|
453
|
+
this.disablePushDetail = false;
|
|
423
454
|
} else {
|
|
424
|
-
this.
|
|
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.
|
|
543
|
-
config['
|
|
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.
|
|
546
|
-
config['
|
|
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
|
-
|
|
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)}`);
|
|
@@ -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
|
-
|
|
24
|
-
|
|
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.
|
|
33
|
-
this.
|
|
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
|
-
|
|
68
|
-
|
|
69
|
-
|
|
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
|
-
+ `
|
|
90
|
-
if (this.Active === this.platform.Characteristic.Active.
|
|
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
|
-
+ `
|
|
105
|
-
if (this.Active === this.platform.Characteristic.Active.
|
|
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
|
|
184
|
-
if (device.
|
|
185
|
-
this.
|
|
179
|
+
async disablePushOnChanges({ device }: { device: irdevice & irDevicesConfig; }): Promise<void> {
|
|
180
|
+
if (device.disablePushOn === undefined) {
|
|
181
|
+
this.disablePushOn = false;
|
|
186
182
|
} else {
|
|
187
|
-
this.
|
|
183
|
+
this.disablePushOn = device.disablePushOn;
|
|
188
184
|
}
|
|
189
185
|
}
|
|
190
186
|
|
|
191
|
-
async
|
|
192
|
-
if (device.
|
|
193
|
-
this.
|
|
187
|
+
async disablePushOffChanges({ device }: { device: irdevice & irDevicesConfig; }): Promise<void> {
|
|
188
|
+
if (device.disablePushOff === undefined) {
|
|
189
|
+
this.disablePushOff = false;
|
|
194
190
|
} else {
|
|
195
|
-
this.
|
|
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.
|
|
314
|
-
config['
|
|
309
|
+
if (device.disablePushOn !== undefined) {
|
|
310
|
+
config['disablePushOn'] = device.disablePushOn;
|
|
315
311
|
}
|
|
316
|
-
if (device.
|
|
317
|
-
config['
|
|
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)}`] });
|