homebridge-august
Advanced tools
Comparing version 0.0.8 to 0.0.9-beta.0
import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge'; | ||
import { AugustPlatform } from '../platform'; | ||
import { device } from '../settings'; | ||
/** | ||
@@ -11,5 +12,8 @@ * Platform Accessory | ||
private accessory; | ||
device: any; | ||
device: device; | ||
service: Service; | ||
fanService?: Service; | ||
batteryService: Service; | ||
LockTargetState: CharacteristicValue; | ||
LockCurrentState: CharacteristicValue; | ||
lockStatus: any; | ||
deviceLogging: string; | ||
@@ -19,4 +23,3 @@ deviceRefreshRate: number; | ||
doLockUpdate: any; | ||
LockCurrentState: any; | ||
constructor(platform: AugustPlatform, accessory: PlatformAccessory, device: any); | ||
constructor(platform: AugustPlatform, accessory: PlatformAccessory, device: device); | ||
/** | ||
@@ -38,3 +41,3 @@ * Parse the device status from the August api | ||
updateHomeKitCharacteristics(): Promise<void>; | ||
setLockCurrentState(value: CharacteristicValue): Promise<void>; | ||
setLockTargetState(value: CharacteristicValue): Promise<void>; | ||
config(device: any): Promise<void>; | ||
@@ -41,0 +44,0 @@ refreshRate(device: any): Promise<void>; |
@@ -27,8 +27,8 @@ "use strict"; | ||
.setCharacteristic(this.platform.Characteristic.Manufacturer, 'August') | ||
.setCharacteristic(this.platform.Characteristic.Model, device.deviceModel) | ||
.setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceID) | ||
.setCharacteristic(this.platform.Characteristic.Model, accessory.context.model) | ||
.setCharacteristic(this.platform.Characteristic.SerialNumber, accessory.context.serialnumber) | ||
.setCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.firmwareRevision) | ||
.getCharacteristic(this.platform.Characteristic.FirmwareRevision) | ||
.updateValue(accessory.context.firmwareRevision); | ||
//Thermostat Service | ||
//LockManagement Service | ||
(this.service = | ||
@@ -42,3 +42,9 @@ this.accessory.getService(this.platform.Service.LockManagement) || this.accessory.addService(this.platform.Service.LockManagement)), | ||
this.parseStatus(); | ||
this.service.getCharacteristic(this.platform.Characteristic.LockCurrentState).onSet(this.setLockCurrentState.bind(this)); | ||
this.service.getCharacteristic(this.platform.Characteristic.LockTargetState).onSet(this.setLockTargetState.bind(this)); | ||
this.service.getCharacteristic(this.platform.Characteristic.LockCurrentState).onGet(() => { | ||
return this.LockCurrentState; | ||
}); | ||
(this.batteryService = | ||
this.accessory.getService(this.platform.Service.Battery) || this.accessory.addService(this.platform.Service.Battery)), | ||
`${accessory.displayName} Battery`; | ||
// Retrieve initial values and updateHomekit | ||
@@ -80,2 +86,11 @@ this.refreshStatus(); | ||
async parseStatus() { | ||
/*if (this.lockStatus.retryCount) { | ||
this.LockCurrentState = this.platform.Characteristic.LockCurrentState.JAMMED; | ||
} else if (this.lockStatus.state.locked) { | ||
this.LockCurrentState = this.platform.Characteristic.LockCurrentState.SECURED; | ||
} else if (this.lockStatus.state.unlocked) { | ||
this.LockCurrentState = this.platform.Characteristic.LockCurrentState.UNSECURED; | ||
} else {*/ | ||
this.LockCurrentState = this.platform.Characteristic.LockCurrentState.UNKNOWN; | ||
//} | ||
this.debugLog(`Lock: ${this.accessory.displayName} parseStatus`); | ||
@@ -89,16 +104,5 @@ } | ||
const august = this.platform.august; | ||
const lockStatus = await august.status('7EDFA965E0AE0CE19772AFA435364295'); | ||
this.infoLog(lockStatus); | ||
// { | ||
// lockID: '7EDFA965E0AE0CE19772AFA435364295' | ||
// status: 'kAugLockState_Locked', | ||
// doorState: 'kAugDoorState_Closed', | ||
// state: { | ||
// locked: true, | ||
// unlocked: false, | ||
// closed: true, | ||
// open: false, | ||
// } | ||
// ... | ||
// } | ||
const lockStatus = await august.status(this.device.lockId); | ||
this.debugLog(JSON.stringify(lockStatus)); | ||
this.lockStatus = lockStatus; | ||
this.debugLog(`Lock: ${this.accessory.displayName} device: ${JSON.stringify(this.device)}`); | ||
@@ -128,13 +132,13 @@ this.parseStatus(); | ||
async updateHomeKitCharacteristics() { | ||
if (this.LockCurrentState === undefined) { | ||
this.debugLog(`Lock: ${this.accessory.displayName} LockCurrentState: ${this.LockCurrentState}`); | ||
if (this.LockTargetState === undefined) { | ||
this.debugLog(`Lock: ${this.accessory.displayName} LockTargetState: ${this.LockTargetState}`); | ||
} | ||
else { | ||
this.service.updateCharacteristic(this.platform.Characteristic.LockCurrentState, this.LockCurrentState); | ||
this.debugLog(`Lock: ${this.accessory.displayName} updateCharacteristic LockCurrentState: ${this.LockCurrentState}`); | ||
this.service.updateCharacteristic(this.platform.Characteristic.LockTargetState, this.LockTargetState); | ||
this.debugLog(`Lock: ${this.accessory.displayName} updateCharacteristic LockTargetState: ${this.LockTargetState}`); | ||
} | ||
} | ||
async setLockCurrentState(value) { | ||
this.debugLog(`Lock: ${this.accessory.displayName} Set LockCurrentState: ${value}`); | ||
this.LockCurrentState = value; | ||
async setLockTargetState(value) { | ||
this.debugLog(`Lock: ${this.accessory.displayName} Set LockTargetState: ${value}`); | ||
this.LockTargetState = value; | ||
this.doLockUpdate.next(); | ||
@@ -141,0 +145,0 @@ } |
import August from 'august-api'; | ||
import { API, Characteristic, DynamicPlatformPlugin, Logger, PlatformAccessory, Service } from 'homebridge'; | ||
import { AugustPlatformConfig } from './settings'; | ||
import { AugustPlatformConfig, device } from './settings'; | ||
/** | ||
@@ -37,3 +37,3 @@ * HomebridgePlatform | ||
private createLock; | ||
unregisterPlatformAccessories(existingAccessory: PlatformAccessory): void; | ||
unregisterPlatformAccessories(existingAccessory: PlatformAccessory, device: device): void; | ||
locationinfo(location: any): void; | ||
@@ -40,0 +40,0 @@ /** |
@@ -132,3 +132,3 @@ "use strict"; | ||
}); | ||
this.warnLog(JSON.stringify(this.august)); | ||
this.debugLog(JSON.stringify(this.august)); | ||
// If this is the first time you're using this installId, you need to authorize and validate: | ||
@@ -144,11 +144,10 @@ if (!this.config.credentials?.validateCode) { | ||
const myLocks = await this.august.locks(); | ||
this.warnLog(JSON.stringify(myLocks)); | ||
for (const device of myLocks) { | ||
const lockId = Object.keys(myLocks)[0]; | ||
this.august.lock(lockId); | ||
this.warnLog(JSON.stringify(lockId)); | ||
this.warnLog(JSON.stringify(device)); | ||
this.debugLog(`Discovered ${device.LockName} (${lockId}) ${device.UserType} ${device.macAddress} ${device.macAddress} ` | ||
+ `@ ${device.HouseName} (${device.HouseID})`); | ||
this.createLock(device, uuid); | ||
this.debugLog(JSON.stringify(myLocks)); | ||
const lockIds = Object.keys(myLocks); | ||
this.debugLog(JSON.stringify(lockIds)); | ||
for (const lockId of lockIds) { | ||
this.debugLog(JSON.stringify(lockId)); | ||
const device = await this.august.details(lockId); | ||
this.debugLog(JSON.stringify(device)); | ||
this.createLock(device); | ||
} | ||
@@ -160,3 +159,4 @@ } | ||
} | ||
async createLock(device, uuid) { | ||
async createLock(device) { | ||
const uuid = this.api.hap.uuid.generate(device.lockId); | ||
// see if an accessory with the same uuid has already been registered and restored from | ||
@@ -168,9 +168,10 @@ // the cached devices we stored in the `configureAccessory` method above | ||
if (!this.config.disablePlugin) { | ||
this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.lockId}`); | ||
this.infoLog(`Restoring existing accessory from cache: ${device.LockName} DeviceID: ${device.lockId}`); | ||
// if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.: | ||
existingAccessory.displayName = device.lockDetails.LockName; | ||
existingAccessory.context.firmwareRevision = this.version; | ||
existingAccessory.context.device = device; | ||
existingAccessory.displayName = device.LockName; | ||
existingAccessory.context.firmwareRevision = device.currentFirmwareVersion; | ||
existingAccessory.context.model = device.skuNumber; | ||
existingAccessory.context.serialnumber = device.SerialNumber; | ||
existingAccessory.context.deviceID = device.lockId; | ||
//existingAccessory.context.model = device.deviceModel; | ||
this.api.updatePlatformAccessories([existingAccessory]); | ||
@@ -180,6 +181,6 @@ // create the accessory handler for the restored accessory | ||
new lock_1.LockManagement(this, existingAccessory, device); | ||
this.debugLog(`${device.lockDetails.LockName} (${device.lockId}) uuid: ${existingAccessory.UUID}`); | ||
this.debugLog(`${device.LockName} (${device.lockId}) uuid: ${existingAccessory.UUID}`); | ||
} | ||
else { | ||
this.unregisterPlatformAccessories(existingAccessory); | ||
this.unregisterPlatformAccessories(existingAccessory, device); | ||
} | ||
@@ -189,15 +190,17 @@ } | ||
// the accessory does not yet exist, so we need to create it | ||
this.infoLog(`Adding new accessory: ${device.lockDetails.LockName} Lock ID: ${device.lockId}`); | ||
this.infoLog(`Adding new accessory: ${device.LockName} Lock ID: ${device.lockId}`); | ||
// create a new accessory | ||
const accessory = new this.api.platformAccessory(device.lockDetails.LockName, uuid); | ||
const accessory = new this.api.platformAccessory(device.LockName, uuid); | ||
// store a copy of the device object in the `accessory.context` | ||
// the `context` property can be used to store any data about the accessory you may need | ||
accessory.context.firmwareRevision = this.version; | ||
accessory.context.device = device; | ||
accessory.displayName = device.LockName; | ||
accessory.context.firmwareRevision = device.currentFirmwareVersion; | ||
accessory.context.model = device.skuNumber; | ||
accessory.context.serialnumber = device.SerialNumber; | ||
accessory.context.deviceID = device.lockId; | ||
//accessory.context.model = device.deviceModel; | ||
// create the accessory handler for the newly create accessory | ||
// this is imported from `platformAccessory.ts` | ||
new lock_1.LockManagement(this, accessory, device); | ||
this.debugLog(`${device.lockDetails.LockName} (${device.lockId}) uuid: ${accessory.UUID}`); | ||
this.debugLog(`${device.LockName} (${device.lockId}) uuid: ${accessory.UUID}`); | ||
// link the accessory to your platform | ||
@@ -209,3 +212,3 @@ this.api.registerPlatformAccessories(settings_1.PLUGIN_NAME, settings_1.PLATFORM_NAME, [accessory]); | ||
if (this.platformLogging?.includes('debug')) { | ||
this.errorLog(`Unable to Register new device: ${device.lockDetails.LockName} ${device.lockId} Lock ID: ${device.lockId}`); | ||
this.errorLog(`Unable to Register new device: ${device.LockName} Lock ID: ${device.lockId}`); | ||
this.errorLog('Check Config to see if DeviceID is being Hidden.'); | ||
@@ -215,6 +218,6 @@ } | ||
} | ||
unregisterPlatformAccessories(existingAccessory) { | ||
unregisterPlatformAccessories(existingAccessory, device) { | ||
// remove platform accessories when no longer present | ||
this.api.unregisterPlatformAccessories(settings_1.PLUGIN_NAME, settings_1.PLATFORM_NAME, [existingAccessory]); | ||
this.warnLog(`Removing existing accessory from cache: ${existingAccessory.displayName}`); | ||
this.warnLog(`Removing existing accessory from cache: ${device.LockName}`); | ||
} | ||
@@ -221,0 +224,0 @@ locationinfo(location) { |
@@ -26,12 +26,134 @@ import { PlatformConfig } from 'homebridge'; | ||
export declare type device = { | ||
lockId: string; | ||
lockDetails: lockDetails | Record<string, never>; | ||
}; | ||
export declare type lockDetails = { | ||
LockName: string; | ||
UserType: string; | ||
macAddress: string; | ||
Type: number; | ||
Created: string; | ||
Updated: string; | ||
LockId: string; | ||
HouseID: string; | ||
HouseName: string; | ||
Calibrated: boolean; | ||
timeZone: string; | ||
battery: number; | ||
batteryInfo: BatteryInfo; | ||
doorStateOpenTimeout: number; | ||
hostLockInfo: HostLockInfo; | ||
supportsEntryCodes: boolean; | ||
remoteOperateSecret: string; | ||
skuNumber: string; | ||
macAddress: string; | ||
SerialNumber: string; | ||
LockStatus: LockStatus; | ||
currentFirmwareVersion: string; | ||
homeKitEnabled: boolean; | ||
zWaveEnabled: boolean; | ||
isGalileo: boolean; | ||
Bridge: Bridge; | ||
OfflineKeys: OfflineKeys; | ||
parametersToSet: Record<any, undefined>; | ||
users: Record<any, undefined>; | ||
pubsubChannel: string; | ||
ruleHash: any; | ||
cameras: any[]; | ||
geofenceLimits: GeofenceLimits; | ||
pins: Pins; | ||
lockId: string; | ||
}; | ||
export interface BatteryInfo { | ||
level: number; | ||
warningState: string; | ||
infoUpdatedDate: string; | ||
lastChangeDate: string; | ||
lastChangeVoltage: number; | ||
} | ||
export interface HostLockInfo { | ||
serialNumber: string; | ||
manufacturer: string; | ||
productID: number; | ||
productTypeID: number; | ||
} | ||
export interface LockStatus { | ||
status: string; | ||
dateTime: string; | ||
isLockStatusChanged: boolean; | ||
valid: boolean; | ||
doorState: string; | ||
} | ||
export interface Bridge { | ||
_id: string; | ||
mfgBridgeID: string; | ||
deviceModel: string; | ||
firmwareVersion: string; | ||
operative: boolean; | ||
status: Status; | ||
locks: Lock[]; | ||
hyperBridge: boolean; | ||
} | ||
export interface Status { | ||
current: string; | ||
lastOffline: string; | ||
updated: string; | ||
lastOnline: string; | ||
} | ||
export interface Lock { | ||
_id: string; | ||
LockID: string; | ||
macAddress: string; | ||
} | ||
export interface OfflineKeys { | ||
created: any[]; | ||
loaded: Loaded[]; | ||
deleted: any[]; | ||
loadedhk: Loadedhk[]; | ||
} | ||
export interface Loaded { | ||
created: string; | ||
key: string; | ||
slot: number; | ||
UserID: string; | ||
loaded: string; | ||
} | ||
export interface Loadedhk { | ||
key: string; | ||
slot: number; | ||
UserID: string; | ||
created: string; | ||
loaded: string; | ||
} | ||
export interface GeofenceLimits { | ||
ios: Ios; | ||
} | ||
export interface Ios { | ||
debounceInterval: number; | ||
gpsAccuracyMultiplier: number; | ||
maximumGeofence: number; | ||
minimumGeofence: number; | ||
minGPSAccuracyRequired: number; | ||
} | ||
export interface Pins { | ||
created: any[]; | ||
loaded: Loaded2[]; | ||
disabled: any[]; | ||
disabling: any[]; | ||
enabling: any[]; | ||
deleting: any[]; | ||
updating: any[]; | ||
} | ||
export interface Loaded2 { | ||
_id: string; | ||
type: string; | ||
lockID: string; | ||
userID: string; | ||
state: string; | ||
pin: string; | ||
slot: number; | ||
accessType: string; | ||
callingUserID: string; | ||
apiKey: string; | ||
createdAt: string; | ||
updatedAt: string; | ||
loadedDate: string; | ||
firstName: string; | ||
lastName: string; | ||
unverified: boolean; | ||
} | ||
//# sourceMappingURL=settings.d.ts.map |
{ | ||
"displayName": "Homebridge August", | ||
"name": "homebridge-august", | ||
"version": "0.0.8", | ||
"version": "0.0.9-beta.0", | ||
"description": "The [Homebridge](https://homebridge.io) August plugin allows you to access your [August](https://august.com) & [Yale](https://shopyalehome.com) device(s) from HomeKit.", | ||
@@ -6,0 +6,0 @@ "author": "donavanbecker", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
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
104455
43
1341
1
1