Search in sources :

Example 1 with Key

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;
}
Also used : RemoteSession(de.quist.samy.remocon.RemoteSession) Key(de.quist.samy.remocon.Key)

Example 2 with Key

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);
}
Also used : BindingConfigParseException(org.openhab.model.item.binding.BindingConfigParseException) Key(de.quist.samy.remocon.Key)

Aggregations

Key (de.quist.samy.remocon.Key)2 RemoteSession (de.quist.samy.remocon.RemoteSession)1 BindingConfigParseException (org.openhab.model.item.binding.BindingConfigParseException)1