How to use Storage Integration for device data?

I have an application with a LoRaWAN device and I want to use the storage integration to store the data. The storage integration is enabled by opening Integrations → Storage Integration → Enable and I can simulate live data which gets stored.

image

I can see the data by using the API, but the data from the device aren´t stored in the database.

How can I forward my device data into my database to store them?

Which API and which database are you referring to?

Data Storage you fetch the data, other integrations forward.

MQTT or WebHooks give you the maximum amount of information. MQTT you need an application running to listen for messages & process them. WebHooks you can write a web server script to receive the data & process them.

Data Storage you request the data for an application or just a device & process them.

Hi @descartes,

I´m referring to this database

image

I thought that the storage integration will store the data in my account and then I can access them as I wish.

And you can access it as you wish - not only is it all detailed in the documentation but there are even some sample web addresses being displayed on the console for you.

What do you mean when you say you can see your data by using the API?

How do you know the data is not being stored in the database?

If you can see your data, surely that means it is stored in the database!

Hi,

I use the following Python snipped to access the data:

import json
import requests

Application = "kampi-smartmetering"
APIKey = ""
Fields = "up.uplink_message.decoded_payload,up.uplink_message.frm_payload"
NumberOfRecords = 30
URL = "https://eu1.cloud.thethings.network/api/v3/as/applications/" + Application + "/packages/storage/uplink_message?order=-received_at&limit=" + str(NumberOfRecords) + "&field_mask=" + Fields
Header = { "Accept": "text/event-stream", "Authorization": "Bearer " + APIKey }

print("\n\nFetching from data storage...\n")

r = requests.get(URL, headers = Header)
JSON = "{\"data\": [" + r.text.replace("\n\n", ",")[:-1] + "]}";

print("URL: {}\n".format(r.url))
print("Status: {}\n".format(r.status_code))
print("Response: {}\n".format(r.text))
print("JSON: ")
print(json.dumps(json.loads(JSON), indent = 4))
print()

The script only returns the data which I have simulated (4 data points) over the Messaging tab

image

but not the data from the device over the last hours (18 messages).

Somewhat frustrating that you just didn’t start with this as that’s either my code or you are a miracle mind-reader!

My code is working. Your code is working with my application & key.

I don’t know how long is storing uplinks in Data Storage in v3. Can you trigger an uplink and then try?

Have you tried removing the limit just in case?

Hi,

removing limit doesn´t change something. My device is sending new data every hour. The simulated data are older than the last data from my device.
But I have configured a payload formatter in my device. May this formatter cause this issue?

If it is generating an issue I’d still expect the raw part of the payload to be stored.

I’d try removing the sort and the field filters, again, worth a try.

Then I’d try turning off the payload formatter, again just to see.

Yes it can. What happens if you reset to the default formatted?

I will check it.

Edit: I have checked it and it seems that the formatter was the issue. The data is stored correctly after I removed it.

1 Like