# LoRaWAN Device Template Decoder

### Overview

The **LoRaWAN Device Template Decoder** allows you to **automatically decode payloads** from supported LoRaWAN devices using predefined templates. This ensures that incoming data is correctly structured without requiring custom decoding logic.

### How It Works

{% @mermaid/diagram content="graph LR;
A\[LoRaWAN Device Sends Data] --> B{Decoder Available?};

B -- No --> C{If Incoming Payload is Valid JSON?};
C -- Yes --> D\[Store JSON Data in Qubitro];
C -- No --> E\[Requires a Decoder Function];

B -- Yes --> F\[Apply Predefined Template];
F --> G\[Store Decoded Data in Qubitro];

%% Style Adjustments
style A fill:#d9d9d9,stroke:#000,color:#000;
style B fill:#f2f2f2,stroke:#000,color:#000;
style C fill:#f2f2f2,stroke:#000,color:#000;
style F fill:#e0e0e0,stroke:#000,color:#000;
style G fill:#e0e0e0,stroke:#000,color:#000;" %}

{% hint style="warning" %}
If a [Transformation Function](https://qubitro.gitbook.io/qubitro-documentation/platform/functions/transformation-function) is enabled, data will be processed before storage. The decoder applies first, and then any defined transformation function modifies the data before it is stored in Qubitro.
{% endhint %}

### Creating a LoRaWAN Device Decoder Function Template

You can create a new function by navigating to the **device details page**, selecting the **Functions** tab, and clicking on **Create function**, then choosing **Decoder Function** from the list.

{% stepper %}
{% step %}
**Select the Device Template**

1. Open the **device details page** in the **Qubitro Portal**.
2. Click the **Functions** tab.
3. Click **Create function** and select **Decoder Function**.
4. Choose **LoRaWAN Device Template** as the **formatter type**.
5. Use the search bar to find the **manufacturer** and **model** of your device.

<figure><img src="/files/DpqpBhxj3W4Y2nEuwIPA" alt="" width="563"><figcaption></figcaption></figure>

{% hint style="success" %}
The formatter code **can** be customized before saving to fit your needs (e.g., data keys can be changed).
{% endhint %}
{% endstep %}

{% step %}
**Save and Apply the Template**

1. Click **Save and complete** to apply the device template.
2. The **decoder function** will now process incoming data automatically.

{% hint style="warning" %}
When a function is created using this template, the device information, including **brand, model, and avatar**, is updated.
{% endhint %}
{% endstep %}
{% endstepper %}

### FAQs

<details>

<summary>I created the integration and see the device is listed but I don't see data. How can I understand that?</summary>

If your device is listed but no data appears, **check the device details page**. If the integration is successful but a **decoder function is missing**, you will see a warning message prompting you to create a function. Without a decoder, raw binary data cannot be processed into readable JSON.<br>

</details>

<details>

<summary>I don't see my devices listed, can Qubitro help me?</summary>

Absolutely! If your devices are not appearing after setting up the integration, please **open a ticket** from the Support Page and our team will assist you.

</details>

<details>

<summary>Can a decoder function work with any LNS provider?</summary>

Yes! Qubitro's decoder functions are **compatible with any LNS provider**, including **Loriot, The Things Stack, and others**. As long as the device is sending data, the decoder function can process and store it.

</details>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.qubitro.com/platform/functions/decoder-function/lorawan-device-template-decoder.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
