@switchbot/homebridge-switchbot 2.8.0-beta.10 → 2.8.0-beta.11
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/bot.d.ts +1 -0
- package/dist/device/bot.d.ts.map +1 -1
- package/dist/device/bot.js +45 -39
- package/dist/device/bot.js.map +1 -1
- package/dist/device/contact.js.map +1 -1
- package/dist/device/curtain.d.ts.map +1 -1
- package/dist/device/curtain.js +2 -0
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/iosensor.js.map +1 -1
- package/dist/device/lock.js +1 -1
- package/dist/device/meter.js +1 -1
- package/dist/device/meter.js.map +1 -1
- package/dist/device/meterplus.js.map +1 -1
- package/dist/device/motion.js.map +1 -1
- package/dist/device/robotvacuumcleaner.d.ts +1 -0
- package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
- package/dist/device/robotvacuumcleaner.js +1 -0
- package/dist/device/robotvacuumcleaner.js.map +1 -1
- package/package.json +1 -1
- package/src/device/bot.ts +45 -36
- package/src/device/contact.ts +2 -2
- package/src/device/curtain.ts +2 -0
- package/src/device/iosensor.ts +2 -2
- package/src/device/lock.ts +1 -1
- package/src/device/meter.ts +2 -2
- package/src/device/meterplus.ts +2 -2
- package/src/device/motion.ts +2 -2
- package/src/device/robotvacuumcleaner.ts +2 -0
package/src/device/bot.ts
CHANGED
|
@@ -33,6 +33,7 @@ export class Bot {
|
|
|
33
33
|
|
|
34
34
|
// OpenAPI Others
|
|
35
35
|
Version: deviceStatus['version'];
|
|
36
|
+
Battery: deviceStatus['battery'];
|
|
36
37
|
power: deviceStatus['power'];
|
|
37
38
|
deviceStatus!: any; //deviceStatusResponse;
|
|
38
39
|
|
|
@@ -114,7 +115,7 @@ export class Bot {
|
|
|
114
115
|
// Add switchService
|
|
115
116
|
(this.switchService = accessory.getService(this.platform.Service.Switch) || accessory.addService(this.platform.Service.Switch)),
|
|
116
117
|
`${accessory.displayName} Switch`;
|
|
117
|
-
this.
|
|
118
|
+
this.debugWarnLog(`${this.device.deviceType}: ${accessory.displayName} Displaying as Switch`);
|
|
118
119
|
|
|
119
120
|
this.switchService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
120
121
|
if (!this.switchService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
|
|
@@ -136,7 +137,7 @@ export class Bot {
|
|
|
136
137
|
(this.garageDoorService =
|
|
137
138
|
accessory.getService(this.platform.Service.GarageDoorOpener) || accessory.addService(this.platform.Service.GarageDoorOpener)),
|
|
138
139
|
`${accessory.displayName} Garage Door Opener`;
|
|
139
|
-
this.
|
|
140
|
+
this.debugWarnLog(`${this.device.deviceType}: ${accessory.displayName} Displaying as Garage Door Opener`);
|
|
140
141
|
|
|
141
142
|
this.garageDoorService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
142
143
|
if (!this.garageDoorService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
|
|
@@ -158,7 +159,7 @@ export class Bot {
|
|
|
158
159
|
// Add switchService
|
|
159
160
|
(this.doorService = accessory.getService(this.platform.Service.Door) || accessory.addService(this.platform.Service.Door)),
|
|
160
161
|
`${accessory.displayName} Door`;
|
|
161
|
-
this.
|
|
162
|
+
this.debugWarnLog(`${this.device.deviceType}: ${accessory.displayName} Displaying as Door`);
|
|
162
163
|
|
|
163
164
|
this.doorService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
164
165
|
if (!this.doorService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
|
|
@@ -188,7 +189,7 @@ export class Bot {
|
|
|
188
189
|
// Add switchService
|
|
189
190
|
(this.windowService = accessory.getService(this.platform.Service.Window) || accessory.addService(this.platform.Service.Window)),
|
|
190
191
|
`${accessory.displayName} Window`;
|
|
191
|
-
this.
|
|
192
|
+
this.debugWarnLog(`${this.device.deviceType}: ${accessory.displayName} Displaying as Window`);
|
|
192
193
|
|
|
193
194
|
this.windowService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
194
195
|
if (!this.windowService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
|
|
@@ -219,7 +220,7 @@ export class Bot {
|
|
|
219
220
|
(this.windowCoveringService =
|
|
220
221
|
accessory.getService(this.platform.Service.WindowCovering) || accessory.addService(this.platform.Service.WindowCovering)),
|
|
221
222
|
`${accessory.displayName} Window Covering`;
|
|
222
|
-
this.
|
|
223
|
+
this.debugWarnLog(`${this.device.deviceType}: ${accessory.displayName} Displaying as Window Covering`);
|
|
223
224
|
|
|
224
225
|
this.windowCoveringService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
225
226
|
if (!this.windowCoveringService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
|
|
@@ -249,7 +250,7 @@ export class Bot {
|
|
|
249
250
|
// Add switchService
|
|
250
251
|
(this.lockService = accessory.getService(this.platform.Service.LockMechanism) || accessory.addService(this.platform.Service.LockMechanism)),
|
|
251
252
|
`${accessory.displayName} Lock`;
|
|
252
|
-
this.
|
|
253
|
+
this.debugWarnLog(`${this.device.deviceType}: ${accessory.displayName} Displaying as Lock`);
|
|
253
254
|
|
|
254
255
|
this.lockService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
255
256
|
if (!this.lockService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
|
|
@@ -270,7 +271,7 @@ export class Bot {
|
|
|
270
271
|
// Add switchService
|
|
271
272
|
(this.faucetService = accessory.getService(this.platform.Service.Faucet) || accessory.addService(this.platform.Service.Faucet)),
|
|
272
273
|
`${accessory.displayName} Faucet`;
|
|
273
|
-
this.
|
|
274
|
+
this.debugWarnLog(`${this.device.deviceType}: ${accessory.displayName} Displaying as Faucet`);
|
|
274
275
|
|
|
275
276
|
this.faucetService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
276
277
|
if (!this.faucetService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
|
|
@@ -291,7 +292,7 @@ export class Bot {
|
|
|
291
292
|
// Add switchService
|
|
292
293
|
(this.fanService = accessory.getService(this.platform.Service.Fan) || accessory.addService(this.platform.Service.Fan)),
|
|
293
294
|
`${accessory.displayName} Fan`;
|
|
294
|
-
this.
|
|
295
|
+
this.debugWarnLog(`${this.device.deviceType}: ${accessory.displayName} Displaying as Fan`);
|
|
295
296
|
|
|
296
297
|
this.fanService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
297
298
|
if (!this.fanService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
|
|
@@ -314,7 +315,7 @@ export class Bot {
|
|
|
314
315
|
accessory.getService(this.platform.Service.StatefulProgrammableSwitch) ||
|
|
315
316
|
accessory.addService(this.platform.Service.StatefulProgrammableSwitch)),
|
|
316
317
|
`${accessory.displayName} Stateful Programmable Switch`;
|
|
317
|
-
this.
|
|
318
|
+
this.debugWarnLog(`${this.device.deviceType}: ${accessory.displayName} Displaying as Stateful Programmable Switch`);
|
|
318
319
|
|
|
319
320
|
this.statefulProgrammableSwitchService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
320
321
|
if (!this.statefulProgrammableSwitchService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
|
|
@@ -337,7 +338,7 @@ export class Bot {
|
|
|
337
338
|
// Add outletService
|
|
338
339
|
(this.outletService = accessory.getService(this.platform.Service.Outlet) || accessory.addService(this.platform.Service.Outlet)),
|
|
339
340
|
`${accessory.displayName} Outlet`;
|
|
340
|
-
this.
|
|
341
|
+
this.debugWarnLog(`${this.device.deviceType}: ${accessory.displayName} Displaying as Outlet`);
|
|
341
342
|
|
|
342
343
|
this.outletService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
343
344
|
if (!this.outletService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
|
|
@@ -347,19 +348,16 @@ export class Bot {
|
|
|
347
348
|
}
|
|
348
349
|
|
|
349
350
|
// Battery Service
|
|
350
|
-
if (!this.
|
|
351
|
-
this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Removing Battery Service`);
|
|
352
|
-
this.batteryService = this.accessory.getService(this.platform.Service.Battery);
|
|
353
|
-
accessory.removeService(this.batteryService!);
|
|
354
|
-
} else if (this.BLE && !this.batteryService) {
|
|
351
|
+
if (!this.batteryService) {
|
|
355
352
|
this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Add Battery Service`);
|
|
356
353
|
(this.batteryService = this.accessory.getService(this.platform.Service.Battery) || this.accessory.addService(this.platform.Service.Battery)),
|
|
357
354
|
`${accessory.displayName} Battery`;
|
|
358
355
|
|
|
359
356
|
this.batteryService.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Battery`);
|
|
360
357
|
if (!this.batteryService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
|
|
361
|
-
this.batteryService.addCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
|
|
358
|
+
this.batteryService.addCharacteristic(this.platform.Characteristic.ConfiguredName, `${accessory.displayName} Battery`);
|
|
362
359
|
}
|
|
360
|
+
this.batteryService.setCharacteristic(this.platform.Characteristic.ChargingState, this.platform.Characteristic.ChargingState.NOT_CHARGEABLE);
|
|
363
361
|
} else {
|
|
364
362
|
this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Battery Service Not Added`);
|
|
365
363
|
}
|
|
@@ -462,6 +460,18 @@ export class Bot {
|
|
|
462
460
|
}
|
|
463
461
|
}
|
|
464
462
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.On}`);
|
|
463
|
+
|
|
464
|
+
// Battery
|
|
465
|
+
this.BatteryLevel = Number(this.Battery);
|
|
466
|
+
if (this.BatteryLevel < 10) {
|
|
467
|
+
this.StatusLowBattery = this.platform.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW;
|
|
468
|
+
} else {
|
|
469
|
+
this.StatusLowBattery = this.platform.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL;
|
|
470
|
+
}
|
|
471
|
+
if (Number.isNaN(this.BatteryLevel)) {
|
|
472
|
+
this.BatteryLevel = 100;
|
|
473
|
+
}
|
|
474
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} BatteryLevel: ${this.BatteryLevel}`);
|
|
465
475
|
}
|
|
466
476
|
|
|
467
477
|
/**
|
|
@@ -559,6 +569,8 @@ export class Bot {
|
|
|
559
569
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Headers: ${JSON.stringify(headers)}`);
|
|
560
570
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} refreshStatus: ${JSON.stringify(deviceStatus)}`);
|
|
561
571
|
this.power = deviceStatus.body.power;
|
|
572
|
+
this.Battery = deviceStatus.body.battery;
|
|
573
|
+
this.Version = deviceStatus.body.version;
|
|
562
574
|
this.openAPIparseStatus();
|
|
563
575
|
this.updateHomeKitCharacteristics();
|
|
564
576
|
} catch (e: any) {
|
|
@@ -986,23 +998,22 @@ export class Bot {
|
|
|
986
998
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic On: ${this.On}`);
|
|
987
999
|
}
|
|
988
1000
|
}
|
|
989
|
-
this.
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
}
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
this.batteryService?.updateCharacteristic(this.platform.Characteristic.StatusLowBattery, this.StatusLowBattery);
|
|
1003
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic StatusLowBattery: ${this.StatusLowBattery}`);
|
|
1004
|
-
}
|
|
1001
|
+
if (this.BatteryLevel === undefined) {
|
|
1002
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} BatteryLevel: ${this.BatteryLevel}`);
|
|
1003
|
+
} else {
|
|
1004
|
+
this.accessory.context.BatteryLevel = this.BatteryLevel;
|
|
1005
|
+
this.batteryService?.updateCharacteristic(this.platform.Characteristic.BatteryLevel, this.BatteryLevel);
|
|
1006
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic BatteryLevel: ${this.BatteryLevel}`);
|
|
1007
|
+
}
|
|
1008
|
+
if (this.StatusLowBattery === undefined) {
|
|
1009
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} StatusLowBattery: ${this.StatusLowBattery}`);
|
|
1010
|
+
} else {
|
|
1011
|
+
this.accessory.context.StatusLowBattery = this.StatusLowBattery;
|
|
1012
|
+
this.batteryService?.updateCharacteristic(this.platform.Characteristic.StatusLowBattery, this.StatusLowBattery);
|
|
1013
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic StatusLowBattery: ${this.StatusLowBattery}`);
|
|
1005
1014
|
}
|
|
1015
|
+
|
|
1016
|
+
this.accessory.context.On = this.On;
|
|
1006
1017
|
}
|
|
1007
1018
|
|
|
1008
1019
|
async removeOutletService(accessory: PlatformAccessory): Promise<void> {
|
|
@@ -1290,10 +1301,8 @@ export class Bot {
|
|
|
1290
1301
|
} else {
|
|
1291
1302
|
this.outletService?.updateCharacteristic(this.platform.Characteristic.On, e);
|
|
1292
1303
|
}
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
this.batteryService?.updateCharacteristic(this.platform.Characteristic.StatusLowBattery, e);
|
|
1296
|
-
}
|
|
1304
|
+
this.batteryService?.updateCharacteristic(this.platform.Characteristic.BatteryLevel, e);
|
|
1305
|
+
this.batteryService?.updateCharacteristic(this.platform.Characteristic.StatusLowBattery, e);
|
|
1297
1306
|
}
|
|
1298
1307
|
|
|
1299
1308
|
FirmwareRevision(accessory: PlatformAccessory<Context>, device: device & devicesConfig): CharacteristicValue {
|
package/src/device/contact.ts
CHANGED
|
@@ -408,8 +408,8 @@ export class Contact {
|
|
|
408
408
|
this.openState = deviceStatus.body.openState;
|
|
409
409
|
this.moveDetected = deviceStatus.body.moveDetected;
|
|
410
410
|
this.brightness = deviceStatus.body.brightness;
|
|
411
|
-
this.Battery = deviceStatus.body.battery
|
|
412
|
-
this.Version = deviceStatus.body.version
|
|
411
|
+
this.Battery = deviceStatus.body.battery;
|
|
412
|
+
this.Version = deviceStatus.body.version;
|
|
413
413
|
this.openAPIparseStatus();
|
|
414
414
|
this.updateHomeKitCharacteristics();
|
|
415
415
|
} catch (e: any) {
|
package/src/device/curtain.ts
CHANGED
|
@@ -567,6 +567,8 @@ export class Curtain {
|
|
|
567
567
|
this.slidePosition = deviceStatus.body.slidePosition;
|
|
568
568
|
this.moving = deviceStatus.body.moving;
|
|
569
569
|
this.brightness = deviceStatus.body.brightness;
|
|
570
|
+
this.Battery = deviceStatus.body.battery;
|
|
571
|
+
this.Version = deviceStatus.body.version;
|
|
570
572
|
this.openAPIparseStatus();
|
|
571
573
|
this.updateHomeKitCharacteristics();
|
|
572
574
|
} catch (e: any) {
|
package/src/device/iosensor.ts
CHANGED
|
@@ -345,8 +345,8 @@ export class IOSensor {
|
|
|
345
345
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} refreshStatus: ${JSON.stringify(deviceStatus)}`);
|
|
346
346
|
this.Humidity = deviceStatus.body.humidity!;
|
|
347
347
|
this.Temperature = deviceStatus.body.temperature!;
|
|
348
|
-
this.Battery = deviceStatus.body.battery
|
|
349
|
-
this.Version = deviceStatus.body.version
|
|
348
|
+
this.Battery = deviceStatus.body.battery;
|
|
349
|
+
this.Version = deviceStatus.body.version;
|
|
350
350
|
this.openAPIparseStatus();
|
|
351
351
|
this.updateHomeKitCharacteristics();
|
|
352
352
|
} catch (e: any) {
|
package/src/device/lock.ts
CHANGED
|
@@ -319,8 +319,8 @@ export class Lock {
|
|
|
319
319
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} refreshStatus: ${JSON.stringify(deviceStatus)}`);
|
|
320
320
|
this.lockState = deviceStatus.body.lockState;
|
|
321
321
|
this.doorState = deviceStatus.body.doorState;
|
|
322
|
-
this.Version = deviceStatus.body.version;
|
|
323
322
|
this.Battery = deviceStatus.body.battery;
|
|
323
|
+
this.Version = deviceStatus.body.version;
|
|
324
324
|
this.openAPIparseStatus();
|
|
325
325
|
this.updateHomeKitCharacteristics();
|
|
326
326
|
} catch (e: any) {
|
package/src/device/meter.ts
CHANGED
|
@@ -351,8 +351,8 @@ export class Meter {
|
|
|
351
351
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} refreshStatus: ${JSON.stringify(deviceStatus)}`);
|
|
352
352
|
this.Humidity = deviceStatus.body.humidity!;
|
|
353
353
|
this.Temperature = deviceStatus.body.temperature!;
|
|
354
|
-
this.Battery = deviceStatus.body.battery
|
|
355
|
-
this.Version = deviceStatus.body.
|
|
354
|
+
this.Battery = deviceStatus.body.battery;
|
|
355
|
+
this.Version = deviceStatus.body.version;
|
|
356
356
|
this.openAPIparseStatus();
|
|
357
357
|
this.updateHomeKitCharacteristics();
|
|
358
358
|
} catch (e: any) {
|
package/src/device/meterplus.ts
CHANGED
|
@@ -351,8 +351,8 @@ export class MeterPlus {
|
|
|
351
351
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} refreshStatus: ${JSON.stringify(deviceStatus)}`);
|
|
352
352
|
this.Humidity = deviceStatus.body.humidity!;
|
|
353
353
|
this.Temperature = deviceStatus.body.temperature!;
|
|
354
|
-
this.Battery = deviceStatus.body.battery
|
|
355
|
-
this.Version = deviceStatus.body.version
|
|
354
|
+
this.Battery = deviceStatus.body.battery;
|
|
355
|
+
this.Version = deviceStatus.body.version;
|
|
356
356
|
this.openAPIparseStatus();
|
|
357
357
|
this.updateHomeKitCharacteristics();
|
|
358
358
|
} catch (e: any) {
|
package/src/device/motion.ts
CHANGED
|
@@ -364,8 +364,8 @@ export class Motion {
|
|
|
364
364
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} refreshStatus: ${JSON.stringify(deviceStatus)}`);
|
|
365
365
|
this.moveDetected = deviceStatus.body.moveDetected;
|
|
366
366
|
this.brightness = deviceStatus.body.brightness;
|
|
367
|
-
this.Battery = deviceStatus.body.battery
|
|
368
|
-
this.Version = deviceStatus.body.version
|
|
367
|
+
this.Battery = deviceStatus.body.battery;
|
|
368
|
+
this.Version = deviceStatus.body.version;
|
|
369
369
|
this.openAPIparseStatus();
|
|
370
370
|
this.updateHomeKitCharacteristics();
|
|
371
371
|
} catch (e: any) {
|
|
@@ -20,6 +20,7 @@ export class RobotVacuumCleaner {
|
|
|
20
20
|
StatusLowBattery?: CharacteristicValue;
|
|
21
21
|
|
|
22
22
|
// OpenAPI Others
|
|
23
|
+
Version: deviceStatus['version'];
|
|
23
24
|
Battery: deviceStatus['battery'];
|
|
24
25
|
power: deviceStatus['power'];
|
|
25
26
|
deviceStatus!: any; //deviceStatusResponse;
|
|
@@ -309,6 +310,7 @@ export class RobotVacuumCleaner {
|
|
|
309
310
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} refreshStatus: ${JSON.stringify(deviceStatus)}`);
|
|
310
311
|
this.power = deviceStatus.body.power;
|
|
311
312
|
this.Battery = deviceStatus.body.battery;
|
|
313
|
+
this.Version = deviceStatus.body.version;
|
|
312
314
|
this.openAPIparseStatus();
|
|
313
315
|
this.updateHomeKitCharacteristics();
|
|
314
316
|
} catch (e: any) {
|