homebridge-abode
Advanced tools
Comparing version 0.0.3 to 0.0.4
@@ -122,3 +122,2 @@ { | ||
"no-undefined": 0, | ||
"no-use-before-define": 2, | ||
"handle-callback-err": 0, | ||
@@ -125,0 +124,0 @@ "no-mixed-requires": 0, |
37
index.js
@@ -6,11 +6,15 @@ 'use strict'; | ||
module.exports = function (homebridge) { | ||
Service = homebridge.hap.Service; | ||
Characteristic = homebridge.hap.Characteristic; | ||
homebridge.registerAccessory('homebridge-abode', 'AbodeCommand', AbodeCommandAccessory); | ||
}; | ||
function AbodeCommandAccessory(log, config) { | ||
this.log = log; | ||
this.name = config.name; | ||
this.open = true; | ||
} | ||
AbodeCommandAccessory.prototype.setState = function (isClosed, callback) { | ||
this.log('Hello World'); | ||
if (this.open) { | ||
if (!isClosed) { | ||
this.alarmService.setCharacteristic(Characteristic.CurrentDoorState, Characteristic.CurrentDoorState.CLOSED); | ||
@@ -27,31 +31,16 @@ this.open = true; | ||
AbodeCommandAccessory.prototype.getState = function (callback) { | ||
callback(null, Characteristic.CurrentDoorState.open); | ||
callback(null, this.open ? Characteristic.CurrentDoorState.OPEN : Characteristic.CurrentDoorState.CLOSED); | ||
}; | ||
AbodeCommandAccessory.prototype.getServices = function () { | ||
this.informationService = new Service.AccessoryInformation(); | ||
this.alarmService = new Service.LockMechanism(this.name); | ||
this.informationService | ||
.setCharacteristic(Characteristic.Manufacturer, 'Abode Command') | ||
.setCharacteristic(Characteristic.Model, 'Homebridge Plugin') | ||
.setCharacteristic(Characteristic.SerialNumber, '001'); | ||
this.alarmService.getCharacteristic(Characteristic.TargetDoorState) | ||
.on('set', this.setState.bind(this)); | ||
.on('set', this.setState.bind(this)) | ||
.on('get', this.getState.bind(this)); | ||
if (this.stateCommand) { | ||
this.alarmService.getCharacteristic(Characteristic.CurrentDoorState) | ||
.on('get', this.getState.bind(this)); | ||
this.alarmService.getCharacteristic(Characteristic.TargetDoorState) | ||
.on('get', this.getState.bind(this)); | ||
} | ||
this.alarmService.getCharacteristic(Characteristic.CurrentDoorState) | ||
.on('get', this.getState.bind(this)); | ||
return [this.informationService, this.garageDoorService]; | ||
return [this.alarmService]; | ||
}; | ||
module.exports = function (homebridge) { | ||
Service = homebridge.hap.Service; | ||
Characteristic = homebridge.hap.Characteristic; | ||
homebridge.registerAccessory('homebridge-abode', 'AbodeCommand', AbodeCommandAccessory); | ||
}; |
{ | ||
"name": "homebridge-abode", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "Abode Plugin for homebridge", | ||
@@ -5,0 +5,0 @@ "scripts": { |
6969
214