@switchbot/homebridge-switchbot 3.5.0-beta.26 → 3.5.0-beta.28
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/dist/device/blindtilt.d.ts.map +1 -1
- package/dist/device/blindtilt.js +19 -16
- package/dist/device/blindtilt.js.map +1 -1
- package/dist/device/bot.js +15 -15
- package/dist/device/bot.js.map +1 -1
- package/dist/device/ceilinglight.js +8 -8
- package/dist/device/ceilinglight.js.map +1 -1
- package/dist/device/colorbulb.js +4 -4
- package/dist/device/colorbulb.js.map +1 -1
- package/dist/device/contact.js +6 -6
- package/dist/device/contact.js.map +1 -1
- package/dist/device/curtain.d.ts.map +1 -1
- package/dist/device/curtain.js +13 -13
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/device.d.ts +2 -1
- package/dist/device/device.d.ts.map +1 -1
- package/dist/device/device.js +10 -3
- package/dist/device/device.js.map +1 -1
- package/dist/device/hub.d.ts.map +1 -1
- package/dist/device/hub.js +7 -7
- package/dist/device/hub.js.map +1 -1
- package/dist/device/humidifier.js +5 -5
- package/dist/device/humidifier.js.map +1 -1
- package/dist/device/iosensor.js +6 -6
- package/dist/device/iosensor.js.map +1 -1
- package/dist/device/lightstrip.js +4 -4
- package/dist/device/lightstrip.js.map +1 -1
- package/dist/device/lock.js +7 -7
- package/dist/device/lock.js.map +1 -1
- package/dist/device/meter.js +6 -6
- package/dist/device/meter.js.map +1 -1
- package/dist/device/meterplus.js +6 -6
- package/dist/device/meterplus.js.map +1 -1
- package/dist/device/motion.js +6 -7
- package/dist/device/motion.js.map +1 -1
- package/dist/device/plug.js +4 -4
- package/dist/device/plug.js.map +1 -1
- package/dist/device/robotvacuumcleaner.js +6 -6
- package/dist/device/robotvacuumcleaner.js.map +1 -1
- package/dist/device/waterdetector.d.ts.map +1 -1
- package/dist/device/waterdetector.js +10 -17
- package/dist/device/waterdetector.js.map +1 -1
- package/dist/irdevice/airconditioner.d.ts +4 -14
- package/dist/irdevice/airconditioner.d.ts.map +1 -1
- package/dist/irdevice/airconditioner.js +227 -235
- package/dist/irdevice/airconditioner.js.map +1 -1
- package/dist/irdevice/airpurifier.d.ts +3 -6
- package/dist/irdevice/airpurifier.d.ts.map +1 -1
- package/dist/irdevice/airpurifier.js +66 -57
- package/dist/irdevice/airpurifier.js.map +1 -1
- package/dist/irdevice/camera.d.ts +2 -3
- package/dist/irdevice/camera.d.ts.map +1 -1
- package/dist/irdevice/camera.js +25 -28
- package/dist/irdevice/camera.js.map +1 -1
- package/dist/irdevice/fan.d.ts +2 -7
- package/dist/irdevice/fan.d.ts.map +1 -1
- package/dist/irdevice/fan.js +58 -62
- package/dist/irdevice/fan.js.map +1 -1
- package/dist/irdevice/irdevice.d.ts +2 -1
- package/dist/irdevice/irdevice.d.ts.map +1 -1
- package/dist/irdevice/irdevice.js +10 -3
- package/dist/irdevice/irdevice.js.map +1 -1
- package/dist/irdevice/light.d.ts +1 -1
- package/dist/irdevice/light.d.ts.map +1 -1
- package/dist/irdevice/light.js +14 -16
- package/dist/irdevice/light.js.map +1 -1
- package/dist/irdevice/other.js +52 -51
- package/dist/irdevice/other.js.map +1 -1
- package/dist/irdevice/tv.js +3 -3
- package/dist/irdevice/tv.js.map +1 -1
- package/dist/irdevice/vacuumcleaner.js +2 -2
- package/dist/irdevice/vacuumcleaner.js.map +1 -1
- package/dist/irdevice/waterheater.js +2 -2
- package/dist/irdevice/waterheater.js.map +1 -1
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +22 -1
- package/dist/platform.js.map +1 -1
- package/package.json +2 -2
- package/src/custom.d.ts +1 -0
- package/src/device/blindtilt.ts +22 -20
- package/src/device/bot.ts +16 -16
- package/src/device/ceilinglight.ts +9 -9
- package/src/device/colorbulb.ts +5 -5
- package/src/device/contact.ts +7 -7
- package/src/device/curtain.ts +15 -14
- package/src/device/device.ts +11 -3
- package/src/device/hub.ts +8 -7
- package/src/device/humidifier.ts +6 -6
- package/src/device/iosensor.ts +7 -7
- package/src/device/lightstrip.ts +5 -5
- package/src/device/lock.ts +8 -8
- package/src/device/meter.ts +7 -7
- package/src/device/meterplus.ts +7 -7
- package/src/device/motion.ts +7 -7
- package/src/device/plug.ts +5 -5
- package/src/device/robotvacuumcleaner.ts +7 -7
- package/src/device/waterdetector.ts +10 -18
- package/src/irdevice/airconditioner.ts +240 -239
- package/src/irdevice/airpurifier.ts +76 -57
- package/src/irdevice/camera.ts +28 -28
- package/src/irdevice/fan.ts +64 -64
- package/src/irdevice/irdevice.ts +11 -3
- package/src/irdevice/light.ts +18 -16
- package/src/irdevice/other.ts +52 -52
- package/src/irdevice/tv.ts +3 -3
- package/src/irdevice/vacuumcleaner.ts +2 -2
- package/src/irdevice/waterheater.ts +2 -2
- package/src/platform.ts +21 -4
package/src/irdevice/light.ts
CHANGED
|
@@ -15,7 +15,11 @@ import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
|
|
|
15
15
|
*/
|
|
16
16
|
export class Light extends irdeviceBase {
|
|
17
17
|
// Services
|
|
18
|
-
|
|
18
|
+
private LightBulb!: {
|
|
19
|
+
Service: Service;
|
|
20
|
+
On: CharacteristicValue;
|
|
21
|
+
};
|
|
22
|
+
|
|
19
23
|
ProgrammableSwitchServiceOn?: Service;
|
|
20
24
|
ProgrammableSwitchServiceOff?: Service;
|
|
21
25
|
|
|
@@ -33,25 +37,23 @@ export class Light extends irdeviceBase {
|
|
|
33
37
|
) {
|
|
34
38
|
super(platform, accessory, device);
|
|
35
39
|
|
|
36
|
-
// default placeholders
|
|
37
|
-
if (this.On === undefined) {
|
|
38
|
-
this.On = false;
|
|
39
|
-
} else {
|
|
40
|
-
this.On = accessory.context.On;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
40
|
if (!device.irlight?.stateless) {
|
|
41
|
+
// Initialize LightBulb property
|
|
42
|
+
this.LightBulb = {
|
|
43
|
+
Service: accessory.getService(this.hap.Service.Lightbulb)!,
|
|
44
|
+
On: accessory.context.On || false,
|
|
45
|
+
};
|
|
44
46
|
// get the Light service if it exists, otherwise create a new Light service
|
|
45
47
|
// you can create multiple services for each accessory
|
|
46
|
-
const
|
|
47
|
-
(this.
|
|
48
|
-
|| accessory.addService(this.hap.Service.Lightbulb)),
|
|
48
|
+
const LightBulbService = `${accessory.displayName} ${device.remoteType}`;
|
|
49
|
+
(this.LightBulb.Service = accessory.getService(this.hap.Service.Lightbulb)
|
|
50
|
+
|| accessory.addService(this.hap.Service.Lightbulb)), LightBulbService;
|
|
49
51
|
|
|
50
52
|
|
|
51
|
-
this.
|
|
53
|
+
this.LightBulb.Service.setCharacteristic(this.hap.Characteristic.Name, accessory.displayName);
|
|
52
54
|
|
|
53
55
|
// handle on / off events using the On characteristic
|
|
54
|
-
this.
|
|
56
|
+
this.LightBulb.Service.getCharacteristic(this.hap.Characteristic.On).onSet(this.OnSet.bind(this));
|
|
55
57
|
} else {
|
|
56
58
|
|
|
57
59
|
// create a new Stateful Programmable Switch On service
|
|
@@ -221,7 +223,7 @@ export class Light extends irdeviceBase {
|
|
|
221
223
|
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
222
224
|
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} deviceStatus statusCode: ${deviceStatus.statusCode}`);
|
|
223
225
|
if ((statusCode === 200 || statusCode === 100) && (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)) {
|
|
224
|
-
this.
|
|
226
|
+
this.debugSuccessLog(`${this.device.remoteType}: ${this.accessory.displayName} `
|
|
225
227
|
+ `statusCode: ${statusCode} & deviceStatus StatusCode: ${deviceStatus.statusCode}`);
|
|
226
228
|
this.successLog(`${this.device.remoteType}: ${this.accessory.displayName} request to SwitchBot API, body: ${bodyChange} sent successfully`);
|
|
227
229
|
this.accessory.context.On = this.On;
|
|
@@ -252,7 +254,7 @@ export class Light extends irdeviceBase {
|
|
|
252
254
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} On: ${this.On}`);
|
|
253
255
|
} else {
|
|
254
256
|
this.accessory.context.On = this.On;
|
|
255
|
-
this.
|
|
257
|
+
this.LightBulb.Service?.updateCharacteristic(this.hap.Characteristic.On, this.On);
|
|
256
258
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic On: ${this.On}`);
|
|
257
259
|
}
|
|
258
260
|
} else {
|
|
@@ -283,7 +285,7 @@ export class Light extends irdeviceBase {
|
|
|
283
285
|
|
|
284
286
|
async apiError(e: any): Promise<void> {
|
|
285
287
|
if (this.device.irlight?.stateless) {
|
|
286
|
-
this.
|
|
288
|
+
this.LightBulb.Service?.updateCharacteristic(this.hap.Characteristic.On, e);
|
|
287
289
|
} else {
|
|
288
290
|
this.ProgrammableSwitchServiceOn?.updateCharacteristic(this.hap.Characteristic.ProgrammableSwitchEvent, e);
|
|
289
291
|
this.ProgrammableSwitchServiceOn?.updateCharacteristic(this.hap.Characteristic.ProgrammableSwitchOutputState, e);
|
package/src/irdevice/other.ts
CHANGED
|
@@ -14,7 +14,7 @@ import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
|
|
|
14
14
|
* Each accessory may expose multiple services of different service types.
|
|
15
15
|
*/
|
|
16
16
|
export class Others extends irdeviceBase {
|
|
17
|
-
|
|
17
|
+
// Services
|
|
18
18
|
private Switch?: {
|
|
19
19
|
Service: Service;
|
|
20
20
|
On: CharacteristicValue;
|
|
@@ -82,8 +82,8 @@ export class Others extends irdeviceBase {
|
|
|
82
82
|
if (this.otherDeviceType === 'switch') {
|
|
83
83
|
// Initialize Switch property
|
|
84
84
|
this.Switch = {
|
|
85
|
-
Service: accessory.
|
|
86
|
-
On: accessory.context.On ||
|
|
85
|
+
Service: accessory.getService(this.hap.Service.Switch)!,
|
|
86
|
+
On: accessory.context.On || false,
|
|
87
87
|
};
|
|
88
88
|
this.removeFanService(accessory);
|
|
89
89
|
this.removeLockService(accessory);
|
|
@@ -106,8 +106,8 @@ export class Others extends irdeviceBase {
|
|
|
106
106
|
} else if (this.otherDeviceType === 'garagedoor') {
|
|
107
107
|
// Initialize Garage Door property
|
|
108
108
|
this.GarageDoor = {
|
|
109
|
-
Service: accessory.
|
|
110
|
-
On: accessory.context.On ||
|
|
109
|
+
Service: accessory.getService(this.hap.Service.GarageDoorOpener)!,
|
|
110
|
+
On: accessory.context.On || false,
|
|
111
111
|
};
|
|
112
112
|
this.removeFanService(accessory);
|
|
113
113
|
this.removeLockService(accessory);
|
|
@@ -131,8 +131,8 @@ export class Others extends irdeviceBase {
|
|
|
131
131
|
} else if (this.otherDeviceType === 'door') {
|
|
132
132
|
// Initialize Door property
|
|
133
133
|
this.Door = {
|
|
134
|
-
Service: accessory.
|
|
135
|
-
On: accessory.context.On ||
|
|
134
|
+
Service: accessory.getService(this.hap.Service.Door)!,
|
|
135
|
+
On: accessory.context.On || false,
|
|
136
136
|
};
|
|
137
137
|
this.removeFanService(accessory);
|
|
138
138
|
this.removeLockService(accessory);
|
|
@@ -164,8 +164,8 @@ export class Others extends irdeviceBase {
|
|
|
164
164
|
} else if (this.otherDeviceType === 'window') {
|
|
165
165
|
// Initialize Window property
|
|
166
166
|
this.Window = {
|
|
167
|
-
Service: accessory.
|
|
168
|
-
On: accessory.context.On ||
|
|
167
|
+
Service: accessory.getService(this.hap.Service.Window)!,
|
|
168
|
+
On: accessory.context.On || false,
|
|
169
169
|
};
|
|
170
170
|
this.removeFanService(accessory);
|
|
171
171
|
this.removeLockService(accessory);
|
|
@@ -197,8 +197,8 @@ export class Others extends irdeviceBase {
|
|
|
197
197
|
} else if (this.otherDeviceType === 'windowcovering') {
|
|
198
198
|
// Initialize WindowCovering property
|
|
199
199
|
this.WindowCovering = {
|
|
200
|
-
Service: accessory.
|
|
201
|
-
On: accessory.context.On ||
|
|
200
|
+
Service: accessory.getService(this.hap.Service.WindowCovering)!,
|
|
201
|
+
On: accessory.context.On || false,
|
|
202
202
|
};
|
|
203
203
|
this.removeFanService(accessory);
|
|
204
204
|
this.removeLockService(accessory);
|
|
@@ -230,8 +230,8 @@ export class Others extends irdeviceBase {
|
|
|
230
230
|
} else if (this.otherDeviceType === 'lock') {
|
|
231
231
|
// Initialize Lock property
|
|
232
232
|
this.Lock = {
|
|
233
|
-
Service: accessory.
|
|
234
|
-
On: accessory.context.On ||
|
|
233
|
+
Service: accessory.getService(this.hap.Service.LockMechanism)!,
|
|
234
|
+
On: accessory.context.On || false,
|
|
235
235
|
};
|
|
236
236
|
this.removeFanService(accessory);
|
|
237
237
|
this.removeDoorService(accessory);
|
|
@@ -254,8 +254,8 @@ export class Others extends irdeviceBase {
|
|
|
254
254
|
} else if (this.otherDeviceType === 'faucet') {
|
|
255
255
|
// Initialize Faucet property
|
|
256
256
|
this.Faucet = {
|
|
257
|
-
Service: accessory.
|
|
258
|
-
On: accessory.context.On ||
|
|
257
|
+
Service: accessory.getService(this.hap.Service.Faucet)!,
|
|
258
|
+
On: accessory.context.On || false,
|
|
259
259
|
};
|
|
260
260
|
this.removeFanService(accessory);
|
|
261
261
|
this.removeLockService(accessory);
|
|
@@ -278,8 +278,8 @@ export class Others extends irdeviceBase {
|
|
|
278
278
|
} else if (this.otherDeviceType === 'fan') {
|
|
279
279
|
// Initialize Fan property
|
|
280
280
|
this.Fan = {
|
|
281
|
-
Service: accessory.
|
|
282
|
-
On: accessory.context.On ||
|
|
281
|
+
Service: accessory.getService(this.hap.Service.Fanv2)!,
|
|
282
|
+
On: accessory.context.On || false,
|
|
283
283
|
};
|
|
284
284
|
this.removeLockService(accessory);
|
|
285
285
|
this.removeDoorService(accessory);
|
|
@@ -302,8 +302,8 @@ export class Others extends irdeviceBase {
|
|
|
302
302
|
} else if (this.otherDeviceType === 'stateful') {
|
|
303
303
|
// Initialize StatefulProgrammableSwitch property
|
|
304
304
|
this.StatefulProgrammableSwitch = {
|
|
305
|
-
Service: accessory.
|
|
306
|
-
On: accessory.context.On ||
|
|
305
|
+
Service: accessory.getService(this.hap.Service.StatefulProgrammableSwitch)!,
|
|
306
|
+
On: accessory.context.On || false,
|
|
307
307
|
};
|
|
308
308
|
this.removeFanService(accessory);
|
|
309
309
|
this.removeLockService(accessory);
|
|
@@ -328,8 +328,8 @@ export class Others extends irdeviceBase {
|
|
|
328
328
|
} else {
|
|
329
329
|
// Initialize Outlet property
|
|
330
330
|
this.Outlet = {
|
|
331
|
-
Service: accessory.
|
|
332
|
-
On: accessory.context.On ||
|
|
331
|
+
Service: accessory.getService(this.hap.Service.Outlet)!,
|
|
332
|
+
On: accessory.context.On || false,
|
|
333
333
|
};
|
|
334
334
|
this.removeFanService(accessory);
|
|
335
335
|
this.removeLockService(accessory);
|
|
@@ -491,7 +491,7 @@ export class Others extends irdeviceBase {
|
|
|
491
491
|
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
492
492
|
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} deviceStatus statusCode: ${deviceStatus.statusCode}`);
|
|
493
493
|
if ((statusCode === 200 || statusCode === 100) && (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)) {
|
|
494
|
-
this.
|
|
494
|
+
this.debugSuccessLog(`${this.device.remoteType}: ${this.accessory.displayName} `
|
|
495
495
|
+ `statusCode: ${statusCode} & deviceStatus StatusCode: ${deviceStatus.statusCode}`);
|
|
496
496
|
this.successLog(`${this.device.remoteType}: ${this.accessory.displayName} request to SwitchBot API, body: ${bodyChange} sent successfully`);
|
|
497
497
|
this.updateHomeKitCharacteristics();
|
|
@@ -700,92 +700,92 @@ export class Others extends irdeviceBase {
|
|
|
700
700
|
|
|
701
701
|
async removeOutletService(accessory: PlatformAccessory): Promise<void> {
|
|
702
702
|
// If Outlet.Service still present, then remove first
|
|
703
|
+
if (this.Outlet?.Service) {
|
|
703
704
|
this.Outlet!.Service = this.accessory.getService(this.hap.Service.Outlet) as Service;
|
|
704
|
-
|
|
705
|
-
this.warnLog(`${this.device.remoteType}: ${accessory.displayName} Removing Leftover Outlet Service`);
|
|
706
|
-
}
|
|
705
|
+
this.warnLog(`${this.device.remoteType}: ${accessory.displayName} Removing Leftover Outlet Service`);
|
|
707
706
|
accessory.removeService(this.Outlet!.Service);
|
|
707
|
+
}
|
|
708
708
|
}
|
|
709
709
|
|
|
710
710
|
async removeGarageDoorService(accessory: PlatformAccessory): Promise<void> {
|
|
711
711
|
// If GarageDoor.Service still present, then remove first
|
|
712
|
+
if (this.GarageDoor?.Service) {
|
|
712
713
|
this.GarageDoor!.Service = this.accessory.getService(this.hap.Service.GarageDoorOpener) as Service;
|
|
713
|
-
|
|
714
|
-
this.warnLog(`${this.device.remoteType}: ${accessory.displayName} Removing Leftover Garage Door Service`);
|
|
715
|
-
}
|
|
714
|
+
this.warnLog(`${this.device.remoteType}: ${accessory.displayName} Removing Leftover Garage Door Service`);
|
|
716
715
|
accessory.removeService(this.GarageDoor!.Service);
|
|
716
|
+
}
|
|
717
717
|
}
|
|
718
718
|
|
|
719
719
|
async removeDoorService(accessory: PlatformAccessory): Promise<void> {
|
|
720
720
|
// If Door.Service still present, then remove first
|
|
721
|
+
if (this.Door?.Service) {
|
|
721
722
|
this.Door!.Service = this.accessory.getService(this.hap.Service.Door) as Service;
|
|
722
|
-
|
|
723
|
-
this.warnLog(`${this.device.remoteType}: ${accessory.displayName} Removing Leftover Door Service`);
|
|
724
|
-
}
|
|
723
|
+
this.warnLog(`${this.device.remoteType}: ${accessory.displayName} Removing Leftover Door Service`);
|
|
725
724
|
accessory.removeService(this.Door!.Service);
|
|
725
|
+
}
|
|
726
726
|
}
|
|
727
727
|
|
|
728
728
|
async removeLockService(accessory: PlatformAccessory): Promise<void> {
|
|
729
729
|
// If Lock.Service still present, then remove first
|
|
730
|
+
if (this.Lock?.Service) {
|
|
730
731
|
this.Lock!.Service = this.accessory.getService(this.hap.Service.LockMechanism) as Service;
|
|
731
|
-
|
|
732
|
-
this.warnLog(`${this.device.remoteType}: ${accessory.displayName} Removing Leftover Lock Service`);
|
|
733
|
-
}
|
|
732
|
+
this.warnLog(`${this.device.remoteType}: ${accessory.displayName} Removing Leftover Lock Service`);
|
|
734
733
|
accessory.removeService(this.Lock!.Service);
|
|
734
|
+
}
|
|
735
735
|
}
|
|
736
736
|
|
|
737
737
|
async removeFaucetService(accessory: PlatformAccessory): Promise<void> {
|
|
738
738
|
// If Faucet.Service still present, then remove first
|
|
739
|
+
if (this.Faucet?.Service) {
|
|
739
740
|
this.Faucet!.Service = this.accessory.getService(this.hap.Service.Faucet) as Service;
|
|
740
|
-
|
|
741
|
-
this.warnLog(`${this.device.remoteType}: ${accessory.displayName} Removing Leftover Faucet Service`);
|
|
742
|
-
}
|
|
741
|
+
this.warnLog(`${this.device.remoteType}: ${accessory.displayName} Removing Leftover Faucet Service`);
|
|
743
742
|
accessory.removeService(this.Faucet!.Service);
|
|
743
|
+
}
|
|
744
744
|
}
|
|
745
745
|
|
|
746
746
|
async removeFanService(accessory: PlatformAccessory): Promise<void> {
|
|
747
747
|
// If Fan Service still present, then remove first
|
|
748
|
+
if (this.Fan?.Service) {
|
|
748
749
|
this.Fan!.Service = this.accessory.getService(this.hap.Service.Fan) as Service;
|
|
749
|
-
|
|
750
|
-
this.warnLog(`${this.device.remoteType}: ${accessory.displayName} Removing Leftover Fan Service`);
|
|
751
|
-
}
|
|
750
|
+
this.warnLog(`${this.device.remoteType}: ${accessory.displayName} Removing Leftover Fan Service`);
|
|
752
751
|
accessory.removeService(this.Fan!.Service);
|
|
752
|
+
}
|
|
753
753
|
}
|
|
754
754
|
|
|
755
755
|
async removeWindowService(accessory: PlatformAccessory): Promise<void> {
|
|
756
756
|
// If Window.Service still present, then remove first
|
|
757
|
+
if (this.Window?.Service) {
|
|
757
758
|
this.Window!.Service = this.accessory.getService(this.hap.Service.Window) as Service;
|
|
758
|
-
|
|
759
|
-
this.warnLog(`${this.device.remoteType}: ${accessory.displayName} Removing Leftover Window Service`);
|
|
760
|
-
}
|
|
759
|
+
this.warnLog(`${this.device.remoteType}: ${accessory.displayName} Removing Leftover Window Service`);
|
|
761
760
|
accessory.removeService(this.Window!.Service);
|
|
761
|
+
}
|
|
762
762
|
}
|
|
763
763
|
|
|
764
764
|
async removeWindowCoveringService(accessory: PlatformAccessory): Promise<void> {
|
|
765
765
|
// If WindowCovering.Service still present, then remove first
|
|
766
|
+
if (this.WindowCovering?.Service) {
|
|
766
767
|
this.WindowCovering!.Service = this.accessory.getService(this.hap.Service.WindowCovering) as Service;
|
|
767
|
-
|
|
768
|
-
this.warnLog(`${this.device.remoteType}: ${accessory.displayName} Removing Leftover Window Covering Service`);
|
|
769
|
-
}
|
|
768
|
+
this.warnLog(`${this.device.remoteType}: ${accessory.displayName} Removing Leftover Window Covering Service`);
|
|
770
769
|
accessory.removeService(this.WindowCovering!.Service);
|
|
770
|
+
}
|
|
771
771
|
}
|
|
772
772
|
|
|
773
773
|
async removeStatefulProgrammableSwitchService(accessory: PlatformAccessory): Promise<void> {
|
|
774
774
|
// If StatefulProgrammableSwitch.Service still present, then remove first
|
|
775
|
+
if (this.StatefulProgrammableSwitch?.Service) {
|
|
775
776
|
this.StatefulProgrammableSwitch!.Service = this.accessory.getService(this.hap.Service.StatefulProgrammableSwitch) as Service;
|
|
776
|
-
|
|
777
|
-
this.warnLog(`${this.device.remoteType}: ${accessory.displayName} Removing Leftover Stateful Programmable Switch Service`);
|
|
778
|
-
}
|
|
777
|
+
this.warnLog(`${this.device.remoteType}: ${accessory.displayName} Removing Leftover Stateful Programmable Switch Service`);
|
|
779
778
|
accessory.removeService(this.StatefulProgrammableSwitch!.Service);
|
|
779
|
+
}
|
|
780
780
|
}
|
|
781
781
|
|
|
782
782
|
async removeSwitchService(accessory: PlatformAccessory): Promise<void> {
|
|
783
783
|
// If Switch.Service still present, then remove first
|
|
784
|
+
if (this.Switch?.Service) {
|
|
784
785
|
this.Switch!.Service = this.accessory.getService(this.hap.Service.Switch) as Service;
|
|
785
|
-
|
|
786
|
-
this.warnLog(`${this.device.remoteType}: ${accessory.displayName} Removing Leftover Switch Service`);
|
|
787
|
-
}
|
|
786
|
+
this.warnLog(`${this.device.remoteType}: ${accessory.displayName} Removing Leftover Switch Service`);
|
|
788
787
|
accessory.removeService(this.Switch!.Service);
|
|
788
|
+
}
|
|
789
789
|
}
|
|
790
790
|
|
|
791
791
|
async getOtherConfigSettings(device: irdevice & irDevicesConfig): Promise<void> {
|
package/src/irdevice/tv.ts
CHANGED
|
@@ -41,7 +41,7 @@ export class TV extends irdeviceBase {
|
|
|
41
41
|
|
|
42
42
|
// Initialize Television property
|
|
43
43
|
this.Television = {
|
|
44
|
-
Service: accessory.
|
|
44
|
+
Service: accessory.getService(this.hap.Service.Television)!,
|
|
45
45
|
Active: accessory.context.Active || this.hap.Characteristic.Active.INACTIVE,
|
|
46
46
|
ActiveIdentifier: accessory.context.ActiveIdentifier || 1,
|
|
47
47
|
SleepDiscoveryMode: accessory.context.SleepDiscoveryMode || this.hap.Characteristic.SleepDiscoveryMode.ALWAYS_DISCOVERABLE,
|
|
@@ -50,7 +50,7 @@ export class TV extends irdeviceBase {
|
|
|
50
50
|
|
|
51
51
|
// Initialize TelevisionSpeaker property
|
|
52
52
|
this.TelevisionSpeaker = {
|
|
53
|
-
Service: accessory.
|
|
53
|
+
Service: accessory.getService(this.hap.Service.TelevisionSpeaker)!,
|
|
54
54
|
Active: accessory.context.Active || false,
|
|
55
55
|
VolumeControlType: accessory.context.VolumeControlType || this.hap.Characteristic.VolumeControlType.ABSOLUTE,
|
|
56
56
|
VolumeSelector: accessory.context.VolumeSelector || this.hap.Characteristic.VolumeSelector.INCREMENT,
|
|
@@ -388,7 +388,7 @@ export class TV extends irdeviceBase {
|
|
|
388
388
|
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
389
389
|
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} deviceStatus statusCode: ${deviceStatus.statusCode}`);
|
|
390
390
|
if ((statusCode === 200 || statusCode === 100) && (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)) {
|
|
391
|
-
this.
|
|
391
|
+
this.debugSuccessLog(`${this.device.remoteType}: ${this.accessory.displayName} `
|
|
392
392
|
+ `statusCode: ${statusCode} & deviceStatus StatusCode: ${deviceStatus.statusCode}`);
|
|
393
393
|
this.successLog(`${this.device.remoteType}: ${this.accessory.displayName} request to SwitchBot API, body: ${bodyChange} sent successfully`);
|
|
394
394
|
this.updateHomeKitCharacteristics();
|
|
@@ -29,7 +29,7 @@ export class VacuumCleaner extends irdeviceBase {
|
|
|
29
29
|
|
|
30
30
|
// Initialize Switch property
|
|
31
31
|
this.Switch = {
|
|
32
|
-
Service: accessory.
|
|
32
|
+
Service: accessory.getService(this.hap.Service.Switch)!,
|
|
33
33
|
On: accessory.context.On || false,
|
|
34
34
|
};
|
|
35
35
|
|
|
@@ -107,7 +107,7 @@ export class VacuumCleaner extends irdeviceBase {
|
|
|
107
107
|
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
108
108
|
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} deviceStatus statusCode: ${deviceStatus.statusCode}`);
|
|
109
109
|
if ((statusCode === 200 || statusCode === 100) && (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)) {
|
|
110
|
-
this.
|
|
110
|
+
this.debugSuccessLog(`${this.device.remoteType}: ${this.accessory.displayName} `
|
|
111
111
|
+ `statusCode: ${statusCode} & deviceStatus StatusCode: ${deviceStatus.statusCode}`);
|
|
112
112
|
this.successLog(`${this.device.remoteType}: ${this.accessory.displayName} request to SwitchBot API, body: ${bodyChange} sent successfully`);
|
|
113
113
|
this.updateHomeKitCharacteristics();
|
|
@@ -29,7 +29,7 @@ export class WaterHeater extends irdeviceBase {
|
|
|
29
29
|
|
|
30
30
|
// Initialize Valve property
|
|
31
31
|
this.Valve = {
|
|
32
|
-
Service: accessory.
|
|
32
|
+
Service: accessory.getService(this.hap.Service.Valve)!,
|
|
33
33
|
Active: accessory.context.Active || this.hap.Characteristic.Active.INACTIVE,
|
|
34
34
|
};
|
|
35
35
|
|
|
@@ -112,7 +112,7 @@ export class WaterHeater extends irdeviceBase {
|
|
|
112
112
|
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
113
113
|
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} deviceStatus statusCode: ${deviceStatus.statusCode}`);
|
|
114
114
|
if ((statusCode === 200 || statusCode === 100) && (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)) {
|
|
115
|
-
this.
|
|
115
|
+
this.debugSuccessLog(`${this.device.remoteType}: ${this.accessory.displayName} `
|
|
116
116
|
+ `statusCode: ${statusCode} & deviceStatus StatusCode: ${deviceStatus.statusCode}`);
|
|
117
117
|
this.successLog(`${this.device.remoteType}: ${this.accessory.displayName} request to SwitchBot API, body: ${bodyChange} sent successfully`);
|
|
118
118
|
this.updateHomeKitCharacteristics();
|
package/src/platform.ts
CHANGED
|
@@ -39,12 +39,10 @@ import fakegato from 'fakegato-history';
|
|
|
39
39
|
import asyncmqtt from 'async-mqtt';
|
|
40
40
|
import crypto, { randomUUID } from 'crypto';
|
|
41
41
|
import { readFileSync, writeFileSync } from 'fs';
|
|
42
|
-
import { EveHomeKitTypes } from 'homebridge-lib';
|
|
42
|
+
import { EveHomeKitTypes } from 'homebridge-lib/EveHomeKitTypes';
|
|
43
43
|
import { UrlObject } from 'url';
|
|
44
44
|
import { sleep } from './utils.js';
|
|
45
45
|
|
|
46
|
-
|
|
47
|
-
|
|
48
46
|
/**
|
|
49
47
|
* HomebridgePlatform
|
|
50
48
|
* This class is the main constructor for your plugin, this is where you should
|
|
@@ -387,7 +385,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
387
385
|
}
|
|
388
386
|
|
|
389
387
|
if (!this.config.options.maxRetries) {
|
|
390
|
-
this.config.options
|
|
388
|
+
this.config.options.maxRetries = 5;
|
|
391
389
|
this.debugWarnLog('Using Default Max Retries.');
|
|
392
390
|
} else {
|
|
393
391
|
this.maxRetries = this.config.options.maxRetries;
|
|
@@ -513,6 +511,9 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
513
511
|
let retryCount = 0;
|
|
514
512
|
const maxRetries = this.maxRetries; // Maximum number of retries
|
|
515
513
|
const delayBetweenRetries = this.delayBetweenRetries; // Delay between retries in milliseconds
|
|
514
|
+
this.debugWarnLog(`Retry Count: ${retryCount}`);
|
|
515
|
+
this.debugWarnLog(`Max Retries: ${maxRetries}`);
|
|
516
|
+
this.debugWarnLog(`Delay Between Retries: ${delayBetweenRetries}`);
|
|
516
517
|
while (retryCount < maxRetries) {
|
|
517
518
|
try {
|
|
518
519
|
const { body, statusCode } = await request(Devices, {
|
|
@@ -2718,6 +2719,22 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
2718
2719
|
if (this.config.options.pushRate) {
|
|
2719
2720
|
platformConfig.pushRate = this.config.options.pushRate;
|
|
2720
2721
|
}
|
|
2722
|
+
if (this.config.options.maxRetries) {
|
|
2723
|
+
this.maxRetries = this.config.options.maxRetries;
|
|
2724
|
+
platformConfig.maxRetries = this.config.options.maxRetries;
|
|
2725
|
+
} else {
|
|
2726
|
+
this.maxRetries = 3;
|
|
2727
|
+
this.debugWarnLog('Using Default Max Retries');
|
|
2728
|
+
platformConfig.maxRetries = this.maxRetries;
|
|
2729
|
+
}
|
|
2730
|
+
if (this.config.options.delayBetweenRetries) {
|
|
2731
|
+
this.delayBetweenRetries = this.config.options.delayBetweenRetries * 1000;
|
|
2732
|
+
platformConfig.delayBetweenRetries = this.config.options.delayBetweenRetries;
|
|
2733
|
+
} else {
|
|
2734
|
+
this.delayBetweenRetries = 3000;
|
|
2735
|
+
this.debugWarnLog('Using Default Delay Between Retries');
|
|
2736
|
+
platformConfig.delayBetweenRetries = this.delayBetweenRetries / 1000;
|
|
2737
|
+
}
|
|
2721
2738
|
if (Object.entries(platformConfig).length !== 0) {
|
|
2722
2739
|
this.debugLog(`Platform Config: ${JSON.stringify(platformConfig)}`);
|
|
2723
2740
|
}
|