Retrieve metadata of Kura components/drivers

71 Views Asked by At

I need a way to retrieve Kura compontents metadata. For instance, when you add a new component from the Kura web interface, you are prompted with a data form which has different fields according to the component you've added. Some of these fields are required and some are not, some of them require a value in a specific range and some are up to the user, etc. I would like to know if there is a Kura API that could give such data, like information about the data a component needs and what type of data. I was giving a look at the classes ComponentConfiguration and ConfigurationService but I didn't find anything useful. Is there a way to retrieve and get such data?

3

There are 3 best solutions below

0
On

Just share my understanding of Kura, FYI.

As we know, Kura is based on OSGi framework and provides some extra features like MQTT integration and friendly user interfaces, etc.

So, at its core, Kura shall be agnostic to user component's implementation, the interfaces like ComponentConfiguration and ConfigurationService are only helping Kura to compose user interfaces, but not designed to understand the configuration details.

In my opinion, Kura will not provide such APIs to describe the details of components' configuration, but you can write a component to read from your target components via above-mentioned interfaces and try to understand according to some beforehand knowledge.

0
On

Actually, there are three ways to obtain what you need in Kura 5.1.1:

  • API REST: there is a set of REST requests to manage the configuration in Kura. Specifically you could use getConfigurableComponentsConfigurations. It returns the configuration and the definition. Remember you need the rest.configuration permission assigned to the user you use.
  • Programmatically: when you are developing something to run in Kura framework, you can use the ConfigurationService you've already explored. With the method getComponentConfigurations you retrieve all the configurations and their definitions (OCD).
  • MQTT API: Kura provides an MQTT API to interact with an IoT Platform (preferably Eclipse Kapua) and through this API you can request the configuration with not only the data but also the definition of the configuration. It is intended to be used by a third party platform to provide a full configuration interface. Specifically, the request you need is Read all configurations.
0
On

If you implement an OSGi bundle that implements the ConfigurableComponent interface, then all the metatype data will be passed as a Map<String, Object> to the activation and updating hook methods. You can then extract the inserted value by specifying the key of the searched property.

In the Kura documentation you can find some examples.