Plugin file
Plugin configuration file
{
"name": "dragino_lgt92",
"version": "1.0.0",
"description": "The Dragino LGT-92 LoRaWAN® GPS Tracker includes a low-power GPS module for location tracking and a 9-axis accelerometer for motion detection. The captured data is sent to a LoRaWAN network for analysis.",
"author": "Thinger.io",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/thinger-io/plugins.git",
"directory": "dragino-lgt92"
},
"metadata": {
"name": "Dragino LGT92",
"description": "The Dragino LGT-92 LoRaWAN® GPS Tracker includes a low-power GPS module for location tracking and a 9-axis accelerometer for motion detection. The captured data is sent to a LoRaWAN network for analysis.",
"image": "assets/lgt92.png",
"category": "devices",
"vendor": "dragino"
},
"resources": {
"products": [
{
"description": "The Dragino LGT-92 LoRaWAN® GPS Tracker includes a low-power GPS module for location tracking and a 9-axis accelerometer for motion detection. The captured data is sent to a LoRaWAN network for analysis.",
"enabled": true,
"name": "Dragino LGT92",
"product": "dragino_lgt92",
"profile": {
"api": {
"downlink": {
"enabled": true,
"handle_connectivity": false,
"request": {
"data": {
"path": "/downlink",
"payload": "{\r\n \"data\" : \"{{payload.data=\"\"}}\",\r\n \"port\" : {{payload.port=2}},\r\n \"priority\": {{payload.priority=3}},\r\n \"confirmed\" : {{payload.confirmed=false}},\r\n \"uplink\" : {{property.uplink}} \r\n}",
"payload_function": "",
"payload_type": "",
"plugin": "{{property.uplink.source}}",
"target": "plugin_endpoint"
}
}
},
"uplink": {
"enabled": true,
"handle_connectivity": true,
"request": {
"data": {
"payload": "{{payload}}",
"payload_function": "",
"payload_type": "source_payload",
"resource_stream": "uplink",
"target": "resource_stream"
}
}
}
},
"autoprovisions": {
"device_autoprovisioning": {
"config": {
"mode": "pattern",
"pattern": "lgt92_.*"
},
"enabled": true
}
},
"buckets": {
"dragino_lgt92_data": {
"backend": "mongodb",
"data": {
"payload": "{{payload}}",
"payload_function": "",
"payload_type": "source_payload",
"resource": "uplink_decoded",
"source": "resource",
"update": "events"
},
"enabled": true,
"retention": {
"period": 3,
"unit": "months"
},
"tags": []
}
},
"code": {
"code": "function decodeThingerUplink(thingerData) {\n // 0. If data has already been decoded, we will return it\n if (thingerData.decodedPayload) return thingerData.decodedPayload;\n \n // 1. Extract and Validate Input\n // We need 'payload' (hex string) and 'fPort' (integer)\n const hexPayload = thingerData.payload || \"\";\n const port = thingerData.fPort || 1;\n\n // 2. Convert Hex String to Byte Array\n const bytes = [];\n for (let i = 0; i < hexPayload.length; i += 2) {\n bytes.push(parseInt(hexPayload.substr(i, 2), 16));\n }\n\n // 3. Dynamic Function Detection and Execution\n \n // CASE A: (The Things Stack v3)\n if (typeof decodeUplink === 'function') {\n try {\n const input = {\n bytes: bytes,\n fPort: port\n };\n var result = decodeUplink(input);\n \n if (result.data) return result.data;\n\n return result; \n } catch (e) {\n console.error(\"Error inside decodeUplink:\", e);\n throw e;\n }\n }\n\n // CASE B: Legacy TTN (v2)\n else if (typeof Decoder === 'function') {\n try {\n return Decoder(bytes, port);\n } catch (e) {\n console.error(\"Error inside Decoder:\", e);\n throw e;\n }\n }\n\n // CASE C: No decoder found\n else {\n throw new Error(\"No compatible TTN decoder function (decodeUplink or Decoder) found in scope.\");\n }\n}\n\n\n// TTN decoder\nvar movement = ['Disable', 'Move', 'Collide', 'User'];\n\nfunction decodeUplink(input) {\n if (input.fPort != 2) {\n return {\n errors: ['unknown FPort'],\n };\n }\n var bytes = input.bytes;\n var warnings = [];\n var data = {\n latitude: ((bytes[0] << 24) | (bytes[1] << 16) | (bytes[2] << 8) | bytes[3]) / 1000000,\n longitude: ((bytes[4] << 24) | (bytes[5] << 16) | (bytes[6] << 8) | bytes[7]) / 1000000,\n ALARM_status: !!(bytes[8] & (1 << 6)),\n BatV: (((bytes[8] & 0x3f) << 8) | bytes[9]) / 1000,\n MD: movement[bytes[10] >> 6],\n LON: !!(bytes[10] & (1 << 5)),\n FW: 160 + (bytes[10] & 0x1f), // NB: 1.5 firmware uses an offset of 150 ...\n };\n\n // i.e. latitude/longitude are set to 0x0fffffff which decodes to 268.xxx\n if (data.BatV <= 2.84 && data.latitude > 268 && data.longitude > 268) {\n delete data.latitude;\n delete data.longitude;\n warnings.push('GPS turned off because of low battery');\n } else if (data.latitude == 0 && data.longitude == 0) {\n delete data.latitude;\n delete data.longitude;\n warnings.push('GPS failed to obtain location');\n }\n\n switch (bytes.length) {\n case 18: // GW verison 1.6\n data.hdop = bytes[15] / 100;\n data.altitude = (((bytes[16] << 24) >> 16) | bytes[17]) / 100;\n // fall-through\n case 15: // FW version 1.5\n data.Roll = (((bytes[11] << 24) >> 16) | bytes[12]) / 100;\n data.Pitch = (((bytes[13] << 24) >> 16) | bytes[14]) / 100;\n break;\n }\n\n if (warnings.length > 0) return { data: data, warnings: warnings };\n else return { data: data };\n}\n",
"environment": "javascript",
"storage": "",
"version": "1.0"
},
"flows": {
"dragino_lgt92_decoder": {
"data": {
"payload": "{{payload}}",
"payload_function": "decodeThingerUplink",
"payload_type": "source_payload",
"resource": "uplink",
"source": "resource",
"update": "events"
},
"enabled": true,
"sink": {
"payload": "{{payload}}",
"payload_function": "",
"payload_type": "source_payload",
"resource_stream": "uplink_decoded",
"target": "resource_stream"
},
"split_data": false
}
},
"properties": {
"uplink": {
"data": {
"payload": "{{payload}}",
"payload_function": "",
"payload_type": "source_payload",
"resource": "uplink",
"source": "resource",
"update": "events"
},
"default": {
"source": "value"
},
"enabled": true
}
}
},
"_resources": {
"properties": [
{
"property": "dashboard",
"value": {
"tabs": [
{
"name": "LGT92 - GPS Tracker",
"widgets": [
{
"layout": {
"col": 0,
"row": 0,
"sizeX": 4,
"sizeY": 12
},
"panel": {
"color": "#ffffff",
"currentColor": "#ffffff",
"showOffline": {
"type": "none"
},
"title": "GPS Location"
},
"properties": {
"center": {
"latitude": 40.4168,
"longitude": -3.7038
},
"zoom": 12
},
"sources": [
{
"bucket": {
"backend": "mongodb",
"id": "dragino_lgt92_data",
"mapping": "latitude,longitude",
"tags": {
"device": [],
"group": []
}
},
"color": "#e74c3c",
"name": "GPS Position",
"source": "bucket",
"timespan": {
"magnitude": "hour",
"mode": "relative",
"period": "latest",
"value": 24
}
}
],
"type": "map"
},
{
"layout": {
"col": 4,
"row": 0,
"sizeX": 2,
"sizeY": 5
},
"panel": {
"color": "#ffffff",
"currentColor": "#ffffff",
"showOffline": {
"type": "none"
},
"title": "Battery Voltage"
},
"properties": {
"color": "#27ae60",
"gradient": false,
"icon": "fas fa-battery-full",
"iconColor": "#27ae60",
"iconSize": "",
"majorTicks": 10,
"max": 4.2,
"min": 2.5,
"plateColor": "#ffffff",
"showValue": true,
"textColor": "#1E313E",
"tickColor": "#000000",
"unit": "V"
},
"sources": [
{
"bucket": {
"backend": "mongodb",
"id": "dragino_lgt92_data",
"mapping": "BatV",
"tags": {
"device": [],
"group": []
}
},
"color": "#27ae60",
"name": "Battery",
"source": "bucket",
"timespan": {
"mode": "latest"
}
}
],
"type": "gauge"
},
{
"layout": {
"col": 4,
"row": 5,
"sizeX": 1,
"sizeY": 3
},
"panel": {
"color": "#ffffff",
"currentColor": "#ffffff",
"showOffline": {
"type": "none"
},
"title": "Movement Status"
},
"properties": {
"decimalPlaces": 2,
"enableExtraTextColor": false,
"enableIconColor": true,
"enableIconSize": true,
"extraText": "",
"extraTextColor": "#1E313E",
"extraTextColorConditions": [],
"extraTextPosition": "above-value",
"extraTextSize": "20px",
"extraTextWeight": "font-light",
"icon": "fas fa-running",
"iconColor": "#1E313E",
"iconColorConditions": [],
"iconGap": "8px",
"iconPosition": "before-value",
"iconSize": "50px",
"iconVerticalOffset": "0px",
"link": "",
"textAlign": "center",
"textColor": "#1E313E",
"textColorConditions": [
{
"color": "#e74c3c",
"operator": "eq",
"value": "Move"
},
{
"color": "#e67e22",
"operator": "eq",
"value": "Collide"
},
{
"color": "#3498db",
"operator": "eq",
"value": "User"
},
{
"color": "#95a5a6",
"operator": "eq",
"value": "Disable"
}
],
"textSize": "30px",
"textWeight": "font-bold",
"unit": "",
"unitSize": "20px"
},
"sources": [
{
"bucket": {
"backend": "mongodb",
"id": "dragino_lgt92_data",
"mapping": "MD",
"tags": {
"device": [],
"group": []
}
},
"color": "#3498db",
"name": "Movement",
"source": "bucket",
"timespan": {
"mode": "latest"
}
}
],
"type": "text"
},
{
"layout": {
"col": 5,
"row": 5,
"sizeX": 1,
"sizeY": 3
},
"panel": {
"color": "#ffffff",
"currentColor": "#ffffff",
"showOffline": {
"type": "none"
},
"title": "Alarm Status"
},
"properties": {
"color": "#95a5a6",
"colorCondition": {
"conditions": [
{
"color": "#e74c3c",
"operator": "eq",
"value": true
},
{
"color": "#27ae60",
"operator": "eq",
"value": false
}
],
"enabled": true
},
"size": "75px"
},
"sources": [
{
"bucket": {
"backend": "mongodb",
"id": "dragino_lgt92_data",
"mapping": "ALARM_status",
"tags": {
"device": [],
"group": []
}
},
"color": "#e74c3c",
"name": "Alarm",
"source": "bucket",
"timespan": {
"mode": "latest"
}
}
],
"type": "led"
},
{
"layout": {
"col": 4,
"row": 8,
"sizeX": 1,
"sizeY": 4
},
"panel": {
"color": "#ffffff",
"currentColor": "#ffffff",
"showOffline": {
"type": "none"
},
"title": "Roll (°)"
},
"properties": {
"color": "#9b59b6",
"max": 180,
"min": -180,
"unit": "°"
},
"sources": [
{
"bucket": {
"backend": "mongodb",
"id": "dragino_lgt92_data",
"mapping": "Roll",
"tags": {
"device": [],
"group": []
}
},
"color": "#9b59b6",
"name": "Roll",
"source": "bucket",
"timespan": {
"mode": "latest"
}
}
],
"type": "donutchart"
},
{
"layout": {
"col": 5,
"row": 8,
"sizeX": 1,
"sizeY": 4
},
"panel": {
"color": "#ffffff",
"currentColor": "#ffffff",
"showOffline": {
"type": "none"
},
"title": "Pitch (°)"
},
"properties": {
"color": "#3498db",
"max": 90,
"min": -90,
"unit": "°"
},
"sources": [
{
"bucket": {
"backend": "mongodb",
"id": "dragino_lgt92_data",
"mapping": "Pitch",
"tags": {
"device": [],
"group": []
}
},
"color": "#3498db",
"name": "Pitch",
"source": "bucket",
"timespan": {
"mode": "latest"
}
}
],
"type": "donutchart"
},
{
"layout": {
"col": 0,
"row": 12,
"sizeX": 3,
"sizeY": 8
},
"panel": {
"color": "#ffffff",
"currentColor": "#ffffff",
"showOffline": {
"type": "none"
},
"title": "Battery History (24h)"
},
"properties": {
"alignTimeSeries": false,
"axis": true,
"fill": true,
"legend": true,
"multiple_axes": false,
"options": "var options = {\n chart: {\n type: 'area',\n zoom: {\n type: 'x',\n enabled: true,\n autoScaleYaxis: true\n }\n },\n dataLabels: {\n enabled: false\n },\n stroke: {\n curve: 'smooth',\n width: 2\n },\n fill: {\n type: 'gradient',\n gradient: {\n shadeIntensity: 1,\n opacityFrom: 0.7,\n opacityTo: 0.3\n }\n },\n xaxis: {\n type: 'datetime',\n labels: {\n datetimeUTC: false\n },\n tooltip: {\n enabled: false\n }\n },\n yaxis: {\n labels: {\n formatter: function (val) {\n if (val !== null && typeof val !== 'undefined')\n return val.toFixed(2) + ' V';\n }\n },\n min: 2.5,\n max: 4.2\n },\n tooltip: {\n x: {\n format: 'dd/MM/yyyy HH:mm:ss'\n }\n }\n};\n"
},
"sources": [
{
"bucket": {
"backend": "mongodb",
"id": "dragino_lgt92_data",
"mapping": "BatV",
"tags": {
"device": [],
"group": []
}
},
"color": "#27ae60",
"name": "Battery (V)",
"source": "bucket",
"timespan": {
"magnitude": "hour",
"mode": "relative",
"period": "latest",
"value": 24
}
}
],
"type": "apex_charts"
},
{
"layout": {
"col": 3,
"row": 12,
"sizeX": 3,
"sizeY": 8
},
"panel": {
"color": "#ffffff",
"currentColor": "#ffffff",
"showOffline": {
"type": "none"
},
"title": "Accelerometer (24h)"
},
"properties": {
"alignTimeSeries": false,
"axis": true,
"fill": false,
"legend": true,
"multiple_axes": false,
"options": "var options = {\n chart: {\n type: 'line',\n zoom: {\n type: 'x',\n enabled: true,\n autoScaleYaxis: true\n }\n },\n stroke: {\n curve: 'smooth',\n width: 3\n },\n markers: {\n size: 0\n },\n xaxis: {\n type: 'datetime',\n labels: {\n datetimeUTC: false\n },\n tooltip: {\n enabled: false\n }\n },\n yaxis: {\n labels: {\n formatter: function (val) {\n if (val !== null && typeof val !== 'undefined')\n return val.toFixed(1) + '°';\n }\n }\n },\n tooltip: {\n x: {\n format: 'dd/MM/yyyy HH:mm:ss'\n }\n }\n};\n"
},
"sources": [
{
"bucket": {
"backend": "mongodb",
"id": "dragino_lgt92_data",
"mapping": "Roll",
"tags": {
"device": [],
"group": []
}
},
"color": "#9b59b6",
"name": "Roll (°)",
"source": "bucket",
"timespan": {
"magnitude": "hour",
"mode": "relative",
"period": "latest",
"value": 24
}
},
{
"bucket": {
"backend": "mongodb",
"id": "dragino_lgt92_data",
"mapping": "Pitch",
"tags": {
"device": [],
"group": []
}
},
"color": "#3498db",
"name": "Pitch (°)",
"source": "bucket",
"timespan": {
"magnitude": "hour",
"mode": "relative",
"period": "latest",
"value": 24
}
}
],
"type": "apex_charts"
},
{
"layout": {
"col": 0,
"row": 20,
"sizeX": 2,
"sizeY": 3
},
"panel": {
"color": "#ffffff",
"currentColor": "#ffffff",
"showOffline": {
"type": "none"
},
"title": "Latitude"
},
"properties": {
"decimalPlaces": 6,
"enableExtraTextColor": false,
"enableIconColor": false,
"enableIconSize": false,
"extraText": "",
"extraTextColor": "#1E313E",
"extraTextColorConditions": [],
"extraTextPosition": "above-value",
"extraTextSize": "20px",
"extraTextWeight": "font-light",
"icon": "fas fa-compass",
"iconColor": "#e74c3c",
"iconColorConditions": [],
"iconGap": "8px",
"iconPosition": "before-value",
"iconSize": "40px",
"iconVerticalOffset": "0px",
"link": "",
"textAlign": "center",
"textColor": "#1E313E",
"textColorConditions": [],
"textSize": "25px",
"textWeight": "font-bold",
"unit": "°",
"unitSize": "18px"
},
"sources": [
{
"bucket": {
"backend": "mongodb",
"id": "dragino_lgt92_data",
"mapping": "latitude",
"tags": {
"device": [],
"group": []
}
},
"color": "#e74c3c",
"name": "Latitude",
"source": "bucket",
"timespan": {
"mode": "latest"
}
}
],
"type": "text"
},
{
"layout": {
"col": 2,
"row": 20,
"sizeX": 2,
"sizeY": 3
},
"panel": {
"color": "#ffffff",
"currentColor": "#ffffff",
"showOffline": {
"type": "none"
},
"title": "Longitude"
},
"properties": {
"decimalPlaces": 6,
"enableExtraTextColor": false,
"enableIconColor": false,
"enableIconSize": false,
"extraText": "",
"extraTextColor": "#1E313E",
"extraTextColorConditions": [],
"extraTextPosition": "above-value",
"extraTextSize": "20px",
"extraTextWeight": "font-light",
"icon": "fas fa-compass",
"iconColor": "#3498db",
"iconColorConditions": [],
"iconGap": "8px",
"iconPosition": "before-value",
"iconSize": "40px",
"iconVerticalOffset": "0px",
"link": "",
"textAlign": "center",
"textColor": "#1E313E",
"textColorConditions": [],
"textSize": "25px",
"textWeight": "font-bold",
"unit": "°",
"unitSize": "18px"
},
"sources": [
{
"bucket": {
"backend": "mongodb",
"id": "dragino_lgt92_data",
"mapping": "longitude",
"tags": {
"device": [],
"group": []
}
},
"color": "#3498db",
"name": "Longitude",
"source": "bucket",
"timespan": {
"mode": "latest"
}
}
],
"type": "text"
},
{
"layout": {
"col": 4,
"row": 20,
"sizeX": 1,
"sizeY": 3
},
"panel": {
"color": "#ffffff",
"currentColor": "#ffffff",
"showOffline": {
"type": "none"
},
"title": "Altitude"
},
"properties": {
"decimalPlaces": 1,
"enableExtraTextColor": false,
"enableIconColor": false,
"enableIconSize": false,
"extraText": "",
"extraTextColor": "#1E313E",
"extraTextColorConditions": [],
"extraTextPosition": "above-value",
"extraTextSize": "20px",
"extraTextWeight": "font-light",
"icon": "fas fa-mountain",
"iconColor": "#16a085",
"iconColorConditions": [],
"iconGap": "8px",
"iconPosition": "before-value",
"iconSize": "40px",
"iconVerticalOffset": "0px",
"link": "",
"textAlign": "center",
"textColor": "#1E313E",
"textColorConditions": [],
"textSize": "25px",
"textWeight": "font-bold",
"unit": "m",
"unitSize": "18px"
},
"sources": [
{
"bucket": {
"backend": "mongodb",
"id": "dragino_lgt92_data",
"mapping": "altitude",
"tags": {
"device": [],
"group": []
}
},
"color": "#16a085",
"name": "Altitude",
"source": "bucket",
"timespan": {
"mode": "latest"
}
}
],
"type": "text"
},
{
"layout": {
"col": 5,
"row": 20,
"sizeX": 1,
"sizeY": 3
},
"panel": {
"color": "#ffffff",
"currentColor": "#ffffff",
"showOffline": {
"type": "none"
},
"title": "HDOP"
},
"properties": {
"decimalPlaces": 2,
"enableExtraTextColor": false,
"enableIconColor": false,
"enableIconSize": false,
"extraText": "GPS Accuracy",
"extraTextColor": "#7f8c8d",
"extraTextColorConditions": [],
"extraTextPosition": "below-value",
"extraTextSize": "14px",
"extraTextWeight": "font-light",
"icon": "fas fa-satellite",
"iconColor": "#95a5a6",
"iconColorConditions": [],
"iconGap": "8px",
"iconPosition": "before-value",
"iconSize": "40px",
"iconVerticalOffset": "0px",
"link": "",
"textAlign": "center",
"textColor": "#1E313E",
"textColorConditions": [
{
"color": "#27ae60",
"operator": "lt",
"value": 2
},
{
"color": "#f39c12",
"operator": "gte",
"value": 2
},
{
"color": "#e74c3c",
"operator": "gte",
"value": 5
}
],
"textSize": "25px",
"textWeight": "font-bold",
"unit": "",
"unitSize": "18px"
},
"sources": [
{
"bucket": {
"backend": "mongodb",
"id": "dragino_lgt92_data",
"mapping": "hdop",
"tags": {
"device": [],
"group": []
}
},
"color": "#f39c12",
"name": "HDOP",
"source": "bucket",
"timespan": {
"mode": "latest"
}
}
],
"type": "text"
},
{
"layout": {
"col": 0,
"row": 23,
"sizeX": 2,
"sizeY": 3
},
"panel": {
"color": "#ffffff",
"currentColor": "#ffffff",
"showOffline": {
"type": "none"
},
"title": "LED on Fix"
},
"properties": {
"decimalPlaces": 0,
"enableExtraTextColor": false,
"enableIconColor": false,
"enableIconSize": false,
"extraText": "",
"extraTextColor": "#1E313E",
"extraTextColorConditions": [],
"extraTextPosition": "above-value",
"extraTextSize": "20px",
"extraTextWeight": "font-light",
"icon": "fas fa-lightbulb",
"iconColor": "#f39c12",
"iconColorConditions": [],
"iconGap": "8px",
"iconPosition": "before-value",
"iconSize": "40px",
"iconVerticalOffset": "0px",
"link": "",
"textAlign": "center",
"textColor": "#1E313E",
"textColorConditions": [
{
"color": "#27ae60",
"operator": "eq",
"value": true
},
{
"color": "#95a5a6",
"operator": "eq",
"value": false
}
],
"textSize": "25px",
"textWeight": "font-bold",
"unit": "",
"unitSize": "18px"
},
"sources": [
{
"bucket": {
"backend": "mongodb",
"id": "dragino_lgt92_data",
"mapping": "LON",
"tags": {
"device": [],
"group": []
}
},
"color": "#f39c12",
"name": "LED Status",
"source": "bucket",
"timespan": {
"mode": "latest"
}
}
],
"type": "text"
},
{
"layout": {
"col": 2,
"row": 23,
"sizeX": 2,
"sizeY": 3
},
"panel": {
"color": "#ffffff",
"currentColor": "#ffffff",
"showOffline": {
"type": "none"
},
"title": "Firmware Version"
},
"properties": {
"decimalPlaces": 0,
"enableExtraTextColor": false,
"enableIconColor": false,
"enableIconSize": false,
"extraText": "",
"extraTextColor": "#1E313E",
"extraTextColorConditions": [],
"extraTextPosition": "above-value",
"extraTextSize": "20px",
"extraTextWeight": "font-light",
"icon": "fas fa-microchip",
"iconColor": "#34495e",
"iconColorConditions": [],
"iconGap": "8px",
"iconPosition": "before-value",
"iconSize": "40px",
"iconVerticalOffset": "0px",
"link": "",
"textAlign": "center",
"textColor": "#34495e",
"textColorConditions": [],
"textSize": "30px",
"textWeight": "font-bold",
"unit": "",
"unitSize": "18px"
},
"sources": [
{
"bucket": {
"backend": "mongodb",
"id": "dragino_lgt92_data",
"mapping": "FW",
"tags": {
"device": [],
"group": []
}
},
"color": "#34495e",
"name": "Firmware",
"source": "bucket",
"timespan": {
"mode": "latest"
}
}
],
"type": "text"
}
]
}
]
}
}
]
}
}
]
}
}