Custom AddOn: Retrieve Configuration Settings in PaperUI Programmically

(Felix Lo) #1


I know how to retrieve configuration of a custom addon in /service/ folder. But, how do I retrieve those custom (i.e. custom UI) saved in PaperUI? My code to retrieve settings saved in xxxx.cfg are as below, which return a list of property map. Thanks

bundleContext = componentContext.getBundleContext();

            ConfigurationAdmin confAdmin = (ConfigurationAdmin) bundleContext
            Configuration conf;

            serviceId = componentContext.getProperties().get("").toString();
            conf = confAdmin.getConfiguration(serviceId, null);

(Felix Lo) #2

I have looked at OpenHabCloud connector and HabPanel examples, but couldn’t figure out why the configs are not passed to my code. Here are what I have extracted from OpenHabCloud and i also followed OSGI-INF file format as well. Please give me some pointers what I am missing. Cheers

Actual Java Code

 protected void activate(BundleContext context, Map<String, ?> config) {
        clientVersion = StringUtils.substringBefore(context.getBundle().getVersion().toString(), ".qualifier");
        localPort = HttpServiceUtil.getHttpServicePort(context);
        if (localPort == -1) {
            logger.warn("openHAB Cloud connector not started, since no local HTTP port could be determined");
        } else {
            logger.debug("openHAB Cloud connector activated");


<scr:component xmlns:scr="" activate="activate" configuration-policy="optional" deactivate="deactivate" immediate="true" name="org.openhab.openhabcloud">
   <implementation class=""/>
       <provide interface=""/>
       <provide interface="org.eclipse.smarthome.model.script.engine.action.ActionService"/>
   <reference bind="setItemRegistry" cardinality="1..1" interface="org.eclipse.smarthome.core.items.ItemRegistry" name="ItemRegistry" policy="dynamic" unbind="unsetItemRegistry"/>
   <reference bind="setEventPublisher" cardinality="0..1" interface="" name="EventPublisher" policy="dynamic" unbind="unsetEventPublisher"/>
   <property name="" type="String" value="org.openhab.openhabcloud"/>
   <property name="service.config.description.uri" type="String" value="io:openhabcloud"/>
   <property name="service.config.label" type="String" value="openHAB Cloud"/>
   <property name="service.config.category" type="String" value="io"/>