Package org.openhab.model.item.binding

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


    String bindingConfigTail =
      StringUtils.substringAfter(bindingConfigs, ",");

    String[] configParts = bindingConfig.split(":");
    if (configParts.length != 3) {
      throw new BindingConfigParseException("MPD binding configuration must consist of three parts [config=" + configParts + "]");
    }

    String command = StringUtils.trim(configParts[0]);
    String playerId = StringUtils.trim(configParts[1]);
    String playerCommand = StringUtils.trim(configParts[2]);
View Full Code Here


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

    EHealthSensorPropertyName propertyName;
    try {
      propertyName = EHealthSensorPropertyName.getPropertyName(bindingConfig.trim());
    } catch (Exception e) {
      throw new BindingConfigParseException("Invalid sensor property name '" + bindingConfig + "' > please fix your *.items accordingly!");
    }
   
    config.itemType = item.getClass();
    config.sensorPropertyName = propertyName;

View Full Code Here

        ",");

    String[] configParts = bindingConfig.trim().split(":");

    if (configParts.length != 2) {
      throw new BindingConfigParseException(
          "JointSpace binding must contain two parts separated by ':', e.g. <command>:<tvcommand>");
    }

    String command = StringUtils.trim(configParts[0]);
    String tvCommand = StringUtils.trim(configParts[1]);
View Full Code Here

      config.itemType = item.getClass();

      Matcher bindingMatcher = BINDING_PATTERN.matcher(bindingConfig);

      if (!bindingMatcher.matches()) {
        throw new BindingConfigParseException(getBindingType()+
            " binding configuration must consist of two parts [config="+bindingMatcher+"]");
      } else {
        config.address = Integer.parseInt(bindingMatcher.group(1));
        config.function = Functions.valueOf(bindingMatcher.group(2));
View Full Code Here

    HomematicBindingConfigHelper helper = new HomematicBindingConfigHelper();

    for (String entry : entries) {
      String[] entryParts = StringUtils.trimToEmpty(entry).split("[=]");
      if (entryParts.length != 2) {
        throw new BindingConfigParseException("Each entry must have a key and a value");
      }

      String key = StringUtils.trim(entryParts[0]);

      // convert entry id to device if necessary
      if ("id".equalsIgnoreCase(key)) {
        logger.info("Please change the Homematic binding with the attribute 'id' to 'address' in entry: "
            + entry + " -> " + StringUtils.replace(entry, "id=", "address="));
        key = "address";
      }
      String value = StringUtils.trim(entryParts[1]);
      value = StringUtils.removeStart(value, "\"");
      value = StringUtils.removeEnd(value, "\"");

      try {
        helper.getClass().getDeclaredField(key).set(helper, value);
      } catch (Exception e) {
        throw new BindingConfigParseException("Could not set value " + value + " for attribute " + key);
      }
    }

    Converter<?> converter = null;
    // if (helper.isValidDatapoint() || helper.isValidVariable()) {
    // converter = instantiateConverter(helper.converter);
    // }

    BindingAction bindingAction = getBindingAction(item, helper.action);

    if (helper.isValidDatapoint()) {
      return new DatapointConfig(helper.address, helper.channel, helper.parameter, converter, bindingAction,
          helper.isForceUpdate());
    } else if (helper.isValidVariable()) {
      return new VariableConfig(helper.variable, converter, bindingAction, helper.isForceUpdate());
    } else if (helper.isValidProgram()) {
      if (!acceptsOnOffType(item)) {
        throw new BindingConfigParseException(
            "Programs can only be attached to items which accepts OnOffType commands, ignoring item "
                + item.getName());
      }
      return new ProgramConfig(helper.program, bindingAction);
    } else if (bindingAction != null) {
      return new ActionConfig(bindingAction);
    } else {
      throw new BindingConfigParseException("Invalid binding: " + bindingConfig);
    }
  }
View Full Code Here

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

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

   * {@inheritDoc}
   */
  @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 Switch/String/NumberItems are allowed - please check your *.items configuration");
    }
  }
View Full Code Here

    if (bindingConfig == null || bindingConfig.trim().isEmpty())
      return; // empty binding - nothing to do

    final String[] segments = bindingConfig.trim().split(":");
    if (segments.length != 2)
      throw new BindingConfigParseException("Invalid binding format '" + bindingConfig
          + "', expected: '<anelId>:<property>'");

    final String deviceId = segments[0];
    final String commandType = segments[1];
    try {
      AnelCommandType.validateBinding(commandType, item.getClass());
      final AnelCommandType cmdType = AnelCommandType.getCommandType(commandType);

      // if command type was validated successfully, add binding config
      addBindingConfig(item, new AnelBindingConfig(item.getClass(), cmdType, deviceId));
    } catch (IllegalArgumentException e) {
      throw new BindingConfigParseException("'" + commandType + "' is not a valid Anel property");
    } catch (InvalidClassException e) {
      throw new BindingConfigParseException("Invalid class for Anel property '" + commandType + "'");
    }
  }
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.