Package org.openhab.model.item.binding

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


   */
  protected OWServerBindingConfig parseInBindingConfig(Item item, String bindingConfig, OWServerBindingConfig config) throws BindingConfigParseException {
    Matcher matcher = IN_BINDING_PATTERN.matcher(bindingConfig);
   
    if (!matcher.matches()) {
      throw new BindingConfigParseException("bindingConfig '" + bindingConfig + "' doesn't represent a valid in-binding-configuration. A valid configuration is matched by the RegExp '"+IN_BINDING_PATTERN+"'");
    }
    matcher.reset();
       
    OWServerBindingConfigElement configElement;

View Full Code Here


    config.itemType = item.getClass();
   
    String[] configParts = bindingConfig.trim().split(":");

    if (configParts.length > 2) {
      throw new BindingConfigParseException(
          "IHC / ELKO LS binding must contain of max two two parts separated by ':'");
    }

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

      if (configParts.length == 1) {
        config.outBindingOnly = true;
        String resourceId = configParts[0].replace(">", "");

        if (resourceId.startsWith("0x")) {
          config.resourceId = Integer.parseInt(
              resourceId.replace("0x", ""), 16);
        } else {
          config.resourceId = Integer.parseInt(resourceId);
        }
       
      } else {
        throw new BindingConfigParseException(
            "When configuration start with '>', refresh interval is not supported ");
      }

    } else {
View Full Code Here

    if (!(item instanceof NumberItem || item instanceof SwitchItem
        || item instanceof ContactItem || item instanceof StringItem
        || item instanceof DateTimeItem || item instanceof DimmerItem
        || item instanceof RollershutterItem)) {
      throw new BindingConfigParseException(
          "Item '"
              + item.getName()
              + "' is of type '"
              + item.getClass().getSimpleName()
              + "', only NumberItems, SwitchItems, ContactItems, DateTimeItem, StringItem, DimmerItem or RollershutterItem are allowed - please check your *.items configuration");
View Full Code Here

        String datapointConfig = datapointConfigs[i].trim();
        KNXBindingConfigItem configItem = new KNXBindingConfigItem();
        configItem.itemName = item.getName();
       
        if (datapointConfig.split("<").length > 2) {
          throw new BindingConfigParseException("Only one readable GA allowed.");
        }

        Class<? extends Type> typeClass = item.getAcceptedCommandTypes().size() > 0 ?
            item.getAcceptedCommandTypes().get(i) : item.getAcceptedDataTypes().size() > 1 ?
                item.getAcceptedDataTypes().get(i) : item.getAcceptedDataTypes().get(0);
       
        String[] dataPoints = datapointConfig.split("\\+");
        for (int j = 0; j < dataPoints.length; ++j) {
          String dataPoint = dataPoints[j].trim();
         
          // If dataPoint is empty, we most likely have "pure" listening DP (+x/y/z).
          // Just skip it, it will be handle in the next iteration.
          if (dataPoint.isEmpty()) {
            continue;
          }
         
          // check for the readable flag
          boolean isReadable = false;
          if (dataPoint.startsWith("<")) {
            isReadable = true;
            dataPoint = dataPoint.substring(1);
          }
         
          // find the DPT for this entry
          String[] segments = dataPoint.split(":");
          String dptID = (segments.length == 1) ? getDefaultDPTId(typeClass) : segments[0];
          if (dptID == null || dptID.trim().isEmpty()) {
            throw new BindingConfigParseException(
              "No DPT could be determined for the type '"  + typeClass.getSimpleName() + "'.");
          }
          // check if this DPT is supported
          if (KNXCoreTypeMapper.toTypeClass(dptID) == null) {
            throw new BindingConfigParseException(
              "DPT " + dptID + " is not supported by the KNX binding.");
          }
       
          String ga = (segments.length == 1) ? segments[0].trim() : segments[1].trim();
         
          // create group address and datapoint
          GroupAddress groupAddress = new GroupAddress(ga);
          Datapoint dp;
          if (j != 0 || item.getAcceptedCommandTypes().size() == 0) {
            dp = new StateDP(groupAddress, item.getName(), 0, dptID);
          } else {
            dp = new CommandDP(groupAddress, item.getName(), 0, dptID);
          }
         
          // assign datapoint to configuration item
          if (configItem.mainDataPoint == null) {
            configItem.mainDataPoint = dp;
          }
          if (isReadable) {
            configItem.readableDataPoint = dp;
          }
          if(!configItem.allDataPoints.contains(dp)) {
            configItem.allDataPoints.add(dp);
          } else {
            throw new BindingConfigParseException(
                "Datapoint '"+dp.getDPT() + "' already exists for item '"+item.getName()+"'.");
          }
        }
       
        config.add(configItem);
       
      } catch (IndexOutOfBoundsException e) {
        throw new BindingConfigParseException(
          "No more than " + i  + " datapoint definitions are allowed for this item.");
      } catch (KNXFormatException e) {
        throw new BindingConfigParseException(e.getMessage());
      }
    }
    return config;
  }
