use of de.quist.samy.remocon.Key in project openhab1-addons by openhab.
the class SamsungTvConnection method send.
/**
* Sends a command to Samsung device.
*
* @param cmd
* Command to send
*/
public void send(final String cmd) {
RemoteSession remoteController = null;
try {
remoteController = RemoteSession.create("openHAB", "openHAB", ip, port);
Key key = Key.valueOf(cmd);
logger.debug("Try to send command: {}", cmd);
remoteController.sendKey(key);
} catch (Exception e) {
logger.error("Could not send command to device on {}: {}", ip + ":" + port, e);
}
remoteController = null;
}
use of de.quist.samy.remocon.Key in project openhab1-addons by openhab.
the class SamsungTvGenericBindingProvider method parseBindingConfig.
protected void parseBindingConfig(String bindingConfigs, SamsungTvBindingConfig config) throws BindingConfigParseException {
String bindingConfig = StringUtils.substringBefore(bindingConfigs, ",");
String bindingConfigTail = StringUtils.substringAfter(bindingConfigs, ",");
String[] configParts = bindingConfig.trim().split(":");
if (configParts.length != 3) {
throw new BindingConfigParseException("Samsung TV binding must contain three parts separated by ':'");
}
String command = StringUtils.trim(configParts[0]);
String tvId = StringUtils.trim(configParts[1]);
String tvCommand = StringUtils.trim(configParts[2]);
Key key = Key.valueOf(tvCommand);
if (key == null) {
throw new BindingConfigParseException("Unregonized value '" + tvCommand + "'");
}
// if there are more commands to parse do that recursively ...
if (StringUtils.isNotBlank(bindingConfigTail)) {
parseBindingConfig(bindingConfigTail, config);
}
config.put(command, tvId + ":" + tvCommand);
}
Aggregations