@switchbot/homebridge-switchbot 2.8.0-beta.0 → 2.8.0-beta.10
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/.prettierrc +1 -1
- package/.vscode/settings.json +1 -1
- package/CHANGELOG.md +10 -0
- package/config.schema.json +8 -0
- package/dist/device/blindtilt.d.ts +1 -0
- package/dist/device/blindtilt.d.ts.map +1 -1
- package/dist/device/blindtilt.js +58 -65
- package/dist/device/blindtilt.js.map +1 -1
- package/dist/device/bot.d.ts +1 -0
- package/dist/device/bot.d.ts.map +1 -1
- package/dist/device/bot.js +52 -55
- package/dist/device/bot.js.map +1 -1
- package/dist/device/ceilinglight.d.ts +1 -0
- package/dist/device/ceilinglight.d.ts.map +1 -1
- package/dist/device/ceilinglight.js +68 -68
- package/dist/device/ceilinglight.js.map +1 -1
- package/dist/device/colorbulb.d.ts +1 -0
- package/dist/device/colorbulb.d.ts.map +1 -1
- package/dist/device/colorbulb.js +76 -75
- package/dist/device/colorbulb.js.map +1 -1
- package/dist/device/contact.d.ts +2 -0
- package/dist/device/contact.d.ts.map +1 -1
- package/dist/device/contact.js +67 -59
- package/dist/device/contact.js.map +1 -1
- package/dist/device/curtain.d.ts +2 -0
- package/dist/device/curtain.d.ts.map +1 -1
- package/dist/device/curtain.js +81 -94
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/hub.d.ts +9 -1
- package/dist/device/hub.d.ts.map +1 -1
- package/dist/device/hub.js +197 -30
- package/dist/device/hub.js.map +1 -1
- package/dist/device/humidifier.d.ts.map +1 -1
- package/dist/device/humidifier.js +58 -62
- package/dist/device/humidifier.js.map +1 -1
- package/dist/device/iosensor.d.ts +1 -0
- package/dist/device/iosensor.d.ts.map +1 -1
- package/dist/device/iosensor.js +28 -26
- package/dist/device/iosensor.js.map +1 -1
- package/dist/device/lightstrip.d.ts +1 -0
- package/dist/device/lightstrip.d.ts.map +1 -1
- package/dist/device/lightstrip.js +68 -67
- package/dist/device/lightstrip.js.map +1 -1
- package/dist/device/lock.d.ts +2 -0
- package/dist/device/lock.d.ts.map +1 -1
- package/dist/device/lock.js +51 -47
- package/dist/device/lock.js.map +1 -1
- package/dist/device/meter.d.ts +5 -3
- package/dist/device/meter.d.ts.map +1 -1
- package/dist/device/meter.js +75 -74
- package/dist/device/meter.js.map +1 -1
- package/dist/device/meterplus.d.ts +4 -3
- package/dist/device/meterplus.d.ts.map +1 -1
- package/dist/device/meterplus.js +74 -74
- package/dist/device/meterplus.js.map +1 -1
- package/dist/device/motion.d.ts +2 -0
- package/dist/device/motion.d.ts.map +1 -1
- package/dist/device/motion.js +66 -54
- package/dist/device/motion.js.map +1 -1
- package/dist/device/plug.d.ts +1 -0
- package/dist/device/plug.d.ts.map +1 -1
- package/dist/device/plug.js +39 -39
- package/dist/device/plug.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 +74 -53
- package/dist/device/robotvacuumcleaner.js.map +1 -1
- package/dist/irdevice/airconditioner.d.ts.map +1 -1
- package/dist/irdevice/airconditioner.js +64 -66
- package/dist/irdevice/airconditioner.js.map +1 -1
- package/dist/irdevice/airpurifier.d.ts +1 -1
- package/dist/irdevice/airpurifier.d.ts.map +1 -1
- package/dist/irdevice/airpurifier.js +32 -34
- package/dist/irdevice/airpurifier.js.map +1 -1
- package/dist/irdevice/camera.d.ts +1 -1
- package/dist/irdevice/camera.d.ts.map +1 -1
- package/dist/irdevice/camera.js +20 -23
- package/dist/irdevice/camera.js.map +1 -1
- package/dist/irdevice/fan.d.ts +2 -2
- package/dist/irdevice/fan.d.ts.map +1 -1
- package/dist/irdevice/fan.js +30 -32
- package/dist/irdevice/fan.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 +26 -29
- package/dist/irdevice/light.js.map +1 -1
- package/dist/irdevice/other.d.ts +1 -1
- package/dist/irdevice/other.d.ts.map +1 -1
- package/dist/irdevice/other.js +22 -23
- package/dist/irdevice/other.js.map +1 -1
- package/dist/irdevice/tv.d.ts +2 -2
- package/dist/irdevice/tv.d.ts.map +1 -1
- package/dist/irdevice/tv.js +47 -50
- package/dist/irdevice/tv.js.map +1 -1
- package/dist/irdevice/vacuumcleaner.d.ts +1 -1
- package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
- package/dist/irdevice/vacuumcleaner.js +20 -23
- package/dist/irdevice/vacuumcleaner.js.map +1 -1
- package/dist/irdevice/waterheater.d.ts +1 -1
- package/dist/irdevice/waterheater.d.ts.map +1 -1
- package/dist/irdevice/waterheater.js +22 -23
- package/dist/irdevice/waterheater.js.map +1 -1
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +46 -44
- package/dist/platform.js.map +1 -1
- package/dist/settings.d.ts +1 -0
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js.map +1 -1
- package/dist/utils.js +1 -1
- package/dist/utils.js.map +1 -1
- package/package.json +3 -3
- package/src/device/blindtilt.ts +114 -78
- package/src/device/bot.ts +102 -63
- package/src/device/ceilinglight.ts +113 -73
- package/src/device/colorbulb.ts +144 -87
- package/src/device/contact.ts +98 -63
- package/src/device/curtain.ts +160 -134
- package/src/device/hub.ts +228 -39
- package/src/device/humidifier.ts +136 -85
- package/src/device/iosensor.ts +52 -32
- package/src/device/lightstrip.ts +118 -72
- package/src/device/lock.ts +85 -50
- package/src/device/meter.ts +104 -80
- package/src/device/meterplus.ts +103 -80
- package/src/device/motion.ts +95 -59
- package/src/device/plug.ts +70 -44
- package/src/device/robotvacuumcleaner.ts +107 -56
- package/src/irdevice/airconditioner.ts +116 -86
- package/src/irdevice/airpurifier.ts +60 -39
- package/src/irdevice/camera.ts +40 -28
- package/src/irdevice/fan.ts +52 -38
- package/src/irdevice/light.ts +48 -34
- package/src/irdevice/other.ts +44 -28
- package/src/irdevice/tv.ts +70 -56
- package/src/irdevice/vacuumcleaner.ts +40 -28
- package/src/irdevice/waterheater.ts +48 -32
- package/src/platform.ts +87 -56
- package/src/settings.ts +41 -40
- package/src/utils.ts +1 -1
package/src/device/contact.ts
CHANGED
|
@@ -27,6 +27,8 @@ export class Contact {
|
|
|
27
27
|
StatusLowBattery!: CharacteristicValue;
|
|
28
28
|
|
|
29
29
|
// OpenAPI others
|
|
30
|
+
Version: deviceStatus['version'];
|
|
31
|
+
Battery: deviceStatus['battery'];
|
|
30
32
|
openState: deviceStatus['openState'];
|
|
31
33
|
moveDetected: deviceStatus['moveDetected'];
|
|
32
34
|
brightness: deviceStatus['brightness'];
|
|
@@ -59,16 +61,20 @@ export class Contact {
|
|
|
59
61
|
doContactUpdate!: Subject<void>;
|
|
60
62
|
|
|
61
63
|
// Connection
|
|
62
|
-
private readonly BLE =
|
|
63
|
-
private readonly OpenAPI =
|
|
64
|
-
|
|
65
|
-
constructor(
|
|
64
|
+
private readonly BLE = this.device.connectionType === 'BLE' || this.device.connectionType === 'BLE/OpenAPI';
|
|
65
|
+
private readonly OpenAPI = this.device.connectionType === 'OpenAPI' || this.device.connectionType === 'BLE/OpenAPI';
|
|
66
|
+
|
|
67
|
+
constructor(
|
|
68
|
+
private readonly platform: SwitchBotPlatform,
|
|
69
|
+
private accessory: PlatformAccessory,
|
|
70
|
+
public device: device & devicesConfig,
|
|
71
|
+
) {
|
|
66
72
|
// default placeholders
|
|
67
73
|
this.logs(device);
|
|
68
74
|
this.scan(device);
|
|
69
75
|
this.refreshRate(device);
|
|
70
|
-
this.config(device);
|
|
71
76
|
this.context();
|
|
77
|
+
this.config(device);
|
|
72
78
|
|
|
73
79
|
// this is subject we use to track when we need to POST changes to the SwitchBot API
|
|
74
80
|
this.doContactUpdate = new Subject();
|
|
@@ -141,17 +147,16 @@ export class Contact {
|
|
|
141
147
|
}
|
|
142
148
|
|
|
143
149
|
// Battery Service
|
|
144
|
-
if (!this.
|
|
145
|
-
this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Removing Battery Service`);
|
|
146
|
-
this.batteryService = this.accessory.getService(this.platform.Service.Battery);
|
|
147
|
-
accessory.removeService(this.batteryService!);
|
|
148
|
-
} else if (this.BLE && !this.batteryService) {
|
|
150
|
+
if (!this.batteryService) {
|
|
149
151
|
this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Add Battery Service`);
|
|
150
152
|
(this.batteryService = this.accessory.getService(this.platform.Service.Battery) || this.accessory.addService(this.platform.Service.Battery)),
|
|
151
153
|
`${accessory.displayName} Battery`;
|
|
152
154
|
|
|
153
155
|
this.batteryService.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Battery`);
|
|
154
|
-
this.batteryService.
|
|
156
|
+
if (!this.batteryService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
|
|
157
|
+
this.batteryService.addCharacteristic(this.platform.Characteristic.ConfiguredName, `${accessory.displayName} Battery`);
|
|
158
|
+
}
|
|
159
|
+
this.batteryService.setCharacteristic(this.platform.Characteristic.ChargingState, this.platform.Characteristic.ChargingState.NOT_CHARGEABLE);
|
|
155
160
|
} else {
|
|
156
161
|
this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Battery Service Not Added`);
|
|
157
162
|
}
|
|
@@ -179,8 +184,9 @@ export class Contact {
|
|
|
179
184
|
await this.openAPIparseStatus();
|
|
180
185
|
} else {
|
|
181
186
|
await this.offlineOff();
|
|
182
|
-
this.debugWarnLog(
|
|
183
|
-
+ ` ${this.device.connectionType}, parseStatus will not happen
|
|
187
|
+
this.debugWarnLog(
|
|
188
|
+
`${this.device.deviceType}: ${this.accessory.displayName} Connection Type:` + ` ${this.device.connectionType}, parseStatus will not happen.`,
|
|
189
|
+
);
|
|
184
190
|
}
|
|
185
191
|
}
|
|
186
192
|
|
|
@@ -200,15 +206,17 @@ export class Contact {
|
|
|
200
206
|
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} timeout no closed, doorstate: ${this.doorState}`);
|
|
201
207
|
}
|
|
202
208
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} ContactSensorState: ${this.ContactSensorState}`);
|
|
203
|
-
if (
|
|
204
|
-
|
|
209
|
+
if (
|
|
210
|
+
this.ContactSensorState !== this.accessory.context.ContactSensorState &&
|
|
211
|
+
this.platform.Characteristic.ContactSensorState.CONTACT_NOT_DETECTED
|
|
212
|
+
) {
|
|
205
213
|
this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Opened`);
|
|
206
214
|
}
|
|
207
215
|
// Movement
|
|
208
216
|
if (!this.device.contact?.hide_motionsensor) {
|
|
209
217
|
this.MotionDetected = Boolean(this.movement);
|
|
210
218
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} MotionDetected: ${this.MotionDetected}`);
|
|
211
|
-
if (
|
|
219
|
+
if (this.MotionDetected !== this.accessory.context.MotionDetected && this.MotionDetected) {
|
|
212
220
|
this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Detected Motion`);
|
|
213
221
|
}
|
|
214
222
|
}
|
|
@@ -223,8 +231,10 @@ export class Contact {
|
|
|
223
231
|
default:
|
|
224
232
|
this.CurrentAmbientLightLevel = this.set_maxLux;
|
|
225
233
|
}
|
|
226
|
-
this.debugLog(
|
|
227
|
-
|
|
234
|
+
this.debugLog(
|
|
235
|
+
`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.is_light},` +
|
|
236
|
+
` CurrentAmbientLightLevel: ${this.CurrentAmbientLightLevel}`,
|
|
237
|
+
);
|
|
228
238
|
if (this.CurrentAmbientLightLevel !== this.accessory.context.CurrentAmbientLightLevel) {
|
|
229
239
|
this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} CurrentAmbientLightLevel: ${this.CurrentAmbientLightLevel}`);
|
|
230
240
|
}
|
|
@@ -239,8 +249,9 @@ export class Contact {
|
|
|
239
249
|
} else {
|
|
240
250
|
this.StatusLowBattery = this.platform.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL;
|
|
241
251
|
}
|
|
242
|
-
this.debugLog(
|
|
243
|
-
+ `StatusLowBattery: ${this.StatusLowBattery}
|
|
252
|
+
this.debugLog(
|
|
253
|
+
`${this.device.deviceType}: ${this.accessory.displayName} BatteryLevel: ${this.BatteryLevel}, ` + `StatusLowBattery: ${this.StatusLowBattery}`,
|
|
254
|
+
);
|
|
244
255
|
}
|
|
245
256
|
|
|
246
257
|
async openAPIparseStatus(): Promise<void> {
|
|
@@ -274,6 +285,19 @@ export class Contact {
|
|
|
274
285
|
}
|
|
275
286
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} CurrentAmbientLightLevel: ${this.CurrentAmbientLightLevel}`);
|
|
276
287
|
}
|
|
288
|
+
// Battery
|
|
289
|
+
if (this.battery === undefined) {
|
|
290
|
+
this.battery === 100;
|
|
291
|
+
}
|
|
292
|
+
this.BatteryLevel = Number(this.Battery);
|
|
293
|
+
if (this.BatteryLevel < 10) {
|
|
294
|
+
this.StatusLowBattery = this.platform.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW;
|
|
295
|
+
} else {
|
|
296
|
+
this.StatusLowBattery = this.platform.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL;
|
|
297
|
+
}
|
|
298
|
+
this.debugLog(
|
|
299
|
+
`${this.device.deviceType}: ${this.accessory.displayName} BatteryLevel: ${this.BatteryLevel}, ` + `StatusLowBattery: ${this.StatusLowBattery}`,
|
|
300
|
+
);
|
|
277
301
|
}
|
|
278
302
|
|
|
279
303
|
/**
|
|
@@ -288,8 +312,10 @@ export class Contact {
|
|
|
288
312
|
await this.openAPIRefreshStatus();
|
|
289
313
|
} else {
|
|
290
314
|
await this.offlineOff();
|
|
291
|
-
this.debugWarnLog(
|
|
292
|
-
|
|
315
|
+
this.debugWarnLog(
|
|
316
|
+
`${this.device.deviceType}: ${this.accessory.displayName} Connection Type:` +
|
|
317
|
+
` ${this.device.connectionType}, refreshStatus will not happen.`,
|
|
318
|
+
);
|
|
293
319
|
}
|
|
294
320
|
}
|
|
295
321
|
|
|
@@ -317,8 +343,10 @@ export class Contact {
|
|
|
317
343
|
this.scanning = true;
|
|
318
344
|
switchbot.onadvertisement = async (ad: any) => {
|
|
319
345
|
this.address = ad.address;
|
|
320
|
-
this.debugLog(
|
|
321
|
-
|
|
346
|
+
this.debugLog(
|
|
347
|
+
`${this.device.deviceType}: ${this.accessory.displayName} Config BLE Address: ${this.device.bleMac},` +
|
|
348
|
+
` BLE Address Found: ${this.address}`,
|
|
349
|
+
);
|
|
322
350
|
this.serviceData = ad.serviceData;
|
|
323
351
|
this.movement = ad.serviceData.movement;
|
|
324
352
|
this.tested = ad.serviceData.tested;
|
|
@@ -355,8 +383,10 @@ export class Contact {
|
|
|
355
383
|
})
|
|
356
384
|
.catch(async (e: any) => {
|
|
357
385
|
this.apiError(e);
|
|
358
|
-
this.errorLog(
|
|
359
|
-
|
|
386
|
+
this.errorLog(
|
|
387
|
+
`${this.device.deviceType}: ${this.accessory.displayName} failed BLERefreshStatus with ${this.device.connectionType}` +
|
|
388
|
+
` Connection, Error Message: ${JSON.stringify(e.message)}`,
|
|
389
|
+
);
|
|
360
390
|
await this.BLERefreshConnection(switchbot);
|
|
361
391
|
});
|
|
362
392
|
} else {
|
|
@@ -374,19 +404,20 @@ export class Contact {
|
|
|
374
404
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Devices: ${JSON.stringify(deviceStatus.body)}`);
|
|
375
405
|
this.statusCode(statusCode);
|
|
376
406
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Headers: ${JSON.stringify(headers)}`);
|
|
377
|
-
this.debugLog(
|
|
378
|
-
`${this.device.deviceType}: ${this.accessory.displayName
|
|
379
|
-
} refreshStatus: ${JSON.stringify(deviceStatus)}`,
|
|
380
|
-
);
|
|
407
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} refreshStatus: ${JSON.stringify(deviceStatus)}`);
|
|
381
408
|
this.openState = deviceStatus.body.openState;
|
|
382
409
|
this.moveDetected = deviceStatus.body.moveDetected;
|
|
383
410
|
this.brightness = deviceStatus.body.brightness;
|
|
411
|
+
this.Battery = deviceStatus.body.battery!;
|
|
412
|
+
this.Version = deviceStatus.body.version!;
|
|
384
413
|
this.openAPIparseStatus();
|
|
385
414
|
this.updateHomeKitCharacteristics();
|
|
386
415
|
} catch (e: any) {
|
|
387
416
|
this.apiError(e);
|
|
388
|
-
this.errorLog(
|
|
389
|
-
|
|
417
|
+
this.errorLog(
|
|
418
|
+
`${this.device.deviceType}: ${this.accessory.displayName} failed openAPIRefreshStatus with ${this.device.connectionType}` +
|
|
419
|
+
` Connection, Error Message: ${JSON.stringify(e.message)}`,
|
|
420
|
+
);
|
|
390
421
|
}
|
|
391
422
|
}
|
|
392
423
|
|
|
@@ -416,26 +447,25 @@ export class Contact {
|
|
|
416
447
|
} else {
|
|
417
448
|
this.accessory.context.CurrentAmbientLightLevel = this.CurrentAmbientLightLevel;
|
|
418
449
|
this.lightSensorService?.updateCharacteristic(this.platform.Characteristic.CurrentAmbientLightLevel, this.CurrentAmbientLightLevel);
|
|
419
|
-
this.debugLog(
|
|
420
|
-
|
|
450
|
+
this.debugLog(
|
|
451
|
+
`${this.device.deviceType}: ${this.accessory.displayName}` +
|
|
452
|
+
` updateCharacteristic CurrentAmbientLightLevel: ${this.CurrentAmbientLightLevel}`,
|
|
421
453
|
);
|
|
422
454
|
}
|
|
423
455
|
}
|
|
424
|
-
if (this.
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic StatusLowBattery: ${this.StatusLowBattery}`);
|
|
438
|
-
}
|
|
456
|
+
if (this.BatteryLevel === undefined) {
|
|
457
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} BatteryLevel: ${this.BatteryLevel}`);
|
|
458
|
+
} else {
|
|
459
|
+
this.accessory.context.BatteryLevel = this.BatteryLevel;
|
|
460
|
+
this.batteryService?.updateCharacteristic(this.platform.Characteristic.BatteryLevel, this.BatteryLevel);
|
|
461
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic BatteryLevel: ${this.BatteryLevel}`);
|
|
462
|
+
}
|
|
463
|
+
if (this.StatusLowBattery === undefined) {
|
|
464
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} StatusLowBattery: ${this.StatusLowBattery}`);
|
|
465
|
+
} else {
|
|
466
|
+
this.accessory.context.StatusLowBattery = this.StatusLowBattery;
|
|
467
|
+
this.batteryService?.updateCharacteristic(this.platform.Characteristic.StatusLowBattery, this.StatusLowBattery);
|
|
468
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic StatusLowBattery: ${this.StatusLowBattery}`);
|
|
439
469
|
}
|
|
440
470
|
}
|
|
441
471
|
|
|
@@ -523,8 +553,10 @@ export class Contact {
|
|
|
523
553
|
this.offlineOff();
|
|
524
554
|
break;
|
|
525
555
|
case 171:
|
|
526
|
-
this.errorLog(
|
|
527
|
-
|
|
556
|
+
this.errorLog(
|
|
557
|
+
`${this.device.deviceType}: ${this.accessory.displayName} Hub Device is offline, statusCode: ${statusCode}. ` +
|
|
558
|
+
`Hub: ${this.device.hubDeviceId}`,
|
|
559
|
+
);
|
|
528
560
|
this.offlineOff();
|
|
529
561
|
break;
|
|
530
562
|
case 190:
|
|
@@ -540,8 +572,10 @@ export class Contact {
|
|
|
540
572
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Request successful, statusCode: ${statusCode}`);
|
|
541
573
|
break;
|
|
542
574
|
default:
|
|
543
|
-
this.infoLog(
|
|
544
|
-
|
|
575
|
+
this.infoLog(
|
|
576
|
+
`${this.device.deviceType}: ${this.accessory.displayName} Unknown statusCode: ` +
|
|
577
|
+
`${statusCode}, Submit Bugs Here: ' + 'https://tinyurl.com/SwitchBotBug`,
|
|
578
|
+
);
|
|
545
579
|
}
|
|
546
580
|
}
|
|
547
581
|
|
|
@@ -560,22 +594,23 @@ export class Contact {
|
|
|
560
594
|
if (!this.device.contact?.hide_lightsensor) {
|
|
561
595
|
this.lightSensorService?.updateCharacteristic(this.platform.Characteristic.CurrentAmbientLightLevel, e);
|
|
562
596
|
}
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
this.batteryService?.updateCharacteristic(this.platform.Characteristic.StatusLowBattery, e);
|
|
566
|
-
}
|
|
597
|
+
this.batteryService?.updateCharacteristic(this.platform.Characteristic.BatteryLevel, e);
|
|
598
|
+
this.batteryService?.updateCharacteristic(this.platform.Characteristic.StatusLowBattery, e);
|
|
567
599
|
}
|
|
568
600
|
|
|
569
601
|
FirmwareRevision(accessory: PlatformAccessory<Context>, device: device & devicesConfig): CharacteristicValue {
|
|
570
602
|
let FirmwareRevision: string;
|
|
571
|
-
this.debugLog(
|
|
572
|
-
+ ` accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}
|
|
603
|
+
this.debugLog(
|
|
604
|
+
`${this.device.deviceType}: ${this.accessory.displayName}` + ` accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}`,
|
|
605
|
+
);
|
|
573
606
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} device.firmware: ${device.firmware}`);
|
|
574
607
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} this.platform.version: ${this.platform.version}`);
|
|
575
|
-
if (
|
|
576
|
-
FirmwareRevision = accessory.context.FirmwareRevision;
|
|
577
|
-
} else if (device.firmware) {
|
|
608
|
+
if (device.firmware) {
|
|
578
609
|
FirmwareRevision = device.firmware;
|
|
610
|
+
} else if (device.version) {
|
|
611
|
+
FirmwareRevision = JSON.stringify(device.version);
|
|
612
|
+
} else if (accessory.context.FirmwareRevision) {
|
|
613
|
+
FirmwareRevision = accessory.context.FirmwareRevision;
|
|
579
614
|
} else {
|
|
580
615
|
FirmwareRevision = this.platform.version;
|
|
581
616
|
}
|
|
@@ -626,7 +661,7 @@ export class Contact {
|
|
|
626
661
|
config['scanDuration'] = device.scanDuration;
|
|
627
662
|
}
|
|
628
663
|
if (Object.entries(config).length !== 0) {
|
|
629
|
-
this.
|
|
664
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
|
|
630
665
|
}
|
|
631
666
|
}
|
|
632
667
|
|