use of org.openhab.binding.dscalarm.internal.protocol.APIMessage in project openhab1-addons by openhab.
the class Keypad method handleEvent.
/**
* {@inheritDoc}
*/
@Override
public void handleEvent(Item item, DSCAlarmBindingConfig config, EventPublisher publisher, DSCAlarmEvent event) {
APIMessage apiMessage = null;
int state;
if (event != null) {
apiMessage = event.getAPIMessage();
logger.debug("handleEvent(): Keypad Item Name: {}", item.getName());
if (config != null) {
if (config.getDSCAlarmItemType() != null) {
switch(config.getDSCAlarmItemType()) {
case KEYPAD_READY_LED:
case KEYPAD_ARMED_LED:
case KEYPAD_MEMORY_LED:
case KEYPAD_BYPASS_LED:
case KEYPAD_TROUBLE_LED:
case KEYPAD_PROGRAM_LED:
case KEYPAD_FIRE_LED:
case KEYPAD_BACKLIGHT_LED:
case KEYPAD_AC_LED:
state = Integer.parseInt(apiMessage.getAPIData().substring(1));
if (item instanceof NumberItem) {
publisher.postUpdate(item.getName(), new DecimalType(state));
}
if (item instanceof StringItem) {
publisher.postUpdate(item.getName(), new StringType(ledStates[state]));
}
break;
case KEYPAD_LCD_UPDATE:
case KEYPAD_LCD_CURSOR:
publisher.postUpdate(item.getName(), new StringType(apiMessage.getAPIData()));
break;
default:
logger.debug("handleEvent(): Keypad item not updated.");
break;
}
}
}
}
}
use of org.openhab.binding.dscalarm.internal.protocol.APIMessage in project openhab1-addons by openhab.
the class Panel method handleEvent.
/**
* {@inheritDoc}
*/
@Override
public void handleEvent(Item item, DSCAlarmBindingConfig config, EventPublisher publisher, DSCAlarmEvent event) {
APIMessage apiMessage = null;
int apiCode = -1;
boolean boolState;
int state = 0;
OnOffType onOffType;
if (event != null) {
apiMessage = event.getAPIMessage();
apiCode = Integer.parseInt(apiMessage.getAPICode());
String str = "";
logger.debug("handleEvent(): Panel Item Name: {}", item.getName());
if (config != null) {
if (config.getDSCAlarmItemType() != null) {
switch(config.getDSCAlarmItemType()) {
case PANEL_CONNECTION:
publisher.postUpdate(item.getName(), new DecimalType(state));
break;
case PANEL_MESSAGE:
if (apiMessage != null) {
str = apiMessage.getAPIDescription();
}
publisher.postUpdate(item.getName(), new StringType(str));
break;
case PANEL_SYSTEM_ERROR:
int systemErrorCode = 0;
if (apiMessage != null) {
systemErrorCode = Integer.parseInt(apiMessage.getAPIData());
str = String.format("%03d: %s", systemErrorCode, apiMessage.getError());
publisher.postUpdate(item.getName(), new StringType(str));
}
break;
case PANEL_TROUBLE_MESSAGE:
if (apiMessage != null) {
str = apiMessage.getAPIDescription();
}
publisher.postUpdate(item.getName(), new StringType(str));
break;
case PANEL_TROUBLE_LED:
if (apiMessage != null) {
boolState = (apiCode == 840) ? true : false;
onOffType = boolState ? OnOffType.ON : OnOffType.OFF;
publisher.postUpdate(item.getName(), onOffType);
}
break;
case PANEL_TIME:
if (apiMessage != null) {
str = getFormattedPanelTime(apiMessage.getAPIData());
publisher.postUpdate(item.getName(), new DateTimeType(str));
}
break;
default:
logger.debug("handleEvent(): Panel item not updated.");
break;
}
}
}
}
}
use of org.openhab.binding.dscalarm.internal.protocol.APIMessage in project openhab1-addons by openhab.
the class Partition method handleEvent.
/**
* {@inheritDoc}
*/
@Override
public void handleEvent(Item item, DSCAlarmBindingConfig config, EventPublisher publisher, DSCAlarmEvent event) {
int state = 0;
int apiCode = -1;
APIMessage apiMessage = null;
String str = "";
if (event != null) {
apiMessage = event.getAPIMessage();
apiCode = Integer.parseInt(apiMessage.getAPICode());
str = apiMessage.getAPIName();
logger.debug("handleEvent(): Partition Item Name: {}", item.getName());
if (config != null) {
if (config.getDSCAlarmItemType() != null) {
switch(config.getDSCAlarmItemType()) {
case PARTITION_STATUS:
switch(apiCode) {
case 650:
case 653:
case 654:
state = 1;
break;
case 651:
case 672:
case 673:
state = 0;
break;
default:
break;
}
publisher.postUpdate(item.getName(), new StringType(str));
break;
case PARTITION_ARM_MODE:
if (apiCode == 652) {
state = Integer.parseInt(apiMessage.getMode()) + 1;
}
if (item instanceof NumberItem) {
publisher.postUpdate(item.getName(), new DecimalType(state));
}
if (item instanceof StringItem) {
publisher.postUpdate(item.getName(), new StringType(str));
}
break;
case PARTITION_OPENING_CLOSING_MODE:
switch(apiCode) {
case 700:
state = 1;
break;
case 701:
state = 2;
break;
case 702:
state = 3;
break;
case 750:
state = 4;
break;
case 751:
state = 5;
break;
default:
state = 0;
str = "";
break;
}
if (item instanceof NumberItem) {
publisher.postUpdate(item.getName(), new DecimalType(state));
}
if (item instanceof StringItem) {
publisher.postUpdate(item.getName(), new StringType(str));
}
break;
default:
logger.debug("handleEvent(): Partition item not updated.");
break;
}
}
}
}
}
use of org.openhab.binding.dscalarm.internal.protocol.APIMessage in project openhab1-addons by openhab.
the class Zone method handleEvent.
/**
* {@inheritDoc}
*/
@Override
public void handleEvent(Item item, DSCAlarmBindingConfig config, EventPublisher publisher, DSCAlarmEvent event) {
int apiCode = -1;
APIMessage apiMessage = null;
String str = "Status Unknown!";
if (event != null) {
apiMessage = event.getAPIMessage();
apiCode = Integer.parseInt(apiMessage.getAPICode());
str = apiMessage.getAPIName();
logger.debug("handleEvent(): Zone Item Name: {}", item.getName());
if (config != null) {
if (config.getDSCAlarmItemType() != null) {
switch(config.getDSCAlarmItemType()) {
case ZONE_ALARM_STATUS:
publisher.postUpdate(item.getName(), new StringType(str));
break;
case ZONE_TAMPER_STATUS:
publisher.postUpdate(item.getName(), new StringType(str));
break;
case ZONE_FAULT_STATUS:
publisher.postUpdate(item.getName(), new StringType(str));
break;
case ZONE_GENERAL_STATUS:
publisher.postUpdate(item.getName(), (apiCode == 609) ? OpenClosedType.OPEN : OpenClosedType.CLOSED);
break;
default:
logger.debug("handleEvent(): Zone item not updated.");
break;
}
}
}
}
}
use of org.openhab.binding.dscalarm.internal.protocol.APIMessage in project openhab1-addons by openhab.
the class DSCAlarmActiveBinding method verboseTroubleStatusHandler.
/**
* Handle Verbose Trouble Status events for the EyezOn Envisalink 3/2DS DSC Alarm Interface
*
* @param event
*/
private void verboseTroubleStatusHandler(EventObject event) {
DSCAlarmEvent dscAlarmEvent = (DSCAlarmEvent) event;
APIMessage apiMessage = dscAlarmEvent.getAPIMessage();
DSCAlarmItemType[] dscAlarmItemTypes = { DSCAlarmItemType.PANEL_SERVICE_REQUIRED, DSCAlarmItemType.PANEL_AC_TROUBLE, DSCAlarmItemType.PANEL_TELEPHONE_TROUBLE, DSCAlarmItemType.PANEL_FTC_TROUBLE, DSCAlarmItemType.PANEL_ZONE_FAULT, DSCAlarmItemType.PANEL_ZONE_TAMPER, DSCAlarmItemType.PANEL_ZONE_LOW_BATTERY, DSCAlarmItemType.PANEL_TIME_LOSS };
String itemName;
int bitField = Integer.decode("0x" + apiMessage.getAPIData());
int[] masks = { 1, 2, 4, 8, 16, 32, 64, 128 };
int[] bits = new int[8];
for (int i = 0; i < 8; i++) {
bits[i] = bitField & masks[i];
itemName = getItemName(dscAlarmItemTypes[i], 0, 0);
if (StringUtils.isNotEmpty(itemName)) {
updateItem(itemName, bits[i] != 0 ? 1 : 0, "");
}
}
}
Aggregations