Package org.openhab.action.openwebif.internal.impl.config

Examples of org.openhab.action.openwebif.internal.impl.config.OpenWebIfConfig


      @ParamDoc(name = "timeout", text = "How long the text will stay on the screen in seconds") int timeout) {

    if (configs.isEmpty()) {
      throw new RuntimeException("No OpenWebIf receiver configs available, please check your openhab.cfg!");
    }
    OpenWebIfConfig config = configs.get(name);
    if (config == null) {
      throw new RuntimeException("OpenWebIf receiver config with name '" + name + "' not found!");
    }
    try {
      MessageType type = MessageType.valueOf(StringUtils.upperCase(messageType));
      if (!communicator.isOff(config)) {
        if (!communicator.isStandby(config)) {
          SimpleResult result = communicator.sendMessage(config, message, type, timeout);
          if (!result.isValid()) {
            logger.warn("Can't send message to OpenWebIf receiver with name '{}': {}", config.getName(),
                result.getStateText());
          } else {
            return true;
          }
        } else {
          logger.debug("OpenWebIf receiver with name '{}' is in standby", config.getName());
        }
      } else {
        logger.debug("OpenWebIf receiver with name '{}' is off", config.getName());
      }
      return false;
    } catch (IOException ex) {
      throw new RuntimeException("OpenWebIf error for receiver with name '" + config.getName() + "': " + ex.getMessage(), ex);
    }
  }
View Full Code Here


    if (receiverName == null) {
      throw new ConfigurationException("openwebif", "Malformed receiver property '" + key
          + "', please check your openhab.cfg!");
    }

    OpenWebIfConfig rc = OpenWebIf.getConfigs().get(receiverName);
    if (rc == null) {
      rc = new OpenWebIfConfig();
      rc.setName(receiverName);
      OpenWebIf.getConfigs().put(receiverName, rc);
    }

    String keyId = StringUtils.substringAfterLast(key, ".");
    if (StringUtils.equalsIgnoreCase(keyId, "host")) {
      rc.setHost(value);
    } else if (StringUtils.equalsIgnoreCase(keyId, "port")) {
      rc.setPort(parseNumber(key, value).intValue());
    } else if (StringUtils.equalsIgnoreCase(keyId, "user")) {
      rc.setUser(value);
    } else if (StringUtils.equalsIgnoreCase(keyId, "password")) {
      rc.setPassword(value);
    } else if (StringUtils.equalsIgnoreCase(keyId, "https")) {
      rc.setHttps(Boolean.parseBoolean(value));
    } else {
      throw new ConfigurationException("openwebif", "Unknown configuration key '" + key
          + "', please check your openhab.cfg!");
    }
  }
View Full Code Here

TOP

Related Classes of org.openhab.action.openwebif.internal.impl.config.OpenWebIfConfig

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.