Skip to main content
All CollectionsUser Guides
Plugins: Integrate Golioth Output Streams with Ubidots
Plugins: Integrate Golioth Output Streams with Ubidots

Send data from Golioth LightDB Stream to Ubidots.

David Sepúlveda avatar
Written by David Sepúlveda
Updated over a month ago

The Golioth Plugin is a serverless function tailored to receive LightDB Stream Events from Golioth platform and upload them appropriately to Ubidots. All steps needed to set up devices and variables at Ubidots will be carried out by the plugin’s logic, so you don’t have to worry about those rudimentary things.

If all of the above reads well, follow this guide to start receiving Golioth LightDB Stream Events in Ubidots.

Requirements

1. Plugin setup

  1. Log in to your Ubidots account, click on Devices tab, then Plugins, then click on the + icon to create a new data plugin and search for the Golioth plugin.


    The plugin setup wizard will appear, click Next and select/fill the required parameters.
    Ubidots Token: Select the Ubidots token you would like to use for this plugin. It is recommended to create a new token dedicated to this plugin only, should you need to increase its rate limit in the future.
    LightDB Stream: Datastream location to use with this plugin. Let’s say you are doing something like the following in your code to send data to LightDB Stream:

    err = golioth_lightdb_set(client,
    GOLIOTH_LIGHTDB_STREAM_PATH("temp"),
    COAP_CONTENT_FORMAT_TEXT_PLAIN,
    str_temperature,
    strlen(str_temperature));


    The stream location in this case is temp, i.e. the string given as argument to GOLIOTH_LIGHTDB_STREAM_PATH() macro.
    Root-level stream: Set this if you are sending data to the root-level stream, i.e. you are using the GOLIOTH_LIGHTDB_STREAM_PATH() with an empty string (""). Activating this option will cause the LightDB Stream field to be ignored, despite this, it is still necessary to put something in it.
    Device Type: An Ubidots device type will be created and linked to this plugin. This allows you to make batch changes to all of the devices that receive data through this plugin.

  2. Click Next to finish the process. You will see the new plugin listed on the Plugins list. Click on the newly created plugin and navigate to the Decoder section on the left menu and grab from the HTTPs Endpoint URL field, the URL you will be using to setup the webhook in your Golioth Dashboard.

2. Output Stream setup

  1. Log in to Golioth Console and navigate to the Output Streams section on the left panel, then click on Create an Output Stream.

  2. Select Webhooks as the Output Stream Type.

  3. Give the Output Stream a name, select *DEVICE_STREAM_TYPE* as the Event Type Filter, set *HTTPs Endpoint URL* from previous section as the Webhook URI. Finally, add a header with key X-Auth-Token and value to your Ubidots.

  4. If Output Stream creation was successful, you will see a summary of the webhook configuration and its status as enabled.

3. Advanced usage

By default, the plugin expects to receive JSON payload as stated on the description of the DeviceStreamMessage event type on Golioth’s documentation:

{
"device_id": "612d3cecf3ee17d321adbec6",
"data": {
"temp": {
"temperature": 34
}
},
"timestamp": {
"nanos": 250818000,
"seconds": 1642796612
}
}

The device_id value will be used as the device label on Ubidots and timestamp will be rounded to milliseconds precision. Each key: value pair inside data object will be interpreted as variable_label: variable_value and will be sent as is to the device in your Ubidots account. If for some reason that does not meet your requirements, you can customize how received data is processed before it is sent to Ubidots by editing the Decoding Function code. For that, you can go to the plugin’s decode settings (see Section 1.3) and edit the function’s code to better suit your needs. The return value for that function should conform to the format stated here.

Did this answer your question?