@dcaton1220 Found another issue. I do not have secure arming enabled, but was getting an error in the app when not providing the user code:
QolSys IQ Alarm Panel: Secure arming enabled for partition 0. User code must be specified in order to arm panel.
I could see in the logs, that the "Secure_Arm_Partition_0" object should have been set to 'false'.
QolSys IQ Alarm Panel: json: [event:INFO, info_type:SUMMARY, partition_list:[[partition_id:0, name:partition1, status:DISARM, secure_arm:false,
Here's where I think the problem is:
private boolean checkSecureArming(String partition_id, BigDecimal user_code = 0) {
if (getDataValue( "Secure_Arm_Partition_${partition_id}" ) && user_code == 0) {
logError( "Secure arming enabled for partition ${partition_id}. User code must be specified in order to arm panel.")
return false;
}
return true;
}
I don't think the function was working as intended. If I've got it right in my head (and there's a good chance I don't) then inside of checkSecureArming, this would have returned a string of 'false' and not an evaluated condition of 'false'. That would make the evaluated condition 'true' so the whole if condition is always true.
getDataValue( "Secure_Arm_Partition_${partition_id}" )
I think the intent was (in pseudocode)
if (secure_arm == true AND user_code == null)
log(error)
return true
Which brings me to the second point. From what I can tell in the rest of the code you want to check if secure arming is enabled. So, if the above conditions are met, then you'd want to return a 'true' response.
So, I updated the method to this:
private boolean checkSecureArming(String partition_id, BigDecimal user_code = 0) {
if (getDataValue( "Secure_Arm_Partition_${partition_id}" ) == 'true' && user_code == 0) {
logError( "Secure arming enabled for partition ${partition_id}. User code must be specified in order to arm panel.")
return false;
}
return true;
}
The issue now is that there's no defined message format for this. There's still a space for the user code in the sent message. I imagine the panel is looking for it to either not be there or have a placeholder like "arming_type": "ARM_STAY", "user_code":, "delay": 0
EDIT: It's looking for the field to just not be there. I moved the comma after "arming_type" to the if statement for the user code to keep it from sending the comma if no user code was provided.
private String _createArmCommand( String partition_id, String arming_type, BigDecimal user_code = 0, BigDecimal delay = 0, String bypass = "" ) {
def command = '{ "version": 1, "source": "C4", "action": "ARMING", "nonce": "", "token": "' + accessToken + '", "partition_id":' + partition_id.toString() + '", "arming_type": "' + arming_type + '"' ;
if (user_code != 0) {
command += ', "usercode": "' + user_code.toString() + '"';
}
if (arming_type == "ARM_STAY" || arming_type == "ARM_AWAY" ) {
command += ', "delay": ' + delay.toString() + ', "bypass": ' + (bypass == "Yes" ? "true" : "false");
}
command += '}';
return command
}