Package org.openhab.model.item.binding

Examples of org.openhab.model.item.binding.BindingConfigParseException


  protected void parseBindingConfig(String bindingConfig, AutoUpdateBindingConfig config) throws BindingConfigParseException {
    if (StringUtils.isNotBlank(bindingConfig)) {
      try {
        config.autoupdate = Boolean.valueOf(bindingConfig.trim());
      } catch (IllegalArgumentException iae) {
        throw new BindingConfigParseException("The given parameter '" + bindingConfig.trim() + "' has to be set to either 'true' or 'false'.");
      }
    }
  }
View Full Code Here


      if (elements.length == 2) {
        ConfigAdminBindingConfig config =
          new ConfigAdminBindingConfig(item, normalizePid(elements[0]), elements[1]);
        addBindingConfig(item, config);   
      } else {
        throw new BindingConfigParseException("BindingConfig string must contain two elements separated by ':'");
      }
    }
  }
View Full Code Here

  @Override
  public void validateItemType(Item item, String bindingConfig)
      throws BindingConfigParseException {
    if (!(item instanceof SwitchItem || item instanceof NumberItem || item instanceof StringItem || item instanceof DateTimeItem)) {
      throw new BindingConfigParseException("item '" + item.getName()
          + "' is of type '" + item.getClass().getSimpleName()
          + "', only Switch-, String and NumberItems are allowed - please check your *.items configuration");
    }   
  }
View Full Code Here

      Matcher actionMatcher = ACTION_CONFIG_PATTERN.matcher(bindingConfig);
      Matcher statusMatcher = STATUS_CONFIG_PATTERN.matcher(bindingConfig);

      if (!actionMatcher.matches() && !statusMatcher.matches()) {
        throw new BindingConfigParseException(
            "Plugwise binding configuration must consist of either three [config="
                + statusMatcher + "] or four parts [config="+actionMatcher+"]");
      } else
        if(actionMatcher.matches()) {
          commandAsString = actionMatcher.group(1);
          plugwiseID = actionMatcher.group(2);
          plugwiseCommand = actionMatcher.group(3);
          interval = Integer.valueOf(actionMatcher.group(4))
        } else if(statusMatcher.matches()){
          commandAsString = null;
          plugwiseID = statusMatcher.group(1);
          plugwiseCommand = statusMatcher.group(2);
          interval = Integer.valueOf(statusMatcher.group(3));
        }

        PlugwiseCommandType type = PlugwiseCommandType.getCommandType(plugwiseCommand)

        if(PlugwiseCommandType.validateBinding(type, item)) {

          PlugwiseBindingConfigElement newElement = new PlugwiseBindingConfigElement(plugwiseID,type,interval);

          Command command = null;
          if(commandAsString == null) {
            // for those configuration strings that are not really linked to a openHAB command we
            // create a dummy Command to be able to store the configuration information
            // I have choosen to do that with NumberItems
            NumberItem dummy = new NumberItem(Integer.toString(counter));
            command = createCommandFromString(dummy,Integer.toString(counter));
            counter++;
            config.put(command, newElement);           
          } else {
            command = createCommandFromString(item, commandAsString);
            config.put(command, newElement);
          }
        } else {
          String validItemType = PlugwiseCommandType.getValidItemTypes(plugwiseCommand);
          if (StringUtils.isEmpty(validItemType)) {
            throw new BindingConfigParseException("'" + bindingConfig
                + "' is no valid binding type");         
          } else {
            throw new BindingConfigParseException("'" + bindingConfig
                + "' is not bound to a valid item type. Valid item type(s): " + validItemType) ;
          }
        }
      }
    }
View Full Code Here

   
    Command command = TypeParser.parseCommand(
        item.getAcceptedCommandTypes(), commandAsString);

    if (command == null) {
      throw new BindingConfigParseException("couldn't create Command from '" + commandAsString + "' ");
    }

    return command;
  }
View Full Code Here

   */
  @Override
  public void validateItemType(Item item, String bindingConfig)
      throws BindingConfigParseException {
    if (!(item instanceof SwitchItem || item instanceof NumberItem || item instanceof StringItem)) {
      throw new BindingConfigParseException(
          "item '"
              + item.getName()
              + "' is of type '"
              + item.getClass().getSimpleName()
              + "', only SwitchItem, NumberItem and StringItem are allowed - please check your *.items configuration");
View Full Code Here

    config.itemType = item.getClass();

    if (bindingConfig.startsWith("<")) {

      if (configParts.length != 3) {
        throw new BindingConfigParseException(
            "Epson projector in binding must contain 3 parts separated by ':'");
      }

      config.outBinding = false;
      config.deviceID = configParts[0].trim().replace("<", "");
      parseRefreshPeriod(configParts[2], config);
     
    } else if (bindingConfig.startsWith(">")) {
     
      if (configParts.length != 2) {
        throw new BindingConfigParseException(
            "Epson projector out binding must contain 2 parts separated by ':'");
      }

      config.inBinding = false;
      config.deviceID = configParts[0].trim().replace(">", "");

    } else {
     
      if (configParts.length != 3) {
        throw new BindingConfigParseException(
            "Epson projector bi-directional binding must contain 3 parts separated by ':'");
      }

      config.deviceID = configParts[0].trim();
      parseRefreshPeriod(configParts[2], config);
View Full Code Here

    if (refreshPeriodString.trim().contains(",")) {
     
      String[] refreshIntervalParts = refreshPeriodString.trim().split(",");
     
      if (refreshIntervalParts.length != 2) {
        throw new BindingConfigParseException(
            "Epson projector refresh interval must contain 1-2 parts separated by ','");
      }
     
      if (refreshIntervalParts[0].trim().equals("ON")) {
        config.refreshInterval =  Integer.valueOf(refreshIntervalParts[1].trim());
View Full Code Here

      EpsonProjectorCommandType.validateBinding(commandTypeString, item.getClass());

      commandType = EpsonProjectorCommandType.getCommandType(commandTypeString);

    } catch (IllegalArgumentException e) {
      throw new BindingConfigParseException("Invalid command type '"
          + commandTypeString + "'!");

    } catch (InvalidClassException e) {
      throw new BindingConfigParseException(
          "Invalid item type for command type '" + commandTypeString
              + "'!");

    }
   
View Full Code Here

  private SqueezeboxBindingConfig parseBindingConfig(String bindingConfig) throws BindingConfigParseException {
    String[] configParts = bindingConfig.split(":");
   
    if (configParts.length < 2)
      throw new BindingConfigParseException("Squeezebox binding configuration must consist of two parts [config=" + configParts + "]");

    String playerId = StringUtils.trim(configParts[0]);

    String command = StringUtils.trim(configParts[1]);
    CommandType commandType = CommandType.fromString(command);
View Full Code Here

TOP

Related Classes of org.openhab.model.item.binding.BindingConfigParseException

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.