diff --git a/elspina-em-elst01/CHANGELOG.md b/elspina-em-elst01/CHANGELOG.md new file mode 100644 index 00000000..901dee62 --- /dev/null +++ b/elspina-em-elst01/CHANGELOG.md @@ -0,0 +1,5 @@ +# Changelog + +## 1.0.0 - 2026-02-23 + +- First version of plugin \ No newline at end of file diff --git a/elspina-em-elst01/LICENSE.md b/elspina-em-elst01/LICENSE.md new file mode 100644 index 00000000..bffeef34 --- /dev/null +++ b/elspina-em-elst01/LICENSE.md @@ -0,0 +1,7 @@ +Copyright 2026 Thinger.io + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/elspina-em-elst01/README.md b/elspina-em-elst01/README.md new file mode 100644 index 00000000..a2a27b76 --- /dev/null +++ b/elspina-em-elst01/README.md @@ -0,0 +1,57 @@ +# EM-ELST01 LoRaWAN State Change Sensor + +The EM-ELST01 is a LoRaWAN sensor node designed to capture state changes through its integrated accelerometer and switch sensor. Manufactured by Elspina VEINZ Inc., this device is engineered to reliably detect structural state changes in harsh environmental conditions. + +## Features + +- **Accelerometer sensor** for motion and vibration detection +- **Conductivity sensor** for environmental monitoring +- **Temperature sensor** for ambient temperature measurement +- **Switch sensor** for digital state detection +- **Wide operating temperature range**: -40°C to 85°C +- **Compact form factor**: 70 x 140 x 50 mm +- **LoRaWAN connectivity** for long-range wireless communication + +## Use Cases + +- Structural health monitoring +- Asset tracking and condition monitoring +- Industrial equipment state detection +- Environmental monitoring in harsh conditions +- Predictive maintenance applications + +## Thinger.io Integration + +The EM-ELST01 can be integrated with Thinger.io through LoRaWAN network servers, enabling real-time monitoring and data visualization of accelerometer events, switch states, and environmental parameters. + +## Requirements + +A LoRaWAN server is required to communicate the EM-ELST01 into Thinger.io, some options are: + +- [The Things Stack](https://www.thethingsindustries.com/stack/) +- [LORIOT](https://loriot.io/) +- [ChirpStack](https://www.chirpstack.io/) + +Alongside, the corresponding plugin for the selected LoRaWAN server needs to be installed in your Thinger.io instance. + +## Get Started + +### Installation + +Look for the plugin in the [Thinger.io Plugin Store](https://marketplace.thinger.io/) and install it in your Thinger.io instance. Once the plugin is installed a new Product will be created for this device. + +### Configuration + +The Product is already preconfigured, check that the auto provision prefix matches the one selected in your LoRaWAN server plugin in Thinger.io, or change it to your desire. + +### Usage + +Start sending uplinks for autoprovisioning devices and buckets. +This product also provides a predefined dashboard for monitoring accelerometer events, switch states, temperature, and conductivity readings. + +## Additional Resources + +Elspina VEINZ resources can be found at: + +- [Device Repository](https://www.thethingsnetwork.org/device-repository/devices/elspina/em-elst01/) +- [Thinger docs](https://docs.thinger.io) \ No newline at end of file diff --git a/elspina-em-elst01/assets/em-elst01-e.jpg b/elspina-em-elst01/assets/em-elst01-e.jpg new file mode 100644 index 00000000..2137c044 Binary files /dev/null and b/elspina-em-elst01/assets/em-elst01-e.jpg differ diff --git a/elspina-em-elst01/plugin.json b/elspina-em-elst01/plugin.json new file mode 100644 index 00000000..897746da --- /dev/null +++ b/elspina-em-elst01/plugin.json @@ -0,0 +1,593 @@ +{ + "name": "elspina_em_elst01", + "version": "1.0.0", + "description": "Device to capture state changes through its accelerometer and switch sensor.", + "author": "Thinger.io", + "license": "MIT", + "repository": { + "type": "git", + "url": "https://github.com/thinger-io/plugins.git", + "directory": "elspina-em-elst01" + }, + "metadata": { + "name": "Elspina EM-ELST01", + "description": "Device to capture state changes through its accelerometer and switch sensor.", + "image": "assets/em-elst01-e.jpg", + "category": "devices", + "vendor": "elspina" + }, + "resources": { + "products": [ + { + "description": "Device to capture state changes through its accelerometer and switch sensor.", + "enabled": true, + "name": "Elspina EM-ELST01", + "product": "elspina_em_elst01", + "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": "", + "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": { + "device_autoprovisioning": { + "config": { + "mode": "pattern", + "pattern": "elspina-em-elst01-.*" + }, + "enabled": true + } + }, + "buckets": { + "elspina_em_elst01_data": { + "backend": "mongodb", + "data": { + "payload": "{{payload}}", + "payload_function": "decodeThingerUplink", + "payload_type": "source_payload", + "resource": "uplink", + "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\nfunction decodeUplink(input) {\n // Decode an uplink message from a buffer\n // (array) of bytes to an object of fields.\n var port = input.fPort;\n var bytes = input.bytes;\n var switch_status = (bytes[0]>>4)&0xFF;\n var value=(bytes[0]<<8 | bytes[1]) & 0x0FFF;\n var batV=value/1000;//Battery,units:V\n \n if(bytes.length == 4)\n {\n var tnomd = (bytes[2]<<8 | bytes[3]) & 0xFFFF;\n return {\n status:switch_status,\n Bat:batV ,\n TNOMD:tnomd,\n };\n }\n else if(bytes.length == 9)\n {\n var tode = (bytes[2]<<16 | bytes[3]<<8 | bytes[4]) & 0xFFFFFF;\n var ldod = (bytes[5]<<16 | bytes[6]<<8 | bytes[7]) & 0xFFFFFF;\n var alarm = bytes[8];\n return {\n status:switch_status,\n Bat:batV ,\n TODE:tode,\n LDOD:ldod,\n ALARM:alarm,\n };\n }\n else if(bytes.length == 19)\n {\n var tode1 = (bytes[2]<<16 | bytes[3]<<8 | bytes[4]) & 0xFFFFFF;\n var ldod1 = (bytes[5]<<16 | bytes[6]<<8 | bytes[7]) & 0xFFFFFF;\n var alarm1 = bytes[8];\n var tnomd1 = (bytes[9]<<8 | bytes[10]) & 0xFFFF;\n \n value=bytes[11]<<8 | bytes[12];\n var X = 0;\n if(bytes[11]>>4 == 0x0F)\n X=((value-0xFFFF)/100).toFixed(2);\n else\n X=(value/100).toFixed(2);\n \n value=bytes[13]<<8 | bytes[14];\n var Y=0;\n if(bytes[13]>>4 == 0x0F)\n Y=((value-0xFFFF)/100).toFixed(2);\n else\n Y=(value/100).toFixed(2);\n \n value=bytes[15]<<8 | bytes[16];\n var Z=0;\n if(bytes[15]>>4 == 0x0F)\n Z=((value-0xFFFF)/100).toFixed(2);\n else\n Z=(value/100).toFixed(2);\n \n value=bytes[17]<<8 | bytes[18];\n var temp_DS18B20=0;//DS18B20,temperature,units:°C\n if(bytes[17]>>4 == 0x0F)\n temp_DS18B20=((value-0xFFFF)/10).toFixed(1);\n else\n temp_DS18B20=(value/10).toFixed(1);\n return {\n data:{\n status:switch_status,\n Bat:batV ,\n TODE:tode1,\n LDOD:ldod1,\n ALARM:alarm1,\n TNOMD:tnomd1,\n X:X,\n Y:Y,\n Z:Z,\n temp_ds:temp_DS18B20\n },\n };\n }\n }", + "environment": "javascript", + "storage": "", + "version": "1.0" + }, + "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": "Main", + "widgets": [ + { + "layout": { + "col": 0, + "row": 0, + "sizeX": 1, + "sizeY": 6 + }, + "panel": { + "color": "#ffffff", + "currentColor": "#ffffff", + "showOffline": { + "type": "none" + }, + "title": "Switch Status" + }, + "properties": { + "color": "#3498db", + "max": 15, + "min": 0, + "unit": "" + }, + "sources": [ + { + "bucket": { + "backend": "mongodb", + "id": "elspina_em_elst01_data", + "mapping": "status", + "tags": { + "device": [], + "group": [] + } + }, + "color": "#3498db", + "name": "Status", + "source": "bucket", + "timespan": { + "mode": "latest" + } + } + ], + "type": "donutchart" + }, + { + "layout": { + "col": 1, + "row": 0, + "sizeX": 1, + "sizeY": 6 + }, + "panel": { + "color": "#ffffff", + "currentColor": "#ffffff", + "showOffline": { + "type": "none" + }, + "title": "Battery Voltage" + }, + "properties": { + "color": "#f39c12", + "max": 4, + "min": 2, + "unit": "V" + }, + "sources": [ + { + "bucket": { + "backend": "mongodb", + "id": "elspina_em_elst01_data", + "mapping": "Bat", + "tags": { + "device": [], + "group": [] + } + }, + "color": "#f39c12", + "name": "Battery", + "source": "bucket", + "timespan": { + "mode": "latest" + } + } + ], + "type": "donutchart" + }, + { + "layout": { + "col": 2, + "row": 0, + "sizeX": 1, + "sizeY": 6 + }, + "panel": { + "color": "#ffffff", + "currentColor": "#ffffff", + "showOffline": { + "type": "none" + }, + "title": "Temperature" + }, + "properties": { + "color": "#e74c3c", + "max": 50, + "min": -20, + "unit": "°C" + }, + "sources": [ + { + "bucket": { + "backend": "mongodb", + "id": "elspina_em_elst01_data", + "mapping": "temp_ds", + "tags": { + "device": [], + "group": [] + } + }, + "color": "#e74c3c", + "name": "Temperature", + "source": "bucket", + "timespan": { + "mode": "latest" + } + } + ], + "type": "donutchart" + }, + { + "layout": { + "col": 3, + "row": 0, + "sizeX": 1, + "sizeY": 6 + }, + "panel": { + "color": "#ffffff", + "currentColor": "#ffffff", + "showOffline": { + "type": "none" + }, + "title": "Alarm Counter" + }, + "properties": { + "color": "#e67e22", + "max": 255, + "min": 0, + "unit": "" + }, + "sources": [ + { + "bucket": { + "backend": "mongodb", + "id": "elspina_em_elst01_data", + "mapping": "ALARM", + "tags": { + "device": [], + "group": [] + } + }, + "color": "#e67e22", + "name": "Alarms", + "source": "bucket", + "timespan": { + "mode": "latest" + } + } + ], + "type": "donutchart" + }, + { + "layout": { + "col": 0, + "row": 6, + "sizeX": 2, + "sizeY": 9 + }, + "panel": { + "color": "#ffffff", + "currentColor": "#ffffff", + "showOffline": { + "type": "none" + }, + "title": "Accelerometer Data (X, Y, Z)" + }, + "properties": { + "axis": true, + "fill": false, + "legend": true, + "multiple_axes": false + }, + "sources": [ + { + "bucket": { + "backend": "mongodb", + "id": "elspina_em_elst01_data", + "mapping": "X", + "tags": { + "device": [], + "group": [] + } + }, + "color": "#e74c3c", + "name": "X-Axis", + "source": "bucket", + "timespan": { + "magnitude": "hour", + "mode": "relative", + "period": "latest", + "value": 24 + } + }, + { + "bucket": { + "backend": "mongodb", + "id": "elspina_em_elst01_data", + "mapping": "Y", + "tags": { + "device": [], + "group": [] + } + }, + "color": "#2ecc71", + "name": "Y-Axis", + "source": "bucket", + "timespan": { + "magnitude": "hour", + "mode": "relative", + "period": "latest", + "value": 24 + } + }, + { + "bucket": { + "backend": "mongodb", + "id": "elspina_em_elst01_data", + "mapping": "Z", + "tags": { + "device": [], + "group": [] + } + }, + "color": "#3498db", + "name": "Z-Axis", + "source": "bucket", + "timespan": { + "magnitude": "hour", + "mode": "relative", + "period": "latest", + "value": 24 + } + } + ], + "type": "chart" + }, + { + "layout": { + "col": 2, + "row": 6, + "sizeX": 2, + "sizeY": 9 + }, + "panel": { + "color": "#ffffff", + "currentColor": "#ffffff", + "showOffline": { + "type": "none" + }, + "title": "Event Counters History" + }, + "properties": { + "axis": true, + "fill": false, + "legend": true, + "multiple_axes": false + }, + "sources": [ + { + "bucket": { + "backend": "mongodb", + "id": "elspina_em_elst01_data", + "mapping": "TNOMD", + "tags": { + "device": [], + "group": [] + } + }, + "color": "#9b59b6", + "name": "TNOMD (Time No Motion Detected)", + "source": "bucket", + "timespan": { + "magnitude": "hour", + "mode": "relative", + "period": "latest", + "value": 24 + } + }, + { + "bucket": { + "backend": "mongodb", + "id": "elspina_em_elst01_data", + "mapping": "TODE", + "tags": { + "device": [], + "group": [] + } + }, + "color": "#1abc9c", + "name": "TODE (Time on Door Event)", + "source": "bucket", + "timespan": { + "magnitude": "hour", + "mode": "relative", + "period": "latest", + "value": 24 + } + }, + { + "bucket": { + "backend": "mongodb", + "id": "elspina_em_elst01_data", + "mapping": "LDOD", + "tags": { + "device": [], + "group": [] + } + }, + "color": "#34495e", + "name": "LDOD (Last Door Open Duration)", + "source": "bucket", + "timespan": { + "magnitude": "hour", + "mode": "relative", + "period": "latest", + "value": 24 + } + } + ], + "type": "chart" + }, + { + "layout": { + "col": 4, + "row": 0, + "sizeX": 2, + "sizeY": 15 + }, + "panel": { + "color": "#ffffff", + "currentColor": "#ffffff", + "showOffline": { + "type": "none" + }, + "title": "Recent Device Events" + }, + "properties": { + "source": "code", + "template": "
| Timestamp | \nStatus | \nBattery (V) | \nTemp (°C) | \nAlarm | \n
|---|---|---|---|---|
| {{ entry.ts | date:'short' }} | \n{{ entry.status !== undefined ? entry.status : '—' }} | \n{{ entry.Bat !== undefined ? entry.Bat.toFixed(2) : '—' }} | \n{{ entry.temp_ds !== undefined ? entry.temp_ds : '—' }} | \n{{ entry.ALARM !== undefined ? entry.ALARM : '—' }} | \n