From f740fa8828aba641e2f11b0ceb6f44c7196fcf5d Mon Sep 17 00:00:00 2001 From: admin Date: Mon, 5 Jan 2026 21:23:21 +0100 Subject: [PATCH] SSH-nodered --- SSH-nodered | 1884 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 1884 insertions(+) create mode 100644 SSH-nodered diff --git a/SSH-nodered b/SSH-nodered new file mode 100644 index 0000000..6762724 --- /dev/null +++ b/SSH-nodered @@ -0,0 +1,1884 @@ +[ + { + "id": "e8e98e942de24836", + "type": "tab", + "label": "SSH_VDG", + "disabled": false, + "info": "", + "env": [] + }, + { + "id": "4a8ec85389231f56", + "type": "group", + "z": "e8e98e942de24836", + "name": "BeamMP", + "style": { + "label": true + }, + "nodes": [ + "d8eabe917de5c0c4", + "6bb2e499199a5541", + "a36c6e1fd60f2f39", + "11a73a8a607d532c", + "bc73295e11a8303b", + "8518e15a5133cc01", + "99ef2d4b9888b9ec", + "c71962307fe6c615", + "a7cdab0892a8af6c", + "0777d95675e68c18", + "f8abcf2464eb4adb", + "014afe957a4c7c1e", + "8a2d5d26a6c71eae", + "eef6018d28ea6aab" + ], + "x": 54, + "y": 19, + "w": 962, + "h": 302 + }, + { + "id": "61142084a4786c65", + "type": "group", + "z": "e8e98e942de24836", + "name": "fiveM", + "style": { + "label": true + }, + "nodes": [ + "c36020838e2d4d50", + "05fa8aa266c2c39f" + ], + "x": 88, + "y": 433, + "w": 1824, + "h": 634 + }, + { + "id": "c36020838e2d4d50", + "type": "group", + "z": "e8e98e942de24836", + "g": "61142084a4786c65", + "name": "services", + "style": { + "label": true + }, + "nodes": [ + "7b6bd00a172fb298", + "2f613b5167ce8a59", + "f714c28d1baf5880", + "3d41ecfb2f21a534", + "f4037f22e607d0dd", + "6fbf883e63073d9e", + "e2317d13abc9fcf4", + "7f5a62eeff5b7ec7", + "0f9d67aef385d6b4", + "30d45582d638bfd5", + "54cd717db58718b7" + ], + "x": 154, + "y": 459, + "w": 592, + "h": 262 + }, + { + "id": "05fa8aa266c2c39f", + "type": "group", + "z": "e8e98e942de24836", + "g": "61142084a4786c65", + "name": "Server", + "style": { + "label": true + }, + "nodes": [ + "inject_check", + "http_status", + "fn_status_ok", + "catch_status", + "fn_status_fail", + "6889fd4ae926c478", + "inj_fx3_start", + "inj_fx3_stop", + "fn_fx3_login_req", + "http_fx3_login", + "dbg_fx3_login", + "fn_fx3_controls_req", + "http_fx3_controls", + "dbg_fx3_controls", + "194c2029d84d4697", + "eba7b1b802fe8bde", + "37d396b9b8476f17", + "1b1e33484fb3a522", + "68a3939b4b8b038a" + ], + "x": 114, + "y": 779, + "w": 1772, + "h": 262 + }, + { + "id": "d82bb543eed13730", + "type": "ssh-v3", + "z": "e8e98e942de24836", + "name": "", + "conf": "5faf28207240410e", + "debug": false, + "x": 1190, + "y": 40, + "wires": [ + [ + "a245b6e071c14540" + ] + ] + }, + { + "id": "d8eabe917de5c0c4", + "type": "inject", + "z": "e8e98e942de24836", + "g": "4a8ec85389231f56", + "name": "", + "props": [ + { + "p": "payload" + }, + { + "p": "topic", + "vt": "str" + } + ], + "repeat": "", + "crontab": "", + "once": false, + "onceDelay": 0.1, + "topic": "", + "payload": "", + "payloadType": "date", + "x": 160, + "y": 80, + "wires": [ + [ + "6bb2e499199a5541" + ] + ] + }, + { + "id": "6bb2e499199a5541", + "type": "function", + "z": "e8e98e942de24836", + "g": "4a8ec85389231f56", + "name": "Start BeamMP", + "func": "msg.payload = 'schtasks /Run /TN \"BeamMP Server\"';\nreturn msg;\n", + "outputs": 1, + "timeout": 0, + "noerr": 0, + "initialize": "", + "finalize": "", + "libs": [], + "x": 500, + "y": 60, + "wires": [ + [ + "d82bb543eed13730" + ] + ] + }, + { + "id": "a36c6e1fd60f2f39", + "type": "function", + "z": "e8e98e942de24836", + "g": "4a8ec85389231f56", + "name": "Stop BeamMP", + "func": "msg.payload = 'taskkill /IM \"BeamMP-server.exe\" /F';\nreturn msg;\n", + "outputs": 1, + "timeout": 0, + "noerr": 0, + "initialize": "", + "finalize": "", + "libs": [], + "x": 500, + "y": 100, + "wires": [ + [ + "d82bb543eed13730" + ] + ] + }, + { + "id": "11a73a8a607d532c", + "type": "inject", + "z": "e8e98e942de24836", + "g": "4a8ec85389231f56", + "name": "", + "props": [ + { + "p": "payload" + }, + { + "p": "topic", + "vt": "str" + } + ], + "repeat": "", + "crontab": "", + "once": false, + "onceDelay": 0.1, + "topic": "", + "payload": "", + "payloadType": "date", + "x": 160, + "y": 120, + "wires": [ + [ + "a36c6e1fd60f2f39" + ] + ] + }, + { + "id": "bc73295e11a8303b", + "type": "ha-button", + "z": "e8e98e942de24836", + "g": "4a8ec85389231f56", + "name": "BeamMP On", + "version": 0, + "debugenabled": false, + "outputs": 1, + "entityConfig": "96e8b42cefda33ac", + "outputProperties": [ + { + "property": "payload", + "propertyType": "msg", + "value": "string", + "valueType": "entityState" + }, + { + "property": "topic", + "propertyType": "msg", + "value": "", + "valueType": "triggerId" + }, + { + "property": "data", + "propertyType": "msg", + "value": "", + "valueType": "entity" + } + ], + "x": 150, + "y": 160, + "wires": [ + [ + "6bb2e499199a5541", + "f8abcf2464eb4adb" + ] + ] + }, + { + "id": "8518e15a5133cc01", + "type": "ha-button", + "z": "e8e98e942de24836", + "g": "4a8ec85389231f56", + "name": "BeamMP-OFF", + "version": 0, + "debugenabled": false, + "outputs": 1, + "entityConfig": "110f73d18d9f3904", + "outputProperties": [ + { + "property": "payload", + "propertyType": "msg", + "value": "string", + "valueType": "entityState" + }, + { + "property": "topic", + "propertyType": "msg", + "value": "", + "valueType": "triggerId" + }, + { + "property": "data", + "propertyType": "msg", + "value": "", + "valueType": "entity" + } + ], + "x": 150, + "y": 200, + "wires": [ + [ + "a36c6e1fd60f2f39", + "0777d95675e68c18" + ] + ] + }, + { + "id": "99ef2d4b9888b9ec", + "type": "http in", + "z": "e8e98e942de24836", + "g": "4a8ec85389231f56", + "name": "", + "url": "restartBeam", + "method": "get", + "upload": false, + "skipBodyParsing": false, + "swaggerDoc": "", + "x": 170, + "y": 280, + "wires": [ + [ + "a36c6e1fd60f2f39", + "c71962307fe6c615", + "eef6018d28ea6aab" + ] + ] + }, + { + "id": "c71962307fe6c615", + "type": "delay", + "z": "e8e98e942de24836", + "g": "4a8ec85389231f56", + "name": "", + "pauseType": "delay", + "timeout": "20", + "timeoutUnits": "seconds", + "rate": "1", + "nbRateUnits": "1", + "rateUnits": "second", + "randomFirst": "1", + "randomLast": "5", + "randomUnits": "seconds", + "drop": false, + "allowrate": false, + "outputs": 1, + "x": 460, + "y": 240, + "wires": [ + [ + "6bb2e499199a5541" + ] + ] + }, + { + "id": "7b6bd00a172fb298", + "type": "function", + "z": "e8e98e942de24836", + "g": "c36020838e2d4d50", + "name": "Start FIVEM", + "func": "msg.payload = 'schtasks /Run /TN \"FIVEM\"';\nreturn msg;\n", + "outputs": 1, + "timeout": 0, + "noerr": 0, + "initialize": "", + "finalize": "", + "libs": [], + "x": 590, + "y": 500, + "wires": [ + [ + "d82bb543eed13730" + ] + ] + }, + { + "id": "2f613b5167ce8a59", + "type": "function", + "z": "e8e98e942de24836", + "g": "c36020838e2d4d50", + "name": "Stop FIVEM", + "func": "msg.payload = 'taskkill /IM \"FXServer.exe\" /F';\nreturn msg;\n", + "outputs": 1, + "timeout": 0, + "noerr": 0, + "initialize": "", + "finalize": "", + "libs": [], + "x": 590, + "y": 540, + "wires": [ + [ + "d82bb543eed13730" + ] + ] + }, + { + "id": "f714c28d1baf5880", + "type": "inject", + "z": "e8e98e942de24836", + "g": "c36020838e2d4d50", + "name": "", + "props": [ + { + "p": "payload" + }, + { + "p": "topic", + "vt": "str" + } + ], + "repeat": "", + "crontab": "", + "once": false, + "onceDelay": 0.1, + "topic": "", + "payload": "", + "payloadType": "date", + "x": 260, + "y": 500, + "wires": [ + [ + "7b6bd00a172fb298" + ] + ] + }, + { + "id": "3d41ecfb2f21a534", + "type": "inject", + "z": "e8e98e942de24836", + "g": "c36020838e2d4d50", + "name": "", + "props": [ + { + "p": "payload" + }, + { + "p": "topic", + "vt": "str" + } + ], + "repeat": "", + "crontab": "", + "once": false, + "onceDelay": 0.1, + "topic": "", + "payload": "", + "payloadType": "date", + "x": 260, + "y": 540, + "wires": [ + [ + "2f613b5167ce8a59" + ] + ] + }, + { + "id": "a7cdab0892a8af6c", + "type": "ha-button", + "z": "e8e98e942de24836", + "g": "4a8ec85389231f56", + "name": "BeamMP-Restart", + "version": 0, + "debugenabled": false, + "outputs": 1, + "entityConfig": "115c6bf4eacce241", + "outputProperties": [ + { + "property": "payload", + "propertyType": "msg", + "value": "string", + "valueType": "entityState" + }, + { + "property": "topic", + "propertyType": "msg", + "value": "", + "valueType": "triggerId" + }, + { + "property": "data", + "propertyType": "msg", + "value": "", + "valueType": "entity" + } + ], + "x": 160, + "y": 240, + "wires": [ + [ + "a36c6e1fd60f2f39", + "c71962307fe6c615", + "eef6018d28ea6aab" + ] + ] + }, + { + "id": "f4037f22e607d0dd", + "type": "ha-button", + "z": "e8e98e942de24836", + "g": "c36020838e2d4d50", + "name": "FiveM On", + "version": 0, + "debugenabled": false, + "outputs": 1, + "entityConfig": "3a83995fb7451dbc", + "outputProperties": [ + { + "property": "payload", + "propertyType": "msg", + "value": "string", + "valueType": "entityState" + }, + { + "property": "topic", + "propertyType": "msg", + "value": "", + "valueType": "triggerId" + }, + { + "property": "data", + "propertyType": "msg", + "value": "", + "valueType": "entity" + } + ], + "x": 260, + "y": 580, + "wires": [ + [ + "7b6bd00a172fb298" + ] + ] + }, + { + "id": "6fbf883e63073d9e", + "type": "ha-button", + "z": "e8e98e942de24836", + "g": "c36020838e2d4d50", + "name": "FiveM Off", + "version": 0, + "debugenabled": false, + "outputs": 1, + "entityConfig": "0bd09ec9e22c89a5", + "outputProperties": [ + { + "property": "payload", + "propertyType": "msg", + "value": "string", + "valueType": "entityState" + }, + { + "property": "topic", + "propertyType": "msg", + "value": "", + "valueType": "triggerId" + }, + { + "property": "data", + "propertyType": "msg", + "value": "", + "valueType": "entity" + } + ], + "x": 260, + "y": 620, + "wires": [ + [ + "2f613b5167ce8a59" + ] + ] + }, + { + "id": "e2317d13abc9fcf4", + "type": "ha-button", + "z": "e8e98e942de24836", + "g": "c36020838e2d4d50", + "name": "FiveM Restart", + "version": 0, + "debugenabled": false, + "outputs": 1, + "entityConfig": "74a8e0fdb0f4e143", + "outputProperties": [ + { + "property": "payload", + "propertyType": "msg", + "value": "string", + "valueType": "entityState" + }, + { + "property": "topic", + "propertyType": "msg", + "value": "", + "valueType": "triggerId" + }, + { + "property": "data", + "propertyType": "msg", + "value": "", + "valueType": "entity" + } + ], + "x": 270, + "y": 660, + "wires": [ + [ + "2f613b5167ce8a59", + "7f5a62eeff5b7ec7", + "54cd717db58718b7" + ] + ] + }, + { + "id": "7f5a62eeff5b7ec7", + "type": "delay", + "z": "e8e98e942de24836", + "g": "c36020838e2d4d50", + "name": "", + "pauseType": "delay", + "timeout": "20", + "timeoutUnits": "seconds", + "rate": "1", + "nbRateUnits": "1", + "rateUnits": "second", + "randomFirst": "1", + "randomLast": "5", + "randomUnits": "seconds", + "drop": false, + "allowrate": false, + "outputs": 1, + "x": 580, + "y": 580, + "wires": [ + [ + "7b6bd00a172fb298" + ] + ] + }, + { + "id": "faed3f3da7be2f13", + "type": "mqtt in", + "z": "e8e98e942de24836", + "name": "", + "topic": "servers/windows1_clean/status", + "qos": "2", + "datatype": "auto", + "broker": "24560fc20b3695b6", + "nl": false, + "rap": true, + "rh": 0, + "inputs": 0, + "x": 890, + "y": 340, + "wires": [ + [ + "dd265ddf19aef8d4", + "5982b0bac568537f" + ] + ] + }, + { + "id": "dd265ddf19aef8d4", + "type": "function", + "z": "e8e98e942de24836", + "name": "MQTT-to-status", + "func": "function parsePayload(x) {\n // Buffer -> string\n if (Buffer.isBuffer(x)) x = x.toString(\"utf8\");\n\n // Al object? klaar\n if (x && typeof x === \"object\") return x;\n\n if (typeof x !== \"string\") return {};\n\n const s = x.trim();\n\n // 1) Probeer echte JSON\n try { return JSON.parse(s); } catch (e) { }\n\n // 2) Probeer pseudo-json -> echte JSON\n // {fivem:true,beammp:true,host:VDG...,timestamp:2025-...}\n let t = s;\n\n // quote keys: {fivem: -> {\"fivem\":\n t = t.replace(/([{,]\\s*)([A-Za-z0-9_]+)\\s*:/g, '$1\"$2\":');\n\n // quote bareword values (zoals host:VDG...)\n t = t.replace(/:\\s*([A-Za-z_][A-Za-z0-9_]*)(\\s*[},])/g, ':\"$1\"$2');\n\n // quote timestamps zonder quotes\n t = t.replace(/:\\s*(\\d{4}-\\d{2}-\\d{2}T[0-9:]+)(\\s*[},])/g, ':\"$1\"$2');\n\n try { return JSON.parse(t); } catch (e) {\n node.warn(\"Kon payload niet parsen: \" + s);\n return {};\n }\n}\n\nconst p = parsePayload(msg.payload);\n\n// Zorg dat 'true' écht true is (ook als het \"true\" string zou zijn)\nconst fivem = (p.fivem === true || p.fivem === \"true\");\nconst beammp = (p.beammp === true || p.beammp === \"true\");\n\nreturn [\n { topic: \"FiveM\", payload: fivem ? \"DRAAIT\" : \"UIT\", running: fivem, raw: p.fivem, host: p.host, timestamp: p.timestamp },\n { topic: \"BeamMP\", payload: beammp ? \"DRAAIT\" : \"UIT\", running: beammp, raw: p.beammp, host: p.host, timestamp: p.timestamp }\n];\n", + "outputs": 2, + "timeout": 0, + "noerr": 0, + "initialize": "", + "finalize": "", + "libs": [], + "x": 940, + "y": 400, + "wires": [ + [ + "0f9d67aef385d6b4" + ], + [ + "014afe957a4c7c1e" + ] + ] + }, + { + "id": "0f9d67aef385d6b4", + "type": "ha-sensor", + "z": "e8e98e942de24836", + "g": "c36020838e2d4d50", + "name": "FiveM-Status", + "entityConfig": "0f9f03424eb9f328", + "version": 0, + "state": "payload", + "stateType": "msg", + "attributes": [], + "inputOverride": "allow", + "outputProperties": [], + "x": 590, + "y": 620, + "wires": [ + [ + "30d45582d638bfd5" + ] + ] + }, + { + "id": "014afe957a4c7c1e", + "type": "ha-sensor", + "z": "e8e98e942de24836", + "g": "4a8ec85389231f56", + "name": "BeamMP-Status", + "entityConfig": "4e5bd984cfc87e26", + "version": 0, + "state": "payload", + "stateType": "msg", + "attributes": [], + "inputOverride": "allow", + "outputProperties": [], + "x": 840, + "y": 280, + "wires": [ + [ + "8a2d5d26a6c71eae" + ] + ] + }, + { + "id": "0777d95675e68c18", + "type": "api-call-service", + "z": "e8e98e942de24836", + "g": "4a8ec85389231f56", + "name": "BEAMNG portforwading OFF", + "server": "8c797fff6dc8e6ce", + "version": 7, + "debugenabled": false, + "action": "switch.turn_off", + "floorId": [], + "areaId": [], + "deviceId": [], + "entityId": [ + "switch.unifi_network_beamng" + ], + "labelId": [], + "data": "", + "dataType": "jsonata", + "mergeContext": "", + "mustacheAltTags": false, + "outputProperties": [], + "queue": "none", + "blockInputOverrides": true, + "domain": "switch", + "service": "turn_off", + "x": 800, + "y": 220, + "wires": [ + [] + ] + }, + { + "id": "f8abcf2464eb4adb", + "type": "api-call-service", + "z": "e8e98e942de24836", + "g": "4a8ec85389231f56", + "name": "BEAMNG portforwading ON", + "server": "8c797fff6dc8e6ce", + "version": 7, + "debugenabled": false, + "action": "switch.turn_on", + "floorId": [], + "areaId": [], + "deviceId": [], + "entityId": [ + "switch.unifi_network_beamng" + ], + "labelId": [], + "data": "", + "dataType": "jsonata", + "mergeContext": "", + "mustacheAltTags": false, + "outputProperties": [], + "queue": "none", + "blockInputOverrides": true, + "domain": "switch", + "service": "turn_on", + "x": 800, + "y": 160, + "wires": [ + [] + ] + }, + { + "id": "5982b0bac568537f", + "type": "debug", + "z": "e8e98e942de24836", + "name": "debug 1", + "active": false, + "tosidebar": true, + "console": false, + "tostatus": false, + "complete": "false", + "statusVal": "", + "statusType": "auto", + "x": 920, + "y": 440, + "wires": [] + }, + { + "id": "30d45582d638bfd5", + "type": "link out", + "z": "e8e98e942de24836", + "g": "c36020838e2d4d50", + "name": "FiveM-status", + "mode": "link", + "links": [ + "8ed402ac5cd98a26" + ], + "x": 705, + "y": 620, + "wires": [] + }, + { + "id": "8a2d5d26a6c71eae", + "type": "link out", + "z": "e8e98e942de24836", + "g": "4a8ec85389231f56", + "name": "Beam status", + "mode": "link", + "links": [ + "a8394016a8dcacc4" + ], + "x": 975, + "y": 260, + "wires": [] + }, + { + "id": "eef6018d28ea6aab", + "type": "link out", + "z": "e8e98e942de24836", + "g": "4a8ec85389231f56", + "name": "BeamMP restart Requested", + "mode": "link", + "links": [ + "b04d93eaedb9e026" + ], + "x": 465, + "y": 280, + "wires": [] + }, + { + "id": "54cd717db58718b7", + "type": "link out", + "z": "e8e98e942de24836", + "g": "c36020838e2d4d50", + "name": "FiveM restart Requested", + "mode": "link", + "links": [ + "70b419c6c830d1e3" + ], + "x": 535, + "y": 680, + "wires": [] + }, + { + "id": "a245b6e071c14540", + "type": "debug", + "z": "e8e98e942de24836", + "name": "debug 4", + "active": false, + "tosidebar": true, + "console": false, + "tostatus": false, + "complete": "false", + "statusVal": "", + "statusType": "auto", + "x": 1400, + "y": 40, + "wires": [] + }, + { + "id": "inject_check", + "type": "inject", + "z": "e8e98e942de24836", + "g": "05fa8aa266c2c39f", + "name": "CHECK ONLINE (5s)", + "props": [], + "repeat": "10", + "crontab": "", + "once": true, + "onceDelay": 2, + "topic": "", + "x": 460, + "y": 1000, + "wires": [ + [ + "http_status" + ] + ] + }, + { + "id": "http_status", + "type": "http request", + "z": "e8e98e942de24836", + "g": "05fa8aa266c2c39f", + "name": "FiveM players.json", + "method": "GET", + "ret": "obj", + "paytoqs": "ignore", + "url": "http://10.10.40.80:30120/players.json", + "tls": "", + "persist": false, + "proxy": "", + "insecureHTTPParser": false, + "authType": "", + "senderr": true, + "headers": [], + "x": 970, + "y": 860, + "wires": [ + [ + "fn_status_ok" + ] + ] + }, + { + "id": "fn_status_ok", + "type": "function", + "z": "e8e98e942de24836", + "g": "05fa8aa266c2c39f", + "name": "ONLINE", + "func": "msg.state = \"on\";\nmsg.payload = \"ONLINE\";\nreturn msg;", + "outputs": 1, + "x": 1140, + "y": 860, + "wires": [ + [ + "6889fd4ae926c478", + "68a3939b4b8b038a" + ] + ] + }, + { + "id": "catch_status", + "type": "catch", + "z": "e8e98e942de24836", + "g": "05fa8aa266c2c39f", + "name": "OFFLINE (catch)", + "scope": [ + "http_status" + ], + "uncaught": false, + "x": 960, + "y": 900, + "wires": [ + [ + "fn_status_fail" + ] + ] + }, + { + "id": "fn_status_fail", + "type": "function", + "z": "e8e98e942de24836", + "g": "05fa8aa266c2c39f", + "name": "OFFLINE", + "func": "msg.state = \"off\";\nmsg.payload = \"OFFLINE\";\nreturn msg;", + "outputs": 1, + "x": 1140, + "y": 900, + "wires": [ + [ + "6889fd4ae926c478", + "68a3939b4b8b038a" + ] + ] + }, + { + "id": "6889fd4ae926c478", + "type": "debug", + "z": "e8e98e942de24836", + "g": "05fa8aa266c2c39f", + "name": "debug 5", + "active": false, + "tosidebar": true, + "console": false, + "tostatus": false, + "complete": "false", + "statusVal": "", + "statusType": "auto", + "x": 1640, + "y": 900, + "wires": [] + }, + { + "id": "inj_fx3_start", + "type": "inject", + "z": "e8e98e942de24836", + "g": "05fa8aa266c2c39f", + "name": "START", + "props": [ + { + "p": "payload" + } + ], + "repeat": "", + "crontab": "", + "once": false, + "onceDelay": 0.1, + "topic": "", + "payload": "{\"action\":\"start\"}", + "payloadType": "json", + "x": 410, + "y": 920, + "wires": [ + [ + "fn_fx3_login_req" + ] + ] + }, + { + "id": "inj_fx3_stop", + "type": "inject", + "z": "e8e98e942de24836", + "g": "05fa8aa266c2c39f", + "name": "STOP", + "props": [ + { + "p": "payload" + } + ], + "repeat": "", + "crontab": "", + "once": false, + "onceDelay": 0.1, + "topic": "", + "payload": "{\"action\":\"stop\"}", + "payloadType": "json", + "x": 410, + "y": 960, + "wires": [ + [ + "fn_fx3_login_req" + ] + ] + }, + { + "id": "fn_fx3_login_req", + "type": "function", + "z": "e8e98e942de24836", + "g": "05fa8aa266c2c39f", + "name": "Build LOGIN (keep desired action)", + "func": "const BASE = 'http://10.10.40.80:40120';\n\n// jouw gevonden endpoint\nmsg.loginUrl = BASE + '/auth/password?uiVersion=8.0.1';\nmsg.controlsUrl = BASE + '/fxserver/controls';\n\n// bewaar gewenste action payload (bijv. {action:\"stop\"})\nmsg.desired = msg.payload;\n\n// cookie jar (belangrijk!)\nlet jar = flow.get('fx_jar');\nif (!jar) {\n jar = {};\n flow.set('fx_jar', jar);\n}\nmsg.jar = jar;\n\n// login request\nmsg.method = 'POST';\nmsg.url = msg.loginUrl;\nmsg.headers = { 'Content-Type': 'application/json' };\nmsg.payload = { username: 'nodered', password: 'nodered' };\n\n// korte timeout voorkomt hang/close timed out\nmsg.requestTimeout = 5000;\n\nreturn msg;", + "outputs": 1, + "timeout": "", + "noerr": 0, + "initialize": "", + "finalize": "", + "libs": [], + "x": 720, + "y": 820, + "wires": [ + [ + "http_fx3_login" + ] + ] + }, + { + "id": "http_fx3_login", + "type": "http request", + "z": "e8e98e942de24836", + "g": "05fa8aa266c2c39f", + "name": "LOGIN", + "method": "use", + "ret": "obj", + "paytoqs": "ignore", + "url": "", + "tls": "", + "persist": false, + "proxy": "", + "authType": "", + "senderr": true, + "headers": [], + "x": 940, + "y": 820, + "wires": [ + [ + "fn_fx3_controls_req", + "dbg_fx3_login" + ] + ] + }, + { + "id": "dbg_fx3_login", + "type": "debug", + "z": "e8e98e942de24836", + "g": "05fa8aa266c2c39f", + "name": "DEBUG LOGIN (full msg)", + "active": false, + "tosidebar": true, + "complete": "true", + "targetType": "full", + "x": 1690, + "y": 860, + "wires": [] + }, + { + "id": "fn_fx3_controls_req", + "type": "function", + "z": "e8e98e942de24836", + "g": "05fa8aa266c2c39f", + "name": "Build CONTROLS (send cookie jar)", + "func": "// === CONFIG ===\nvar BASE = \"http://10.10.40.80:40120\"; // pas aan indien nodig\n// ==============\n\n// csrfToken uit login response payload\nvar csrf = \"\";\nif (msg.payload && typeof msg.payload === \"object\" && msg.payload.csrfToken) {\n csrf = msg.payload.csrfToken;\n}\n\n// Cookie header bouwen uit responseCookies (tx:... is dynamisch)\nvar cookieHeader = \"\";\nif (msg.responseCookies && typeof msg.responseCookies === \"object\") {\n var parts = [];\n for (var name in msg.responseCookies) {\n if (Object.prototype.hasOwnProperty.call(msg.responseCookies, name)) {\n var c = msg.responseCookies[name];\n if (c && c.value) {\n parts.push(name + \"=\" + c.value);\n }\n }\n }\n cookieHeader = parts.join(\"; \");\n}\n\n// optioneel theme cookie toevoegen (zoals browser)\nif (cookieHeader) {\n cookieHeader = \"txAdmin-theme=dark; \" + cookieHeader;\n}\n\n// bewaren voor hergebruik\nif (csrf) flow.set(\"tx_csrf\", csrf);\nif (cookieHeader) flow.set(\"tx_cookie\", cookieHeader);\n\n// fallback naar opgeslagen waarden\nvar csrfToken = csrf || flow.get(\"tx_csrf\") || \"\";\nvar cookie = cookieHeader || flow.get(\"tx_cookie\") || \"\";\n\n// Controls request bouwen\nmsg.method = \"POST\";\nmsg.url = BASE + \"/fxserver/controls\";\nmsg.headers = {\n \"Content-Type\": \"application/json; charset=UTF-8\",\n \"Accept\": \"application/json\",\n \"Cookie\": cookie,\n \"Origin\": BASE,\n \"Referer\": BASE + \"/\",\n \"x-txadmin-csrftoken\": csrfToken,\n \"Connection\": \"close\"\n};\n\n// payload exact zoals jij verwacht\nmsg.payload = msg.desired; // {action:\"start\"} of {action:\"stop\"}\n\n// timeout\nmsg.requestTimeout = 5000;\n\nreturn msg;\n", + "outputs": 1, + "timeout": "", + "noerr": 0, + "initialize": "", + "finalize": "", + "libs": [], + "x": 1220, + "y": 820, + "wires": [ + [ + "http_fx3_controls" + ] + ] + }, + { + "id": "http_fx3_controls", + "type": "http request", + "z": "e8e98e942de24836", + "g": "05fa8aa266c2c39f", + "name": "CONTROLS", + "method": "use", + "ret": "obj", + "paytoqs": "ignore", + "url": "", + "tls": "", + "persist": false, + "proxy": "", + "authType": "", + "senderr": true, + "headers": [], + "x": 1470, + "y": 820, + "wires": [ + [ + "dbg_fx3_controls" + ] + ] + }, + { + "id": "dbg_fx3_controls", + "type": "debug", + "z": "e8e98e942de24836", + "g": "05fa8aa266c2c39f", + "name": "DEBUG CONTROLS (full msg)", + "active": false, + "tosidebar": true, + "complete": "true", + "targetType": "full", + "statusVal": "", + "statusType": "auto", + "x": 1710, + "y": 820, + "wires": [] + }, + { + "id": "194c2029d84d4697", + "type": "ha-button", + "z": "e8e98e942de24836", + "g": "05fa8aa266c2c39f", + "name": "Server fivem on", + "version": 0, + "debugenabled": false, + "outputs": 1, + "entityConfig": "227f0668c6bf202c", + "outputProperties": [ + { + "property": "payload", + "propertyType": "msg", + "value": "string", + "valueType": "entityState" + }, + { + "property": "topic", + "propertyType": "msg", + "value": "", + "valueType": "triggerId" + }, + { + "property": "data", + "propertyType": "msg", + "value": "", + "valueType": "entity" + } + ], + "x": 220, + "y": 820, + "wires": [ + [ + "37d396b9b8476f17" + ] + ] + }, + { + "id": "eba7b1b802fe8bde", + "type": "ha-button", + "z": "e8e98e942de24836", + "g": "05fa8aa266c2c39f", + "name": "Server fivem off", + "version": 0, + "debugenabled": false, + "outputs": 1, + "entityConfig": "dcd6caa4283cd571", + "outputProperties": [ + { + "property": "payload", + "propertyType": "msg", + "value": "string", + "valueType": "entityState" + }, + { + "property": "topic", + "propertyType": "msg", + "value": "", + "valueType": "triggerId" + }, + { + "property": "data", + "propertyType": "msg", + "value": "", + "valueType": "entity" + } + ], + "x": 220, + "y": 860, + "wires": [ + [ + "1b1e33484fb3a522" + ] + ] + }, + { + "id": "37d396b9b8476f17", + "type": "change", + "z": "e8e98e942de24836", + "g": "05fa8aa266c2c39f", + "name": "start", + "rules": [ + { + "t": "set", + "p": "payload", + "pt": "msg", + "to": "{\"action\":\"start\"}", + "tot": "str" + } + ], + "action": "", + "property": "", + "from": "", + "to": "", + "reg": false, + "x": 410, + "y": 820, + "wires": [ + [ + "fn_fx3_login_req" + ] + ] + }, + { + "id": "1b1e33484fb3a522", + "type": "change", + "z": "e8e98e942de24836", + "g": "05fa8aa266c2c39f", + "name": "stop", + "rules": [ + { + "t": "set", + "p": "payload", + "pt": "msg", + "to": "{\"action\":\"stop\"}", + "tot": "str" + } + ], + "action": "", + "property": "", + "from": "", + "to": "", + "reg": false, + "x": 410, + "y": 860, + "wires": [ + [ + "fn_fx3_login_req" + ] + ] + }, + { + "id": "68a3939b4b8b038a", + "type": "ha-sensor", + "z": "e8e98e942de24836", + "g": "05fa8aa266c2c39f", + "name": "Server status fiveM", + "entityConfig": "91ee1a0f15b0e3af", + "version": 0, + "state": "payload", + "stateType": "msg", + "attributes": [], + "inputOverride": "allow", + "outputProperties": [], + "x": 1690, + "y": 940, + "wires": [ + [] + ] + }, + { + "id": "5faf28207240410e", + "type": "ssh-conf", + "ssh": "", + "name": "VDG", + "userlabel": "VDG" + }, + { + "id": "96e8b42cefda33ac", + "type": "ha-entity-config", + "server": "8c797fff6dc8e6ce", + "deviceConfig": "6258dc8242384d92", + "name": "BeamMP-ON", + "version": 6, + "entityType": "button", + "haConfig": [ + { + "property": "name", + "value": "BeamMP-ON" + }, + { + "property": "icon", + "value": "" + }, + { + "property": "entity_picture", + "value": "" + }, + { + "property": "entity_category", + "value": "" + }, + { + "property": "device_class", + "value": "" + } + ], + "resend": false, + "debugEnabled": false + }, + { + "id": "110f73d18d9f3904", + "type": "ha-entity-config", + "server": "8c797fff6dc8e6ce", + "deviceConfig": "f257b8a45566bcc5", + "name": "BeamMP-OFF", + "version": 6, + "entityType": "button", + "haConfig": [ + { + "property": "name", + "value": "BeamMP-OFF" + }, + { + "property": "icon", + "value": "" + }, + { + "property": "entity_picture", + "value": "" + }, + { + "property": "entity_category", + "value": "" + }, + { + "property": "device_class", + "value": "" + } + ], + "resend": false, + "debugEnabled": false + }, + { + "id": "115c6bf4eacce241", + "type": "ha-entity-config", + "server": "8c797fff6dc8e6ce", + "deviceConfig": "6bbe6f220ec2cccb", + "name": "BeamMP-Restart", + "version": 6, + "entityType": "button", + "haConfig": [ + { + "property": "name", + "value": "BeamMP-Restart" + }, + { + "property": "icon", + "value": "" + }, + { + "property": "entity_picture", + "value": "" + }, + { + "property": "entity_category", + "value": "" + }, + { + "property": "device_class", + "value": "" + } + ], + "resend": false, + "debugEnabled": false + }, + { + "id": "3a83995fb7451dbc", + "type": "ha-entity-config", + "server": "8c797fff6dc8e6ce", + "deviceConfig": "da8f0d7fd9d27964", + "name": "FiveM On", + "version": 6, + "entityType": "button", + "haConfig": [ + { + "property": "name", + "value": "FiveM On" + }, + { + "property": "icon", + "value": "" + }, + { + "property": "entity_picture", + "value": "" + }, + { + "property": "entity_category", + "value": "" + }, + { + "property": "device_class", + "value": "" + } + ], + "resend": false, + "debugEnabled": false + }, + { + "id": "0bd09ec9e22c89a5", + "type": "ha-entity-config", + "server": "8c797fff6dc8e6ce", + "deviceConfig": "73e36735cb8ae0b4", + "name": "FiveM Off", + "version": 6, + "entityType": "button", + "haConfig": [ + { + "property": "name", + "value": "FiveM Off" + }, + { + "property": "icon", + "value": "" + }, + { + "property": "entity_picture", + "value": "" + }, + { + "property": "entity_category", + "value": "" + }, + { + "property": "device_class", + "value": "" + } + ], + "resend": false, + "debugEnabled": false + }, + { + "id": "74a8e0fdb0f4e143", + "type": "ha-entity-config", + "server": "8c797fff6dc8e6ce", + "deviceConfig": "3b8a7f886adffd5c", + "name": "FiveM Restart", + "version": 6, + "entityType": "button", + "haConfig": [ + { + "property": "name", + "value": "FiveM Restart" + }, + { + "property": "icon", + "value": "" + }, + { + "property": "entity_picture", + "value": "" + }, + { + "property": "entity_category", + "value": "" + }, + { + "property": "device_class", + "value": "" + } + ], + "resend": false, + "debugEnabled": false + }, + { + "id": "24560fc20b3695b6", + "type": "mqtt-broker", + "name": "", + "broker": "10.10.40.52", + "port": 1883, + "clientid": "", + "autoConnect": true, + "usetls": false, + "protocolVersion": 4, + "keepalive": 60, + "cleansession": true, + "autoUnsubscribe": true, + "birthTopic": "", + "birthQos": "0", + "birthRetain": "false", + "birthPayload": "", + "birthMsg": {}, + "closeTopic": "", + "closeQos": "0", + "closeRetain": "false", + "closePayload": "", + "closeMsg": {}, + "willTopic": "", + "willQos": "0", + "willRetain": "false", + "willPayload": "", + "willMsg": {}, + "userProps": "", + "sessionExpiry": "" + }, + { + "id": "0f9f03424eb9f328", + "type": "ha-entity-config", + "server": "8c797fff6dc8e6ce", + "deviceConfig": "0e7fb4e33e932e9a", + "name": "FiveM-Status", + "version": 6, + "entityType": "sensor", + "haConfig": [ + { + "property": "name", + "value": "FiveM-Status" + }, + { + "property": "icon", + "value": "" + }, + { + "property": "entity_picture", + "value": "" + }, + { + "property": "entity_category", + "value": "" + }, + { + "property": "device_class", + "value": "" + }, + { + "property": "unit_of_measurement", + "value": "" + }, + { + "property": "state_class", + "value": "" + } + ], + "resend": false, + "debugEnabled": false + }, + { + "id": "4e5bd984cfc87e26", + "type": "ha-entity-config", + "server": "8c797fff6dc8e6ce", + "deviceConfig": "0b4874c76d8e4de9", + "name": "BeamMP-Status", + "version": 6, + "entityType": "sensor", + "haConfig": [ + { + "property": "name", + "value": "BeamMP-Status" + }, + { + "property": "icon", + "value": "" + }, + { + "property": "entity_picture", + "value": "" + }, + { + "property": "entity_category", + "value": "" + }, + { + "property": "device_class", + "value": "" + }, + { + "property": "unit_of_measurement", + "value": "" + }, + { + "property": "state_class", + "value": "" + } + ], + "resend": false, + "debugEnabled": false + }, + { + "id": "8c797fff6dc8e6ce", + "type": "server", + "name": "Home Assistant", + "version": 6, + "addon": false, + "rejectUnauthorizedCerts": false, + "ha_boolean": [ + "y", + "yes", + "true", + "on", + "home", + "open" + ], + "connectionDelay": true, + "cacheJson": true, + "heartbeat": true, + "heartbeatInterval": 30, + "areaSelector": "friendlyName", + "deviceSelector": "friendlyName", + "entitySelector": "friendlyName", + "statusSeparator": ": ", + "statusYear": "hidden", + "statusMonth": "short", + "statusDay": "numeric", + "statusHourCycle": "default", + "statusTimeFormat": "h:m", + "enableGlobalContextStore": false + }, + { + "id": "227f0668c6bf202c", + "type": "ha-entity-config", + "server": "8c797fff6dc8e6ce", + "deviceConfig": "4394725fcca15767", + "name": "Server fivem on", + "version": 6, + "entityType": "button", + "haConfig": [ + { + "property": "name", + "value": "Server fivem on" + }, + { + "property": "icon", + "value": "" + }, + { + "property": "entity_picture", + "value": "" + }, + { + "property": "entity_category", + "value": "" + }, + { + "property": "device_class", + "value": "" + } + ], + "resend": false, + "debugEnabled": false + }, + { + "id": "dcd6caa4283cd571", + "type": "ha-entity-config", + "server": "8c797fff6dc8e6ce", + "deviceConfig": "dacbd7b7117bc310", + "name": "Server fivem off", + "version": 6, + "entityType": "button", + "haConfig": [ + { + "property": "name", + "value": "Server fivem off" + }, + { + "property": "icon", + "value": "" + }, + { + "property": "entity_picture", + "value": "" + }, + { + "property": "entity_category", + "value": "" + }, + { + "property": "device_class", + "value": "" + } + ], + "resend": false, + "debugEnabled": false + }, + { + "id": "91ee1a0f15b0e3af", + "type": "ha-entity-config", + "server": "8c797fff6dc8e6ce", + "deviceConfig": "a00d51e1878020c8", + "name": "Server status fiveM", + "version": 6, + "entityType": "sensor", + "haConfig": [ + { + "property": "name", + "value": "Server status fiveM" + }, + { + "property": "icon", + "value": "" + }, + { + "property": "entity_picture", + "value": "" + }, + { + "property": "entity_category", + "value": "" + }, + { + "property": "device_class", + "value": "" + }, + { + "property": "unit_of_measurement", + "value": "" + }, + { + "property": "state_class", + "value": "" + } + ], + "resend": false, + "debugEnabled": false + }, + { + "id": "6258dc8242384d92", + "type": "ha-device-config", + "name": "BeamMP-ON", + "hwVersion": "", + "manufacturer": "Node-RED", + "model": "", + "swVersion": "" + }, + { + "id": "f257b8a45566bcc5", + "type": "ha-device-config", + "name": "BeamMP-OFF", + "hwVersion": "", + "manufacturer": "Node-RED", + "model": "", + "swVersion": "" + }, + { + "id": "6bbe6f220ec2cccb", + "type": "ha-device-config", + "name": "BeamMP-Restart", + "hwVersion": "", + "manufacturer": "Node-RED", + "model": "", + "swVersion": "" + }, + { + "id": "da8f0d7fd9d27964", + "type": "ha-device-config", + "name": "FiveM On", + "hwVersion": "", + "manufacturer": "Node-RED", + "model": "", + "swVersion": "" + }, + { + "id": "73e36735cb8ae0b4", + "type": "ha-device-config", + "name": "FiveM Off", + "hwVersion": "", + "manufacturer": "Node-RED", + "model": "", + "swVersion": "" + }, + { + "id": "3b8a7f886adffd5c", + "type": "ha-device-config", + "name": "FiveM Restart", + "hwVersion": "", + "manufacturer": "Node-RED", + "model": "", + "swVersion": "" + }, + { + "id": "0e7fb4e33e932e9a", + "type": "ha-device-config", + "name": "FiveM-Status", + "hwVersion": "", + "manufacturer": "Node-RED", + "model": "", + "swVersion": "" + }, + { + "id": "0b4874c76d8e4de9", + "type": "ha-device-config", + "name": "BeamMP-Status", + "hwVersion": "", + "manufacturer": "Node-RED", + "model": "", + "swVersion": "" + }, + { + "id": "4394725fcca15767", + "type": "ha-device-config", + "name": "Server fivem on", + "hwVersion": "", + "manufacturer": "Node-RED", + "model": "", + "swVersion": "" + }, + { + "id": "dacbd7b7117bc310", + "type": "ha-device-config", + "name": "Server fivem off", + "hwVersion": "", + "manufacturer": "Node-RED", + "model": "", + "swVersion": "" + }, + { + "id": "a00d51e1878020c8", + "type": "ha-device-config", + "name": "Server status fiveM", + "hwVersion": "", + "manufacturer": "Node-RED", + "model": "", + "swVersion": "" + }, + { + "id": "b6516b5834d2adf5", + "type": "global-config", + "env": [], + "modules": { + "node-red-contrib-ssh-v3": "2.0.5", + "node-red-contrib-home-assistant-websocket": "0.80.3" + } + } +] \ No newline at end of file