use of org.openhab.binding.mpd.MpdBindingProvider in project openhab1-addons by openhab.
the class MpdBinding method internalReceiveCommand.
/**
* @{inheritDoc}
*/
@Override
public void internalReceiveCommand(String itemName, Command command) {
MpdBindingProvider provider;
String matchingPlayerCommand;
// nothing by default
Object params = new Object();
if (command instanceof PercentType) {
// we have received volume adjustment request
matchingPlayerCommand = "PERCENT";
params = command;
} else if (command instanceof DecimalType) {
// we have received play song id request
matchingPlayerCommand = "NUMBER";
params = command;
} else {
matchingPlayerCommand = command.toString();
}
provider = findFirstMatchingBindingProvider(itemName, matchingPlayerCommand);
if (provider == null) {
logger.warn("Cannot find matching binding provider [itemName={}, command={}]", itemName, command);
return;
}
String playerCommand = provider.getPlayerCommand(itemName, matchingPlayerCommand);
if (StringUtils.isNotBlank(playerCommand)) {
String playerCommandParam = provider.getPlayerCommandParam(itemName, matchingPlayerCommand);
if (playerCommandParam != null) {
params = playerCommandParam;
}
executePlayerCommand(playerCommand, params);
}
}
use of org.openhab.binding.mpd.MpdBindingProvider in project openhab1-addons by openhab.
the class MpdBinding method getItemsByPlayerCommandAndOutput.
private String[] getItemsByPlayerCommandAndOutput(String playerId, PlayerCommandTypeMapping playerCommand, MPDOutput output) {
Set<String> itemNames = new HashSet<String>();
// internally mpd uses 0-based indexes
int outputId = output.getId() + 1;
for (MpdBindingProvider provider : this.providers) {
itemNames.addAll(Arrays.asList(provider.getItemNamesByPlayerOutputCommand(playerId, playerCommand, outputId)));
}
return itemNames.toArray(new String[itemNames.size()]);
}
Aggregations