/** * Returns the variable provider of this unit like {@code generateVariablePool()}. Additionally this provider also contains variables related to the given service of this unit. * For this it's needed that this unit supports the given service. Additional to the {@code generateVariablePool()} this method further provides: * * BindingServiceConfig (if available) * * ServiceMetaConfig (if available) * * ServiceConfig (protobuf fields) * * @return a key - value pair pool providing all related variable of this unit including the service variables. * * @throws NotAvailableException is thrown if the variable pool is not available. */ default VariableProvider generateVariablePool(final ServiceConfig serviceConfig) throws NotAvailableException { final MetaConfigPool configPool = (MetaConfigPool) generateVariablePool(); if (serviceConfig.hasBindingConfig()) { configPool.register(new MetaConfigVariableProvider("BindingServiceConfig", serviceConfig.getBindingConfig().getMetaConfig())); } configPool.register(new MetaConfigVariableProvider("ServiceMetaConfig", serviceConfig.getMetaConfig())); configPool.register(new ProtobufVariableProvider(serviceConfig)); return configPool; }
public static String getItemName(final Service service, final ServiceConfigType.ServiceConfig serviceConfig) throws CouldNotPerformException { try { if (!serviceConfig.hasBindingConfig()) { throw new NotAvailableException("binding service config"); } if (!serviceConfig.getBindingConfig().hasMetaConfig()) { throw new NotAvailableException("binding service config meta config"); } MetaConfigVariableProvider metaConfigVariableProvider = new MetaConfigVariableProvider("BindingServiceConfig", serviceConfig.getBindingConfig().getMetaConfig()); return metaConfigVariableProvider.getValue(OPENHAB_BINDING_ITEM_ID); } catch (CouldNotPerformException ex) { throw new CouldNotPerformException("Could not generate item name!", ex); } } }