@eduardoramirez/homebridge-dwelo
Advanced tools
Comparing version 1.0.12 to 1.0.13
@@ -46,4 +46,4 @@ "use strict"; | ||
stopCondition: s => { var _a; return ((_a = s.find(s => s.sensorType === 'lock')) === null || _a === void 0 ? void 0 : _a.value) === target; }, | ||
interval: 3000, | ||
timeout: 30 * 1000, | ||
interval: 5000, | ||
timeout: 60 * 1000, | ||
}); | ||
@@ -50,0 +50,0 @@ } |
@@ -10,2 +10,3 @@ import { AccessoryPlugin, API, Logging, Service } from 'homebridge'; | ||
private readonly lockService; | ||
private readonly batteryService; | ||
private targetState; | ||
@@ -15,8 +16,8 @@ constructor(log: Logging, api: API, dweloAPI: DweloAPI, name: string, lockID: number); | ||
getServices(): Service[]; | ||
private toLockState; | ||
private getLockState; | ||
private getTargetLockState; | ||
private setTargetLockState; | ||
private toLockState; | ||
private setBatteryLevel; | ||
} | ||
//# sourceMappingURL=DweloLockAccessory.d.ts.map |
@@ -17,4 +17,5 @@ "use strict"; | ||
.onSet(this.setTargetLockState.bind(this)); | ||
this.lockService.addCharacteristic(api.hap.Characteristic.BatteryLevel); | ||
this.lockService.addCharacteristic(api.hap.Characteristic.StatusLowBattery); | ||
this.batteryService = new api.hap.Service.Battery(name); | ||
this.batteryService.getCharacteristic(api.hap.Characteristic.BatteryLevel); | ||
this.batteryService.getCharacteristic(api.hap.Characteristic.StatusLowBattery); | ||
log.info(`Dwelo Lock '${name} ' created!`); | ||
@@ -26,13 +27,4 @@ } | ||
getServices() { | ||
return [this.lockService]; | ||
return [this.lockService, this.batteryService]; | ||
} | ||
toLockState(sensors) { | ||
const lockSensor = sensors.find(s => s.sensorType === 'lock'); | ||
if (!lockSensor) { | ||
return this.api.hap.Characteristic.LockCurrentState.UNKNOWN; | ||
} | ||
return lockSensor.value === 'locked' | ||
? this.api.hap.Characteristic.LockCurrentState.SECURED | ||
: this.api.hap.Characteristic.LockCurrentState.UNSECURED; | ||
} | ||
async getLockState() { | ||
@@ -51,12 +43,18 @@ const sensors = await this.dweloAPI.sensors(this.lockID); | ||
this.targetState = value; | ||
this.log.info(`Lock state is setting to: ${value}`); | ||
this.log.info(`Setting lock to: ${value}`); | ||
await this.dweloAPI.toggleLock(!!value, this.lockID); | ||
this.log.info('Lock toggle completed'); | ||
this.lockService.updateCharacteristic(this.api.hap.Characteristic.LockCurrentState, value); | ||
this.targetState = undefined; | ||
return value; | ||
this.lockService.getCharacteristic(this.api.hap.Characteristic.LockCurrentState).updateValue(value); | ||
} | ||
toLockState(sensors) { | ||
const lockSensor = sensors.find(s => s.sensorType === 'lock'); | ||
if (!lockSensor) { | ||
return this.api.hap.Characteristic.LockCurrentState.UNKNOWN; | ||
} | ||
return lockSensor.value === 'locked' | ||
? this.api.hap.Characteristic.LockCurrentState.SECURED | ||
: this.api.hap.Characteristic.LockCurrentState.UNSECURED; | ||
} | ||
setBatteryLevel(sensors) { | ||
const batterySensor = sensors.find(s => s.sensorType === 'battery'); | ||
this.log.info('Lock battery percentage: ', batterySensor === null || batterySensor === void 0 ? void 0 : batterySensor.value); | ||
if (!batterySensor) { | ||
@@ -69,4 +67,5 @@ return; | ||
: this.api.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW; | ||
this.lockService.updateCharacteristic(this.api.hap.Characteristic.BatteryLevel, batteryLevel); | ||
this.lockService.updateCharacteristic(this.api.hap.Characteristic.StatusLowBattery, batteryStatus); | ||
this.batteryService.getCharacteristic(this.api.hap.Characteristic.BatteryLevel).updateValue(batteryLevel); | ||
this.batteryService.getCharacteristic(this.api.hap.Characteristic.StatusLowBattery).updateValue(batteryStatus); | ||
this.log.info('Lock battery: ', batterySensor === null || batterySensor === void 0 ? void 0 : batterySensor.value); | ||
} | ||
@@ -73,0 +72,0 @@ } |
{ | ||
"displayName": "Homebridge Dwelo Plugin", | ||
"name": "@eduardoramirez/homebridge-dwelo", | ||
"version": "1.0.12", | ||
"version": "1.0.13", | ||
"description": "Adds support for Dwelo accessories to Homebridge.", | ||
@@ -6,0 +6,0 @@ "license": "Apache-2.0", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
43469