use of org.openhab.core.binding.BindingConfig in project openhab1-addons by openhab.
the class MilightGenericBindingProvider method processBindingConfiguration.
@Override
public void processBindingConfiguration(String context, Item item, String bindingConfig) throws BindingConfigParseException {
super.processBindingConfiguration(context, item, bindingConfig);
try {
if (bindingConfig != null) {
String[] configParts = bindingConfig.split(";");
if (configParts.length > 4) {
throw new BindingConfigParseException("milight binding configuration must not have more than four parts");
}
if (item instanceof ColorItem) {
BindingConfig milightBindingConfig = new MilightBindingConfig(configParts[0], configParts[1], BindingType.rgb.name(), null);
addBindingConfig(item, milightBindingConfig);
} else if (item instanceof DimmerItem || item instanceof SwitchItem) {
BindingConfig milightBindingConfig = new MilightBindingConfig(configParts[0], configParts[1], configParts.length < 3 ? null : configParts[2], configParts.length < 4 ? null : configParts[3]);
addBindingConfig(item, milightBindingConfig);
}
} else {
logger.warn("bindingConfig is NULL (item=" + item + ") -> processing bindingConfig aborted!");
}
} catch (ArrayIndexOutOfBoundsException e) {
logger.warn("bindingConfig is invalid (item=" + item + ") -> processing bindingConfig aborted!");
}
}
use of org.openhab.core.binding.BindingConfig in project openhab1-addons by openhab.
the class MochadX10GenericBindingProvider method processBindingConfiguration.
@Override
public void processBindingConfiguration(String context, Item item, String bindingConfig) throws BindingConfigParseException {
String bindingConfigLc = bindingConfig.toLowerCase();
super.processBindingConfiguration(context, item, bindingConfigLc);
if (bindingConfigLc != null) {
String address = getAddress(bindingConfigLc);
String transmitMethod = getTransmitMethod(bindingConfigLc);
String dimMethod = getDimMethod(bindingConfigLc);
if (address != null) {
if (transmitMethod == null) {
transmitMethod = "pl";
}
if (dimMethod == null) {
dimMethod = "xdim";
}
BindingConfig mochadX10BindingConfig = new MochadX10BindingConfig(item.getName(), item.getClass(), transmitMethod, dimMethod, address);
addBindingConfig(item, mochadX10BindingConfig);
} else {
throw new BindingConfigParseException("No address specified, bindingConfig is invalid (item=" + item + ") -> processing bindingConfig aborted!");
}
} else {
throw new BindingConfigParseException("No binding config specified (item=" + item + ") -> processing bindingConfig aborted!");
}
}
use of org.openhab.core.binding.BindingConfig in project openhab1-addons by openhab.
the class VDRGenericBindingProvider method getBindingItemName.
/*
* (non-Javadoc)
*
* @see
* org.openhab.binding.vdr.VDRBindingProvider#getBindingItemName(java.lang
* .String, org.openhab.binding.vdr.internal.VDRCommandType)
*/
@Override
public String getBindingItemName(String vdrId, VDRCommandType vdrCommand) {
String itemName = null;
logger.debug("Searching for a binding config that matches the id '{}' and command '{}'", vdrId, vdrCommand);
for (BindingConfig config : this.bindingConfigs.values()) {
VDRBindingConfig vdrConfig = (VDRBindingConfig) config;
if (vdrConfig.vDRId.equals(vdrId) && vdrConfig.command.equals(vdrCommand.getVDRCommand())) {
itemName = vdrConfig.item.getName();
logger.debug("Match found: '{}'", itemName);
break;
} else {
logger.debug("Not a match: '{}':'{}'", vdrConfig.vDRId, vdrConfig.command);
}
}
return itemName;
}
use of org.openhab.core.binding.BindingConfig in project openhab1-addons by openhab.
the class HueGenericBindingProvider method processBindingConfiguration.
@Override
public void processBindingConfiguration(String context, Item item, String bindingConfig) throws BindingConfigParseException {
super.processBindingConfiguration(context, item, bindingConfig);
try {
if (bindingConfig != null) {
String[] configParts = bindingConfig.split(";");
if (item instanceof ColorItem) {
BindingConfig hueBindingConfig = new HueBindingConfig(configParts[0], BindingType.rgb.name(), null);
addBindingConfig(item, hueBindingConfig);
} else if (item instanceof DimmerItem) {
BindingConfig hueBindingConfig = new HueBindingConfig(configParts[0], configParts.length < 2 ? null : configParts[1], configParts.length < 3 ? null : configParts[2]);
addBindingConfig(item, hueBindingConfig);
} else if (item instanceof SwitchItem) {
BindingConfig hueBindingConfig = new HueBindingConfig(configParts[0], BindingType.switching.name(), null);
addBindingConfig(item, hueBindingConfig);
}
} else {
logger.warn("bindingConfig is NULL (item=" + item + ") -> processing bindingConfig aborted!");
}
} catch (ArrayIndexOutOfBoundsException e) {
logger.warn("bindingConfig is invalid (item=" + item + ") -> processing bindingConfig aborted!");
}
}
use of org.openhab.core.binding.BindingConfig in project openhab1-addons by openhab.
the class OneWireBinding method scheduleAllBindings.
/**
* schedule All Bindings to get updated
*
* @param pvProvider
*/
private void scheduleAllBindings(BindingProvider pvProvider) {
if (OneWireConnection.isConnectionEstablished()) {
logger.debug("scheduleAllBindings");
if (pvProvider instanceof OneWireBindingProvider) {
OneWireBindingProvider lvBindingProvider = (OneWireBindingProvider) pvProvider;
ivOneWireReaderScheduler.clear();
ivCacheItemStates.clear();
Map<String, BindingConfig> lvBindigConfigs = lvBindingProvider.getBindingConfigs();
for (String lvItemName : lvBindigConfigs.keySet()) {
logger.debug("scheduleAllBindings, now item {}.", lvItemName);
OneWireBindingConfig lvOneWireBindingConfig = (OneWireBindingConfig) lvBindigConfigs.get(lvItemName);
if (lvOneWireBindingConfig instanceof AbstractOneWireDevicePropertyBindingConfig) {
logger.debug("Initializing read of item {}.", lvItemName);
AbstractOneWireDevicePropertyBindingConfig lvDevicePropertyBindingConfig = (AbstractOneWireDevicePropertyBindingConfig) lvOneWireBindingConfig;
if (lvDevicePropertyBindingConfig != null) {
int lvAutoRefreshTimeInSecs = lvDevicePropertyBindingConfig.getAutoRefreshInSecs();
if (lvAutoRefreshTimeInSecs > -1) {
ivOneWireReaderScheduler.updateOnce(lvItemName);
}
if (lvAutoRefreshTimeInSecs > 0) {
if (!ivOneWireReaderScheduler.scheduleUpdate(lvItemName, lvAutoRefreshTimeInSecs)) {
logger.warn("Couldn't add to OneWireUpdate scheduler", lvDevicePropertyBindingConfig);
}
}
}
} else {
logger.debug("Didn't schedule item {} because it is not a DevicePropertyBinding.", lvItemName);
}
}
}
}
}
Aggregations