use of org.openhab.core.types.Command in project openhab1-addons by openhab.
the class IRtransGenericBindingProvider method getInetSocketAddresses.
/**
* {@inheritDoc}
*/
@Override
public List<InetSocketAddress> getInetSocketAddresses(String itemName) {
List<InetSocketAddress> theList = new ArrayList<InetSocketAddress>();
for (Command command : getAllCommands(itemName)) {
InetSocketAddress anAddress = null;
try {
anAddress = new InetSocketAddress(InetAddress.getByName(getHost(itemName, command)), getPort(itemName, command));
} catch (UnknownHostException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
theList.add(anAddress);
}
return theList;
}
use of org.openhab.core.types.Command in project openhab1-addons by openhab.
the class IRtransGenericBindingProvider method getQualifiedCommands.
/**
* {@inheritDoc}
*/
@Override
public List<Command> getQualifiedCommands(String itemName, Command command) {
List<Command> commands = new ArrayList<Command>();
IRtransBindingConfig aConfig = (IRtransBindingConfig) bindingConfigs.get(itemName);
for (Command aCommand : aConfig.keySet()) {
if (aCommand == command) {
commands.add(aCommand);
} else {
if (aCommand instanceof DecimalType) {
commands.add(aCommand);
}
}
}
return commands;
}
use of org.openhab.core.types.Command in project openhab1-addons by openhab.
the class KNXBinding method sendTypeToItemButNotToKnx.
private void sendTypeToItemButNotToKnx(GroupAddress destination, String itemName, Type type) {
// we need to make sure that we won't send out this event to
// the knx bus again, when receiving it on the openHAB bus
ignoreEventList.add(itemName + type.toString());
logger.trace("Added event (item='{}', type='{}') to the ignore event list", itemName, type.toString());
if (type instanceof Command && isCommandGA(destination)) {
eventPublisher.postCommand(itemName, (Command) type);
} else if (type instanceof State) {
eventPublisher.postUpdate(itemName, (State) type);
} else {
throw new IllegalClassException("Cannot process datapoint of type " + type.toString());
}
logger.trace("Processed event (item='{}', type='{}', destination='{}')", itemName, type.toString(), destination.toString());
}
use of org.openhab.core.types.Command in project openhab1-addons by openhab.
the class LcnBinding method internalReceiveCommand.
/** {@inheritDoc} */
@Override
protected void internalReceiveCommand(String itemName, Command command) {
final String itemName2 = itemName;
final Command command2 = command;
this.runOnRefreshThreadAsync(new LcnBindingNotification() {
@Override
public void execute() {
for (LcnGenericBindingProvider provider : LcnBinding.this.providers) {
LcnBindingConfig itemConfig = provider.getLcnItemConfig(itemName2);
if (itemConfig != null) {
itemConfig.send(LcnBinding.this.connections, command2);
}
}
}
});
}
use of org.openhab.core.types.Command in project openhab1-addons by openhab.
the class LcnGenericBindingProvider method processBindingConfiguration.
/**
* Item processing for the LCN bindings.
* {@inheritDoc}
*/
@Override
public void processBindingConfiguration(String context, Item item, String bindingConfig) throws BindingConfigParseException {
super.processBindingConfiguration(context, item, bindingConfig);
Matcher matcher = PATTERN_BINDING_GENERAL.matcher(bindingConfig);
if (!matcher.matches()) {
throw new BindingConfigParseException(bindingConfig + "' contains no valid binding!");
}
matcher.reset();
LcnBindingConfig bc = new LcnBindingConfig(item);
while (matcher.find()) {
String binding = matcher.group(1);
if (binding != null && !binding.trim().isEmpty()) {
String openHabCmd = null;
String connId, lcnTarget;
Matcher openHabMatcher = PATTERN_BINDING_WITH_OPENHAB.matcher(binding);
Matcher pureMatcher = PATTERN_BINDING_PURE.matcher(binding);
if (openHabMatcher.matches()) {
openHabCmd = openHabMatcher.group(1);
connId = openHabMatcher.group(2);
lcnTarget = openHabMatcher.group(3);
} else if (pureMatcher.matches()) {
connId = pureMatcher.group(1);
lcnTarget = pureMatcher.group(2);
} else {
throw new BindingConfigParseException("Invalid binding configuration for " + binding + "!");
}
String lcnShort = resolveMappings(lcnTarget, openHabCmd);
if (lcnShort == null || lcnShort.equals(openHabCmd)) {
lcnShort = lcnTarget;
}
Command cmd = openHabCmd == null ? TypeParser.parseCommand(new StringItem("").getAcceptedCommandTypes(), "") : openHabCmd.equals("%i") ? new StringType("%i") : TypeParser.parseCommand(item.getAcceptedCommandTypes(), openHabCmd);
bc.add(new LcnBindingConfig.Mapping(cmd, connId, lcnShort));
}
}
// Finished
this.addBindingConfig(item, bc);
for (LcnAddrMod addr : bc.getRelatedModules()) {
HashSet<String> l = this.itemNamesByModulCache.get(addr);
if (l == null) {
l = new HashSet<String>();
this.itemNamesByModulCache.put(addr, l);
}
l.add(item.getName());
}
}
Aggregations