The Things Stack integration for DeviceChain
If your LoRaWAN devices report to The Things Stack, a custom webhook on the application can forward each uplink to DeviceChain. DeviceChain stores what your payload formatter produced, or what a payload decoder on the device profile decodes, as ordinary measurements, so the readings reach history, live state, dashboards and rules like any other. The device never connects to DeviceChain.
- Read None
- Write None
- Subscribe Partial
How it is wired
You create an integration in the console with the sender type The Things Stack v3, choose whether devices are matched by DevEUI or by device id, scope it to device types, and copy its bearer token. The token is generated by the server, shown once, and stored only as a keyed digest.
In The Things Stack you add a custom webhook with the JSON format, set its base URL to the integration's URL, send the token in an Authorization header, and enable the uplink message event with the path /uplink-message. The platform also reads the paths /up, /uplink and /uplinks.
What the platform reads
Without a payload decoder on the device's profile, the platform stores the formatter's output, so set a payload formatter on the application or on the device; the LoRaWAN Device Repository offers one for many sensors. Without either, the uplink is counted as undecoded instead of stored. With a payload decoder on the profile, DeviceChain decodes the frame itself.
When confirmed downlinks are in use, the downlink_ack, downlink_nack, downlink_sent and downlink_failed events are read too; enable them on the webhook with paths that start with downlink. A message posted to any other path, such as a join accept, is answered with 204 and ignored. The message time is the uplink's received_at, which must be present and not older than 366 days.
Matching devices
Add each device in DeviceChain with its DevEUI as a lorawan.deveui alias, or with its device id as a tts.device-id alias if you chose to match by device id. A device outside the integration's scope, or no device at all, means the message is not stored.
Commands
When the operator switches LoRaWAN downlink on, a published lorawan_downlink connector names the Things Stack application, and a command to a device with a tts.device-id alias is queued there as a downlink. Its parameters are the raw port and payload, or typed values that an encoder on the command definition turns into bytes.
An unconfirmed downlink succeeds when the network server queues it, which is not an acknowledgement from the device. A confirmed downlink waits for the device to acknowledge it; an uncertain failure, or no answer by its deadline, leaves the outcome unknown.
Trust
The bearer token speaks for every device of the scoped types that has an alias for it, and there is no payload signature, so use TLS, scope the integration narrowly and rotate the token if it may have been exposed.
What it does not do.
- LoRaWAN downlink is off unless the operator switches it on. Until then, a command to a device that last reported through an integration fails, with COMMAND_TRANSPORT_UNSUPPORTED, instead of waiting until it expires.
- Join, status and location messages are acknowledged and ignored.
- Only numbers and booleans become readings; strings and nulls in the decoded object are skipped. A message that arrives while the tenant is over its ingest allowance is answered with 202 and not stored, which is why the matrix marks subscribe as partial.
Inbound integrations: The Things Stack v3 → · Transport matrix → · All integrations →