Closed Cinezaster closed 6 years ago
Hi @Cinezaster,
thanks for using the TTN integration! Could you paste an example of your payload_fields
object here?
Also, have you configured the HTTP Integration on the thethingsnetwork console?
In order to be understood by the openSenseMap, you have to use one of the json formats described here: https://docs.opensensemap.org/#api-Measurements-postNewMeasurements
I think it would be possible to just add the required fields to the payload_fields
in the decoder in the thingsnetwork console.
Ping @noerw
Indeed, the json
option needs to be added in the frontend, I will do so asap
Meanwhile you could set the json
decoding profile directly via the API, by sending a PUT request to https://api.opensensemap.org/boxes/<your-box-id>
.
This route requires authentication, via a JWT token that you obtain by calling https://api.opensensemap.org/users/login
first.
With curl
and jq
this would look like this:
OSEM_API=https://api.opensensemap.org
OSEM_BOX=YOURBOXID
OSEM_USER=YOUREMAIL
OSEM_PASS=YOURPASSWORD
TTN_DEVID=YOURDEV
TTN_APPID=YOURAPP
# login
OSEM_TOKEN=$(curl -H "content-type: application/json" $OSEM_API/users/sign-in -d '{"email":"'$OSEM_USER'","password":"'$OSEM_PASS'"}' | jq .token | tr -d '"')
# set TTN profile to json
curl -H "content-type: application/json" \
-H "Authorization: Bearer $OSEM_TOKEN" \
-XPUT $OSEM_API/boxes/$OSEM_BOX \
-d '{"ttn": { "profile": "json", "app_id": "'$TTN_APPID'", "dev_id": "'$TTN_DEVID'" } }'
hi @ubergesundheit
I tried something like this, no clue if this is correct or not.
[
{ "sensor_type": "SDS011", "sensor_title": "PM10", "payload_fields": "SDS_P1" },
{ "sensor_type": "SDS011", "sensor_title": "PM2.5", "payload_fields": "SDS_P2" }
]
And I did not configure a http integration. I thought osem would connect to the broker and uses my appId and deviceId to find the correct data. It makes sense, but is not clear from the documentation.
Thanks for helping
Currently the integration works as a HTTP webhook, so you need to configure the HTTP Integration in TTN to point to POST https://ttn.opensensemap.org/v1.1
.
Also, you need to make sure that your payload function results in a JSON format that is understood by the osem API, eg. something like this would work:
{"sensorid1": value1, "sensorid2": value2}
An advanced payload function using lora-serialization encoding on the node could look like this.
EDIT: it seems we are currently having issues with the the endpoint is working again!ttn.opensensemap.org
domain, I will post once that is resolved
I'm using the luftdaten Format:
{
"sensordatavalues": [
{
"value_type": "SDS_P1",
"value": "5.38"
},
{
"value_type": "SDS_P2",
"value": "4.98"
}
]
}
Sorry, this one only works through the traditional HTTP Rest endpoint via POST for now.
Ok. My decode function:
function Decoder(bytes, port) {
var decoded = {
"596cb2638ecc890010075e53" : ((bytes[2]*256)+bytes[3])/10,
"596cb2638ecc890010075e52" : ((bytes[0]*256)+bytes[1])/10
};
return decoded;
}
What should I add in my "Dekodierungsoptionen"?
Although this is not very manageable and future proof, to add sensorID's to my decode function. If I want to run 20 luftdaten sensors on Lora I can't add all the sensorID's to my application.
"Dekodierungsoptionen" (decode options) for the json
profile are ignored, as the decoding already happened on TTN side.
I agree on the lack of futureproofness. Currently the most robust way is to use the lora-serialization
profile & mapping the sensors via their name property, removing the need to explicitly specify the sensor IDs.
The plan for the next iteration of this integration is to also let the TTN application be managed by this integration, allowing an automated TTN setup just with one registration on openSenseMap. The concept is explained in #8.
https://github.com/sensebox/openSenseMap/commit/71f4339daef49a42ac22b8e199ee1fc3b4d82133 should be online soon
Still no data on the map:
Integration settings:
payload decoder:
openSenseMap configuration:
And in the ttn data console:
The only thing I don't know is the integration settings headers or authorization
Your configuration and payload function seem to be fine. There is no authorization header required.
We are receiving messages resulting in 404 errors, meaning that no box can be matched to the received dev_id
& app_id
. Are you sure that the values do match exactly in both openSenseMap and TTN configuration?
Got it it is not the EUI but the name I gave it in TTN (they call it the id)
I'm using the form on https://opensensemap.org/account/xxxxMY_BOX_IDxxxxxxx/edit/ttn The Decoding Profile only has
Since I decode my message in ttn I would like to use
payload_fields
. In that case I need the json decoding profile I already tried some configurations with the Lora serialization. But no data appears.I someone could explain me what I'm doing wrong.
I have a Lora version of the luftdaten.info sensor and the output is PM10 and PM2.5.