use of org.openhab.binding.dscalarm.DSCAlarmBindingConfig in project openhab1-addons by openhab.
the class DSCAlarmActiveBinding method setTimeStampState.
/**
* Method to set the time stamp state
*
* @param timeStamp
*/
private void setTimeStampState(String timeStamp) {
logger.debug("setTimeStampState(): Time Stamp: {}", timeStamp);
int state = 0;
String itemName = "";
itemName = getItemName(DSCAlarmItemType.PANEL_TIME_STAMP, 0, 0);
if (StringUtils.isNotEmpty(itemName)) {
DSCAlarmBindingConfig config = getItemConfig(itemName);
if (config != null) {
Item item = getItem(itemName);
if (item != null) {
State onOffState = item.getState();
if (onOffState instanceof OnOffType) {
OnOffType value = (OnOffType) onOffState;
if ((StringUtils.isEmpty(timeStamp) && value.equals(OnOffType.OFF)) || (StringUtils.isNotEmpty(timeStamp) && value.equals(OnOffType.ON))) {
logger.debug("setTimeStampState(): Already Set!", timeStamp);
return;
} else if (StringUtils.isNotEmpty(timeStamp)) {
state = 1;
}
}
}
}
}
updateItemByItemType(DSCAlarmItemType.PANEL_TIME_STAMP, 0, 0, state);
logger.debug("setTimeStampState(): Changed state to '{}'.", state == 1 ? OnOffType.ON : OnOffType.OFF);
}
use of org.openhab.binding.dscalarm.DSCAlarmBindingConfig in project openhab1-addons by openhab.
the class DSCAlarmActiveBinding method bindingChanged.
/**
* {@inheritDoc}
*/
@Override
public void bindingChanged(BindingProvider provider, String itemName) {
logger.debug("bindingChanged(): Item Name: {}", itemName);
boolean itemRemoved = false;
int icount = provider.getItemNames().size();
if (icount < itemCount) {
itemRemoved = true;
}
if (itemRemoved) {
dscAlarmUpdateMap.clear();
} else {
DSCAlarmBindingProvider dscAlarmBindingProvider = (DSCAlarmBindingProvider) provider;
if (dscAlarmBindingProvider != null) {
DSCAlarmBindingConfig dscAlarmBindingConfig = dscAlarmBindingProvider.getDSCAlarmBindingConfig(itemName);
if (dscAlarmBindingConfig != null) {
dscAlarmUpdateMap.put(itemName, dscAlarmBindingConfig);
}
}
}
itemCount = provider.getItemNames().size();
itemHasChanged = true;
}
use of org.openhab.binding.dscalarm.DSCAlarmBindingConfig in project openhab1-addons by openhab.
the class DSCAlarmActiveBinding method processUpdateMap.
/**
* Processes the Update Items Map
*/
private void processUpdateMap() {
if (dscAlarmUpdateMap.size() == 0) {
logger.debug("processUpdateMap(): Nothing to update.");
return;
}
Map<String, DSCAlarmBindingConfig> itemsMap = new HashMap<String, DSCAlarmBindingConfig>(dscAlarmUpdateMap);
for (String itemName : itemsMap.keySet()) {
DSCAlarmBindingConfig dscAlarmBindingConfig = itemsMap.get(itemName);
dscAlarmUpdateMap.remove(itemName);
Item item = null;
for (DSCAlarmBindingProvider provider : providers) {
item = provider.getItem(itemName);
}
if (dscAlarmBindingConfig.getDSCAlarmItemType().equals(DSCAlarmItemType.PANEL_COMMAND)) {
dscAlarmItemUpdate.updateDeviceItem(item, dscAlarmBindingConfig, eventPublisher, null, -1, "");
} else {
dscAlarmItemUpdate.updateDeviceItem(item, dscAlarmBindingConfig, eventPublisher, null, 0, "");
}
logger.debug("processUpdateMap(): Updated item: {}", itemName);
}
}
use of org.openhab.binding.dscalarm.DSCAlarmBindingConfig in project openhab1-addons by openhab.
the class DSCAlarmGenericBindingProvider method processBindingConfiguration.
/**
* {@inheritDoc}
*/
@Override
public void processBindingConfiguration(String context, Item item, String bindingConfig) throws BindingConfigParseException {
String[] sections = bindingConfig.split(":");
if (sections.length < 2 || sections.length > 4) {
throw new BindingConfigParseException("Invalid number of sections in the binding: " + bindingConfig);
}
DSCAlarmDeviceType dscAlarmDeviceType = null;
int partitionId = 0;
int zoneId = 0;
DSCAlarmItemType dscAlarmItemType = null;
try {
dscAlarmDeviceType = DSCAlarmDeviceType.getDSCAlarmDeviceType(sections[0]);
switch(dscAlarmDeviceType) {
case PANEL:
dscAlarmItemType = DSCAlarmItemType.getDSCAlarmItemType(sections[1]);
break;
case PARTITION:
partitionId = Integer.parseInt(sections[1]);
dscAlarmItemType = DSCAlarmItemType.getDSCAlarmItemType(sections[2]);
break;
case ZONE:
partitionId = Integer.parseInt(sections[1]);
zoneId = Integer.parseInt(sections[2]);
dscAlarmItemType = DSCAlarmItemType.getDSCAlarmItemType(sections[3]);
break;
case KEYPAD:
dscAlarmItemType = DSCAlarmItemType.getDSCAlarmItemType(sections[1]);
break;
default:
logger.debug("Invalid Device Type in binding configuration: {}", dscAlarmDeviceType);
break;
}
} catch (Exception e) {
throw new BindingConfigParseException("Binding Configuration Error: deviceType: " + dscAlarmDeviceType);
}
if (dscAlarmItemType == null) {
logger.error("processBindingConfiguration(): {}: DSC Alarm Item Type is NULL! Item Not Added!", item.getName());
return;
}
DSCAlarmBindingConfig config = new DSCAlarmBindingConfig(dscAlarmDeviceType, partitionId, zoneId, dscAlarmItemType);
addBindingConfig(item, config);
super.processBindingConfiguration(context, item, bindingConfig);
logger.debug("processBindingConfiguration(): Item added: {} - {}", item.getName(), bindingConfig);
}
Aggregations