Hello friends,
I am building my own webserver, to look at my data of a device in my garden from everywhere in the world.
To make it happen, there where a couple steps necessary:
I ordered a cloudserver and a sim-card for my huawei stick. I want to be complete independet from any network. To make my device accessible from everywhere via my webserver i assigned a public ip to my simcard (thingsmobile).
To combine and test all components i made a small example. From my knowledge right now, the websocket-node is the right tool, but i am not quiet sure whats "the right path" is.
Since ma webdev.skills are very low, a friend is helping me.
Here the example:
[
{
"id": "25ddef56c05ca6e0",
"type": "tab",
"label": "Flow 2",
"disabled": false,
"info": "",
"env": []
},
{
"id": "0455dc400466ecaa",
"type": "inject",
"z": "25ddef56c05ca6e0",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
},
{
"p": "MACADRESS",
"v": "00-14-44-05-0a-a1",
"vt": "str"
},
{
"p": "ppp",
"v": "",
"vt": "date"
}
],
"repeat": "10",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "str",
"x": 90,
"y": 440,
"wires": [
[
"b5d351b75ae1e028",
"19fd4756c576db8f",
"6ceae3489025ad42"
]
]
},
{
"id": "6ceae3489025ad42",
"type": "function",
"z": "25ddef56c05ca6e0",
"name": "ADR_25/FC_3/TX",
"func": "msg.payload = \n{ value: msg.payload, \n'fc': 3, \n'unitid': 0, \n'address': 25, \n'quantity': 1 \n};\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 370,
"y": 400,
"wires": [
[
"e04090392943cb81"
]
]
},
{
"id": "2b35ee12447e9a20",
"type": "json",
"z": "25ddef56c05ca6e0",
"name": "JSON",
"property": "payload",
"action": "str",
"pretty": false,
"x": 1230,
"y": 260,
"wires": [
[
"510fe48699abae71",
"7d8a767b4798647a"
]
]
},
{
"id": "e04090392943cb81",
"type": "modbus-flex-getter",
"z": "25ddef56c05ca6e0",
"name": "",
"showStatusActivities": false,
"showErrors": false,
"logIOActivities": false,
"server": "0e3ec676f3e39293",
"useIOFile": false,
"ioFile": "",
"useIOForPayload": false,
"emptyMsgOnFail": false,
"keepMsgProperties": false,
"x": 630,
"y": 380,
"wires": [
[
"c35cb6122f4b237e",
"1ff4b547127a7746"
],
[]
]
},
{
"id": "c35cb6122f4b237e",
"type": "modbus-response",
"z": "25ddef56c05ca6e0",
"name": "",
"registerShowMax": 20,
"x": 650,
"y": 500,
"wires": []
},
{
"id": "aa8e55b2a0f4865d",
"type": "join",
"z": "25ddef56c05ca6e0",
"name": "",
"mode": "custom",
"build": "object",
"property": "payload",
"propertyType": "msg",
"key": "topic",
"joiner": "\\n",
"joinerType": "str",
"accumulate": false,
"timeout": "1",
"count": "",
"reduceRight": false,
"reduceExp": "",
"reduceInit": "",
"reduceInitType": "",
"reduceFixup": "",
"x": 1050,
"y": 260,
"wires": [
[
"2b35ee12447e9a20"
]
]
},
{
"id": "1ff4b547127a7746",
"type": "function",
"z": "25ddef56c05ca6e0",
"name": "TX",
"func": "var topic=msg.topic; //get topic\nmsg.topic=\"TX\"\n\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 850,
"y": 380,
"wires": [
[
"aa8e55b2a0f4865d"
]
]
},
{
"id": "b5d351b75ae1e028",
"type": "function",
"z": "25ddef56c05ca6e0",
"name": "MACADRESS",
"func": "var payload = msg.payload;\nmsg.payload = msg.MACADRESS\n\n\nvar topic=msg.topic; //get topic\nmsg.topic=\"MACADRESS\"\n\nreturn msg;\n\n",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 360,
"y": 300,
"wires": [
[
"aa8e55b2a0f4865d"
]
]
},
{
"id": "19fd4756c576db8f",
"type": "function",
"z": "25ddef56c05ca6e0",
"name": "timestamp",
"func": "var payload = msg.payload;\nmsg.payload = msg.ppp\n\n\nvar topic=msg.topic; //get topic\nmsg.topic=\"timestamp\"\n\nreturn msg;\n\n",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 350,
"y": 240,
"wires": [
[
"b09afb9ad8c0d6af"
]
]
},
{
"id": "b09afb9ad8c0d6af",
"type": "moment",
"z": "25ddef56c05ca6e0",
"name": "",
"topic": "",
"input": "",
"inputType": "msg",
"inTz": "Europe/London",
"adjAmount": "2",
"adjType": "hours",
"adjDir": "add",
"format": "",
"locale": "de-DE",
"output": "",
"outputType": "msg",
"outTz": "Europe/London",
"x": 620,
"y": 240,
"wires": [
[
"aa8e55b2a0f4865d"
]
]
},
{
"id": "510fe48699abae71",
"type": "websocket out",
"z": "25ddef56c05ca6e0",
"name": "",
"server": "1629835b6653b177",
"client": "",
"x": 1410,
"y": 220,
"wires": []
},
{
"id": "7d8a767b4798647a",
"type": "debug",
"z": "25ddef56c05ca6e0",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 1410,
"y": 400,
"wires": []
},
{
"id": "0e3ec676f3e39293",
"type": "modbus-client",
"name": "CIM500",
"clienttype": "tcp",
"bufferCommands": true,
"stateLogEnabled": false,
"queueLogEnabled": false,
"tcpHost": "192.168.1.2",
"tcpPort": "502",
"tcpType": "DEFAULT",
"serialPort": "/dev/ttyUSB",
"serialType": "RTU-BUFFERD",
"serialBaudrate": "9600",
"serialDatabits": "8",
"serialStopbits": "1",
"serialParity": "none",
"serialConnectionDelay": "100",
"serialAsciiResponseStartDelimiter": "0x3A",
"unit_id": "1",
"commandDelay": "1",
"clientTimeout": "1000",
"reconnectOnTimeout": true,
"reconnectTimeout": "2000",
"parallelUnitIdsAllowed": true
},
{
"id": "1629835b6653b177",
"type": "websocket-listener",
"path": "/cimtest",
"wholemsg": "false"
}
]
Is my logic right? I get the data (here testdata), join them, create a jasonfile and combine them via a websocket out - node. From my understanding right now, since i have a public ip and a defined websocket-out-node with a defined path, my buddy should be able to get the data, when i am telling him my ip and the path.
Security-issues are not mentioned here. This will be treated in a further step
Or do i misunderstood the princible of the websocket.
Thank you