Updated to latest version of hap base library. Root project migrated to lower case version. Also added new uuid_base required field which is now needed. Refactored device constructors to use common code.

This commit is contained in:
rodtoll
2015-10-18 11:19:08 -07:00
parent a45779cf48
commit 2d80e5f838

View File

@@ -49,10 +49,12 @@
{ "nameContains": "Remote", "lastAddressDigit": "", "address": "" } - Ignore all devices which have the word Remote in their name { "nameContains": "Remote", "lastAddressDigit": "", "address": "" } - Ignore all devices which have the word Remote in their name
{ "nameContains": "", "lastAddressDigit": "", "address": "15 5 3 2"} - Ignore the device with an ISY address of 15 5 3 2. { "nameContains": "", "lastAddressDigit": "", "address": "15 5 3 2"} - Ignore the device with an ISY address of 15 5 3 2.
*/ */
var types = require("HAP-NodeJS/accessories/types.js");
var types = require("hap-nodejs/accessories/types.js");
var isy = require('isy-js'); var isy = require('isy-js');
var Service = require("HAP-NodeJS").Service; var Service = require("hap-nodejs").Service;
var Characteristic = require("HAP-NodeJS").Characteristic; var Characteristic = require("hap-nodejs").Characteristic;
var inherits = require('util').inherits; var inherits = require('util').inherits;
// Global device map. Needed to map incoming notifications to the corresponding HomeKit device for update. // Global device map. Needed to map incoming notifications to the corresponding HomeKit device for update.
@@ -147,14 +149,22 @@ ISYPlatform.prototype.accessories = function(callback) {
}); });
} }
/////////////////////////////////////////////////////////////////////////////////////////////////
// BASE FOR ALL DEVICES
function ISYAccessoryBaseSetup(accessory,log,device) {
accessory.log = log;
accessory.device = device;
accessory.address = device.address;
accessory.name = device.name;
accessory.uuid_base = device.isy.address+":"+device.address;
}
///////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////
// FANS // FANS
function ISYFanAccessory(log,device) { function ISYFanAccessory(log,device) {
this.log = log; ISYAccessoryBaseSetup(this,log,device);
this.device = device;
this.address = device.address;
this.name = device.name;
} }
ISYFanAccessory.prototype.identify = function(callback) { ISYFanAccessory.prototype.identify = function(callback) {
@@ -276,10 +286,7 @@ ISYFanAccessory.prototype.getServices = function() {
// OUTLETS // OUTLETS
function ISYOutletAccessory(log,device) { function ISYOutletAccessory(log,device) {
this.log = log; ISYAccessoryBaseSetup(this,log,device);
this.device = device;
this.address = device.address;
this.name = device.name;
} }
ISYOutletAccessory.prototype.identify = function(callback) { ISYOutletAccessory.prototype.identify = function(callback) {
@@ -343,10 +350,7 @@ ISYOutletAccessory.prototype.getServices = function() {
// LOCKS // LOCKS
function ISYLockAccessory(log,device) { function ISYLockAccessory(log,device) {
this.log = log; ISYAccessoryBaseSetup(this,log,device);
this.device = device;
this.address = device.address;
this.name = device.name;
} }
ISYLockAccessory.prototype.identify = function(callback) { ISYLockAccessory.prototype.identify = function(callback) {
@@ -416,10 +420,7 @@ ISYLockAccessory.prototype.getServices = function() {
// LIGHTS // LIGHTS
function ISYLightAccessory(log,device) { function ISYLightAccessory(log,device) {
this.log = log; ISYAccessoryBaseSetup(this,log,device);
this.device = device;
this.address = device.address;
this.name = device.name;
this.dimmable = (this.device.deviceType == "DimmableLight"); this.dimmable = (this.device.deviceType == "DimmableLight");
} }
@@ -513,10 +514,7 @@ ISYLightAccessory.prototype.getServices = function() {
// CONTACT SENSOR // CONTACT SENSOR
function ISYDoorWindowSensorAccessory(log,device) { function ISYDoorWindowSensorAccessory(log,device) {
this.log = log; ISYAccessoryBaseSetup(this,log,device);
this.device = device;
this.address = device.address;
this.name = device.name;
this.doorWindowState = false; this.doorWindowState = false;
} }
@@ -562,10 +560,7 @@ ISYDoorWindowSensorAccessory.prototype.getServices = function() {
// ELK SENSOR PANEL // ELK SENSOR PANEL
function ISYElkAlarmPanelAccessory(log,device) { function ISYElkAlarmPanelAccessory(log,device) {
this.log = log; ISYAccessoryBaseSetup(this,log,device);
this.device = device;
this.address = device.address;
this.name = device.name;
} }
ISYElkAlarmPanelAccessory.prototype.identify = function(callback) { ISYElkAlarmPanelAccessory.prototype.identify = function(callback) {