|
| 1 | +--- |
| 2 | +sidebar_position: 3 |
| 3 | +--- |
| 4 | + |
| 5 | +import AssetTypes from './_lorawan-asset-types.md'; |
| 6 | + |
| 7 | +# ChirpStack |
| 8 | + |
| 9 | +The ChirpStack agent allows integration of LoRaWAN devices managed by a [ChirpStack](https://www.chirpstack.io/) Network Server. |
| 10 | + |
| 11 | +## How It Works |
| 12 | + |
| 13 | +The ChirpStack agent acts as a bridge between OpenRemote and a **ChirpStack Network Server** by utilizing two primary communication channels: |
| 14 | + |
| 15 | +### Message Exchange (MQTT) |
| 16 | + |
| 17 | +The agent connects to the **ChirpStack MQTT integration** for real-time data flow: |
| 18 | +* **Uplink messages:** The agent subscribes to device events to receive sensor data. |
| 19 | +* **Downlink messages:** The agent publishes to command topics to send configuration or control packets back to the end-devices. |
| 20 | + |
| 21 | +### Device Management (gRPC API) |
| 22 | + |
| 23 | +The agent utilizes the **ChirpStack gRPC API** to interact with the Network Server's management layer. This is specifically used for: |
| 24 | +* **Auto-discovery:** The agent queries the API to list the **devices** registered in ChirpStack. |
| 25 | +* **Device Profiles:** For each discovered device, the agent retrieves its related **device profile**. This allows OpenRemote to understand the device type during the automatic asset creation process. |
| 26 | + |
| 27 | +## Agent configuration |
| 28 | + |
| 29 | +The following describes the supported agent configuration attributes: |
| 30 | + |
| 31 | +| Attribute | Description | Required | Default | |
| 32 | +|-----------------|-----------------------------------------------------------------------------------------------------------------|----------|--------------------------------------------------| |
| 33 | +| `MQTTHost` | The hostname or IP address of the ChirpStack MQTT broker. | Y | - | |
| 34 | +| `MQTTPort` | The network port for the MQTT connection. | Y | - | |
| 35 | +| `clientId` | The unique identifier for this agent's session on the MQTT broker. | Y | - | |
| 36 | +| `secureMode` | Boolean flag indicating if the MQTT connection should use TLS/SSL encryption. | N | false | |
| 37 | +| `resumeSession` | Boolean flag indicating if the MQTT broker should persist the session and queue messages during agent downtime. | N | false | |
| 38 | +| `subscribeQos` | MQTT Quality of Service level for receiving uplinks (0, 1, 2). | N | 0 | |
| 39 | +| `publishQos` | MQTT Quality of Service level for sending downlinks (0, 1, 2). | N | 0 | |
| 40 | +| `host` | The hostname or IP address of the ChirpStack gRPC API. | Y | - | |
| 41 | +| `port` | The network port for the ChirpStack gRPC API. | N | secureGRPC==true -> 443, secureGRPC==false -> 80 | |
| 42 | +| `applicationId` | The UUID of the ChirpStack application to be integrated. | Y | - | |
| 43 | +| `apiKey` | A ChirpStack API Key used to authenticate the gRPC connection. | Y | - | |
| 44 | +| `secureGRPC` | Boolean flag to enable gRPC TLS/SSL encryption. | N | false | |
| 45 | + |
| 46 | + |
| 47 | +**Example:** |
| 48 | + |
| 49 | +```yaml |
| 50 | +MQTTHost: 192.168.1.50 |
| 51 | +MQTTPort: 1883 |
| 52 | +clientId: or_chirpstack_agent_1 |
| 53 | +secureMode: false |
| 54 | +resumeSession: true |
| 55 | +host: 192.168.1.50 |
| 56 | +port: 8080 |
| 57 | +applicationId: 7d809e33-d2ad-4ef1-aac8-2be67501c4d3 |
| 58 | +apiKey: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhd... |
| 59 | +secureGRPC: false |
| 60 | +``` |
| 61 | +
|
| 62 | +## Device to Asset Mapping |
| 63 | +
|
| 64 | +To ensure the ChirpStack Agent can automatically create and configure assets, it must be able to map a ChirpStack device to a specific **OpenRemote Asset Type**. |
| 65 | +
|
| 66 | +### Auto-discovery Mapping (ChirpStack Tags) |
| 67 | +
|
| 68 | +For devices discovered via the gRPC API, the mapping is defined within the **ChirpStack Device Profile**. By adding a specific tag to the profile, you provide the agent with the Asset Type template required to create the asset in OpenRemote: |
| 69 | +
|
| 70 | +| Tag Key | Tag Value | |
| 71 | +| :--- | :--- | |
| 72 | +| `openremote-asset-type` | The exact name of the **OpenRemote Asset Type** (e.g., `WeatherStationAsset`). | |
| 73 | + |
| 74 | +During auto-discovery, the agent reads this tag and creates the corresponding asset in OpenRemote. |
| 75 | + |
| 76 | +### CSV Import Mapping |
| 77 | +When importing devices via a CSV file, the asset type is defined directly within the file. The CSV must include a column that specifies the **Asset Type name** for each device record. |
| 78 | + |
| 79 | +For a detailed breakdown of the required columns and an example file, see the [CSV Import Format](#csv-import-format) section below. |
| 80 | + |
| 81 | +## MQTT Agent Link Automation |
| 82 | + |
| 83 | +The ChirpStack agent handles the transmission of sensor data (**uplinks**) and commands (**downlinks**) via the **MQTT protocol**. To eliminate the need for manual configuration of every attribute, the agent automatically provisions these communication links during the discovery or import process. |
| 84 | + |
| 85 | +### Automatic Provisioning Logic |
| 86 | + |
| 87 | +Once a matching Asset Type template is identified, the agent configures the **MQTT Agent Links** based on the following workflow: |
| 88 | + |
| 89 | +1. **Meta item Lookup**: The agent scans the attributes of the selected Asset Type for a meta item named `AGENT_LINK_CONFIG`. For details on the format of this meta item, see [LoRaWAN Asset Types](#lorawan-asset-types). |
| 90 | +2. **Link Creation**: The agent uses the template defined in the meta item to generate the specific MQTT topics and data filters required for that individual device. |
| 91 | + |
| 92 | +### Attributes Configured |
| 93 | + |
| 94 | +The following attributes are automatically populated on the resulting agent links to handle the MQTT protocol logic: |
| 95 | + |
| 96 | +* **MQTT Specific**: `subscriptionTopic`, `publishTopic`. |
| 97 | +* **Generic Data Processing**: `valueFilters`, `messageMatchPredicate`, `messageMatchFilters`, `writeValue`, and `writeValueConverter`. |
| 98 | + |
| 99 | +## CSV Import Format |
| 100 | + |
| 101 | +Bulk provisioning allows you to create many assets at once. The agent processes each row to instantiate a new asset, using the specified `assetType` to identify which **template** to apply for automatic link configuration. |
| 102 | + |
| 103 | +### CSV Column Structure |
| 104 | + |
| 105 | +> **Note:** The CSV file must **not** contain a header row. The agent identifies the data based on the specific column order defined below. |
| 106 | + |
| 107 | +| Col | Required | Attribute | Description | |
| 108 | +| :--- |:---| :--- |:---| |
| 109 | +| 1 | **Y** | `devEUI` | The 16-character hexadecimal unique identifier.| |
| 110 | +| 2 | N | `deviceName` | The display name for the asset in OpenRemote.| |
| 111 | +| 3 | **Y** | `assetType` | The exact name of the **Asset Type template** (case-sensitive).| |
| 112 | +| 4 | N | `vendorId` | The manufacturer of the device.| |
| 113 | +| 5 | N | `modelId` | The specific hardware model identifier.| |
| 114 | +| 6 | N | `firmwareVersion` | The software version on the device.| |
| 115 | + |
| 116 | +### Example File Content |
| 117 | + |
| 118 | +```csv |
| 119 | +a84043d8d1842175,Dragino LHT65 1,DraginoLHT65Asset,dragino,lht65,1.8 |
| 120 | +a84043d8d1842176,Dragino LHT65 2,DraginoLHT65Asset,dragino,lht65,1.8 |
| 121 | +``` |
| 122 | + |
| 123 | +<AssetTypes /> |
| 124 | + |
| 125 | +### Reference Documentation |
| 126 | +* **[Agent Link Overview](overview.md)**: Deep dive into generic OpenRemote attributes like filters and predicates. |
0 commit comments