View Full Code Here

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

   
    super.processBindingConfiguration(context, item, bindingConfig);
   
    String[] configParts = bindingConfig.trim().split(":");
    if (configParts.length > 3) {
      throw new BindingConfigParseException("NetworkHealth configuration can contain three parts at max");
    }
   
    NhBindingConfig config = new NhBindingConfig();
   
    item.getName();
View Full Code Here

    super.processBindingConfiguration(context, item, bindingConfig);

    String[] sections = bindingConfig.split(":");
   
    if (sections.length < 2 || sections.length > 4) {
      throw new BindingConfigParseException("Invalid number of sections in the binding: " + bindingConfig);
    }
   
    DSCAlarmDeviceType dscAlarmDeviceType = null;
    int partitionId = 0;
    int zoneId = 0;
    DSCAlarmItemType dscAlarmItemType = null;

    try{
      dscAlarmDeviceType = DSCAlarmDeviceType.getDSCAlarmDeviceType(sections[0]);
     
      switch(dscAlarmDeviceType) {
        case PANEL:
          dscAlarmItemType = DSCAlarmItemType.getDSCAlarmItemType(sections[1]);
          break;
        case PARTITION:
          partitionId = (int)Integer.parseInt(sections[1]);
          dscAlarmItemType = DSCAlarmItemType.getDSCAlarmItemType(sections[2]);
          break;
        case ZONE:
          partitionId = Integer.parseInt(sections[1]);
          zoneId = Integer.parseInt(sections[2]);
          dscAlarmItemType = DSCAlarmItemType.getDSCAlarmItemType(sections[3]);
          break;
        case KEYPAD:
          dscAlarmItemType = DSCAlarmItemType.getDSCAlarmItemType(sections[1]);
          break;
        default:
          logger.debug("Invalid Device Type in binding configuration: {}", dscAlarmDeviceType);
          break;
      }
   
    } catch (Exception e){
      throw new BindingConfigParseException("Binding Configuration Error: deviceType: " + dscAlarmDeviceType);
    }
   
    if(dscAlarmItemType == null) {
      logger.error("processBindingConfiguration(): {}: DSC Alarm Item Type is NULL! Item Not Added!",item.getName());
      return;
View Full Code Here

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

      String bindingConfig) throws BindingConfigParseException {
    super.processBindingConfiguration(context, item, bindingConfig);
    EKeyBindingConfig config = new EKeyBindingConfig();
   
    if(bindingConfig==null)
      throw new BindingConfigParseException(
          "Your binding configuration is illegal!\n"
              + "Possible values are: ACTION, USERNAME, USERID, TERMINALID, TERMINALNAME, "
              + "FINGERID, KEYID, INPUTID, RELAISID, MODE\nExample: {ekey=\"ACTION\"}");
   
    config.itemType = item.getClass();

    // format the passed config parameter
    String value = bindingConfig.trim().toUpperCase();

    try { // try to convert the parameter to one of the predefined enum
        // types
      config.interestedIn = EKeyBindingConfig.InterestType.getType(value);
    } catch (Exception e) { // throw exception - parameter was illegal
      throw new BindingConfigParseException(
          "eKey does not know the configuration value "
              + "'"
              + value
              + "' that you passed in the item binding configuration!\n"
              + "Possible values are: ACTION, USERNAME, USERID, TERMINALID, TERMINALNAME, "
View Full Code Here

  /**
   * @{inheritDoc}
   */
  public void validateItemType(Item item, String bindingConfig) throws BindingConfigParseException {
    if (!(item instanceof SwitchItem || item instanceof CallItem || item instanceof StringItem || item instanceof NumberItem)) {
      throw new BindingConfigParseException("item '" + item.getName()
          + "' is of type '" + item.getClass().getSimpleName()
          + "', only Switch- and CallItems are allowed - please check your *.items configuration");
    }
  }
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.