[caddx] Add new channels and support for ignoring zone status transitions (#10923)
* Cleanup of binding configuration classes * Added context to CaddxMessage * Logging enhancements * Added support for ignoring Zone Status Transitions Signed-off-by: Georgios Moutsos <georgios.moutsos@gmail.com>
This commit is contained in:
parent
fe91fb635a
commit
b96bab46d7
@ -125,6 +125,9 @@ Caddx Alarm things support a variety of channels as seen below in the following
|
|||||||
| panel_primary_keypad_function_without_pin | Switch | Configuration | Primary Keypad Function without PIN |
|
| panel_primary_keypad_function_without_pin | Switch | Configuration | Primary Keypad Function without PIN |
|
||||||
| panel_secondary_keypad_function | Switch | Configuration | Secondary Keypad Function |
|
| panel_secondary_keypad_function | Switch | Configuration | Secondary Keypad Function |
|
||||||
| panel_zone_bypass_toggle | Switch | Configuration | Zone Bypass Toggle |
|
| panel_zone_bypass_toggle | Switch | Configuration | Zone Bypass Toggle |
|
||||||
|
| panel_ac_fail | Switch | Configuration | AC fail |
|
||||||
|
| panel_ac_power_on | Switch | Configuration | AC Power on |
|
||||||
|
| panel_low_battery_memory | Switch | Configuration | Low Battery Memory |
|
||||||
| partition_bypass_code_required | Switch | Partition Condition | Bypass code required |
|
| partition_bypass_code_required | Switch | Partition Condition | Bypass code required |
|
||||||
| partition_fire_trouble | Switch | Partition Condition | Fire trouble |
|
| partition_fire_trouble | Switch | Partition Condition | Fire trouble |
|
||||||
| partition_fire | Switch | Partition Condition | Fire |
|
| partition_fire | Switch | Partition Condition | Fire |
|
||||||
|
|||||||
@ -179,17 +179,17 @@ public class CaddxCommunicator implements SerialPortEventListener {
|
|||||||
|
|
||||||
@SuppressWarnings("null")
|
@SuppressWarnings("null")
|
||||||
private void messageDispatchLoop() {
|
private void messageDispatchLoop() {
|
||||||
int @Nullable [] expectedMessageNumbers = null;
|
int[] expectedMessageNumbers = null;
|
||||||
|
|
||||||
@Nullable
|
|
||||||
CaddxMessage outgoingMessage = null;
|
CaddxMessage outgoingMessage = null;
|
||||||
boolean skipTransmit = true;
|
boolean skipTransmit = true;
|
||||||
|
CaddxMessageContext context = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// loop until the thread is interrupted, sending out messages
|
// loop until the thread is interrupted, sending out messages
|
||||||
while (!Thread.currentThread().isInterrupted()) {
|
while (!Thread.currentThread().isInterrupted()) {
|
||||||
// Initialize the state
|
// Initialize the state
|
||||||
outgoingMessage = null;
|
outgoingMessage = null;
|
||||||
|
context = null;
|
||||||
expectedMessageNumbers = null;
|
expectedMessageNumbers = null;
|
||||||
|
|
||||||
if (!skipTransmit) {
|
if (!skipTransmit) {
|
||||||
@ -203,6 +203,7 @@ public class CaddxCommunicator implements SerialPortEventListener {
|
|||||||
out.flush();
|
out.flush();
|
||||||
|
|
||||||
expectedMessageNumbers = outgoingMessage.getReplyMessageNumbers();
|
expectedMessageNumbers = outgoingMessage.getReplyMessageNumbers();
|
||||||
|
context = outgoingMessage.getContext();
|
||||||
|
|
||||||
// Log message
|
// Log message
|
||||||
if (logger.isDebugEnabled()) {
|
if (logger.isDebugEnabled()) {
|
||||||
@ -248,10 +249,12 @@ public class CaddxCommunicator implements SerialPortEventListener {
|
|||||||
if (incomingMessage.hasAcknowledgementFlag()) {
|
if (incomingMessage.hasAcknowledgementFlag()) {
|
||||||
if (incomingMessage.isChecksumCorrect()) {
|
if (incomingMessage.isChecksumCorrect()) {
|
||||||
// send ACK
|
// send ACK
|
||||||
transmitFirst(new CaddxMessage(CaddxMessageType.POSITIVE_ACKNOWLEDGE, ""));
|
transmitFirst(new CaddxMessage(CaddxMessageContext.NONE,
|
||||||
|
CaddxMessageType.POSITIVE_ACKNOWLEDGE, ""));
|
||||||
} else {
|
} else {
|
||||||
// Send NAK
|
// Send NAK
|
||||||
transmitFirst(new CaddxMessage(CaddxMessageType.NEGATIVE_ACKNOWLEDGE, ""));
|
transmitFirst(new CaddxMessage(CaddxMessageContext.NONE,
|
||||||
|
CaddxMessageType.NEGATIVE_ACKNOWLEDGE, ""));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -289,7 +292,10 @@ public class CaddxCommunicator implements SerialPortEventListener {
|
|||||||
if (incomingMessage != null) {
|
if (incomingMessage != null) {
|
||||||
if (incomingMessage.isChecksumCorrect()) {
|
if (incomingMessage.isChecksumCorrect()) {
|
||||||
for (CaddxPanelListener listener : listenerQueue) {
|
for (CaddxPanelListener listener : listenerQueue) {
|
||||||
listener.caddxMessage(this, incomingMessage);
|
if (context != null) {
|
||||||
|
incomingMessage.setContext(context);
|
||||||
|
}
|
||||||
|
listener.caddxMessage(incomingMessage);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
logger.warn(
|
logger.warn(
|
||||||
@ -367,7 +373,7 @@ public class CaddxCommunicator implements SerialPortEventListener {
|
|||||||
logger.trace("Offering received message");
|
logger.trace("Offering received message");
|
||||||
|
|
||||||
// Full message received in data byte array
|
// Full message received in data byte array
|
||||||
CaddxMessage caddxMessage = new CaddxMessage(message, true);
|
CaddxMessage caddxMessage = new CaddxMessage(CaddxMessageContext.NONE, message, true);
|
||||||
if (!exchanger.offer(caddxMessage, 3, TimeUnit.SECONDS)) {
|
if (!exchanger.offer(caddxMessage, 3, TimeUnit.SECONDS)) {
|
||||||
logger.debug("Offered message was not received");
|
logger.debug("Offered message was not received");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -60,4 +60,18 @@ public class CaddxEvent extends EventObject {
|
|||||||
public @Nullable Integer getKeypad() {
|
public @Nullable Integer getKeypad() {
|
||||||
return keypad;
|
return keypad;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a string representation of a CaddxEvent.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
|
sb.append(String.format("partition: %d, zone: %d, keypad: %d\r\n", partition, zone, keypad));
|
||||||
|
sb.append(caddxMessage.toString());
|
||||||
|
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -40,8 +40,9 @@ public class CaddxMessage {
|
|||||||
private final byte checksum2In;
|
private final byte checksum2In;
|
||||||
private final byte checksum1Calc;
|
private final byte checksum1Calc;
|
||||||
private final byte checksum2Calc;
|
private final byte checksum2Calc;
|
||||||
|
private CaddxMessageContext context;
|
||||||
|
|
||||||
public CaddxMessage(byte[] message, boolean withChecksum) {
|
public CaddxMessage(CaddxMessageContext context, byte[] message, boolean withChecksum) {
|
||||||
if (withChecksum && message.length < 3) {
|
if (withChecksum && message.length < 3) {
|
||||||
logger.debug("CaddxMessage: The message should be at least 3 bytes long.");
|
logger.debug("CaddxMessage: The message should be at least 3 bytes long.");
|
||||||
throw new IllegalArgumentException("The message should be at least 3 bytes long");
|
throw new IllegalArgumentException("The message should be at least 3 bytes long");
|
||||||
@ -52,6 +53,7 @@ public class CaddxMessage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Received data
|
// Received data
|
||||||
|
this.context = context;
|
||||||
byte[] msg = message;
|
byte[] msg = message;
|
||||||
|
|
||||||
// Fill in the checksum
|
// Fill in the checksum
|
||||||
@ -94,7 +96,7 @@ public class CaddxMessage {
|
|||||||
processCaddxMessage();
|
processCaddxMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
public CaddxMessage(CaddxMessageType type, String data) {
|
public CaddxMessage(CaddxMessageContext context, CaddxMessageType type, String data) {
|
||||||
int length = type.length;
|
int length = type.length;
|
||||||
String[] tokens = data.split("\\,");
|
String[] tokens = data.split("\\,");
|
||||||
if (length != 1 && tokens.length != length - 1) {
|
if (length != 1 && tokens.length != length - 1) {
|
||||||
@ -102,6 +104,7 @@ public class CaddxMessage {
|
|||||||
throw new IllegalArgumentException("CaddxMessage: data has not the correct format.");
|
throw new IllegalArgumentException("CaddxMessage: data has not the correct format.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.context = context;
|
||||||
byte[] msg = new byte[length];
|
byte[] msg = new byte[length];
|
||||||
msg[0] = (byte) type.number;
|
msg[0] = (byte) type.number;
|
||||||
for (int i = 0; i < length - 1; i++) {
|
for (int i = 0; i < length - 1; i++) {
|
||||||
@ -133,6 +136,14 @@ public class CaddxMessage {
|
|||||||
processCaddxMessage();
|
processCaddxMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public CaddxMessageContext getContext() {
|
||||||
|
return context;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setContext(CaddxMessageContext context) {
|
||||||
|
this.context = context;
|
||||||
|
}
|
||||||
|
|
||||||
public byte getChecksum1In() {
|
public byte getChecksum1In() {
|
||||||
return checksum1In;
|
return checksum1In;
|
||||||
}
|
}
|
||||||
@ -259,6 +270,9 @@ public class CaddxMessage {
|
|||||||
return "Unknown message type";
|
return "Unknown message type";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sb.append(String.format("Context: %s", context.toString()));
|
||||||
|
sb.append(System.lineSeparator());
|
||||||
|
|
||||||
sb.append("Message: ");
|
sb.append("Message: ");
|
||||||
sb.append(String.format("%2s", Integer.toHexString(message[0])));
|
sb.append(String.format("%2s", Integer.toHexString(message[0])));
|
||||||
sb.append(" ");
|
sb.append(" ");
|
||||||
|
|||||||
@ -0,0 +1,27 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2010-2021 Contributors to the openHAB project
|
||||||
|
*
|
||||||
|
* See the NOTICE file(s) distributed with this work for additional
|
||||||
|
* information.
|
||||||
|
*
|
||||||
|
* This program and the accompanying materials are made available under the
|
||||||
|
* terms of the Eclipse Public License 2.0 which is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-2.0
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: EPL-2.0
|
||||||
|
*/
|
||||||
|
package org.openhab.binding.caddx.internal;
|
||||||
|
|
||||||
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to map thing types from the binding string to a ENUM value.
|
||||||
|
*
|
||||||
|
* @author Georgios Moutsos - Initial contribution
|
||||||
|
*/
|
||||||
|
@NonNullByDefault
|
||||||
|
public enum CaddxMessageContext {
|
||||||
|
NONE,
|
||||||
|
DISCOVERY,
|
||||||
|
COMMAND;
|
||||||
|
}
|
||||||
@ -197,100 +197,134 @@ public enum CaddxMessageType {
|
|||||||
false),
|
false),
|
||||||
|
|
||||||
// Byte 3 Zone 1 & 2 (+offset) status flags
|
// Byte 3 Zone 1 & 2 (+offset) status flags
|
||||||
new CaddxProperty("", 3, 1, 0, 1, CaddxPropertyType.BIT, "Zone 1 faulted (or delayed trip)", false),
|
new CaddxProperty("zone_1_faulted", 3, 1, 0, 1, CaddxPropertyType.BIT, "Zone 1 faulted (or delayed trip)",
|
||||||
new CaddxProperty("", 3, 1, 1, 1, CaddxPropertyType.BIT, "Zone 1 bypass (or inhibited)", false),
|
false),
|
||||||
|
new CaddxProperty("zone_1_bypassed", 3, 1, 1, 1, CaddxPropertyType.BIT, "Zone 1 bypass (or inhibited)",
|
||||||
|
false),
|
||||||
new CaddxProperty("zone_1_trouble", 3, 1, 2, 1, CaddxPropertyType.BIT,
|
new CaddxProperty("zone_1_trouble", 3, 1, 2, 1, CaddxPropertyType.BIT,
|
||||||
"Zone 1 trouble (tamper, low battery, or lost)", false),
|
"Zone 1 trouble (tamper, low battery, or lost)", false),
|
||||||
new CaddxProperty("", 3, 1, 3, 1, CaddxPropertyType.BIT, "Zone 1 alarm memory", false),
|
new CaddxProperty("zone_1_alarm_memory", 3, 1, 3, 1, CaddxPropertyType.BIT, "Zone 1 alarm memory", false),
|
||||||
new CaddxProperty("", 3, 1, 4, 1, CaddxPropertyType.BIT, "Zone 2 faulted (or delayed trip)", false),
|
new CaddxProperty("zone_2_faulted", 3, 1, 4, 1, CaddxPropertyType.BIT, "Zone 2 faulted (or delayed trip)",
|
||||||
new CaddxProperty("", 3, 1, 5, 1, CaddxPropertyType.BIT, "Zone 2 bypass (or inhibited)", false),
|
false),
|
||||||
|
new CaddxProperty("zone_2_bypassed", 3, 1, 5, 1, CaddxPropertyType.BIT, "Zone 2 bypass (or inhibited)",
|
||||||
|
false),
|
||||||
new CaddxProperty("zone_2_trouble", 3, 1, 6, 1, CaddxPropertyType.BIT,
|
new CaddxProperty("zone_2_trouble", 3, 1, 6, 1, CaddxPropertyType.BIT,
|
||||||
"Zone 2 trouble (tamper, low battery, or lost)", false),
|
"Zone 2 trouble (tamper, low battery, or lost)", false),
|
||||||
new CaddxProperty("", 3, 1, 7, 1, CaddxPropertyType.BIT, "Zone 2 alarm memory", false),
|
new CaddxProperty("zone_2_alarm_memory", 3, 1, 7, 1, CaddxPropertyType.BIT, "Zone 2 alarm memory", false),
|
||||||
|
|
||||||
// Byte 4 Zone 3 & 4 status flags (see byte 3)
|
// Byte 4 Zone 3 & 4 status flags (see byte 3)
|
||||||
new CaddxProperty("", 4, 1, 0, 1, CaddxPropertyType.BIT, "Zone 3 faulted (or delayed trip)", false),
|
new CaddxProperty("zone_3_faulted", 4, 1, 0, 1, CaddxPropertyType.BIT, "Zone 3 faulted (or delayed trip)",
|
||||||
new CaddxProperty("", 4, 1, 1, 1, CaddxPropertyType.BIT, "Zone 3 bypass (or inhibited)", false),
|
false),
|
||||||
|
new CaddxProperty("zone_3_bypassed", 4, 1, 1, 1, CaddxPropertyType.BIT, "Zone 3 bypass (or inhibited)",
|
||||||
|
false),
|
||||||
new CaddxProperty("zone_3_trouble", 4, 1, 2, 1, CaddxPropertyType.BIT,
|
new CaddxProperty("zone_3_trouble", 4, 1, 2, 1, CaddxPropertyType.BIT,
|
||||||
"Zone 3 trouble (tamper, low battery, or lost)", false),
|
"Zone 3 trouble (tamper, low battery, or lost)", false),
|
||||||
new CaddxProperty("", 4, 1, 3, 1, CaddxPropertyType.BIT, "Zone 3 alarm memory", false),
|
new CaddxProperty("zone_3_alarm_memory", 4, 1, 3, 1, CaddxPropertyType.BIT, "Zone 3 alarm memory", false),
|
||||||
new CaddxProperty("", 4, 1, 4, 1, CaddxPropertyType.BIT, "Zone 4 faulted (or delayed trip)", false),
|
new CaddxProperty("zone_4_faulted", 4, 1, 4, 1, CaddxPropertyType.BIT, "Zone 4 faulted (or delayed trip)",
|
||||||
new CaddxProperty("", 4, 1, 5, 1, CaddxPropertyType.BIT, "Zone 4 bypass (or inhibited)", false),
|
false),
|
||||||
|
new CaddxProperty("zone_4_bypassed", 4, 1, 5, 1, CaddxPropertyType.BIT, "Zone 4 bypass (or inhibited)",
|
||||||
|
false),
|
||||||
new CaddxProperty("zone_4_trouble", 4, 1, 6, 1, CaddxPropertyType.BIT,
|
new CaddxProperty("zone_4_trouble", 4, 1, 6, 1, CaddxPropertyType.BIT,
|
||||||
"Zone 4 trouble (tamper, low battery, or lost)", false),
|
"Zone 4 trouble (tamper, low battery, or lost)", false),
|
||||||
new CaddxProperty("", 4, 1, 7, 1, CaddxPropertyType.BIT, "Zone 4 alarm memory", false),
|
new CaddxProperty("zone_4_alarm_memory", 4, 1, 7, 1, CaddxPropertyType.BIT, "Zone 4 alarm memory", false),
|
||||||
|
|
||||||
// Byte 5 Zone 5 & 6 status flags (see byte 3)
|
// Byte 5 Zone 5 & 6 status flags (see byte 3)
|
||||||
new CaddxProperty("", 5, 1, 0, 1, CaddxPropertyType.BIT, "Zone 5 faulted (or delayed trip)", false),
|
new CaddxProperty("zone_5_faulted", 5, 1, 0, 1, CaddxPropertyType.BIT, "Zone 5 faulted (or delayed trip)",
|
||||||
new CaddxProperty("", 5, 1, 1, 1, CaddxPropertyType.BIT, "Zone 5 bypass (or inhibited)", false),
|
false),
|
||||||
|
new CaddxProperty("zone_5_bypassed", 5, 1, 1, 1, CaddxPropertyType.BIT, "Zone 5 bypass (or inhibited)",
|
||||||
|
false),
|
||||||
new CaddxProperty("zone_5_trouble", 5, 1, 2, 1, CaddxPropertyType.BIT,
|
new CaddxProperty("zone_5_trouble", 5, 1, 2, 1, CaddxPropertyType.BIT,
|
||||||
"Zone 5 trouble (tamper, low battery, or lost)", false),
|
"Zone 5 trouble (tamper, low battery, or lost)", false),
|
||||||
new CaddxProperty("", 5, 1, 3, 1, CaddxPropertyType.BIT, "Zone 5 alarm memory", false),
|
new CaddxProperty("zone_5_alarm_memory", 5, 1, 3, 1, CaddxPropertyType.BIT, "Zone 5 alarm memory", false),
|
||||||
new CaddxProperty("", 5, 1, 4, 1, CaddxPropertyType.BIT, "Zone 6 faulted (or delayed trip)", false),
|
new CaddxProperty("zone_6_faulted", 5, 1, 4, 1, CaddxPropertyType.BIT, "Zone 6 faulted (or delayed trip)",
|
||||||
new CaddxProperty("", 5, 1, 5, 1, CaddxPropertyType.BIT, "Zone 6 bypass (or inhibited)", false),
|
false),
|
||||||
|
new CaddxProperty("zone_6_bypassed", 5, 1, 5, 1, CaddxPropertyType.BIT, "Zone 6 bypass (or inhibited)",
|
||||||
|
false),
|
||||||
new CaddxProperty("zone_6_trouble", 5, 1, 6, 1, CaddxPropertyType.BIT,
|
new CaddxProperty("zone_6_trouble", 5, 1, 6, 1, CaddxPropertyType.BIT,
|
||||||
"Zone 6 trouble (tamper, low battery, or lost)", false),
|
"Zone 6 trouble (tamper, low battery, or lost)", false),
|
||||||
new CaddxProperty("", 5, 1, 7, 1, CaddxPropertyType.BIT, "Zone 6 alarm memory", false),
|
new CaddxProperty("zone_6_alarm_memory", 5, 1, 7, 1, CaddxPropertyType.BIT, "Zone 6 alarm memory", false),
|
||||||
|
|
||||||
// Byte 6 Zone 7 & 8 status flags (see byte 3)
|
// Byte 6 Zone 7 & 8 status flags (see byte 3)
|
||||||
new CaddxProperty("", 6, 1, 0, 1, CaddxPropertyType.BIT, "Zone 7 faulted (or delayed trip)", false),
|
new CaddxProperty("zone_7_faulted", 6, 1, 0, 1, CaddxPropertyType.BIT, "Zone 7 faulted (or delayed trip)",
|
||||||
new CaddxProperty("", 6, 1, 1, 1, CaddxPropertyType.BIT, "Zone 7 bypass (or inhibited)", false),
|
false),
|
||||||
|
new CaddxProperty("zone_7_bypassed", 6, 1, 1, 1, CaddxPropertyType.BIT, "Zone 7 bypass (or inhibited)",
|
||||||
|
false),
|
||||||
new CaddxProperty("zone_7_trouble", 6, 1, 2, 1, CaddxPropertyType.BIT,
|
new CaddxProperty("zone_7_trouble", 6, 1, 2, 1, CaddxPropertyType.BIT,
|
||||||
"Zone 7 trouble (tamper, low battery, or lost)", false),
|
"Zone 7 trouble (tamper, low battery, or lost)", false),
|
||||||
new CaddxProperty("", 6, 1, 3, 1, CaddxPropertyType.BIT, "Zone 7 alarm memory", false),
|
new CaddxProperty("zone_7_alarm_memory", 6, 1, 3, 1, CaddxPropertyType.BIT, "Zone 7 alarm memory", false),
|
||||||
new CaddxProperty("", 6, 1, 4, 1, CaddxPropertyType.BIT, "Zone 8 faulted (or delayed trip)", false),
|
new CaddxProperty("zone_8_faulted", 6, 1, 4, 1, CaddxPropertyType.BIT, "Zone 8 faulted (or delayed trip)",
|
||||||
new CaddxProperty("", 6, 1, 5, 1, CaddxPropertyType.BIT, "Zone 8 bypass (or inhibited)", false),
|
false),
|
||||||
|
new CaddxProperty("zone_8_bypassed", 6, 1, 5, 1, CaddxPropertyType.BIT, "Zone 8 bypass (or inhibited)",
|
||||||
|
false),
|
||||||
new CaddxProperty("zone_8_trouble", 6, 1, 6, 1, CaddxPropertyType.BIT,
|
new CaddxProperty("zone_8_trouble", 6, 1, 6, 1, CaddxPropertyType.BIT,
|
||||||
"Zone 8 trouble (tamper, low battery, or lost)", false),
|
"Zone 8 trouble (tamper, low battery, or lost)", false),
|
||||||
new CaddxProperty("", 6, 1, 7, 1, CaddxPropertyType.BIT, "Zone 8 alarm memory", false),
|
new CaddxProperty("zone_8_alarm_memory", 6, 1, 7, 1, CaddxPropertyType.BIT, "Zone 8 alarm memory", false),
|
||||||
|
|
||||||
// Byte 7 Zone 9 & 10 status flags (see byte 3)
|
// Byte 7 Zone 9 & 10 status flags (see byte 3)
|
||||||
new CaddxProperty("", 7, 1, 0, 1, CaddxPropertyType.BIT, "Zone 9 faulted (or delayed trip)", false),
|
new CaddxProperty("zone_9_faulted", 7, 1, 0, 1, CaddxPropertyType.BIT, "Zone 9 faulted (or delayed trip)",
|
||||||
new CaddxProperty("", 7, 1, 1, 1, CaddxPropertyType.BIT, "Zone 9 bypass (or inhibited)", false),
|
false),
|
||||||
|
new CaddxProperty("zone_9_bypassed", 7, 1, 1, 1, CaddxPropertyType.BIT, "Zone 9 bypass (or inhibited)",
|
||||||
|
false),
|
||||||
new CaddxProperty("zone_9_trouble", 7, 1, 2, 1, CaddxPropertyType.BIT,
|
new CaddxProperty("zone_9_trouble", 7, 1, 2, 1, CaddxPropertyType.BIT,
|
||||||
"Zone 9 trouble (tamper, low battery, or lost)", false),
|
"Zone 9 trouble (tamper, low battery, or lost)", false),
|
||||||
new CaddxProperty("", 7, 1, 3, 1, CaddxPropertyType.BIT, "Zone 9 alarm memory", false),
|
new CaddxProperty("zone_9_alarm_memory", 7, 1, 3, 1, CaddxPropertyType.BIT, "Zone 9 alarm memory", false),
|
||||||
new CaddxProperty("", 7, 1, 4, 1, CaddxPropertyType.BIT, "Zone 10 faulted (or delayed trip)", false),
|
new CaddxProperty("zone_10_faulted", 7, 1, 4, 1, CaddxPropertyType.BIT, "Zone 10 faulted (or delayed trip)",
|
||||||
new CaddxProperty("", 7, 1, 5, 1, CaddxPropertyType.BIT, "Zone 10 bypass (or inhibited)", false),
|
false),
|
||||||
|
new CaddxProperty("zone_10_bypassed", 7, 1, 5, 1, CaddxPropertyType.BIT, "Zone 10 bypass (or inhibited)",
|
||||||
|
false),
|
||||||
new CaddxProperty("zone_10_trouble", 7, 1, 6, 1, CaddxPropertyType.BIT,
|
new CaddxProperty("zone_10_trouble", 7, 1, 6, 1, CaddxPropertyType.BIT,
|
||||||
"Zone 10 trouble (tamper, low battery, or lost)", false),
|
"Zone 10 trouble (tamper, low battery, or lost)", false),
|
||||||
new CaddxProperty("", 7, 1, 7, 1, CaddxPropertyType.BIT, "Zone 10 alarm memory", false),
|
new CaddxProperty("zone_10_alarm_memory", 7, 1, 7, 1, CaddxPropertyType.BIT, "Zone 10 alarm memory", false),
|
||||||
|
|
||||||
// Byte 8 Zone 11 & 12 status flags (see byte 3)
|
// Byte 8 Zone 11 & 12 status flags (see byte 3)
|
||||||
new CaddxProperty("", 8, 1, 0, 1, CaddxPropertyType.BIT, "Zone 11 faulted (or delayed trip)", false),
|
new CaddxProperty("zone_11_faulted", 8, 1, 0, 1, CaddxPropertyType.BIT, "Zone 11 faulted (or delayed trip)",
|
||||||
new CaddxProperty("", 8, 1, 1, 1, CaddxPropertyType.BIT, "Zone 11 bypass (or inhibited)", false),
|
false),
|
||||||
|
new CaddxProperty("zone_11_bypassed", 8, 1, 1, 1, CaddxPropertyType.BIT, "Zone 11 bypass (or inhibited)",
|
||||||
|
false),
|
||||||
new CaddxProperty("zone_11_trouble", 8, 1, 2, 1, CaddxPropertyType.BIT,
|
new CaddxProperty("zone_11_trouble", 8, 1, 2, 1, CaddxPropertyType.BIT,
|
||||||
"Zone 11 trouble (tamper, low battery, or lost)", false),
|
"Zone 11 trouble (tamper, low battery, or lost)", false),
|
||||||
new CaddxProperty("", 8, 1, 3, 1, CaddxPropertyType.BIT, "Zone 11 alarm memory", false),
|
new CaddxProperty("zone_11_alarm_memory", 8, 1, 3, 1, CaddxPropertyType.BIT, "Zone 11 alarm memory", false),
|
||||||
new CaddxProperty("", 8, 1, 4, 1, CaddxPropertyType.BIT, "Zone 12 faulted (or delayed trip)", false),
|
new CaddxProperty("zone_12_faulted", 8, 1, 4, 1, CaddxPropertyType.BIT, "Zone 12 faulted (or delayed trip)",
|
||||||
new CaddxProperty("", 8, 1, 5, 1, CaddxPropertyType.BIT, "Zone 12 bypass (or inhibited)", false),
|
false),
|
||||||
|
new CaddxProperty("zone_12_bypassed", 8, 1, 5, 1, CaddxPropertyType.BIT, "Zone 12 bypass (or inhibited)",
|
||||||
|
false),
|
||||||
new CaddxProperty("zone_12_trouble", 8, 1, 6, 1, CaddxPropertyType.BIT,
|
new CaddxProperty("zone_12_trouble", 8, 1, 6, 1, CaddxPropertyType.BIT,
|
||||||
"Zone 12 trouble (tamper, low battery, or lost)", false),
|
"Zone 12 trouble (tamper, low battery, or lost)", false),
|
||||||
new CaddxProperty("", 8, 1, 7, 1, CaddxPropertyType.BIT, "Zone 12 alarm memory", false),
|
new CaddxProperty("zone_12_alarm_memory", 8, 1, 7, 1, CaddxPropertyType.BIT, "Zone 12 alarm memory", false),
|
||||||
|
|
||||||
// Byte 9 Zone 13 & 14 status flags (see byte 3)
|
// Byte 9 Zone 13 & 14 status flags (see byte 3)
|
||||||
new CaddxProperty("", 9, 1, 0, 1, CaddxPropertyType.BIT, "Zone 13 faulted (or delayed trip)", false),
|
new CaddxProperty("zone_13_faulted", 9, 1, 0, 1, CaddxPropertyType.BIT, "Zone 13 faulted (or delayed trip)",
|
||||||
new CaddxProperty("", 9, 1, 1, 1, CaddxPropertyType.BIT, "Zone 13 bypass (or inhibited)", false),
|
false),
|
||||||
|
new CaddxProperty("zone_13_bypassed", 9, 1, 1, 1, CaddxPropertyType.BIT, "Zone 13 bypass (or inhibited)",
|
||||||
|
false),
|
||||||
new CaddxProperty("zone_13_trouble", 9, 1, 2, 1, CaddxPropertyType.BIT,
|
new CaddxProperty("zone_13_trouble", 9, 1, 2, 1, CaddxPropertyType.BIT,
|
||||||
"Zone 13 trouble (tamper, low battery, or lost)", false),
|
"Zone 13 trouble (tamper, low battery, or lost)", false),
|
||||||
new CaddxProperty("", 9, 1, 3, 1, CaddxPropertyType.BIT, "Zone 13 alarm memory", false),
|
new CaddxProperty("zone_13_alarm_memory", 9, 1, 3, 1, CaddxPropertyType.BIT, "Zone 13 alarm memory", false),
|
||||||
new CaddxProperty("", 9, 1, 4, 1, CaddxPropertyType.BIT, "Zone 14 faulted (or delayed trip)", false),
|
new CaddxProperty("zone_14_faulted", 9, 1, 4, 1, CaddxPropertyType.BIT, "Zone 14 faulted (or delayed trip)",
|
||||||
new CaddxProperty("", 9, 1, 5, 1, CaddxPropertyType.BIT, "Zone 14 bypass (or inhibited)", false),
|
false),
|
||||||
|
new CaddxProperty("zone_14_bypassed", 9, 1, 5, 1, CaddxPropertyType.BIT, "Zone 14 bypass (or inhibited)",
|
||||||
|
false),
|
||||||
new CaddxProperty("zone_14_trouble", 9, 1, 6, 1, CaddxPropertyType.BIT,
|
new CaddxProperty("zone_14_trouble", 9, 1, 6, 1, CaddxPropertyType.BIT,
|
||||||
"Zone 14 trouble (tamper, low battery, or lost)", false),
|
"Zone 14 trouble (tamper, low battery, or lost)", false),
|
||||||
new CaddxProperty("", 9, 1, 7, 1, CaddxPropertyType.BIT, "Zone 14 alarm memory", false),
|
new CaddxProperty("zone_14_alarm_memory", 9, 1, 7, 1, CaddxPropertyType.BIT, "Zone 14 alarm memory", false),
|
||||||
|
|
||||||
// Byte 10 Zone 15 & 16 status flags (see byte 3)
|
// Byte 10 Zone 15 & 16 status flags (see byte 3)
|
||||||
new CaddxProperty("", 10, 1, 0, 1, CaddxPropertyType.BIT, "Zone 15 faulted (or delayed trip)", false),
|
new CaddxProperty("zone_15_faulted", 10, 1, 0, 1, CaddxPropertyType.BIT,
|
||||||
new CaddxProperty("", 10, 1, 1, 1, CaddxPropertyType.BIT, "Zone 15 bypass (or inhibited)", false),
|
"Zone 15 faulted (or delayed trip)", false),
|
||||||
|
new CaddxProperty("zone_15_bypassed", 10, 1, 1, 1, CaddxPropertyType.BIT, "Zone 15 bypass (or inhibited)",
|
||||||
|
false),
|
||||||
new CaddxProperty("zone_15_trouble", 10, 1, 2, 1, CaddxPropertyType.BIT,
|
new CaddxProperty("zone_15_trouble", 10, 1, 2, 1, CaddxPropertyType.BIT,
|
||||||
"Zone 15 trouble (tamper, low battery, or lost)", false),
|
"Zone 15 trouble (tamper, low battery, or lost)", false),
|
||||||
new CaddxProperty("", 10, 1, 3, 1, CaddxPropertyType.BIT, "Zone 15 alarm memory", false),
|
new CaddxProperty("zone_15_alarm_memory", 10, 1, 3, 1, CaddxPropertyType.BIT, "Zone 15 alarm memory",
|
||||||
new CaddxProperty("", 10, 1, 4, 1, CaddxPropertyType.BIT, "Zone 16 faulted (or delayed trip)", false),
|
false),
|
||||||
new CaddxProperty("", 10, 1, 5, 1, CaddxPropertyType.BIT, "Zone 16 bypass (or inhibited)", false),
|
new CaddxProperty("zone_16_faulted", 10, 1, 4, 1, CaddxPropertyType.BIT,
|
||||||
|
"Zone 16 faulted (or delayed trip)", false),
|
||||||
|
new CaddxProperty("zone_16_bypassed", 10, 1, 5, 1, CaddxPropertyType.BIT, "Zone 16 bypass (or inhibited)",
|
||||||
|
false),
|
||||||
new CaddxProperty("zone_16_trouble", 10, 1, 6, 1, CaddxPropertyType.BIT,
|
new CaddxProperty("zone_16_trouble", 10, 1, 6, 1, CaddxPropertyType.BIT,
|
||||||
"Zone 16 trouble (tamper, low battery, or lost)", false),
|
"Zone 16 trouble (tamper, low battery, or lost)", false),
|
||||||
new CaddxProperty("", 10, 1, 7, 1, CaddxPropertyType.BIT, "Zone 16 alarm memory", false)),
|
new CaddxProperty("zone_16_alarm_memory", 10, 1, 7, 1, CaddxPropertyType.BIT, "Zone 16 alarm memory",
|
||||||
|
false)),
|
||||||
|
|
||||||
PARTITION_STATUS_MESSAGE(0x06, null, 9, "Partition Status Message",
|
PARTITION_STATUS_MESSAGE(0x06, null, 9, "Partition Status Message",
|
||||||
"This message will contain all information relevant to a single partition in the system.",
|
"This message will contain all information relevant to a single partition in the system.",
|
||||||
@ -508,7 +542,7 @@ public enum CaddxMessageType {
|
|||||||
new CaddxProperty("", 4, 1, 4, 1, CaddxPropertyType.BIT, "Box tamper", false),
|
new CaddxProperty("", 4, 1, 4, 1, CaddxPropertyType.BIT, "Box tamper", false),
|
||||||
new CaddxProperty("", 4, 1, 5, 1, CaddxPropertyType.BIT, "Siren tamper / trouble", false),
|
new CaddxProperty("", 4, 1, 5, 1, CaddxPropertyType.BIT, "Siren tamper / trouble", false),
|
||||||
new CaddxProperty("", 4, 1, 6, 1, CaddxPropertyType.BIT, "Low Battery", false),
|
new CaddxProperty("", 4, 1, 6, 1, CaddxPropertyType.BIT, "Low Battery", false),
|
||||||
new CaddxProperty("", 4, 1, 7, 1, CaddxPropertyType.BIT, "AC fail", false),
|
new CaddxProperty("panel_ac_fail", 4, 1, 7, 1, CaddxPropertyType.BIT, "AC fail", false),
|
||||||
|
|
||||||
// Byte 5
|
// Byte 5
|
||||||
new CaddxProperty("", 5, 1, 0, 1, CaddxPropertyType.BIT, "Expander box tamper", false),
|
new CaddxProperty("", 5, 1, 0, 1, CaddxPropertyType.BIT, "Expander box tamper", false),
|
||||||
@ -531,8 +565,9 @@ public enum CaddxMessageType {
|
|||||||
|
|
||||||
// Byte 7
|
// Byte 7
|
||||||
new CaddxProperty("", 7, 1, 0, 1, CaddxPropertyType.BIT, "Dynamic battery test", false),
|
new CaddxProperty("", 7, 1, 0, 1, CaddxPropertyType.BIT, "Dynamic battery test", false),
|
||||||
new CaddxProperty("", 7, 1, 1, 1, CaddxPropertyType.BIT, "AC power on", false),
|
new CaddxProperty("panel_ac_power_on", 7, 1, 1, 1, CaddxPropertyType.BIT, "AC power on", false),
|
||||||
new CaddxProperty("", 7, 1, 2, 1, CaddxPropertyType.BIT, "Low battery memory", false),
|
new CaddxProperty("panel_low_battery_memory", 7, 1, 2, 1, CaddxPropertyType.BIT, "Low battery memory",
|
||||||
|
false),
|
||||||
new CaddxProperty("", 7, 1, 3, 1, CaddxPropertyType.BIT, "Ground fault memory", false),
|
new CaddxProperty("", 7, 1, 3, 1, CaddxPropertyType.BIT, "Ground fault memory", false),
|
||||||
new CaddxProperty("", 7, 1, 4, 1, CaddxPropertyType.BIT, "Fire alarm verification being timed", false),
|
new CaddxProperty("", 7, 1, 4, 1, CaddxPropertyType.BIT, "Fire alarm verification being timed", false),
|
||||||
new CaddxProperty("", 7, 1, 5, 1, CaddxPropertyType.BIT, "Smoke power reset", false),
|
new CaddxProperty("", 7, 1, 5, 1, CaddxPropertyType.BIT, "Smoke power reset", false),
|
||||||
|
|||||||
@ -21,5 +21,5 @@ import org.eclipse.jdt.annotation.NonNullByDefault;
|
|||||||
*/
|
*/
|
||||||
@NonNullByDefault
|
@NonNullByDefault
|
||||||
public interface CaddxPanelListener {
|
public interface CaddxPanelListener {
|
||||||
public void caddxMessage(CaddxCommunicator communicator, CaddxMessage message);
|
public void caddxMessage(CaddxMessage message);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -30,11 +30,13 @@ public class CaddxBridgeConfiguration {
|
|||||||
public static final String SERIAL_PORT = "serialPort";
|
public static final String SERIAL_PORT = "serialPort";
|
||||||
public static final String BAUD = "baud";
|
public static final String BAUD = "baud";
|
||||||
public static final String MAX_ZONE_NUMBER = "maxZoneNumber";
|
public static final String MAX_ZONE_NUMBER = "maxZoneNumber";
|
||||||
|
public static final String IGNORE_ZONE_STATUS_TRANSITIONS = "ignoreZoneStatusTransitions";
|
||||||
|
|
||||||
private CaddxProtocol protocol = CaddxProtocol.Binary;
|
private CaddxProtocol protocol = CaddxProtocol.Binary;
|
||||||
private @Nullable String serialPort;
|
private @Nullable String serialPort;
|
||||||
private int baudrate = 9600;
|
private int baudrate = 9600;
|
||||||
private int maxZoneNumber = 16;
|
private int maxZoneNumber = 16;
|
||||||
|
private boolean ignoreZoneStatusTransitions = false;
|
||||||
|
|
||||||
public CaddxProtocol getProtocol() {
|
public CaddxProtocol getProtocol() {
|
||||||
return protocol;
|
return protocol;
|
||||||
@ -51,4 +53,8 @@ public class CaddxBridgeConfiguration {
|
|||||||
public int getMaxZoneNumber() {
|
public int getMaxZoneNumber() {
|
||||||
return maxZoneNumber;
|
return maxZoneNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isIgnoreZoneStatusTransitions() {
|
||||||
|
return ignoreZoneStatusTransitions;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -30,16 +30,7 @@ public class CaddxPartitionConfiguration {
|
|||||||
*/
|
*/
|
||||||
private int partitionNumber;
|
private int partitionNumber;
|
||||||
|
|
||||||
/**
|
|
||||||
* The User Number of the user that will execute commands against the partition.
|
|
||||||
*/
|
|
||||||
private int userNumber;
|
|
||||||
|
|
||||||
public int getPartitionNumber() {
|
public int getPartitionNumber() {
|
||||||
return partitionNumber;
|
return partitionNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getUserNumber() {
|
|
||||||
return userNumber;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -49,7 +49,6 @@ public abstract class CaddxBaseThingHandler extends BaseThingHandler {
|
|||||||
|
|
||||||
/** Partition */
|
/** Partition */
|
||||||
private int partitionNumber;
|
private int partitionNumber;
|
||||||
private int userNumber;
|
|
||||||
|
|
||||||
/** Zone */
|
/** Zone */
|
||||||
private int zoneNumber;
|
private int zoneNumber;
|
||||||
@ -130,7 +129,6 @@ public abstract class CaddxBaseThingHandler extends BaseThingHandler {
|
|||||||
case PARTITION:
|
case PARTITION:
|
||||||
CaddxPartitionConfiguration partitionConfiguration = getConfigAs(CaddxPartitionConfiguration.class);
|
CaddxPartitionConfiguration partitionConfiguration = getConfigAs(CaddxPartitionConfiguration.class);
|
||||||
setPartitionNumber(partitionConfiguration.getPartitionNumber());
|
setPartitionNumber(partitionConfiguration.getPartitionNumber());
|
||||||
setUserNumber(partitionConfiguration.getUserNumber());
|
|
||||||
break;
|
break;
|
||||||
case ZONE:
|
case ZONE:
|
||||||
CaddxZoneConfiguration zoneConfiguration = getConfigAs(CaddxZoneConfiguration.class);
|
CaddxZoneConfiguration zoneConfiguration = getConfigAs(CaddxZoneConfiguration.class);
|
||||||
@ -139,6 +137,7 @@ public abstract class CaddxBaseThingHandler extends BaseThingHandler {
|
|||||||
case KEYPAD:
|
case KEYPAD:
|
||||||
CaddxKeypadConfiguration keypadConfiguration = getConfigAs(CaddxKeypadConfiguration.class);
|
CaddxKeypadConfiguration keypadConfiguration = getConfigAs(CaddxKeypadConfiguration.class);
|
||||||
setKeypadAddress(keypadConfiguration.getKeypadAddress());
|
setKeypadAddress(keypadConfiguration.getKeypadAddress());
|
||||||
|
setTerminalModeSeconds(keypadConfiguration.getTerminalModeSeconds());
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -171,24 +170,6 @@ public abstract class CaddxBaseThingHandler extends BaseThingHandler {
|
|||||||
this.partitionNumber = partitionNumber;
|
this.partitionNumber = partitionNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get User Number.
|
|
||||||
*
|
|
||||||
* @return userNumber
|
|
||||||
*/
|
|
||||||
public int getUserNumber() {
|
|
||||||
return userNumber;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set User Number.
|
|
||||||
*
|
|
||||||
* @param userNumber
|
|
||||||
*/
|
|
||||||
public void setUserNumber(int userNumber) {
|
|
||||||
this.userNumber = userNumber;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Zone Number.
|
* Get Zone Number.
|
||||||
*
|
*
|
||||||
@ -228,16 +209,16 @@ public abstract class CaddxBaseThingHandler extends BaseThingHandler {
|
|||||||
/**
|
/**
|
||||||
* Get Keypad Terminal Mode Seconds.
|
* Get Keypad Terminal Mode Seconds.
|
||||||
*
|
*
|
||||||
* @return keypadAddress
|
* @return terminalModeSeconds
|
||||||
*/
|
*/
|
||||||
public int getTerminalModeSeconds() {
|
public int getTerminalModeSeconds() {
|
||||||
return terminalModeSeconds;
|
return terminalModeSeconds;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set Keypad Address.
|
* Set Keypad Terminal Mode Seconds.
|
||||||
*
|
*
|
||||||
* @param keypadAddress
|
* @param terminalModeSeconds
|
||||||
*/
|
*/
|
||||||
public void setTerminalModeSeconds(int terminalModeSeconds) {
|
public void setTerminalModeSeconds(int terminalModeSeconds) {
|
||||||
this.terminalModeSeconds = terminalModeSeconds;
|
this.terminalModeSeconds = terminalModeSeconds;
|
||||||
|
|||||||
@ -29,6 +29,7 @@ import org.openhab.binding.caddx.internal.CaddxBindingConstants;
|
|||||||
import org.openhab.binding.caddx.internal.CaddxCommunicator;
|
import org.openhab.binding.caddx.internal.CaddxCommunicator;
|
||||||
import org.openhab.binding.caddx.internal.CaddxEvent;
|
import org.openhab.binding.caddx.internal.CaddxEvent;
|
||||||
import org.openhab.binding.caddx.internal.CaddxMessage;
|
import org.openhab.binding.caddx.internal.CaddxMessage;
|
||||||
|
import org.openhab.binding.caddx.internal.CaddxMessageContext;
|
||||||
import org.openhab.binding.caddx.internal.CaddxMessageType;
|
import org.openhab.binding.caddx.internal.CaddxMessageType;
|
||||||
import org.openhab.binding.caddx.internal.CaddxPanelListener;
|
import org.openhab.binding.caddx.internal.CaddxPanelListener;
|
||||||
import org.openhab.binding.caddx.internal.CaddxProtocol;
|
import org.openhab.binding.caddx.internal.CaddxProtocol;
|
||||||
@ -85,6 +86,7 @@ public class CaddxBridgeHandler extends BaseBridgeHandler implements CaddxPanelL
|
|||||||
private String serialPortName = "";
|
private String serialPortName = "";
|
||||||
private int baudRate;
|
private int baudRate;
|
||||||
private int maxZoneNumber;
|
private int maxZoneNumber;
|
||||||
|
private boolean isIgnoreZoneStatusTransitions;
|
||||||
private @Nullable CaddxCommunicator communicator = null;
|
private @Nullable CaddxCommunicator communicator = null;
|
||||||
|
|
||||||
// Things served by the bridge
|
// Things served by the bridge
|
||||||
@ -120,6 +122,7 @@ public class CaddxBridgeHandler extends BaseBridgeHandler implements CaddxPanelL
|
|||||||
protocol = configuration.getProtocol();
|
protocol = configuration.getProtocol();
|
||||||
baudRate = configuration.getBaudrate();
|
baudRate = configuration.getBaudrate();
|
||||||
maxZoneNumber = configuration.getMaxZoneNumber();
|
maxZoneNumber = configuration.getMaxZoneNumber();
|
||||||
|
isIgnoreZoneStatusTransitions = configuration.isIgnoreZoneStatusTransitions();
|
||||||
updateStatus(ThingStatus.OFFLINE);
|
updateStatus(ThingStatus.OFFLINE);
|
||||||
|
|
||||||
// create & start panel interface
|
// create & start panel interface
|
||||||
@ -141,27 +144,28 @@ public class CaddxBridgeHandler extends BaseBridgeHandler implements CaddxPanelL
|
|||||||
comm.addListener(this);
|
comm.addListener(this);
|
||||||
|
|
||||||
// Send discovery commands for the zones
|
// Send discovery commands for the zones
|
||||||
comm.transmit(new CaddxMessage(DISCOVERY_ZONES_SNAPSHOT_REQUEST_00, false));
|
comm.transmit(new CaddxMessage(CaddxMessageContext.DISCOVERY, DISCOVERY_ZONES_SNAPSHOT_REQUEST_00, false));
|
||||||
comm.transmit(new CaddxMessage(DISCOVERY_ZONES_SNAPSHOT_REQUEST_10, false));
|
comm.transmit(new CaddxMessage(CaddxMessageContext.DISCOVERY, DISCOVERY_ZONES_SNAPSHOT_REQUEST_10, false));
|
||||||
comm.transmit(new CaddxMessage(DISCOVERY_ZONES_SNAPSHOT_REQUEST_20, false));
|
comm.transmit(new CaddxMessage(CaddxMessageContext.DISCOVERY, DISCOVERY_ZONES_SNAPSHOT_REQUEST_20, false));
|
||||||
comm.transmit(new CaddxMessage(DISCOVERY_ZONES_SNAPSHOT_REQUEST_30, false));
|
comm.transmit(new CaddxMessage(CaddxMessageContext.DISCOVERY, DISCOVERY_ZONES_SNAPSHOT_REQUEST_30, false));
|
||||||
comm.transmit(new CaddxMessage(DISCOVERY_ZONES_SNAPSHOT_REQUEST_40, false));
|
comm.transmit(new CaddxMessage(CaddxMessageContext.DISCOVERY, DISCOVERY_ZONES_SNAPSHOT_REQUEST_40, false));
|
||||||
comm.transmit(new CaddxMessage(DISCOVERY_ZONES_SNAPSHOT_REQUEST_50, false));
|
comm.transmit(new CaddxMessage(CaddxMessageContext.DISCOVERY, DISCOVERY_ZONES_SNAPSHOT_REQUEST_50, false));
|
||||||
comm.transmit(new CaddxMessage(DISCOVERY_ZONES_SNAPSHOT_REQUEST_60, false));
|
comm.transmit(new CaddxMessage(CaddxMessageContext.DISCOVERY, DISCOVERY_ZONES_SNAPSHOT_REQUEST_60, false));
|
||||||
comm.transmit(new CaddxMessage(DISCOVERY_ZONES_SNAPSHOT_REQUEST_70, false));
|
comm.transmit(new CaddxMessage(CaddxMessageContext.DISCOVERY, DISCOVERY_ZONES_SNAPSHOT_REQUEST_70, false));
|
||||||
comm.transmit(new CaddxMessage(DISCOVERY_ZONES_SNAPSHOT_REQUEST_80, false));
|
comm.transmit(new CaddxMessage(CaddxMessageContext.DISCOVERY, DISCOVERY_ZONES_SNAPSHOT_REQUEST_80, false));
|
||||||
comm.transmit(new CaddxMessage(DISCOVERY_ZONES_SNAPSHOT_REQUEST_90, false));
|
comm.transmit(new CaddxMessage(CaddxMessageContext.DISCOVERY, DISCOVERY_ZONES_SNAPSHOT_REQUEST_90, false));
|
||||||
comm.transmit(new CaddxMessage(DISCOVERY_ZONES_SNAPSHOT_REQUEST_A0, false));
|
comm.transmit(new CaddxMessage(CaddxMessageContext.DISCOVERY, DISCOVERY_ZONES_SNAPSHOT_REQUEST_A0, false));
|
||||||
comm.transmit(new CaddxMessage(DISCOVERY_ZONES_SNAPSHOT_REQUEST_B0, false));
|
comm.transmit(new CaddxMessage(CaddxMessageContext.DISCOVERY, DISCOVERY_ZONES_SNAPSHOT_REQUEST_B0, false));
|
||||||
|
|
||||||
// Send discovery commands for the partitions
|
// Send discovery commands for the partitions
|
||||||
comm.transmit(new CaddxMessage(DISCOVERY_PARTITIONS_SNAPSHOT_REQUEST, false));
|
comm.transmit(
|
||||||
|
new CaddxMessage(CaddxMessageContext.DISCOVERY, DISCOVERY_PARTITIONS_SNAPSHOT_REQUEST, false));
|
||||||
|
|
||||||
// Send status commands to the zones and partitions
|
// Send status commands to the zones and partitions
|
||||||
thingZonesMap.forEach((k, v) -> sendCommand(CaddxBindingConstants.ZONE_STATUS_REQUEST,
|
thingZonesMap.forEach((k, v) -> sendCommand(CaddxMessageContext.COMMAND,
|
||||||
k.subtract(BigDecimal.ONE).toString()));
|
CaddxBindingConstants.ZONE_STATUS_REQUEST, k.subtract(BigDecimal.ONE).toString()));
|
||||||
thingPartitionsMap.forEach((k, v) -> sendCommand(CaddxBindingConstants.PARTITION_STATUS_REQUEST,
|
thingPartitionsMap.forEach((k, v) -> sendCommand(CaddxMessageContext.COMMAND,
|
||||||
k.subtract(BigDecimal.ONE).toString()));
|
CaddxBindingConstants.PARTITION_STATUS_REQUEST, k.subtract(BigDecimal.ONE).toString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// list all channels
|
// list all channels
|
||||||
@ -224,7 +228,7 @@ public class CaddxBridgeHandler extends BaseBridgeHandler implements CaddxPanelL
|
|||||||
data = tokens[1];
|
data = tokens[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
sendCommand(cmd, data);
|
sendCommand(CaddxMessageContext.COMMAND, cmd, data);
|
||||||
|
|
||||||
updateState(channelUID, new StringType(""));
|
updateState(channelUID, new StringType(""));
|
||||||
}
|
}
|
||||||
@ -241,44 +245,44 @@ public class CaddxBridgeHandler extends BaseBridgeHandler implements CaddxPanelL
|
|||||||
* @param command The command to be send
|
* @param command The command to be send
|
||||||
* @param data The associated command data
|
* @param data The associated command data
|
||||||
*/
|
*/
|
||||||
public boolean sendCommand(String command, String data) {
|
public boolean sendCommand(CaddxMessageContext context, String command, String data) {
|
||||||
logger.trace("sendCommand(): Attempting to send Command: command - {} - data: {}", command, data);
|
logger.trace("sendCommand(): Attempting to send Command: command - {} - data: {}", command, data);
|
||||||
|
|
||||||
CaddxMessage msg = null;
|
CaddxMessage msg = null;
|
||||||
|
|
||||||
switch (command) {
|
switch (command) {
|
||||||
case CaddxBindingConstants.ZONE_BYPASSED:
|
case CaddxBindingConstants.ZONE_BYPASSED:
|
||||||
msg = new CaddxMessage(CaddxMessageType.ZONE_BYPASS_TOGGLE, data);
|
msg = new CaddxMessage(context, CaddxMessageType.ZONE_BYPASS_TOGGLE, data);
|
||||||
break;
|
break;
|
||||||
case CaddxBindingConstants.ZONE_STATUS_REQUEST:
|
case CaddxBindingConstants.ZONE_STATUS_REQUEST:
|
||||||
msg = new CaddxMessage(CaddxMessageType.ZONE_STATUS_REQUEST, data);
|
msg = new CaddxMessage(context, CaddxMessageType.ZONE_STATUS_REQUEST, data);
|
||||||
break;
|
break;
|
||||||
case CaddxBindingConstants.ZONE_NAME_REQUEST:
|
case CaddxBindingConstants.ZONE_NAME_REQUEST:
|
||||||
msg = new CaddxMessage(CaddxMessageType.ZONE_NAME_REQUEST, data);
|
msg = new CaddxMessage(context, CaddxMessageType.ZONE_NAME_REQUEST, data);
|
||||||
break;
|
break;
|
||||||
case CaddxBindingConstants.PARTITION_STATUS_REQUEST:
|
case CaddxBindingConstants.PARTITION_STATUS_REQUEST:
|
||||||
msg = new CaddxMessage(CaddxMessageType.PARTITION_STATUS_REQUEST, data);
|
msg = new CaddxMessage(context, CaddxMessageType.PARTITION_STATUS_REQUEST, data);
|
||||||
break;
|
break;
|
||||||
case CaddxBindingConstants.PARTITION_PRIMARY_COMMAND_WITH_PIN:
|
case CaddxBindingConstants.PARTITION_PRIMARY_COMMAND_WITH_PIN:
|
||||||
msg = new CaddxMessage(CaddxMessageType.PRIMARY_KEYPAD_FUNCTION_WITH_PIN, data);
|
msg = new CaddxMessage(context, CaddxMessageType.PRIMARY_KEYPAD_FUNCTION_WITH_PIN, data);
|
||||||
break;
|
break;
|
||||||
case CaddxBindingConstants.PARTITION_SECONDARY_COMMAND:
|
case CaddxBindingConstants.PARTITION_SECONDARY_COMMAND:
|
||||||
msg = new CaddxMessage(CaddxMessageType.SECONDARY_KEYPAD_FUNCTION, data);
|
msg = new CaddxMessage(context, CaddxMessageType.SECONDARY_KEYPAD_FUNCTION, data);
|
||||||
break;
|
break;
|
||||||
case CaddxBindingConstants.PANEL_SYSTEM_STATUS_REQUEST:
|
case CaddxBindingConstants.PANEL_SYSTEM_STATUS_REQUEST:
|
||||||
msg = new CaddxMessage(CaddxMessageType.SYSTEM_STATUS_REQUEST, data);
|
msg = new CaddxMessage(context, CaddxMessageType.SYSTEM_STATUS_REQUEST, data);
|
||||||
break;
|
break;
|
||||||
case CaddxBindingConstants.PANEL_INTERFACE_CONFIGURATION_REQUEST:
|
case CaddxBindingConstants.PANEL_INTERFACE_CONFIGURATION_REQUEST:
|
||||||
msg = new CaddxMessage(CaddxMessageType.INTERFACE_CONFIGURATION_REQUEST, data);
|
msg = new CaddxMessage(context, CaddxMessageType.INTERFACE_CONFIGURATION_REQUEST, data);
|
||||||
break;
|
break;
|
||||||
case CaddxBindingConstants.PANEL_LOG_EVENT_REQUEST:
|
case CaddxBindingConstants.PANEL_LOG_EVENT_REQUEST:
|
||||||
msg = new CaddxMessage(CaddxMessageType.LOG_EVENT_REQUEST, data);
|
msg = new CaddxMessage(context, CaddxMessageType.LOG_EVENT_REQUEST, data);
|
||||||
break;
|
break;
|
||||||
case CaddxBindingConstants.KEYPAD_TERMINAL_MODE_REQUEST:
|
case CaddxBindingConstants.KEYPAD_TERMINAL_MODE_REQUEST:
|
||||||
msg = new CaddxMessage(CaddxMessageType.KEYPAD_TERMINAL_MODE_REQUEST, data);
|
msg = new CaddxMessage(context, CaddxMessageType.KEYPAD_TERMINAL_MODE_REQUEST, data);
|
||||||
break;
|
break;
|
||||||
case CaddxBindingConstants.KEYPAD_SEND_KEYPAD_TEXT_MESSAGE:
|
case CaddxBindingConstants.KEYPAD_SEND_KEYPAD_TEXT_MESSAGE:
|
||||||
msg = new CaddxMessage(CaddxMessageType.SEND_KEYPAD_TEXT_MESSAGE, data);
|
msg = new CaddxMessage(context, CaddxMessageType.SEND_KEYPAD_TEXT_MESSAGE, data);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
logger.debug("Unknown command {}", command);
|
logger.debug("Unknown command {}", command);
|
||||||
@ -312,16 +316,13 @@ public class CaddxBridgeHandler extends BaseBridgeHandler implements CaddxPanelL
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void caddxMessage(CaddxCommunicator communicator, CaddxMessage caddxMessage) {
|
public void caddxMessage(CaddxMessage caddxMessage) {
|
||||||
CaddxSource source = caddxMessage.getSource();
|
CaddxSource source = caddxMessage.getSource();
|
||||||
|
|
||||||
if (source != CaddxSource.NONE) {
|
if (source != CaddxSource.NONE) {
|
||||||
CaddxThingType caddxThingType = null;
|
CaddxThingType caddxThingType = null;
|
||||||
@Nullable
|
|
||||||
Integer partition = null;
|
Integer partition = null;
|
||||||
@Nullable
|
|
||||||
Integer zone = null;
|
Integer zone = null;
|
||||||
@Nullable
|
|
||||||
Integer keypad = null;
|
Integer keypad = null;
|
||||||
|
|
||||||
switch (source) {
|
switch (source) {
|
||||||
@ -347,6 +348,14 @@ public class CaddxBridgeHandler extends BaseBridgeHandler implements CaddxPanelL
|
|||||||
|
|
||||||
CaddxEvent event = new CaddxEvent(caddxMessage, partition, zone, keypad);
|
CaddxEvent event = new CaddxEvent(caddxMessage, partition, zone, keypad);
|
||||||
|
|
||||||
|
// Ignore Zone Status messages according to the configuration
|
||||||
|
if (isIgnoreZoneStatusTransitions
|
||||||
|
&& caddxMessage.getCaddxMessageType() == CaddxMessageType.ZONE_STATUS_MESSAGE
|
||||||
|
&& caddxMessage.getContext() == CaddxMessageContext.NONE) {
|
||||||
|
logger.debug("Zone {} Transition ignored.", zone);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Find the thing
|
// Find the thing
|
||||||
Thing thing = findThing(caddxThingType, partition, zone, keypad);
|
Thing thing = findThing(caddxThingType, partition, zone, keypad);
|
||||||
CaddxDiscoveryService discoveryService = getDiscoveryService();
|
CaddxDiscoveryService discoveryService = getDiscoveryService();
|
||||||
|
|||||||
@ -19,6 +19,7 @@ import org.eclipse.jdt.annotation.NonNullByDefault;
|
|||||||
import org.openhab.binding.caddx.internal.CaddxBindingConstants;
|
import org.openhab.binding.caddx.internal.CaddxBindingConstants;
|
||||||
import org.openhab.binding.caddx.internal.CaddxEvent;
|
import org.openhab.binding.caddx.internal.CaddxEvent;
|
||||||
import org.openhab.binding.caddx.internal.CaddxMessage;
|
import org.openhab.binding.caddx.internal.CaddxMessage;
|
||||||
|
import org.openhab.binding.caddx.internal.CaddxMessageContext;
|
||||||
import org.openhab.binding.caddx.internal.CaddxMessageType;
|
import org.openhab.binding.caddx.internal.CaddxMessageType;
|
||||||
import org.openhab.binding.caddx.internal.CaddxProperty;
|
import org.openhab.binding.caddx.internal.CaddxProperty;
|
||||||
import org.openhab.binding.caddx.internal.action.CaddxKeypadActions;
|
import org.openhab.binding.caddx.internal.action.CaddxKeypadActions;
|
||||||
@ -44,6 +45,19 @@ public class ThingHandlerKeypad extends CaddxBaseThingHandler {
|
|||||||
super(thing, CaddxThingType.KEYPAD);
|
super(thing, CaddxThingType.KEYPAD);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initialize() {
|
||||||
|
super.initialize();
|
||||||
|
|
||||||
|
CaddxBridgeHandler bridgeHandler = getCaddxBridgeHandler();
|
||||||
|
if (bridgeHandler == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Follow the bridge status
|
||||||
|
updateStatus(bridgeHandler.getThing().getStatus());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateChannel(ChannelUID channelUID, String data) {
|
public void updateChannel(ChannelUID channelUID, String data) {
|
||||||
if (channelUID.getId().equals(CaddxBindingConstants.KEYPAD_KEY_PRESSED)) {
|
if (channelUID.getId().equals(CaddxBindingConstants.KEYPAD_KEY_PRESSED)) {
|
||||||
@ -97,7 +111,7 @@ public class ThingHandlerKeypad extends CaddxBaseThingHandler {
|
|||||||
if (bridgeHandler == null) {
|
if (bridgeHandler == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
bridgeHandler.sendCommand(cmd, data);
|
bridgeHandler.sendCommand(CaddxMessageContext.COMMAND, cmd, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendKeypadTextMessage(String displayLocation, String text) {
|
public void sendKeypadTextMessage(String displayLocation, String text) {
|
||||||
@ -114,6 +128,6 @@ public class ThingHandlerKeypad extends CaddxBaseThingHandler {
|
|||||||
if (bridgeHandler == null) {
|
if (bridgeHandler == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
bridgeHandler.sendCommand(cmd, data);
|
bridgeHandler.sendCommand(CaddxMessageContext.COMMAND, cmd, data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,6 +21,7 @@ import org.eclipse.jdt.annotation.Nullable;
|
|||||||
import org.openhab.binding.caddx.internal.CaddxBindingConstants;
|
import org.openhab.binding.caddx.internal.CaddxBindingConstants;
|
||||||
import org.openhab.binding.caddx.internal.CaddxEvent;
|
import org.openhab.binding.caddx.internal.CaddxEvent;
|
||||||
import org.openhab.binding.caddx.internal.CaddxMessage;
|
import org.openhab.binding.caddx.internal.CaddxMessage;
|
||||||
|
import org.openhab.binding.caddx.internal.CaddxMessageContext;
|
||||||
import org.openhab.binding.caddx.internal.CaddxMessageType;
|
import org.openhab.binding.caddx.internal.CaddxMessageType;
|
||||||
import org.openhab.binding.caddx.internal.CaddxProperty;
|
import org.openhab.binding.caddx.internal.CaddxProperty;
|
||||||
import org.openhab.binding.caddx.internal.action.CaddxPanelActions;
|
import org.openhab.binding.caddx.internal.action.CaddxPanelActions;
|
||||||
@ -51,6 +52,20 @@ public class ThingHandlerPanel extends CaddxBaseThingHandler {
|
|||||||
super(thing, CaddxThingType.PANEL);
|
super(thing, CaddxThingType.PANEL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initialize() {
|
||||||
|
super.initialize();
|
||||||
|
|
||||||
|
CaddxBridgeHandler bridgeHandler = getCaddxBridgeHandler();
|
||||||
|
if (bridgeHandler == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String cmd = CaddxBindingConstants.PANEL_SYSTEM_STATUS_REQUEST;
|
||||||
|
String data = "";
|
||||||
|
bridgeHandler.sendCommand(CaddxMessageContext.COMMAND, cmd, data);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateChannel(ChannelUID channelUID, String data) {
|
public void updateChannel(ChannelUID channelUID, String data) {
|
||||||
if (channelUID.getId().equals(CaddxBindingConstants.PANEL_FIRMWARE_VERSION)
|
if (channelUID.getId().equals(CaddxBindingConstants.PANEL_FIRMWARE_VERSION)
|
||||||
@ -82,13 +97,13 @@ public class ThingHandlerPanel extends CaddxBaseThingHandler {
|
|||||||
data = "";
|
data = "";
|
||||||
} else if (System.currentTimeMillis() - lastRefreshTime > 2000) {
|
} else if (System.currentTimeMillis() - lastRefreshTime > 2000) {
|
||||||
// Refresh only if 2 seconds have passed from the last refresh
|
// Refresh only if 2 seconds have passed from the last refresh
|
||||||
cmd = CaddxBindingConstants.PANEL_INTERFACE_CONFIGURATION_REQUEST;
|
cmd = CaddxBindingConstants.PANEL_SYSTEM_STATUS_REQUEST;
|
||||||
data = "";
|
data = "";
|
||||||
} else {
|
} else {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
bridgeHandler.sendCommand(cmd, data);
|
bridgeHandler.sendCommand(CaddxMessageContext.COMMAND, cmd, data);
|
||||||
lastRefreshTime = System.currentTimeMillis();
|
lastRefreshTime = System.currentTimeMillis();
|
||||||
} else {
|
} else {
|
||||||
logger.debug("Unknown command {}", command);
|
logger.debug("Unknown command {}", command);
|
||||||
@ -104,19 +119,22 @@ public class ThingHandlerPanel extends CaddxBaseThingHandler {
|
|||||||
CaddxMessageType mt = message.getCaddxMessageType();
|
CaddxMessageType mt = message.getCaddxMessageType();
|
||||||
ChannelUID channelUID = null;
|
ChannelUID channelUID = null;
|
||||||
|
|
||||||
// Log event messages have special handling
|
|
||||||
if (CaddxMessageType.SYSTEM_STATUS_MESSAGE.equals(mt)) {
|
|
||||||
handleSystemStatusMessage(message);
|
|
||||||
} else if (CaddxMessageType.LOG_EVENT_MESSAGE.equals(mt)) {
|
|
||||||
handleLogEventMessage(message);
|
|
||||||
} else {
|
|
||||||
for (CaddxProperty p : mt.properties) {
|
for (CaddxProperty p : mt.properties) {
|
||||||
if (!p.getId().isEmpty()) {
|
if (!p.getId().isEmpty()) {
|
||||||
String value = message.getPropertyById(p.getId());
|
String value = message.getPropertyById(p.getId());
|
||||||
channelUID = new ChannelUID(getThing().getUID(), p.getId());
|
channelUID = new ChannelUID(getThing().getUID(), p.getId());
|
||||||
updateChannel(channelUID, value);
|
updateChannel(channelUID, value);
|
||||||
|
logger.trace("Updating panel channel: {}", channelUID.getAsString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Log event messages have special handling
|
||||||
|
if (CaddxMessageType.SYSTEM_STATUS_MESSAGE.equals(mt)) {
|
||||||
|
handleSystemStatusMessage(message);
|
||||||
|
} else if (CaddxMessageType.LOG_EVENT_MESSAGE.equals(mt)) {
|
||||||
|
handleLogEventMessage(message);
|
||||||
|
} else if (CaddxMessageType.ZONES_SNAPSHOT_MESSAGE.equals(mt)) {
|
||||||
|
handleZonesSnapshotMessage(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateStatus(ThingStatus.ONLINE);
|
updateStatus(ThingStatus.ONLINE);
|
||||||
@ -140,7 +158,7 @@ public class ThingHandlerPanel extends CaddxBaseThingHandler {
|
|||||||
// build map of log message channels to event numbers
|
// build map of log message channels to event numbers
|
||||||
HashMap<String, String> map = new HashMap<String, String>();
|
HashMap<String, String> map = new HashMap<String, String>();
|
||||||
map.put(pointer, CaddxBindingConstants.PANEL_LOG_MESSAGE_N_0);
|
map.put(pointer, CaddxBindingConstants.PANEL_LOG_MESSAGE_N_0);
|
||||||
bridgeHandler.sendCommand(CaddxBindingConstants.PANEL_LOG_EVENT_REQUEST, pointer);
|
bridgeHandler.sendCommand(CaddxMessageContext.COMMAND, CaddxBindingConstants.PANEL_LOG_EVENT_REQUEST, pointer);
|
||||||
panelLogMessagesMap = map;
|
panelLogMessagesMap = map;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -190,7 +208,8 @@ public class ThingHandlerPanel extends CaddxBaseThingHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
map.put(Integer.toString(eventNumber), "panel_log_message_n_" + i);
|
map.put(Integer.toString(eventNumber), "panel_log_message_n_" + i);
|
||||||
bridgeHandler.sendCommand(CaddxBindingConstants.PANEL_LOG_EVENT_REQUEST, Integer.toString(eventNumber));
|
bridgeHandler.sendCommand(CaddxMessageContext.COMMAND, CaddxBindingConstants.PANEL_LOG_EVENT_REQUEST,
|
||||||
|
Integer.toString(eventNumber));
|
||||||
}
|
}
|
||||||
|
|
||||||
communicatorStackPointer = null;
|
communicatorStackPointer = null;
|
||||||
@ -198,6 +217,45 @@ public class ThingHandlerPanel extends CaddxBaseThingHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void handleZonesSnapshotMessage(CaddxMessage message) {
|
||||||
|
// Get the bridge handler
|
||||||
|
CaddxBridgeHandler bridgeHandler = getCaddxBridgeHandler();
|
||||||
|
if (bridgeHandler == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int zoneOffset = Integer.parseInt(message.getPropertyById("zone_offset"));
|
||||||
|
|
||||||
|
for (int i = 1; i <= 16; i++) {
|
||||||
|
int zoneNumber = zoneOffset * 16 + i;
|
||||||
|
|
||||||
|
String zoneFaulted = message.getPropertyById("zone_" + i + "_faulted");
|
||||||
|
String zoneBypassed = message.getPropertyById("zone_" + i + "_bypassed");
|
||||||
|
String zoneTrouble = message.getPropertyById("zone_" + i + "_trouble");
|
||||||
|
String zoneAlarmMemory = message.getPropertyById("zone_" + i + "_alarm_memory");
|
||||||
|
|
||||||
|
logger.debug("Flags for zone {}. faulted:{}, bypassed:{}, trouble:{}, alarm_memory:{}", zoneNumber,
|
||||||
|
zoneFaulted, zoneBypassed, zoneTrouble, zoneAlarmMemory);
|
||||||
|
|
||||||
|
// Get thing
|
||||||
|
Thing thing = bridgeHandler.findThing(CaddxThingType.ZONE, null, zoneNumber, null);
|
||||||
|
if (thing != null) {
|
||||||
|
ChannelUID channelUID;
|
||||||
|
|
||||||
|
logger.debug("Thing found for zone {}.", zoneNumber);
|
||||||
|
|
||||||
|
channelUID = new ChannelUID(thing.getUID(), "zone_faulted");
|
||||||
|
updateChannel(channelUID, zoneFaulted);
|
||||||
|
channelUID = new ChannelUID(thing.getUID(), "zone_bypassed");
|
||||||
|
updateChannel(channelUID, zoneBypassed);
|
||||||
|
channelUID = new ChannelUID(thing.getUID(), "zone_trouble");
|
||||||
|
updateChannel(channelUID, zoneTrouble);
|
||||||
|
channelUID = new ChannelUID(thing.getUID(), "zone_alarm_memory");
|
||||||
|
updateChannel(channelUID, zoneAlarmMemory);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<Class<? extends ThingHandlerService>> getServices() {
|
public Collection<Class<? extends ThingHandlerService>> getServices() {
|
||||||
return Collections.singleton(CaddxPanelActions.class);
|
return Collections.singleton(CaddxPanelActions.class);
|
||||||
@ -216,7 +274,7 @@ public class ThingHandlerPanel extends CaddxBaseThingHandler {
|
|||||||
if (bridgeHandler == null) {
|
if (bridgeHandler == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
bridgeHandler.sendCommand(cmd, sb.toString());
|
bridgeHandler.sendCommand(CaddxMessageContext.COMMAND, cmd, sb.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendSecondaryCommand(String function) {
|
private void sendSecondaryCommand(String function) {
|
||||||
@ -230,7 +288,7 @@ public class ThingHandlerPanel extends CaddxBaseThingHandler {
|
|||||||
if (bridgeHandler == null) {
|
if (bridgeHandler == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
bridgeHandler.sendCommand(cmd, sb.toString());
|
bridgeHandler.sendCommand(CaddxMessageContext.COMMAND, cmd, sb.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void turnOffAnySounderOrAlarm(String pin) {
|
public void turnOffAnySounderOrAlarm(String pin) {
|
||||||
|
|||||||
@ -19,6 +19,7 @@ import org.eclipse.jdt.annotation.NonNullByDefault;
|
|||||||
import org.openhab.binding.caddx.internal.CaddxBindingConstants;
|
import org.openhab.binding.caddx.internal.CaddxBindingConstants;
|
||||||
import org.openhab.binding.caddx.internal.CaddxEvent;
|
import org.openhab.binding.caddx.internal.CaddxEvent;
|
||||||
import org.openhab.binding.caddx.internal.CaddxMessage;
|
import org.openhab.binding.caddx.internal.CaddxMessage;
|
||||||
|
import org.openhab.binding.caddx.internal.CaddxMessageContext;
|
||||||
import org.openhab.binding.caddx.internal.CaddxMessageType;
|
import org.openhab.binding.caddx.internal.CaddxMessageType;
|
||||||
import org.openhab.binding.caddx.internal.CaddxProperty;
|
import org.openhab.binding.caddx.internal.CaddxProperty;
|
||||||
import org.openhab.binding.caddx.internal.action.CaddxPartitionActions;
|
import org.openhab.binding.caddx.internal.action.CaddxPartitionActions;
|
||||||
@ -48,6 +49,20 @@ public class ThingHandlerPartition extends CaddxBaseThingHandler {
|
|||||||
super(thing, CaddxThingType.PARTITION);
|
super(thing, CaddxThingType.PARTITION);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initialize() {
|
||||||
|
super.initialize();
|
||||||
|
|
||||||
|
CaddxBridgeHandler bridgeHandler = getCaddxBridgeHandler();
|
||||||
|
if (bridgeHandler == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String cmd = CaddxBindingConstants.PARTITION_STATUS_REQUEST;
|
||||||
|
String data = String.format("%d", getPartitionNumber() - 1);
|
||||||
|
bridgeHandler.sendCommand(CaddxMessageContext.COMMAND, cmd, data);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateChannel(ChannelUID channelUID, String data) {
|
public void updateChannel(ChannelUID channelUID, String data) {
|
||||||
if (CaddxBindingConstants.PARTITION_SECONDARY_COMMAND.equals(channelUID.getId())) {
|
if (CaddxBindingConstants.PARTITION_SECONDARY_COMMAND.equals(channelUID.getId())) {
|
||||||
@ -87,7 +102,7 @@ public class ThingHandlerPartition extends CaddxBaseThingHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!data.startsWith("-")) {
|
if (!data.startsWith("-")) {
|
||||||
bridgeHandler.sendCommand(cmd, data);
|
bridgeHandler.sendCommand(CaddxMessageContext.COMMAND, cmd, data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,6 +120,7 @@ public class ThingHandlerPartition extends CaddxBaseThingHandler {
|
|||||||
String value = message.getPropertyById(p.getId());
|
String value = message.getPropertyById(p.getId());
|
||||||
channelUID = new ChannelUID(getThing().getUID(), p.getId());
|
channelUID = new ChannelUID(getThing().getUID(), p.getId());
|
||||||
updateChannel(channelUID, value);
|
updateChannel(channelUID, value);
|
||||||
|
logger.trace("Updating partition channel: {}", channelUID.getAsString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,7 +151,7 @@ public class ThingHandlerPartition extends CaddxBaseThingHandler {
|
|||||||
if (bridgeHandler == null) {
|
if (bridgeHandler == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
bridgeHandler.sendCommand(cmd, sb.toString());
|
bridgeHandler.sendCommand(CaddxMessageContext.COMMAND, cmd, sb.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendSecondaryCommand(String function) {
|
private void sendSecondaryCommand(String function) {
|
||||||
@ -149,7 +165,7 @@ public class ThingHandlerPartition extends CaddxBaseThingHandler {
|
|||||||
if (bridgeHandler == null) {
|
if (bridgeHandler == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
bridgeHandler.sendCommand(cmd, sb.toString());
|
bridgeHandler.sendCommand(CaddxMessageContext.COMMAND, cmd, sb.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void turnOffAnySounderOrAlarm(String pin) {
|
public void turnOffAnySounderOrAlarm(String pin) {
|
||||||
|
|||||||
@ -19,6 +19,7 @@ import org.eclipse.jdt.annotation.NonNullByDefault;
|
|||||||
import org.openhab.binding.caddx.internal.CaddxBindingConstants;
|
import org.openhab.binding.caddx.internal.CaddxBindingConstants;
|
||||||
import org.openhab.binding.caddx.internal.CaddxEvent;
|
import org.openhab.binding.caddx.internal.CaddxEvent;
|
||||||
import org.openhab.binding.caddx.internal.CaddxMessage;
|
import org.openhab.binding.caddx.internal.CaddxMessage;
|
||||||
|
import org.openhab.binding.caddx.internal.CaddxMessageContext;
|
||||||
import org.openhab.binding.caddx.internal.CaddxMessageType;
|
import org.openhab.binding.caddx.internal.CaddxMessageType;
|
||||||
import org.openhab.binding.caddx.internal.CaddxProperty;
|
import org.openhab.binding.caddx.internal.CaddxProperty;
|
||||||
import org.openhab.binding.caddx.internal.action.CaddxZoneActions;
|
import org.openhab.binding.caddx.internal.action.CaddxZoneActions;
|
||||||
@ -49,6 +50,23 @@ public class ThingHandlerZone extends CaddxBaseThingHandler {
|
|||||||
super(thing, CaddxThingType.ZONE);
|
super(thing, CaddxThingType.ZONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initialize() {
|
||||||
|
super.initialize();
|
||||||
|
|
||||||
|
CaddxBridgeHandler bridgeHandler = getCaddxBridgeHandler();
|
||||||
|
if (bridgeHandler == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String cmd1 = CaddxBindingConstants.ZONE_STATUS_REQUEST;
|
||||||
|
String cmd2 = CaddxBindingConstants.ZONE_NAME_REQUEST;
|
||||||
|
String data = String.format("%d", getZoneNumber() - 1);
|
||||||
|
|
||||||
|
bridgeHandler.sendCommand(CaddxMessageContext.COMMAND, cmd1, data);
|
||||||
|
bridgeHandler.sendCommand(CaddxMessageContext.COMMAND, cmd2, data);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateChannel(ChannelUID channelUID, String data) {
|
public void updateChannel(ChannelUID channelUID, String data) {
|
||||||
if (channelUID.getId().equals(CaddxBindingConstants.ZONE_NAME)) {
|
if (channelUID.getId().equals(CaddxBindingConstants.ZONE_NAME)) {
|
||||||
@ -99,8 +117,8 @@ public class ThingHandlerZone extends CaddxBaseThingHandler {
|
|||||||
if (bridgeHandler == null) {
|
if (bridgeHandler == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
bridgeHandler.sendCommand(cmd1, data);
|
bridgeHandler.sendCommand(CaddxMessageContext.COMMAND, cmd1, data);
|
||||||
bridgeHandler.sendCommand(cmd2, data);
|
bridgeHandler.sendCommand(CaddxMessageContext.COMMAND, cmd2, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -119,8 +137,7 @@ public class ThingHandlerZone extends CaddxBaseThingHandler {
|
|||||||
String value = message.getPropertyById(p.getId());
|
String value = message.getPropertyById(p.getId());
|
||||||
channelUID = new ChannelUID(getThing().getUID(), p.getId());
|
channelUID = new ChannelUID(getThing().getUID(), p.getId());
|
||||||
updateChannel(channelUID, value);
|
updateChannel(channelUID, value);
|
||||||
|
logger.trace("Updating zone channel: {}", channelUID.getAsString());
|
||||||
logger.trace(" updateChannel: {} = {}", channelUID, value);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -141,6 +158,6 @@ public class ThingHandlerZone extends CaddxBaseThingHandler {
|
|||||||
if (bridgeHandler == null) {
|
if (bridgeHandler == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
bridgeHandler.sendCommand(cmd, data);
|
bridgeHandler.sendCommand(CaddxMessageContext.COMMAND, cmd, data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -60,6 +60,11 @@
|
|||||||
<default>16</default>
|
<default>16</default>
|
||||||
</parameter>
|
</parameter>
|
||||||
|
|
||||||
|
<parameter name="ignoreZoneStatusTransitions" type="boolean" required="true">
|
||||||
|
<label>Ignore Zone Status Transitions</label>
|
||||||
|
<description>Flag specifying if the Zone Status Transitions should be ignored</description>
|
||||||
|
<default>false</default>
|
||||||
|
</parameter>
|
||||||
</config-description>
|
</config-description>
|
||||||
</bridge-type>
|
</bridge-type>
|
||||||
|
|
||||||
|
|||||||
@ -200,6 +200,20 @@
|
|||||||
<label>Zone Bypass Toggle</label>
|
<label>Zone Bypass Toggle</label>
|
||||||
<description>Zone Bypass Toggle</description>
|
<description>Zone Bypass Toggle</description>
|
||||||
</channel>
|
</channel>
|
||||||
|
|
||||||
|
<channel id="panel_ac_fail" typeId="panel_flag">
|
||||||
|
<label>AC fail</label>
|
||||||
|
<description>AC fail</description>
|
||||||
|
</channel>
|
||||||
|
<channel id="panel_ac_power_on" typeId="panel_flag">
|
||||||
|
<label>AC Power On</label>
|
||||||
|
<description>AC Power On</description>
|
||||||
|
</channel>
|
||||||
|
<channel id="panel_low_battery_memory" typeId="panel_flag">
|
||||||
|
<label>Low Battery Memory</label>
|
||||||
|
<description>Low Battery Memory</description>
|
||||||
|
</channel>
|
||||||
|
|
||||||
</channels>
|
</channels>
|
||||||
</thing-type>
|
</thing-type>
|
||||||
|
|
||||||
|
|||||||
@ -60,6 +60,6 @@ public final class CaddxMessageReaderUtil {
|
|||||||
*/
|
*/
|
||||||
public static CaddxMessage readCaddxMessage(String messageName) {
|
public static CaddxMessage readCaddxMessage(String messageName) {
|
||||||
byte[] bytes = readRawMessage(messageName);
|
byte[] bytes = readRawMessage(messageName);
|
||||||
return new CaddxMessage(bytes, true);
|
return new CaddxMessage(CaddxMessageContext.NONE, bytes, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -34,10 +34,80 @@ public class CaddxMessageParseTest {
|
|||||||
// @formatter:off
|
// @formatter:off
|
||||||
public static final List<Object[]> data() {
|
public static final List<Object[]> data() {
|
||||||
return Arrays.asList(new Object[][] {
|
return Arrays.asList(new Object[][] {
|
||||||
{ "zone_status_message", "zone_number", "4", },
|
|
||||||
{ "interface_configuration_message", "panel_firmware_version", "5.37", },
|
{ "interface_configuration_message", "panel_firmware_version", "5.37", },
|
||||||
{ "interface_configuration_message", "panel_interface_configuration_message", "true", },
|
{ "interface_configuration_message", "panel_interface_configuration_message", "true", },
|
||||||
|
|
||||||
|
{ "zone_status_message", "zone_number", "4", },
|
||||||
|
{ "zone_status_message", "zone_partition1", "true", },
|
||||||
|
{ "zone_status_message", "zone_partition2", "false", },
|
||||||
|
{ "zone_status_message", "zone_partition3", "false", },
|
||||||
|
{ "zone_status_message", "zone_partition4", "false", },
|
||||||
|
{ "zone_status_message", "zone_partition5", "false", },
|
||||||
|
{ "zone_status_message", "zone_partition6", "false", },
|
||||||
|
{ "zone_status_message", "zone_partition7", "false", },
|
||||||
|
{ "zone_status_message", "zone_partition8", "false", },
|
||||||
|
{ "zone_status_message", "zone_fire", "true", },
|
||||||
|
{ "zone_status_message", "zone_24hour", "false", },
|
||||||
|
{ "zone_status_message", "zone_key_switch", "false", },
|
||||||
|
{ "zone_status_message", "zone_follower", "false", },
|
||||||
|
{ "zone_status_message", "zone_entry_exit_delay_1", "false", },
|
||||||
|
{ "zone_status_message", "zone_entry_exit_delay_2", "false", },
|
||||||
|
{ "zone_status_message", "zone_interior", "false", },
|
||||||
|
{ "zone_status_message", "zone_local_only", "false", },
|
||||||
|
{ "zone_status_message", "zone_keypad_sounder", "true", },
|
||||||
|
{ "zone_status_message", "zone_yelping_siren", "false", },
|
||||||
|
{ "zone_status_message", "zone_steady_siren", "true", },
|
||||||
|
{ "zone_status_message", "zone_chime", "false", },
|
||||||
|
{ "zone_status_message", "zone_bypassable", "false", },
|
||||||
|
{ "zone_status_message", "zone_group_bypassable", "false", },
|
||||||
|
{ "zone_status_message", "zone_force_armable", "false", },
|
||||||
|
{ "zone_status_message", "zone_entry_guard", "false", },
|
||||||
|
{ "zone_status_message", "zone_fast_loop_response", "false", },
|
||||||
|
{ "zone_status_message", "zone_double_eol_tamper", "false", },
|
||||||
|
{ "zone_status_message", "zone_type_trouble", "true", },
|
||||||
|
{ "zone_status_message", "zone_cross_zone", "false", },
|
||||||
|
{ "zone_status_message", "zone_dialer_delay", "false", },
|
||||||
|
{ "zone_status_message", "zone_swinger_shutdown", "false", },
|
||||||
|
{ "zone_status_message", "zone_restorable", "true", },
|
||||||
|
{ "zone_status_message", "zone_listen_in", "true", },
|
||||||
|
{ "zone_status_message", "zone_faulted", "false", },
|
||||||
|
{ "zone_status_message", "zone_tampered", "false", },
|
||||||
|
{ "zone_status_message", "zone_trouble", "false", },
|
||||||
|
{ "zone_status_message", "zone_bypassed", "false", },
|
||||||
|
{ "zone_status_message", "zone_inhibited", "false", },
|
||||||
|
{ "zone_status_message", "zone_low_battery", "false", },
|
||||||
|
{ "zone_status_message", "zone_loss_of_supervision", "false", },
|
||||||
|
{ "zone_status_message", "zone_alarm_memory", "false", },
|
||||||
|
{ "zone_status_message", "zone_bypass_memory", "false", },
|
||||||
|
|
||||||
|
{ "zones_snapshot_message", "zone_offset", "1", },
|
||||||
|
{ "zones_snapshot_message", "zone_1_faulted", "false", },
|
||||||
|
{ "zones_snapshot_message", "zone_1_bypassed", "false", },
|
||||||
|
{ "zones_snapshot_message", "zone_1_trouble", "false", },
|
||||||
|
{ "zones_snapshot_message", "zone_1_alarm_memory", "false", },
|
||||||
|
{ "zones_snapshot_message", "zone_2_faulted", "false", },
|
||||||
|
{ "zones_snapshot_message", "zone_2_bypassed", "false", },
|
||||||
|
{ "zones_snapshot_message", "zone_2_trouble", "false", },
|
||||||
|
{ "zones_snapshot_message", "zone_2_alarm_memory", "false", },
|
||||||
|
{ "zones_snapshot_message", "zone_3_faulted", "false", },
|
||||||
|
{ "zones_snapshot_message", "zone_3_bypassed", "false", },
|
||||||
|
{ "zones_snapshot_message", "zone_3_trouble", "false", },
|
||||||
|
{ "zones_snapshot_message", "zone_3_alarm_memory", "false", },
|
||||||
|
{ "zones_snapshot_message", "zone_4_faulted", "true", },
|
||||||
|
{ "zones_snapshot_message", "zone_4_bypassed", "false", },
|
||||||
|
{ "zones_snapshot_message", "zone_4_trouble", "false", },
|
||||||
|
{ "zones_snapshot_message", "zone_4_alarm_memory", "false", },
|
||||||
|
{ "zones_snapshot_message", "zone_5_faulted", "false", },
|
||||||
|
{ "zones_snapshot_message", "zone_6_faulted", "false", },
|
||||||
|
{ "zones_snapshot_message", "zone_7_faulted", "false", },
|
||||||
|
{ "zones_snapshot_message", "zone_8_faulted", "false", },
|
||||||
|
{ "zones_snapshot_message", "zone_9_faulted", "false", },
|
||||||
|
{ "zones_snapshot_message", "zone_10_faulted", "true", },
|
||||||
|
{ "zones_snapshot_message", "zone_11_faulted", "false", },
|
||||||
|
{ "zones_snapshot_message", "zone_12_faulted", "false", },
|
||||||
|
{ "zones_snapshot_message", "zone_13_faulted", "false", },
|
||||||
|
{ "zones_snapshot_message", "zone_14_faulted", "true", },
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
// @formatter:on
|
// @formatter:on
|
||||||
|
|||||||
@ -0,0 +1 @@
|
|||||||
|
85 01 00 10 00 00 10 00 10 00 C0 7F
|
||||||
Loading…
x
Reference in New Issue
Block a user