mirror of
https://github.com/mtan93/homebridge.git
synced 2026-04-15 22:05:12 +01:00
Fixed elk panel state transitions.
This commit is contained in:
@@ -573,51 +573,30 @@ ISYElkAlarmPanelAccessory.prototype.identify = function(callback) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ISYElkAlarmPanelAccessory.prototype.setAlarmTargetState = function(targetStateHK,callback) {
|
ISYElkAlarmPanelAccessory.prototype.setAlarmTargetState = function(targetStateHK,callback) {
|
||||||
this.log("Sending command to set alarm panel state to: "+targetStateHK);
|
this.log("***** Sending command to set alarm panel state to: "+targetStateHK);
|
||||||
var targetState = this.translateHKToAlarmTargetState(targetState);
|
var targetState = this.translateHKToAlarmTargetState(targetStateHK);
|
||||||
if(this.alarmTargetState != targetState) {
|
this.log("***** Would send the target state of: "+targetState);
|
||||||
|
if(this.device.getAlarmMode() != targetState) {
|
||||||
this.device.sendSetAlarmModeCommand(targetState, function(result) {
|
this.device.sendSetAlarmModeCommand(targetState, function(result) {
|
||||||
callback();
|
callback();
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
this.log("***** Redundant command, already in that state.");
|
||||||
callback();
|
callback();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
////// Current State
|
|
||||||
|
|
||||||
/*
|
|
||||||
ELKAlarmPanelDevice.prototype.ALARM_STATE_NOT_READY_TO_ARM = 0;
|
|
||||||
ELKAlarmPanelDevice.prototype.ALARM_STATE_READY_TO_ARM = 1;
|
|
||||||
ELKAlarmPanelDevice.prototype.ALARM_STATE_READY_TO_ARM_VIOLATION = 2;
|
|
||||||
ELKAlarmPanelDevice.prototype.ALARM_STATE_ARMED_WITH_TIMER = 3;
|
|
||||||
ELKAlarmPanelDevice.prototype.ALARM_STATE_ARMED_FULLY = 4;
|
|
||||||
ELKAlarmPanelDevice.prototype.ALARM_STATE_FORCE_ARMED_VIOLATION = 5;
|
|
||||||
ELKAlarmPanelDevice.prototype.ALARM_STATE_ARMED_WITH_BYPASS = 6;
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
ELKAlarmPanelDevice.prototype.ALARM_TRIP_STATE_DISARMED = 0;
|
|
||||||
ELKAlarmPanelDevice.prototype.ALARM_TRIP_STATE_EXIT_DELAY = 1;
|
|
||||||
ELKAlarmPanelDevice.prototype.ALARM_TRIP_STATE_TRIPPED = 2;
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
Characteristic.SecuritySystemCurrentState.STAY_ARM = 0;
|
|
||||||
Characteristic.SecuritySystemCurrentState.AWAY_ARM = 1;
|
|
||||||
Characteristic.SecuritySystemCurrentState.NIGHT_ARM = 2;
|
|
||||||
Characteristic.SecuritySystemCurrentState.DISARMED = 3;
|
|
||||||
Characteristic.SecuritySystemCurrentState.ALARM_TRIGGERED = 4;
|
|
||||||
*/
|
|
||||||
|
|
||||||
ISYElkAlarmPanelAccessory.prototype.translateAlarmCurrentStateToHK = function() {
|
ISYElkAlarmPanelAccessory.prototype.translateAlarmCurrentStateToHK = function() {
|
||||||
var tripState = this.device.getAlarmTripState();
|
var tripState = this.device.getAlarmTripState();
|
||||||
if(tripState == this.device.ALARM_TRIP_STATE_DISARMED || tripState == this.device.ALARM_TRIP_STATE_EXIT_DELAY) {
|
var sourceAlarmState = this.device.getAlarmState();
|
||||||
return Characteristic.SecuritySystemCurrentState.DISARMED;
|
|
||||||
} else if(tripState ==this.device.ALARM_TRIP_STATE_TRIPPED) {
|
if(tripState >= this.device.ALARM_TRIP_STATE_TRIPPED) {
|
||||||
return Characteristic.SecuritySystemCurrentState.ALARM_TRIGGERED;
|
return Characteristic.SecuritySystemCurrentState.ALARM_TRIGGERED;
|
||||||
|
} else if(sourceAlarmState == this.device.ALARM_STATE_NOT_READY_TO_ARM ||
|
||||||
|
sourceAlarmState == this.device.ALARM_STATE_READY_TO_ARM ||
|
||||||
|
sourceAlarmState == this.device.ALARM_STATE_READY_TO_ARM_VIOLATION) {
|
||||||
|
return Characteristic.SecuritySystemCurrentState.DISARMED;
|
||||||
} else {
|
} else {
|
||||||
var sourceAlarmState = this.device.getAlarmMode();
|
|
||||||
if(sourceAlarmState == this.device.ALARM_MODE_STAY || sourceAlarmState == this.device.ALARM_MODE_STAY_INSTANT ) {
|
if(sourceAlarmState == this.device.ALARM_MODE_STAY || sourceAlarmState == this.device.ALARM_MODE_STAY_INSTANT ) {
|
||||||
return Characteristic.SecuritySystemCurrentState.STAY_ARM;
|
return Characteristic.SecuritySystemCurrentState.STAY_ARM;
|
||||||
} else if(sourceAlarmState == this.device.ALARM_MODE_AWAY || sourceAlarmState == this.device.ALARM_MODE_VACATION) {
|
} else if(sourceAlarmState == this.device.ALARM_MODE_AWAY || sourceAlarmState == this.device.ALARM_MODE_VACATION) {
|
||||||
@@ -625,31 +604,12 @@ ISYElkAlarmPanelAccessory.prototype.translateAlarmCurrentStateToHK = function()
|
|||||||
} else if(sourceAlarmState == this.device.ALARM_MODE_NIGHT || sourceAlarmState == this.device.ALARM_MODE_NIGHT_INSTANT) {
|
} else if(sourceAlarmState == this.device.ALARM_MODE_NIGHT || sourceAlarmState == this.device.ALARM_MODE_NIGHT_INSTANT) {
|
||||||
return Characteristic.SecuritySystemCurrentState.NIGHT_ARM;
|
return Characteristic.SecuritySystemCurrentState.NIGHT_ARM;
|
||||||
} else {
|
} else {
|
||||||
return Characteristic.SecuritySystemCurrentState.DISARM;
|
this.log("***** Setting to disarmed because sourceAlarmState is "+sourceAlarmState);
|
||||||
|
return Characteristic.SecuritySystemCurrentState.DISARMED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
////// Target Mode
|
|
||||||
|
|
||||||
/*
|
|
||||||
ELKAlarmPanelDevice.prototype.ALARM_MODE_DISARMED = 0;
|
|
||||||
ELKAlarmPanelDevice.prototype.ALARM_MODE_AWAY = 1;
|
|
||||||
ELKAlarmPanelDevice.prototype.ALARM_MODE_STAY = 2;
|
|
||||||
ELKAlarmPanelDevice.prototype.ALARM_MODE_STAY_INSTANT = 3;
|
|
||||||
ELKAlarmPanelDevice.prototype.ALARM_MODE_NIGHT = 4;
|
|
||||||
ELKAlarmPanelDevice.prototype.ALARM_MODE_NIGHT_INSTANT = 5;
|
|
||||||
ELKAlarmPanelDevice.prototype.ALARM_MODE_VACATION = 6;
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
Characteristic.SecuritySystemTargetState.STAY_ARM = 0;
|
|
||||||
Characteristic.SecuritySystemTargetState.AWAY_ARM = 1;
|
|
||||||
Characteristic.SecuritySystemTargetState.NIGHT_ARM = 2;
|
|
||||||
Characteristic.SecuritySystemTargetState.DISARM = 3;
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
ISYElkAlarmPanelAccessory.prototype.translateAlarmTargetStateToHK = function() {
|
ISYElkAlarmPanelAccessory.prototype.translateAlarmTargetStateToHK = function() {
|
||||||
var sourceAlarmState = this.device.getAlarmMode();
|
var sourceAlarmState = this.device.getAlarmMode();
|
||||||
if(sourceAlarmState == this.device.ALARM_MODE_STAY || sourceAlarmState == this.device.ALARM_MODE_STAY_INSTANT ) {
|
if(sourceAlarmState == this.device.ALARM_MODE_STAY || sourceAlarmState == this.device.ALARM_MODE_STAY_INSTANT ) {
|
||||||
@@ -669,9 +629,9 @@ ISYElkAlarmPanelAccessory.prototype.translateHKToAlarmTargetState = function(sta
|
|||||||
} else if(state == Characteristic.SecuritySystemTargetState.AWAY_ARM) {
|
} else if(state == Characteristic.SecuritySystemTargetState.AWAY_ARM) {
|
||||||
return this.device.ALARM_MODE_AWAY;
|
return this.device.ALARM_MODE_AWAY;
|
||||||
} else if(state == Characteristic.SecuritySystemTargetState.NIGHT_ARM) {
|
} else if(state == Characteristic.SecuritySystemTargetState.NIGHT_ARM) {
|
||||||
return this.device.NIGHT_ARM;
|
return this.device.ALARM_MODE_NIGHT;
|
||||||
} else {
|
} else {
|
||||||
return this.device.DISARM;
|
return this.device.ALARM_MODE_DISARMED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -684,6 +644,8 @@ ISYElkAlarmPanelAccessory.prototype.getAlarmCurrentState = function(callback) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ISYElkAlarmPanelAccessory.prototype.handleExternalChange = function() {
|
ISYElkAlarmPanelAccessory.prototype.handleExternalChange = function() {
|
||||||
|
this.log("***** Source device. Currenty state locally -"+this.device.getAlarmStatusAsText());
|
||||||
|
this.log("***** Got alarm change notification. Setting HK target state to: "+this.translateAlarmTargetStateToHK()+" Setting HK Current state to: "+this.translateAlarmCurrentStateToHK());
|
||||||
this.alarmPanelService
|
this.alarmPanelService
|
||||||
.setCharacteristic(Characteristic.SecuritySystemTargetState, this.translateAlarmTargetStateToHK());
|
.setCharacteristic(Characteristic.SecuritySystemTargetState, this.translateAlarmTargetStateToHK());
|
||||||
this.alarmPanelService
|
this.alarmPanelService
|
||||||
@@ -724,3 +686,4 @@ module.exports.accessory = ISYLightAccessory;
|
|||||||
module.exports.accessory = ISYLockAccessory;
|
module.exports.accessory = ISYLockAccessory;
|
||||||
module.exports.accessory = ISYOutletAccessory;
|
module.exports.accessory = ISYOutletAccessory;
|
||||||
module.exports.accessory = ISYDoorWindowSensorAccessory;
|
module.exports.accessory = ISYDoorWindowSensorAccessory;
|
||||||
|
module.exports.accessory = ISYElkAlarmPanelAccessory;
|
||||||
|
|||||||
Reference in New Issue
Block a user