Plugin file
Plugin configuration file
{
"name": "bosch_tps110",
"version": "1.0.0",
"description": "BOSCH wireless smart parking sensor with magnetometer, radar, GPS, and temperature sensors for parking lot management",
"author": "Thinger.io",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/thinger-io/plugins.git",
"directory": "bosch-tps110"
},
"metadata": {
"name": "BOSCH TPS110",
"description": "BOSCH wireless smart parking sensor with magnetometer, radar, GPS, and temperature sensors for parking lot management",
"image": "assets/bosch-tps110.png",
"category": "devices",
"vendor": "bosch"
},
"resources": {
"products": [
{
"description": "BOSCH wireless smart parking sensor with magnetometer, radar, GPS, and temperature sensors for parking lot management",
"enabled": true,
"name": "BOSCH TPS110",
"product": "bosch_tps110",
"profile": {
"api": {
"downlink": {
"enabled": true,
"handle_connectivity": false,
"request": {
"data": {
"path": "/downlink",
"payload": "{\n \"data\" : \"{{payload.data=\"\"}}\",\n \"port\" : {{payload.port=85}},\n \"priority\": {{payload.priority=3}},\n \"confirmed\" : {{payload.confirmed=false}},\n \"uplink\" : {{property.uplink}} \n}",
"payload_function": "",
"payload_type": "source_payload",
"plugin": "{{property.uplink.source}}",
"target": "plugin_endpoint"
}
}
},
"uplink": {
"device_id_resolver": "getId",
"enabled": true,
"handle_connectivity": true,
"request": {
"data": {
"payload": "{{payload}}",
"payload_function": "",
"payload_type": "source_payload",
"resource_stream": "uplink",
"target": "resource_stream"
}
}
}
},
"autoprovisions": {
"bosch_tps110_autoprovision": {
"config": {
"mode": "pattern",
"pattern": "bosch-tps110-.*"
},
"enabled": true
}
},
"buckets": {
"bosch_tps110_data_bucket": {
"backend": "mongodb",
"data": {
"payload": "{{payload}}",
"payload_function": "decodeThingerUplink",
"payload_type": "source_payload",
"resource": "uplink",
"source": "resource",
"update": "events"
},
"enabled": true,
"retention": {
"period": 6,
"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\nfunction decodeUplink(input) {\n var data = {};\n switch (input.fPort) {\n case 1: // Parking status\n data.type = 'parking status';\n data.occupied = (input.bytes[0] & 0x1) === 0x1;\n break;\n\n case 2: // Heartbeat\n data.type = 'heartbeat';\n data.occupied = (input.bytes[0] & 0x1) === 0x1;\n if (input.bytes.length >= 2) {\n data.temperature =\n input.bytes[1] & 0x80 ? input.bytes[1] - 0x100 : input.bytes[1];\n }\n break;\n\n case 3: // Start-up\n data.type = 'startup';\n data.debugCodes = [];\n for (var i = 0; i <= 8; i += 4) {\n var debugCode = ((input.bytes[i + 1] & 0xf) << 8) | input.bytes[i];\n if (debugCode) {\n data.debugCodes.push(debugCode);\n }\n }\n data.firmwareVersion =\n input.bytes[12] + '.' + input.bytes[13] + '.' + input.bytes[14];\n data.resetCause = [\n undefined,\n 'watchdog',\n 'power on',\n 'system request',\n 'other',\n ][input.bytes[15]];\n data.occupied = (input.bytes[16] & 0x1) == 0x1;\n break;\n\n case 4: // Device information\n data.type = 'device information';\n data.bytes = input.bytes;\n break;\n\n case 5: // Device usage\n data.type = 'device usage';\n data.bytes = input.bytes;\n break;\n\n case 6: // Debug\n data.type = 'debug';\n data.timestamp =\n (input.bytes[3] << 24) |\n (input.bytes[2] << 16) |\n (input.bytes[1] << 8) |\n input.bytes[0];\n data.debugCode = ((input.bytes[5] & 0xf) << 8) | input.bytes[4];\n data.sequenceNumber = (input.bytes[9] << 8) | input.bytes[8];\n break;\n }\n\n return {\n data: data,\n };\n}\n",
"environment": "javascript",
"storage": "",
"version": "1.0"
},
"properties": {
"bosch_tps110_location": {
"data": {
"payload": "{\"latitude\": {{payload.latitude}}, \"longitude\": {{payload.longitude}}}",
"payload_function": "decodeThingerUplink",
"payload_type": "source_payload",
"resource": "uplink",
"source": "resource",
"update": "events"
},
"default": {
"latitude": 0,
"longitude": 0
},
"enabled": true
},
"bosch_tps110_occupancy": {
"data": {
"payload": "{{payload.occupied}}",
"payload_function": "decodeThingerUplink",
"payload_type": "source_payload",
"resource": "uplink",
"source": "resource",
"update": "events"
},
"default": {
"occupied": false
},
"enabled": true
},
"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": {
"name": "Bosch_tps110",
"placeholders": {
"sources": []
},
"tabs": [
{
"name": "Parking Monitor",
"widgets": [
{
"layout": {
"col": 0,
"row": 0,
"sizeX": 3,
"sizeY": 6
},
"panel": {
"color": "#F8F8F8",
"currentColor": "#F8F8F8",
"showOffline": {
"type": "last_sample"
},
"title": "Parking Status"
},
"properties": {
"color": "#4CAF50",
"decimal_places": 0,
"icon": "fa fa-car",
"text": "Occupied",
"unit": ""
},
"sources": [
{
"bucket": {
"backend": "mongodb",
"id": "bosch_tps110_data_bucket",
"mapping": "occupied",
"tags": {
"device": [],
"group": []
}
},
"color": "#4CAF50",
"name": "Occupancy",
"source": "bucket",
"timespan": {
"mode": "latest"
}
}
],
"type": "text"
},
{
"layout": {
"col": 0,
"row": 6,
"sizeX": 3,
"sizeY": 6
},
"panel": {
"color": "#F8F8F8",
"currentColor": "#F8F8F8",
"showOffline": {
"type": "none"
},
"title": "Temperature"
},
"properties": {
"color": "#ff0000",
"max": 50,
"min": -20,
"unit": "°C"
},
"sources": [
{
"bucket": {
"backend": "mongodb",
"id": "bosch_tps110_data_bucket",
"mapping": "temperature",
"tags": {
"device": [],
"group": []
}
},
"color": "#FF5722",
"name": "Temperature",
"source": "bucket",
"timespan": {
"mode": "latest"
}
}
],
"type": "donutchart"
},
{
"layout": {
"col": 3,
"row": 6,
"sizeX": 3,
"sizeY": 6
},
"panel": {
"color": "#F8F8F8",
"currentColor": "#F8F8F8",
"showOffline": {
"type": "none"
},
"title": "Battery"
},
"properties": {
"color": "#4CAF50",
"max": 4.2,
"min": 2.5,
"unit": "V"
},
"sources": [
{
"bucket": {
"backend": "mongodb",
"id": "bosch_tps110_data_bucket",
"mapping": "battery",
"tags": {
"device": [],
"group": []
}
},
"color": "#4CAF50",
"name": "Battery Voltage",
"source": "bucket",
"timespan": {
"mode": "latest"
}
}
],
"type": "donutchart"
},
{
"layout": {
"col": 3,
"row": 0,
"sizeX": 3,
"sizeY": 6
},
"panel": {
"color": "#F8F8F8",
"currentColor": "#F8F8F8",
"showOffline": {
"type": "none"
},
"title": "Radar Confidence"
},
"properties": {
"color": "#32e010",
"max": 100,
"min": 0,
"unit": "%"
},
"sources": [
{
"bucket": {
"backend": "mongodb",
"id": "bosch_tps110_data_bucket",
"mapping": "radar_confidence",
"tags": {
"device": [],
"group": []
}
},
"color": "#E91E63",
"name": "Confidence",
"source": "bucket",
"timespan": {
"mode": "latest"
}
}
],
"type": "donutchart"
},
{
"layout": {
"col": 0,
"row": 24,
"sizeX": 6,
"sizeY": 12
},
"panel": {
"color": "#F8F8F8",
"currentColor": "#F8F8F8",
"showFullscreen": true,
"showOffline": {
"type": "none"
},
"subtitle": "Last 7 days",
"title": "Occupancy History"
},
"properties": {
"alignTimeSeries": true,
"dataAppend": false,
"options": "var options = {\n series: series,\n chart: {\n type: 'area',\n background: '#FCFCFC',\n toolbar: {\n show: true,\n tools: {\n download: true,\n selection: true,\n zoom: true,\n zoomin: true,\n zoomout: true,\n pan: true,\n reset: true\n },\n autoSelected: 'zoom'\n },\n zoom: {\n enabled: true,\n type: 'x',\n autoScaleYaxis: true\n }\n },\n stroke: {\n curve: 'stepline',\n width: 2\n },\n fill: {\n type: 'solid',\n opacity: 0.6\n },\n grid: {\n row: {\n colors: ['#EEEEEE', 'transparent'],\n opacity: 0.5\n }\n },\n xaxis: {\n type: 'datetime',\n labels: {\n datetimeUTC: false,\n style: {\n colors: '#333333'\n }\n }\n },\n yaxis: {\n min: 0,\n max: 1,\n tickAmount: 1,\n labels: {\n formatter: function(val) {\n return val === 1 ? 'Occupied' : 'Free';\n },\n style: {\n colors: '#333333'\n }\n }\n },\n tooltip: {\n x: {\n format: 'dd/MM/yyyy HH:mm:ss'\n },\n y: {\n formatter: function(val) {\n return val === 1 ? 'Occupied' : 'Free';\n }\n },\n shared: true\n },\n legend: {\n position: 'bottom',\n labels: {\n colors: '#333333'\n }\n },\n colors: ['#4CAF50']\n};",
"realTimeUpdate": false
},
"sources": [
{
"aggregation": {
"period": "hour",
"type": "avg"
},
"bucket": {
"backend": "mongodb",
"id": "bosch_tps110_data_bucket",
"mapping": "occupied",
"tags": {
"device": [],
"group": []
}
},
"color": "#4CAF50",
"name": "Parking Space",
"source": "bucket",
"timespan": {
"magnitude": "day",
"mode": "relative",
"period": "latest",
"value": 7
},
"transform": ""
}
],
"type": "apex_charts"
},
{
"layout": {
"col": 0,
"row": 12,
"sizeX": 6,
"sizeY": 12
},
"panel": {
"color": "#F8F8F8",
"currentColor": "#F8F8F8",
"showFullscreen": true,
"showOffline": {
"type": "none"
},
"subtitle": "Temperature trends",
"title": "Environmental Monitoring"
},
"properties": {
"alignTimeSeries": false,
"dataAppend": false,
"options": "var options = {\n series: series,\n chart: {\n background: '#FEFEFE',\n toolbar: {\n show: true,\n autoSelected: 'zoom'\n },\n zoom: {\n enabled: true,\n type: 'x',\n autoScaleYaxis: true\n }\n },\n stroke: {\n curve: 'smooth',\n width: 2\n },\n grid: {\n row: {\n colors: ['#F0F0F0', 'transparent'],\n opacity: 0.5\n }\n },\n xaxis: {\n type: 'datetime',\n labels: {\n datetimeUTC: false,\n style: {\n colors: '#333333'\n }\n }\n },\n yaxis: {\n labels: {\n formatter: function(val) {\n return val.toFixed(1) + '°C';\n },\n style: {\n colors: '#333333'\n }\n }\n },\n tooltip: {\n x: {\n format: 'dd/MM/yyyy HH:mm'\n },\n shared: true\n },\n legend: {\n position: 'bottom',\n labels: {\n colors: '#333333'\n }\n },\n colors: ['#FF5722']\n};",
"realTimeUpdate": true
},
"sources": [
{
"aggregation": {
"period": "hour",
"type": "avg"
},
"bucket": {
"backend": "mongodb",
"id": "bosch_tps110_data_bucket",
"mapping": "temperature",
"tags": {
"device": [],
"group": []
}
},
"color": "#ff0000",
"name": "Temperature",
"source": "bucket",
"timespan": {
"magnitude": "day",
"mode": "relative",
"period": "latest",
"value": 7
},
"transform": ""
}
],
"type": "apex_charts",
"api": {}
}
]
}
]
}
}
]
}
}
]
}
}