mirror of
https://github.com/mtan93/homebridge.git
synced 2026-04-02 06:13:12 +01:00
Adding support for arming Elk M1 security system.
This commit is contained in:
126
accessories/ELKM1.js
Normal file
126
accessories/ELKM1.js
Normal file
@@ -0,0 +1,126 @@
|
|||||||
|
var types = require("../lib/HAP-NodeJS/accessories/types.js");
|
||||||
|
var elkington = require("elkington");
|
||||||
|
|
||||||
|
function ElkM1Accessory(log, config) {
|
||||||
|
this.log = log;
|
||||||
|
this.name = config["name"];
|
||||||
|
this.zone = config["zone"];
|
||||||
|
this.host = config["host"];
|
||||||
|
this.port = config["port"];
|
||||||
|
this.pin = config["pin"];
|
||||||
|
this.arm = config["arm"];
|
||||||
|
}
|
||||||
|
|
||||||
|
ElkM1Accessory.prototype = {
|
||||||
|
setPowerState: function(alarmOn) {
|
||||||
|
var that = this;
|
||||||
|
|
||||||
|
if (!alarmOn)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var elk = elkington.createConnection({
|
||||||
|
port: that.port,
|
||||||
|
host: that.host,
|
||||||
|
});
|
||||||
|
|
||||||
|
switch (that.arm)
|
||||||
|
{
|
||||||
|
case 'Away':
|
||||||
|
elk.armAway({area: that.zone, code: that.pin});
|
||||||
|
break;
|
||||||
|
case 'Stay':
|
||||||
|
elk.armStay({area: that.zone, code: that.pin});
|
||||||
|
break;
|
||||||
|
case 'Night':
|
||||||
|
elk.armNightInstant({area: that.zone, code: that.pin});
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
getServices: function() {
|
||||||
|
var that = this;
|
||||||
|
return [{
|
||||||
|
sType: types.ACCESSORY_INFORMATION_STYPE,
|
||||||
|
characteristics: [{
|
||||||
|
cType: types.NAME_CTYPE,
|
||||||
|
onUpdate: null,
|
||||||
|
perms: ["pr"],
|
||||||
|
format: "string",
|
||||||
|
initialValue: this.name,
|
||||||
|
supportEvents: false,
|
||||||
|
supportBonjour: false,
|
||||||
|
manfDescription: "Name of the accessory",
|
||||||
|
designedMaxLength: 255
|
||||||
|
},{
|
||||||
|
cType: types.MANUFACTURER_CTYPE,
|
||||||
|
onUpdate: null,
|
||||||
|
perms: ["pr"],
|
||||||
|
format: "string",
|
||||||
|
initialValue: "Elk",
|
||||||
|
supportEvents: false,
|
||||||
|
supportBonjour: false,
|
||||||
|
manfDescription: "Manufacturer",
|
||||||
|
designedMaxLength: 255
|
||||||
|
},{
|
||||||
|
cType: types.MODEL_CTYPE,
|
||||||
|
onUpdate: null,
|
||||||
|
perms: ["pr"],
|
||||||
|
format: "string",
|
||||||
|
initialValue: "M1",
|
||||||
|
supportEvents: false,
|
||||||
|
supportBonjour: false,
|
||||||
|
manfDescription: "Model",
|
||||||
|
designedMaxLength: 255
|
||||||
|
},{
|
||||||
|
cType: types.SERIAL_NUMBER_CTYPE,
|
||||||
|
onUpdate: null,
|
||||||
|
perms: ["pr"],
|
||||||
|
format: "string",
|
||||||
|
initialValue: "A1S2NASF88EW",
|
||||||
|
supportEvents: false,
|
||||||
|
supportBonjour: false,
|
||||||
|
manfDescription: "SN",
|
||||||
|
designedMaxLength: 255
|
||||||
|
},{
|
||||||
|
cType: types.IDENTIFY_CTYPE,
|
||||||
|
onUpdate: null,
|
||||||
|
perms: ["pw"],
|
||||||
|
format: "bool",
|
||||||
|
initialValue: false,
|
||||||
|
supportEvents: false,
|
||||||
|
supportBonjour: false,
|
||||||
|
manfDescription: "Identify Accessory",
|
||||||
|
designedMaxLength: 1
|
||||||
|
}]
|
||||||
|
},{
|
||||||
|
sType: types.SWITCH_STYPE,
|
||||||
|
characteristics: [{
|
||||||
|
cType: types.NAME_CTYPE,
|
||||||
|
onUpdate: null,
|
||||||
|
perms: ["pr"],
|
||||||
|
format: "string",
|
||||||
|
initialValue: this.name,
|
||||||
|
supportEvents: false,
|
||||||
|
supportBonjour: false,
|
||||||
|
manfDescription: "Name of service",
|
||||||
|
designedMaxLength: 255
|
||||||
|
},{
|
||||||
|
cType: types.POWER_STATE_CTYPE,
|
||||||
|
onUpdate: function(value) { that.setPowerState(value); },
|
||||||
|
perms: ["pw","pr","ev"],
|
||||||
|
format: "bool",
|
||||||
|
initialValue: false,
|
||||||
|
supportEvents: false,
|
||||||
|
supportBonjour: false,
|
||||||
|
manfDescription: "Alarm the Zone",
|
||||||
|
designedMaxLength: 1
|
||||||
|
}]
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports.accessory = ElkM1Accessory;
|
||||||
@@ -102,6 +102,15 @@
|
|||||||
"off_url": "https://192.168.1.22:3030/devices/23222/off",
|
"off_url": "https://192.168.1.22:3030/devices/23222/off",
|
||||||
"brightness_url": "https://192.168.1.22:3030/devices/23222/brightness/%b",
|
"brightness_url": "https://192.168.1.22:3030/devices/23222/brightness/%b",
|
||||||
"http_method": "POST"
|
"http_method": "POST"
|
||||||
|
},{
|
||||||
|
"accessory": "ELKM1",
|
||||||
|
"name": "Security System",
|
||||||
|
"description": "Allows basic control of Elk M1 security system. You can use 1 of 3 arm modes: Away, Stay, Night. If you need to access all 3, create 3 accessories with different names.",
|
||||||
|
"zone": "1",
|
||||||
|
"host": "192.168.1.10",
|
||||||
|
"port": "2101",
|
||||||
|
"pin": "1234",
|
||||||
|
"arm": "Away"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
"carwingsjs": "0.0.x",
|
"carwingsjs": "0.0.x",
|
||||||
"sonos": "0.8.x",
|
"sonos": "0.8.x",
|
||||||
"wemo": "0.2.x",
|
"wemo": "0.2.x",
|
||||||
"wink-js": "0.0.5"
|
"wink-js": "0.0.5",
|
||||||
|
"elkington": "kevinohara80/elkington"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user