@switchbot/homebridge-switchbot 2.2.2-beta.8 → 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 -11
- 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 -11
- 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
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,
|
|
@@ -197,22 +197,16 @@ export class TV {
|
|
|
197
197
|
async ActiveIdentifierSet(value: CharacteristicValue): Promise<void> {
|
|
198
198
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} ActiveIdentifier: ${value}`);
|
|
199
199
|
this.ActiveIdentifier = value;
|
|
200
|
-
this.accessory.context.ActiveIdentifier = this.ActiveIdentifier;
|
|
201
200
|
}
|
|
202
201
|
|
|
203
202
|
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;
|
|
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) {
|
|
207
|
+
await this.pushTvOnChanges();
|
|
208
|
+
} else {
|
|
209
|
+
await this.pushTvOffChanges();
|
|
216
210
|
}
|
|
217
211
|
}
|
|
218
212
|
|
|
@@ -228,8 +222,8 @@ export class TV {
|
|
|
228
222
|
*/
|
|
229
223
|
async pushTvOnChanges(): Promise<void> {
|
|
230
224
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushTvOnChanges Active: ${this.Active},`
|
|
231
|
-
+ `
|
|
232
|
-
if (this.Active === this.platform.Characteristic.Active.
|
|
225
|
+
+ ` disablePushOn: ${this.disablePushOn}`);
|
|
226
|
+
if (this.Active === this.platform.Characteristic.Active.ACTIVE && !this.disablePushOn) {
|
|
233
227
|
const commandType: string = await this.commandType();
|
|
234
228
|
const command: string = await this.commandOn();
|
|
235
229
|
const body = superStringify({
|
|
@@ -243,8 +237,8 @@ export class TV {
|
|
|
243
237
|
|
|
244
238
|
async pushTvOffChanges(): Promise<void> {
|
|
245
239
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushTvOffChanges Active: ${this.Active},`
|
|
246
|
-
+ `
|
|
247
|
-
if (this.Active === this.platform.Characteristic.Active.
|
|
240
|
+
+ ` disablePushOff: ${this.disablePushOff}`);
|
|
241
|
+
if (this.Active === this.platform.Characteristic.Active.INACTIVE && !this.disablePushOff) {
|
|
248
242
|
const commandType: string = await this.commandType();
|
|
249
243
|
const command: string = await this.commandOff();
|
|
250
244
|
const body = superStringify({
|
|
@@ -337,7 +331,7 @@ export class TV {
|
|
|
337
331
|
await this.pushTVChanges(body);
|
|
338
332
|
}
|
|
339
333
|
|
|
340
|
-
async pushTVChanges(body): Promise<void> {
|
|
334
|
+
async pushTVChanges(body: Array<body>): Promise<void> {
|
|
341
335
|
if (this.device.connectionType === 'OpenAPI') {
|
|
342
336
|
{
|
|
343
337
|
try {
|
|
@@ -409,19 +403,19 @@ export class TV {
|
|
|
409
403
|
}
|
|
410
404
|
}
|
|
411
405
|
|
|
412
|
-
async
|
|
413
|
-
if (device.
|
|
414
|
-
this.
|
|
406
|
+
async disablePushOnChanges({ device }: { device: irdevice & irDevicesConfig; }): Promise<void> {
|
|
407
|
+
if (device.disablePushOn === undefined) {
|
|
408
|
+
this.disablePushOn = false;
|
|
415
409
|
} else {
|
|
416
|
-
this.
|
|
410
|
+
this.disablePushOn = device.disablePushOn;
|
|
417
411
|
}
|
|
418
412
|
}
|
|
419
413
|
|
|
420
|
-
async
|
|
421
|
-
if (device.
|
|
422
|
-
this.
|
|
414
|
+
async disablePushOffChanges({ device }: { device: irdevice & irDevicesConfig; }): Promise<void> {
|
|
415
|
+
if (device.disablePushOff === undefined) {
|
|
416
|
+
this.disablePushOff = false;
|
|
423
417
|
} else {
|
|
424
|
-
this.
|
|
418
|
+
this.disablePushOff = device.disablePushOff;
|
|
425
419
|
}
|
|
426
420
|
}
|
|
427
421
|
|
|
@@ -514,6 +508,11 @@ export class TV {
|
|
|
514
508
|
} else {
|
|
515
509
|
this.Active = this.accessory.context.Active;
|
|
516
510
|
}
|
|
511
|
+
if (this.ActiveIdentifier === undefined) {
|
|
512
|
+
this.ActiveIdentifier = 1;
|
|
513
|
+
} else {
|
|
514
|
+
this.ActiveIdentifier = this.accessory.context.ActiveIdentifier;
|
|
515
|
+
}
|
|
517
516
|
}
|
|
518
517
|
|
|
519
518
|
async config(device: irdevice & irDevicesConfig): Promise<void> {
|
|
@@ -539,11 +538,11 @@ export class TV {
|
|
|
539
538
|
if (device.customize !== undefined) {
|
|
540
539
|
config['customize'] = device.customize;
|
|
541
540
|
}
|
|
542
|
-
if (device.
|
|
543
|
-
config['
|
|
541
|
+
if (device.disablePushOn !== undefined) {
|
|
542
|
+
config['disablePushOn'] = device.disablePushOn;
|
|
544
543
|
}
|
|
545
|
-
if (device.
|
|
546
|
-
config['
|
|
544
|
+
if (device.disablePushOff !== undefined) {
|
|
545
|
+
config['disablePushOff'] = device.disablePushOff;
|
|
547
546
|
}
|
|
548
547
|
if (Object.entries(config).length !== 0) {
|
|
549
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)}`);
|
|
@@ -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)}`] });
|
package/src/platform.ts
CHANGED
|
@@ -471,6 +471,9 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
471
471
|
}
|
|
472
472
|
|
|
473
473
|
private createIRDevice(device: irdevice & devicesConfig) {
|
|
474
|
+
if (device.connectionType === undefined) {
|
|
475
|
+
device.connectionType = 'OpenAPI';
|
|
476
|
+
}
|
|
474
477
|
switch (device.remoteType) {
|
|
475
478
|
case 'TV':
|
|
476
479
|
case 'DIY TV':
|
|
@@ -485,7 +488,12 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
485
488
|
case 'Speaker':
|
|
486
489
|
case 'DIY Speaker':
|
|
487
490
|
this.debugLog(`Discovered ${device.remoteType}: ${device.deviceId}`);
|
|
488
|
-
|
|
491
|
+
if (device.external === undefined) {
|
|
492
|
+
device.external = true;
|
|
493
|
+
this.createTV(device);
|
|
494
|
+
} else {
|
|
495
|
+
this.createTV(device);
|
|
496
|
+
}
|
|
489
497
|
break;
|
|
490
498
|
case 'Fan':
|
|
491
499
|
case 'DIY Fan':
|
|
@@ -1233,7 +1241,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1233
1241
|
existingAccessory.context.firmwareRevision = device.firmware;
|
|
1234
1242
|
existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
|
|
1235
1243
|
this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
|
|
1236
|
-
existingAccessory.context.connectionType =
|
|
1244
|
+
existingAccessory.context.connectionType = device.connectionType;
|
|
1237
1245
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
1238
1246
|
// create the accessory handler for the restored accessory
|
|
1239
1247
|
// this is imported from `platformAccessory.ts`
|
|
@@ -1255,7 +1263,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1255
1263
|
accessory.context.deviceID = device.deviceId;
|
|
1256
1264
|
accessory.context.firmwareRevision = device.firmware;
|
|
1257
1265
|
accessory.context.deviceType = `IR: ${device.remoteType}`;
|
|
1258
|
-
accessory.context.connectionType =
|
|
1266
|
+
accessory.context.connectionType = device.connectionType;
|
|
1259
1267
|
// create the accessory handler for the newly create accessory
|
|
1260
1268
|
// this is imported from `platformAccessory.ts`
|
|
1261
1269
|
new TV(this, accessory, device);
|
|
@@ -1285,7 +1293,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1285
1293
|
existingAccessory.context.firmwareRevision = device.firmware;
|
|
1286
1294
|
existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
|
|
1287
1295
|
this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
|
|
1288
|
-
existingAccessory.context.connectionType =
|
|
1296
|
+
existingAccessory.context.connectionType = device.connectionType;
|
|
1289
1297
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
1290
1298
|
// create the accessory handler for the restored accessory
|
|
1291
1299
|
// this is imported from `platformAccessory.ts`
|
|
@@ -1310,7 +1318,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1310
1318
|
accessory.context.deviceID = device.deviceId;
|
|
1311
1319
|
accessory.context.firmwareRevision = device.firmware;
|
|
1312
1320
|
accessory.context.deviceType = `IR: ${device.remoteType}`;
|
|
1313
|
-
accessory.context.connectionType =
|
|
1321
|
+
accessory.context.connectionType = device.connectionType;
|
|
1314
1322
|
// create the accessory handler for the newly create accessory
|
|
1315
1323
|
// this is imported from `platformAccessory.ts`
|
|
1316
1324
|
new Fan(this, accessory, device);
|
|
@@ -1341,7 +1349,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1341
1349
|
existingAccessory.context.firmwareRevision = device.firmware;
|
|
1342
1350
|
existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
|
|
1343
1351
|
this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
|
|
1344
|
-
existingAccessory.context.connectionType =
|
|
1352
|
+
existingAccessory.context.connectionType = device.connectionType;
|
|
1345
1353
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
1346
1354
|
// create the accessory handler for the restored accessory
|
|
1347
1355
|
// this is imported from `platformAccessory.ts`
|
|
@@ -1366,7 +1374,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1366
1374
|
accessory.context.deviceID = device.deviceId;
|
|
1367
1375
|
accessory.context.firmwareRevision = device.firmware;
|
|
1368
1376
|
accessory.context.deviceType = `IR: ${device.remoteType}`;
|
|
1369
|
-
accessory.context.connectionType =
|
|
1377
|
+
accessory.context.connectionType = device.connectionType;
|
|
1370
1378
|
// create the accessory handler for the newly create accessory
|
|
1371
1379
|
// this is imported from `platformAccessory.ts`
|
|
1372
1380
|
new Light(this, accessory, device);
|
|
@@ -1397,7 +1405,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1397
1405
|
existingAccessory.context.firmwareRevision = device.firmware;
|
|
1398
1406
|
existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
|
|
1399
1407
|
this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
|
|
1400
|
-
existingAccessory.context.connectionType =
|
|
1408
|
+
existingAccessory.context.connectionType = device.connectionType;
|
|
1401
1409
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
1402
1410
|
// create the accessory handler for the restored accessory
|
|
1403
1411
|
// this is imported from `platformAccessory.ts`
|
|
@@ -1422,7 +1430,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1422
1430
|
accessory.context.deviceID = device.deviceId;
|
|
1423
1431
|
accessory.context.firmwareRevision = device.firmware;
|
|
1424
1432
|
accessory.context.deviceType = `IR: ${device.remoteType}`;
|
|
1425
|
-
accessory.context.connectionType =
|
|
1433
|
+
accessory.context.connectionType = device.connectionType;
|
|
1426
1434
|
// create the accessory handler for the newly create accessory
|
|
1427
1435
|
// this is imported from `platformAccessory.ts`
|
|
1428
1436
|
new AirConditioner(this, accessory, device);
|
|
@@ -1453,7 +1461,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1453
1461
|
existingAccessory.context.firmwareRevision = device.firmware;
|
|
1454
1462
|
existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
|
|
1455
1463
|
this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
|
|
1456
|
-
existingAccessory.context.connectionType =
|
|
1464
|
+
existingAccessory.context.connectionType = device.connectionType;
|
|
1457
1465
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
1458
1466
|
// create the accessory handler for the restored accessory
|
|
1459
1467
|
// this is imported from `platformAccessory.ts`
|
|
@@ -1478,7 +1486,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1478
1486
|
accessory.context.deviceID = device.deviceId;
|
|
1479
1487
|
accessory.context.firmwareRevision = device.firmware;
|
|
1480
1488
|
accessory.context.deviceType = `IR: ${device.remoteType}`;
|
|
1481
|
-
accessory.context.connectionType =
|
|
1489
|
+
accessory.context.connectionType = device.connectionType;
|
|
1482
1490
|
// create the accessory handler for the newly create accessory
|
|
1483
1491
|
// this is imported from `platformAccessory.ts`
|
|
1484
1492
|
new AirPurifier(this, accessory, device);
|
|
@@ -1509,7 +1517,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1509
1517
|
existingAccessory.context.firmwareRevision = device.firmware;
|
|
1510
1518
|
existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
|
|
1511
1519
|
this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
|
|
1512
|
-
existingAccessory.context.connectionType =
|
|
1520
|
+
existingAccessory.context.connectionType = device.connectionType;
|
|
1513
1521
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
1514
1522
|
// create the accessory handler for the restored accessory
|
|
1515
1523
|
// this is imported from `platformAccessory.ts`
|
|
@@ -1534,7 +1542,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1534
1542
|
accessory.context.deviceID = device.deviceId;
|
|
1535
1543
|
accessory.context.firmwareRevision = device.firmware;
|
|
1536
1544
|
accessory.context.deviceType = `IR: ${device.remoteType}`;
|
|
1537
|
-
accessory.context.connectionType =
|
|
1545
|
+
accessory.context.connectionType = device.connectionType;
|
|
1538
1546
|
// create the accessory handler for the newly create accessory
|
|
1539
1547
|
// this is imported from `platformAccessory.ts`
|
|
1540
1548
|
new WaterHeater(this, accessory, device);
|
|
@@ -1565,7 +1573,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1565
1573
|
existingAccessory.context.firmwareRevision = device.firmware;
|
|
1566
1574
|
existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
|
|
1567
1575
|
this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
|
|
1568
|
-
existingAccessory.context.connectionType =
|
|
1576
|
+
existingAccessory.context.connectionType = device.connectionType;
|
|
1569
1577
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
1570
1578
|
// create the accessory handler for the restored accessory
|
|
1571
1579
|
// this is imported from `platformAccessory.ts`
|
|
@@ -1590,7 +1598,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1590
1598
|
accessory.context.deviceID = device.deviceId;
|
|
1591
1599
|
accessory.context.firmwareRevision = device.firmware;
|
|
1592
1600
|
accessory.context.deviceType = `IR: ${device.remoteType}`;
|
|
1593
|
-
accessory.context.connectionType =
|
|
1601
|
+
accessory.context.connectionType = device.connectionType;
|
|
1594
1602
|
// create the accessory handler for the newly create accessory
|
|
1595
1603
|
// this is imported from `platformAccessory.ts`
|
|
1596
1604
|
new VacuumCleaner(this, accessory, device);
|
|
@@ -1621,7 +1629,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1621
1629
|
existingAccessory.context.firmwareRevision = device.firmware;
|
|
1622
1630
|
existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
|
|
1623
1631
|
this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
|
|
1624
|
-
existingAccessory.context.connectionType =
|
|
1632
|
+
existingAccessory.context.connectionType = device.connectionType;
|
|
1625
1633
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
1626
1634
|
// create the accessory handler for the restored accessory
|
|
1627
1635
|
// this is imported from `platformAccessory.ts`
|
|
@@ -1646,7 +1654,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1646
1654
|
accessory.context.deviceID = device.deviceId;
|
|
1647
1655
|
accessory.context.firmwareRevision = device.firmware;
|
|
1648
1656
|
accessory.context.deviceType = `IR: ${device.remoteType}`;
|
|
1649
|
-
accessory.context.connectionType =
|
|
1657
|
+
accessory.context.connectionType = device.connectionType;
|
|
1650
1658
|
// create the accessory handler for the newly create accessory
|
|
1651
1659
|
// this is imported from `platformAccessory.ts`
|
|
1652
1660
|
new Camera(this, accessory, device);
|
|
@@ -1677,7 +1685,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1677
1685
|
existingAccessory.context.firmwareRevision = device.firmware;
|
|
1678
1686
|
existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
|
|
1679
1687
|
this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
|
|
1680
|
-
existingAccessory.context.connectionType =
|
|
1688
|
+
existingAccessory.context.connectionType = device.connectionType;
|
|
1681
1689
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
1682
1690
|
// create the accessory handler for the restored accessory
|
|
1683
1691
|
// this is imported from `platformAccessory.ts`
|
|
@@ -1702,7 +1710,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1702
1710
|
accessory.context.deviceID = device.deviceId;
|
|
1703
1711
|
accessory.context.firmwareRevision = device.firmware;
|
|
1704
1712
|
accessory.context.deviceType = `IR: ${device.remoteType}`;
|
|
1705
|
-
accessory.context.connectionType =
|
|
1713
|
+
accessory.context.connectionType = device.connectionType;
|
|
1706
1714
|
// create the accessory handler for the newly create accessory
|
|
1707
1715
|
// this is imported from `platformAccessory.ts`
|
|
1708
1716
|
new Others(this, accessory, device);
|
|
@@ -1753,16 +1761,6 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1753
1761
|
return registerCurtain;
|
|
1754
1762
|
}
|
|
1755
1763
|
|
|
1756
|
-
async connectionTypeIR(device: device & irDevicesConfig): Promise<any> {
|
|
1757
|
-
let connectionType: string;
|
|
1758
|
-
if (!device.connectionType && device.remoteType) {
|
|
1759
|
-
connectionType = 'OpenAPI';
|
|
1760
|
-
} else {
|
|
1761
|
-
connectionType = device.connectionType!;
|
|
1762
|
-
}
|
|
1763
|
-
return connectionType;
|
|
1764
|
-
}
|
|
1765
|
-
|
|
1766
1764
|
async connectionType(device: device & devicesConfig): Promise<any> {
|
|
1767
1765
|
let connectionType: string;
|
|
1768
1766
|
if (!device.connectionType && this.config.credentials?.token && this.config.credentials.secret) {
|
|
@@ -1833,11 +1831,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1833
1831
|
* Only one TV can exist per bridge, to bypass this limitation, you should
|
|
1834
1832
|
* publish your TV as an external accessory.
|
|
1835
1833
|
*/
|
|
1836
|
-
if (device.external
|
|
1837
|
-
device.external = true;
|
|
1838
|
-
this.debugWarnLog(`${accessory.displayName} External TV Accessory Mode`);
|
|
1839
|
-
this.externalAccessory(accessory);
|
|
1840
|
-
} else if (device.external) {
|
|
1834
|
+
if (device.external) {
|
|
1841
1835
|
this.debugWarnLog(`${accessory.displayName} External Accessory Mode`);
|
|
1842
1836
|
this.externalAccessory(accessory);
|
|
1843
1837
|
} else {
|