I've had a lot of success getting LoRa devices to talk to The Things Network (TTN) -> Maker Event -> IFTTT -> Adafruit IO. But, now that legacy TTN v.2 is read-only and new devices need to be added to the The Things Stack Community Edition, I need some advice.
Maker Event is not an option with The Things Stack, and I'm trying to integrate directly with Adafruit IO via Webhooks. I can write raw data and send notify messages (pings). Data from The Things Stack is not in the "value" key, so Adafruit IO is treating the /raw blob as plain text and not as usable data.
Has anyone had success integrating between Things Stack Community Edition and Adafruit IO?
I have setup a LoRa device with: QT Py, Seeeduino XIAO Expansion Board, SHT40, Grove - LoRa-E5, and a pair of DS18B20's.
It's talking to the The Things Stack Community Edition successfully, and I've set up a Webhooks integration....
I am able to configure to connect to Adafruit IO and send /raw and /notify (pings)...
(attachment limit reached, to be continued)
Trying to integrate with The Things Stack Community Edition
Moderators: adafruit_support_bill, adafruit
Forum rules
If you're posting code, please make sure your code does not include your Adafruit IO Active Key or WiFi network credentials.
If you're posting code, please make sure your code does not include your Adafruit IO Active Key or WiFi network credentials.
- adafruitguy
- Posts: 206
- Joined: Sat Jun 07, 2014 7:52 am
- adafruitguy
- Posts: 206
- Joined: Sat Jun 07, 2014 7:52 am
Re: Trying to integrate with The Things Stack Community Edit
On the Adafruit IO Side I have set up a Webhooks receiver....
It is successfully receiving pings and raw data....
But the data is not in the "value" key, so it's treated as a text blob. You can see my data fields in the blob (in green)....
Any hints would be greatly appreciated!
It is successfully receiving pings and raw data....
But the data is not in the "value" key, so it's treated as a text blob. You can see my data fields in the blob (in green)....
Any hints would be greatly appreciated!
- deneaux
- Posts: 2
- Joined: Sun Nov 13, 2016 9:09 am
Re: Trying to integrate with The Things Stack Community Edit
hi,
I have the exact same problem. Even if I have a "value"-field in the json-object, adafruit is still not showing me the value.
This is my payload-formatter on ttn but as I said, it is not working on the adafruit.io side, sadly.
Hope the will create a webhook template for ttn some day.
I have the exact same problem. Even if I have a "value"-field in the json-object, adafruit is still not showing me the value.
This is my payload-formatter on ttn but as I said, it is not working on the adafruit.io side, sadly.
Code: Select all
function decodeUplink(input) {
var sensorData = [];
var floatSize = 4 ;
var buffer = new ArrayBuffer(input.bytes.length);
var dataView = new DataView(buffer);
input.bytes.forEach(function (value, index){
dataView.setUint8(index,value);
});
//Convert the bytes back to float values
sensorData.push(dataView.getFloat32(0, true));
sensorData.push(dataView.getFloat32(4, true));
sensorData.push(dataView.getFloat32(8, true));
var data = {
//bytes: input.bytes,
//adafruit.io
//value: sensorData[0], <- also not working
value: { temp:sensorData[0], hum:sensorData[1] },
//thingsspeak
field1: sensorData[0],
field2: sensorData[1],
field3: sensorData[2]
}
return {
data: data,
warnings: [],
errors: []
};
}
- brubell
- Learn User Page
- Posts: 2017
- Joined: Fri Jul 17, 2015 10:33 pm
Re: Trying to integrate with The Things Stack Community Edit
Do you know if there is a default expected template for TTN payloads? I know TTN (on their side) has a formatter.
I'd like to assist in bridging these platforms.
I'd like to assist in bridging these platforms.
- jwcooper
- Posts: 1004
- Joined: Tue May 01, 2012 9:08 pm
Re: Trying to integrate with The Things Stack Community Edit
Here is our documentation on how to utilize the webhooks:
https://io.adafruit.com/api/docs/#webhooks
We currently don't offer any post processing of data as it comes in. That means we need it posted as the `value` field or you'll end up getting the json if you append the '/raw' flag. The json is useful if you want to post a lot of data to a single feed, then process it elsewhere. If you want to chart the data in IO or use it with triggers, it's definitely not as useful.
That won't work, as it's posting to multiple feeds on a single feeds' webhook. You would need to split that out to multiple webhook endpoints, and something like this:
All that being said, we do have ideas in the future that we would like to utilize for post-processing of data, but no timeline for release on that.
https://io.adafruit.com/api/docs/#webhooks
We currently don't offer any post processing of data as it comes in. That means we need it posted as the `value` field or you'll end up getting the json if you append the '/raw' flag. The json is useful if you want to post a lot of data to a single feed, then process it elsewhere. If you want to chart the data in IO or use it with triggers, it's definitely not as useful.
Code: Select all
value: { temp:sensorData[0], hum:sensorData[1] },
Code: Select all
{ value: sensorData[0] }
- adafruitguy
- Posts: 206
- Joined: Sat Jun 07, 2014 7:52 am
Re: Trying to integrate with The Things Stack Community Edit
I have successfully stitched together a rewrite of the JSON with Node-RED in the middle of my feeds....
The Things Stack Community Edition (mqtt) -> Node-RED -> Adafruit IO (Webhooks)
It's my first time using Node-RED, so it's not pretty. Essentially I have an mqtt feed from The Things Stack to Node-RED where I "Set", "Move", and "Delete" so the JSON looks more inline with what Adafruit IO is expecting, and then feed the output to an Adafruit IO Webhook....
After the re-write rules the JSON looks like this in Node-RED Debug Console...
After that it's fed to Adafruit IO via a Webhook and everything appears happy...
Now I need to explore cloud-delivered Node-RED services that don't cost a fortune.
The Things Stack Community Edition (mqtt) -> Node-RED -> Adafruit IO (Webhooks)
It's my first time using Node-RED, so it's not pretty. Essentially I have an mqtt feed from The Things Stack to Node-RED where I "Set", "Move", and "Delete" so the JSON looks more inline with what Adafruit IO is expecting, and then feed the output to an Adafruit IO Webhook....
After the re-write rules the JSON looks like this in Node-RED Debug Console...
After that it's fed to Adafruit IO via a Webhook and everything appears happy...
Now I need to explore cloud-delivered Node-RED services that don't cost a fortune.
- adafruitguy
- Posts: 206
- Joined: Sat Jun 07, 2014 7:52 am
Re: Trying to integrate with The Things Stack Community Edit
@brubell
The Things Network Community v3 sends along A LOT of data in the Uplink Messages. This includes: device, application, gateway, location, and LoRa performance data.
https://www.thethingsindustries.com/doc ... k-messages
TTN sends the "frame payload" (the bytes as transmitted on TTN) which only becomes useful when user decoded. And, there is a place for user defined (decoded) payload objects under: payload.uplink_message.decoded_payload.
Here are my personally decoded objects defined for my example app...
If the Webhooks integration allowed a simple mapping from my chosen names to "value" we'd likely be in business.
For example, if I wanted the Temperature in my Utility Room, I could map: payload.uplink_message.decoded_payload.tempUtilityRm to value to pass that feed. Of course that means a Webhook for each item in my app, but that's how Adafruit IO is already handling feeds today.
The Things Network Community v3 sends along A LOT of data in the Uplink Messages. This includes: device, application, gateway, location, and LoRa performance data.
https://www.thethingsindustries.com/doc ... k-messages
TTN sends the "frame payload" (the bytes as transmitted on TTN) which only becomes useful when user decoded. And, there is a place for user defined (decoded) payload objects under: payload.uplink_message.decoded_payload.
Here are my personally decoded objects defined for my example app...
If the Webhooks integration allowed a simple mapping from my chosen names to "value" we'd likely be in business.
For example, if I wanted the Temperature in my Utility Room, I could map: payload.uplink_message.decoded_payload.tempUtilityRm to value to pass that feed. Of course that means a Webhook for each item in my app, but that's how Adafruit IO is already handling feeds today.
- axelmagnus
- Posts: 24
- Joined: Thu Oct 20, 2016 5:20 pm
Re: Trying to integrate with The Things Stack Community Edit
YES please do! We are many who wants this bridging b/w TTN & AIO.brubell wrote:Do you know if there is a default expected template for TTN payloads? I know TTN (on their side) has a formatter.
I'd like to assist in bridging these platforms.
Forum rules
If you're posting code, please make sure your code does not include your Adafruit IO Active Key or WiFi network credentials.
If you're posting code, please make sure your code does not include your Adafruit IO Active Key or WiFi network credentials.