/** {@inheritDoc} */ @Override public void processBindingConfiguration(String context, Item item, String bindingConfig) throws BindingConfigParseException { super.processBindingConfiguration(context, item, bindingConfig); LgtvBindingConfig config = new LgtvBindingConfig(); config.itemType = item.getClass(); parseBindingConfig(bindingConfig, config); addBindingConfig(item, config); }
/** {@inheritDoc} */ @Override public void processBindingConfiguration(String context, Item item, String bindingConfig) throws BindingConfigParseException { logger.trace("Processing binding configuration for item {}", item.getName()); super.processBindingConfiguration(context, item, bindingConfig); SatelBindingConfig bc = this.createBindingConfig(bindingConfig); logger.trace("Adding binding configuration for item {}: {}", item.getName(), bc); addBindingConfig(item, bc); }
/** {@inheritDoc} */ @Override public void processBindingConfiguration(String context, Item item, String bindingConfig) throws BindingConfigParseException { super.processBindingConfiguration(context, item, bindingConfig); if (bindingConfig != null) { VDRBindingConfig config = parseBindingConfig(item, bindingConfig, null); addBindingConfig(item, config); } else { logger.warn("bindingConfig is NULL (item=" + item + ") -> processing bindingConfig aborted!"); } }
/** {@inheritDoc} */ @Override public void processBindingConfiguration(String context, Item item, String heatpumpCommand) throws BindingConfigParseException { super.processBindingConfiguration(context, item, heatpumpCommand); if (heatpumpCommand != null) { HeatPumpBindingConfig config = parseBindingConfig(item, HeatpumpCommandType.fromString(heatpumpCommand)); addBindingConfig(item, config); } else { logger.warn("bindingConfig is NULL (item={}) -> processing bindingConfig aborted!", item); } }
/** Item processing for the LCN bindings. {@inheritDoc} */ @Override public void processBindingConfiguration(String context, Item item, String bindingConfig) throws BindingConfigParseException { super.processBindingConfiguration(context, item, bindingConfig); Matcher matcher = PATTERN_BINDING_GENERAL.matcher(bindingConfig); if (!matcher.matches()) { throw new BindingConfigParseException(bindingConfig + "' contains no valid binding!"); } matcher.reset(); LcnBindingConfig bc = new LcnBindingConfig(item); while (matcher.find()) { String binding = matcher.group(1); if (binding != null && !binding.trim().isEmpty()) { String openHabCmd = null; String connId, lcnTarget; Matcher openHabMatcher = PATTERN_BINDING_WITH_OPENHAB.matcher(binding); Matcher pureMatcher = PATTERN_BINDING_PURE.matcher(binding); if (openHabMatcher.matches()) { openHabCmd = openHabMatcher.group(1); connId = openHabMatcher.group(2); lcnTarget = openHabMatcher.group(3); } else if (pureMatcher.matches()) { connId = pureMatcher.group(1); lcnTarget = pureMatcher.group(2); } else { throw new BindingConfigParseException( "Invalid binding configuration for " + binding + "!"); } String lcnShort = resolveMappings(lcnTarget, openHabCmd); if (lcnShort == null || lcnShort.equals(openHabCmd)) { lcnShort = lcnTarget; } Command cmd = openHabCmd == null ? TypeParser.parseCommand(new StringItem("").getAcceptedCommandTypes(), "") : openHabCmd.equals("%i") ? new StringType("%i") : TypeParser.parseCommand(item.getAcceptedCommandTypes(), openHabCmd); bc.add(new LcnBindingConfig.Mapping(cmd, connId, lcnShort)); } } // Finished this.addBindingConfig(item, bc); for (LcnAddrMod addr : bc.getRelatedModules()) { HashSet<String> l = this.itemNamesByModulCache.get(addr); if (l == null) { l = new HashSet<String>(); this.itemNamesByModulCache.put(addr, l); } l.add(item.getName()); } }
/** {@inheritDoc} */ @Override public void processBindingConfiguration(String context, Item item, String bindingConfig) throws BindingConfigParseException { super.processBindingConfiguration(context, item, bindingConfig); NibeHeatpumpBindingConfig config = new NibeHeatpumpBindingConfig(); String itemId = bindingConfig.trim(); if (itemId.startsWith("0x")) { config.itemId = Integer.parseInt(itemId.replace("0x", ""), 16); } else { config.itemId = Integer.parseInt(itemId); } addBindingConfig(item, config); }
/** {@inheritDoc} */ @Override public void processBindingConfiguration(String context, Item item, String bindingConfig) throws BindingConfigParseException { super.processBindingConfiguration(context, item, bindingConfig); HashMap<String, String> params = new HashMap<String, String>(); String[] parts = s_parseConfigString(item.getName(), bindingConfig, params); AlarmDecoderBindingConfig bc = null; if (parts[0].equals("SEND")) { // binding for sending commands if (!(parts.length == 2)) { throw new BindingConfigParseException("invalid SEND item config: " + bindingConfig); } bc = new AlarmDecoderBindingConfig(item, params); } else { // binding for receiving messages ADMsgType mt = ADMsgType.s_fromString(parts[0]); HashMap<String, ArrayList<AlarmDecoderBindingConfig>> addrToItemsMap = m_itemMap.get(mt.getValue()); ArrayList<AlarmDecoderBindingConfig> bcl = addrToItemsMap.get(parts[1]); if (bcl == null) { // don't have this address mapped to anything yet, start a new item list bcl = new ArrayList<AlarmDecoderBindingConfig>(); addrToItemsMap.put(parts[1], bcl); } else { // without this line a new binding configuration is entered whenever // the .items file is edited removeExisting(bcl, item); } bc = new AlarmDecoderBindingConfig(item, mt, parts[1], parts[2], params); bcl.add(bc); } addBindingConfig(item, bc); m_itemsToConfig.put(item.getName(), bc); logger.trace( "processing item \"{}\" read from .items file with cfg string {}", item.getName(), bindingConfig); }
/** {@inheritDoc} */ @Override public void processBindingConfiguration(String context, Item item, String bindingConfig) throws BindingConfigParseException { super.processBindingConfiguration(context, item, bindingConfig); // primitive parsing String[] confparts = bindingConfig.trim().split(";"); int id = -1; try { id = Integer.parseInt(confparts[0]); } catch (NumberFormatException e) { logger.debug( "Could not parse the id value from the items-file in processBindingConfiguration()!"); e.printStackTrace(); } String type = confparts[1]; String ip = confparts[2]; HexaBusBindingConfig config = null; try { config = new HexaBusBindingConfig(id, type, InetAddress.getByName(ip)); } catch (UnknownHostException e) { logger.debug( "Could not parse the device ip from the items-file in processBindingConfiguration()!"); e.printStackTrace(); return; } addBindingConfig(item, config); items.put(item.getName(), item); if (config.getPlugType().equals("plug+")) { logger.debug("BindProv ip string: " + config.getIP()); pullList.add(config.getIP()); } }
/** {@inheritDoc} */ @Override public void processBindingConfiguration(String context, Item item, String bindingConfig) throws BindingConfigParseException { super.processBindingConfiguration(context, item, bindingConfig); if (bindingConfig == null) { logger.debug("binding-configuration is currently not set for item: " + item.getName()); return; } logger.trace("handling config: {}", bindingConfig); List<String> calendar = new ArrayList<String>(); ; String type = null; Type typeEnum = null; String eventNr = null; String value = null; Value valueEnum = null; String[] splits = bindingConfig.split(" "); for (String split : splits) { logger.trace("handling config part: {}", split); Matcher mCalendar = Pattern.compile(REGEX_CALENDAR).matcher(split); if (mCalendar.matches()) { for (String str : mCalendar.group(1).split(",")) { calendar.add(str); } } Matcher mType = Pattern.compile(REGEX_TYPE).matcher(split); if (mType.matches()) { type = mType.group(1); } Matcher mEventNr = Pattern.compile(REGEX_EVENT_NR).matcher(split); if (mEventNr.matches()) { eventNr = mEventNr.group(1); } Matcher mValue = Pattern.compile(REGEX_VALUE).matcher(split); if (mValue.matches()) { value = mValue.group(1); } } logger.trace( "found values: calendar={}, type={}, eventNr={}, value={}", calendar, type, eventNr, value); if (calendar == null || calendar.size() == 0) { throw new BindingConfigParseException("missing attribute 'calendar'"); } if (type == null) { throw new BindingConfigParseException("missing attribute 'type'"); } try { typeEnum = CalDavConfig.Type.valueOf(type.toUpperCase()); } catch (IllegalArgumentException e) { throw new BindingConfigParseException("type '" + type + "' not valid"); } if (typeEnum != Type.PRESENCE) { if (eventNr == null) { throw new BindingConfigParseException("missing attribute 'eventNr'"); } if (value == null) { throw new BindingConfigParseException("missing attribute 'value'"); } if (!NumberUtils.isDigits(eventNr)) { throw new BindingConfigParseException("attribute 'eventNr' must be a valid integer"); } try { valueEnum = CalDavConfig.Value.valueOf(value.toUpperCase()); } catch (IllegalArgumentException e) { throw new BindingConfigParseException("value '" + type + "' not valid"); } } else { if (eventNr != null) { throw new BindingConfigParseException("not required attribute 'eventNr'"); } if (value != null) { throw new BindingConfigParseException("not required attribute 'value'"); } } logger.debug("adding item: {}", item.getName()); this.addBindingConfig( item, new CalDavConfig( calendar, typeEnum, NumberUtils.toInt(eventNr == null ? "0" : eventNr), valueEnum)); }
@Override public void removeConfigurations(String context) { super.removeConfigurations(context); }
/** {@inheritDoc} */ @Override public void processBindingConfiguration(String context, Item item, String bindingConfig) throws BindingConfigParseException { super.processBindingConfiguration(context, item, bindingConfig); addBindingConfig(item, parseBindingConfigString(context, item, bindingConfig)); }
/** {@inheritDoc} */ @Override public void processBindingConfiguration(String context, Item item, String bindingConfig) throws BindingConfigParseException { super.processBindingConfiguration(context, item, bindingConfig); if (bindingConfig != null) { HeatmiserBindingConfig config = new HeatmiserBindingConfig(); 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)); // Check the type for different functions switch (config.function) { case SETTEMP: case FROSTTEMP: case ROOMTEMP: case FLOORTEMP: if (config.itemType != NumberItem.class && config.itemType != StringItem.class) { logger.error( "Only Number and String allowed for Heatmiser:{} function", config.function); config = null; } break; case HOLDTIME: case HOLIDAYTIME: if (config.itemType != SwitchItem.class && config.itemType != DateTimeItem.class) { logger.error( "Only Switch and DateTime allowed for Heatmiser:{} function", config.function); config = null; } break; case HOLIDAYSET: if (config.itemType != SwitchItem.class && config.itemType != NumberItem.class) { logger.error( "Only Switch and Number allowed for Heatmiser:{} function", config.function); config = null; } break; case HOLDMODE: case HOLIDAYMODE: if (config.itemType != SwitchItem.class) { logger.error("Only Switch allowed for Heatmiser:{} function", config.function); config = null; } break; case WATERSTATE: case HEATSTATE: case STATE: case ONOFF: if (config.itemType != SwitchItem.class && config.itemType != StringItem.class) { logger.error( "Only Switch and String allowed for Heatmiser:{} function", config.function); config = null; } break; default: config = null; logger.error("Unknown or unsupported Heatmiser function: {}", bindingConfig); break; } } if (config != null) { addBindingConfig(item, config); } } else { logger.warn("bindingConfig is NULL (item=" + item + ") -> processing bindingConfig aborted!"); } }