use of org.openhab.binding.insteonplm.internal.device.InsteonAddress in project openhab1-addons by openhab.
the class InsteonPLMGenericBindingProvider method processBindingConfiguration.
/**
* Inherited from AbstractGenericBindingProvider.
* Processes InsteonPLM binding configuration string.
* {@inheritDoc}
*/
@Override
public void processBindingConfiguration(String context, Item item, String bindingConfig) throws BindingConfigParseException {
super.processBindingConfiguration(context, item, bindingConfig);
String[] parts = parseConfigString(bindingConfig);
if (parts.length != 3) {
throw new BindingConfigParseException("item config must have addr:prodKey#feature format");
}
InsteonAddress addr = new InsteonAddress(parts[0]);
String[] params = parts[2].split(",");
String feature = params[0];
HashMap<String, String> args = new HashMap<String, String>();
for (int i = 1; i < params.length; i++) {
String[] kv = params[i].split("=");
if (kv.length == 2) {
args.put(kv[0], kv[1]);
} else {
logger.error("parameter {} does not have format a=b", params[i]);
}
}
InsteonPLMBindingConfig config = new InsteonPLMBindingConfig(item.getName(), addr, feature, parts[1], args);
addBindingConfig(item, config);
logger.trace("processing item \"{}\" read from .items file with cfg string {}", item.getName(), bindingConfig);
items.put(item.getName(), item);
}
use of org.openhab.binding.insteonplm.internal.device.InsteonAddress in project openhab1-addons by openhab.
the class Field method getAddress.
/**
* Fetch an insteon address from the field position
*
* @param array the array to fetch from
* @return the address
*/
public InsteonAddress getAddress(byte[] array) throws FieldException {
check(array.length, DataType.ADDRESS);
InsteonAddress adr = new InsteonAddress();
adr.loadBytes(array, m_offset);
return adr;
}
use of org.openhab.binding.insteonplm.internal.device.InsteonAddress in project openhab1-addons by openhab.
the class InsteonPLMActiveBinding method checkIfInModemDatabase.
/**
* Checks if a device is in the modem link database, and, if the database
* is complete, logs a warning if the device is not present
*
* @param dev The device to search for in the modem database
* @return number of devices in modem database
*/
private int checkIfInModemDatabase(InsteonDevice dev) {
InsteonAddress addr = dev.getAddress();
HashMap<InsteonAddress, ModemDBEntry> dbes = m_driver.lockModemDBEntries();
if (dbes.containsKey(addr)) {
if (!dev.hasModemDBEntry()) {
logger.info("device {} found in the modem database and {}.", addr, getLinkInfo(dbes, addr));
dev.setHasModemDBEntry(true);
}
} else {
if (m_driver.isModemDBComplete() && !addr.isX10()) {
logger.warn("device {} not found in the modem database. Did you forget to link?", addr);
}
}
int ndev = dbes.size();
m_driver.unlockModemDBEntries();
return ndev;
}
Aggregations