The plugins service offers the opposite functionality of the integrations service. While with integrations users can forward incoming data to third-party platforms, with plugins users can acquire data from third-party platforms. This is particularly useful in non-IP-based communications, like Satellite IoT or LoRaWAN (e.g., TheThings Network), where the messages are sent to other platforms. However, the functionality can also be used with any third-party platform that provides an API to collect the data.
Three different protocols are currently supported in the plugins service:
The basic principle of the plugins service is that the user defines a plugin for a third-party platform and a number of devices that use that plugin to acquire data from that platform. Each device must be configured to use that plugin during the device creation or can be updated later on. Each device needs to be mapped to an “External Device ID”, which is the device’s ID on the third-party platform. An example of a device configuration is shown in the following sections.
The basic flow of an end-to-end communication for a plugin scenario is the following:
Project viewers cannot create plugin rules, brokers, servers and/or decoders. Also, project editors cannot delete already created plugins entities. The relevant buttons are disabled.
Regardless of the selected communication protocol, each plugin needs to use a predefined decoder for the incoming messages. The role of the decoder is to parse the incoming message and transform it to the appropriate (i.e., SenML) format for the Console. The decoder can also transform the message contents if required. It is a JavaScript function that receives as input the payload and returns an object with two key-value pairs: the device id and the message in the SenML format, which is the supported format for the insigh.io platform. There are several predefined decoders that cover common scenarios:
For other scenarios, users can define a custom decoder:
The user interface allows users to edit the code and also test it by providing the expected input. If the evaluated output is the expected one, proceed with saving the decoder.
Decoders can be reused across multiple plugin rules, even for different rule types.
When defining an MQTT plugin, the service creates a MQTT client that subscribes to the configured broker and topic and listens for new messages. The plugin needs to use a decoder, as described previously and a broker, which is the broker to which the service will subscribe to listen for incoming messages. Users need to define the following information for the broker:
Then, the MQTT Rule can be created. The rule needs to have a name, a MQTT broker, a decoder and a topic to which the client will be subscribed:
MQTT plugins are particularly useful in LoRa scenarios, where the devices typically send data to a LoRa server via MQTT.
HTTP plugins support two ways to acquire device data, Receive and Poll.
This method is used when the third-party platforms support webhooks and can be configured to forward the data for a device to another platform via HTTP POST requests. An example of this scenario is Astrocast, where you can configure callbacks for a particular device. In this scenario, the plugins service listens to incoming HTTP POST requests at the predefined /api/v1/plugins endpoint. The only configuration required for a user is the message decoder. When the plugin is created, an Authentication Token is automatically created. This token must be provided in the HTTP POST message headers as “Authorization: < token >”. This needs to be configured on the third-party platform of course.
This method is used when third-party platforms do not support webhooks, but offer a REST API to poll the data via HTTP POST requests. Currently, only POST requests are supported, but GET requests will soon be supported too.
The basic principle is that we request data from an API every n hours (configurable) using a range field to filter the data. An important configuration for the polling method is that there needs to be a field that we can use so that we can filter the data that we request every time. In the current implementation, only date fields are allowed to filter data. In the future, this could be enhanced so that other types are also supported (e.g., IDs).
For the POST request, the user needs to specify:
The FTP plugin rules offer the option to acquire data from FTP servers. When creating a FTP plugin rule, the service polls the FTP server for files that satisfy the rule’s predefined criteria. The decoders used in the FTP plugins differ from the other plugin types because they operate on the file level and not on the message level, since each file may contain multiple measurements in different timestamps.
The FTP decoders accept a JavaScript object with the following properties:
After defining an FTP decoder, the user needs to create an FTP server. The required FTP server information is the following:
To test whether the provided information is correct, there is a “Test Connection” button in the upper right corner of the FTP Server card.
Finally, to create a new FTP plugin rule, the following information is required:
When a plugin is created, it can be used by a device so that incoming data is mapped on a particular device on the insigh.io platform. To configure a device to use a plugin, select “Alternative Data Source” and then select the appropriate plugin.
Then, the “External Device ID” needs to be provided. As described earlier, this is the ID of the device on the third-party platform and is called differently depending on the platform. For example, it is the Device GUID in Astrocast, the DevEUI on LoRaWAN, etc.
Once the device is created, insigh.io will start getting the data for this device using the configured plugin.