# 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="https://3109056034-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfQfo4zX1x0hfOimS9E2u%2Fuploads%2F9yH7JhKrFngfkHZUFdxD%2FCleanShot%202025-03-01%20at%2021.31.39%402x.png?alt=media&#x26;token=bc9bd114-cc1b-4d47-a149-4a788a93651d" 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>
