We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
`var Service, Characteristic; const { getAccessToken, getStatus, setStatus } = require('yalealarmsystem');
module.exports = function(homebridge) { Service = homebridge.hap.Service; Characteristic = homebridge.hap.Characteristic;
homebridge.registerAccessory("homebridge-yalealarmsystem", "YaleAlarm", YaleAlarm);
}
function YaleAlarm(log, config) { this.log = log; this.name = config["name"]; this.config = config;
this.service = new Service.SecuritySystem(this.name);
console.log(this.service); this.service .getCharacteristic(Characteristic.SecuritySystemCurrentState) .on('get', this.getState.bind(this));
this.service .getCharacteristic(Characteristic.SecuritySystemTargetState) .on('get', this.getState.bind(this)) .on('set', this.setState.bind(this));
YaleAlarm.prototype.getState = function(callback) { this.log("Getting current state...");
getAccessToken( this.config.username, this.config.password ).then(getStatus).then((response) => { console.log(response); callback(null, response === 'arm'); }).catch(console.log);
YaleAlarm.prototype.setState = function(state, callback) { var alarmState = null;
console.log(`Incoming Alarm state is ${state}`); switch(state){ case Characteristic.SecuritySystemTargetState.STAY_ARM: case Characteristic.SecuritySystemTargetState.NIGHT_ARM: var alarmState = "home"; break; case Characteristic.SecuritySystemTargetState.AWAY_ARM: var alarmState = "arm"; break; case Characteristic.SecuritySystemTargetState.DISARM: default: var alarmState = "disarm"; break; } console.log(`Set Alarm state to ${alarmState}`); getAccessToken( this.config.username, this.config.password ).then((accessToken) => { setStatus(accessToken, alarmState).then((response) => { var currentState = ""; switch(state){ case Characteristic.SecuritySystemTargetState.STAY_ARM: currentState = Characteristic.SecuritySystemCurrentState.STAY_ARM break; case Characteristic.SecuritySystemTargetState.NIGHT_ARM: currentState = Characteristic.SecuritySystemCurrentState.NIGHT_ARM break; case Characteristic.SecuritySystemTargetState.AWAY_ARM: currentState = Characteristic.SecuritySystemCurrentState.AWAY_ARM break; case Characteristic.SecuritySystemTargetState.DISARM: currentState = Characteristic.SecuritySystemCurrentState.DISARMED break; } console.log(Characteristic.SecuritySystemCurrentState); this.service.setCharacteristic(Characteristic.SecuritySystemCurrentState, currentState); callback(null); // success }).catch((response) => { console.log('catch') console.log(response) }); });
YaleAlarm.prototype.getServices = function() { return [this.service]; }`
The text was updated successfully, but these errors were encountered:
No branches or pull requests
`var Service, Characteristic;
const { getAccessToken, getStatus, setStatus } = require('yalealarmsystem');
module.exports = function(homebridge) {
Service = homebridge.hap.Service;
Characteristic = homebridge.hap.Characteristic;
}
function YaleAlarm(log, config) {
this.log = log;
this.name = config["name"];
this.config = config;
console.log(this.service);
this.service
.getCharacteristic(Characteristic.SecuritySystemCurrentState)
.on('get', this.getState.bind(this));
}
YaleAlarm.prototype.getState = function(callback) {
this.log("Getting current state...");
}
YaleAlarm.prototype.setState = function(state, callback) {
var alarmState = null;
}
YaleAlarm.prototype.getServices = function() {
return [this.service];
}`
The text was updated successfully, but these errors were encountered: