[
    {
        "id": "18d6e383.86da7c",
        "type": "tab",
        "label": "SPS einelsen",
        "disabled": false,
        "info": ""
    },
    {
        "id": "a94b9dcd.27759",
        "type": "s7 in",
        "z": "18d6e383.86da7c",
        "endpoint": "768d34f7.c887ec",
        "mode": "all",
        "variable": "",
        "diff": true,
        "name": "SPS_verbindung",
        "x": 120,
        "y": 160,
        "wires": [
            [
                "1a56b2e2.87e36d",
                "218cf7bc.ae3588"
            ]
        ]
    },
    {
        "id": "f6309448.1fc528",
        "type": "function",
        "z": "18d6e383.86da7c",
        "name": "SQL eintragen",
        "func": "msg.topic = \"INSERT INTO `data` (`date`, `id`, `ref_temp`, `sens_temp`, `status`) VALUES ('\" +msg.date+ \"' , '\" +msg.payload[0].id+ \"', '\"+msg.payload[0].ref+\"', '\"+msg.payload[0].temp+\"', '\"+msg.payload[0].stat+\"');\"\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "x": 1160,
        "y": 160,
        "wires": [
            [
                "3ac9cf6f.d645e",
                "e39e15fb.2f6538"
            ]
        ]
    },
    {
        "id": "3ac9cf6f.d645e",
        "type": "mysql",
        "z": "18d6e383.86da7c",
        "mydb": "92414223.53143",
        "name": "",
        "x": 1330,
        "y": 160,
        "wires": [
            []
        ]
    },
    {
        "id": "bc73f7aa.368738",
        "type": "status",
        "z": "18d6e383.86da7c",
        "name": "status_sps",
        "scope": [
            "a94b9dcd.27759"
        ],
        "x": 100,
        "y": 420,
        "wires": [
            [
                "3eb434ad.ee5bbc",
                "4ec49cc0.b77134"
            ]
        ]
    },
    {
        "id": "3eb434ad.ee5bbc",
        "type": "function",
        "z": "18d6e383.86da7c",
        "name": "status_funktion",
        "func": "if(msg.status.fill == \"green\")\n{\n    msg.payload= \"Online\";\n}\nelse if(msg.status.fill == \"yellow\")\n{\n    msg.payload = \"Verbinde...\";   \n}\nelse\n{\n    msg.payload=\"Offline\";\n}\n\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 300,
        "y": 420,
        "wires": [
            [
                "ec1a241b.198dd8",
                "ea94110c.9a824"
            ]
        ]
    },
    {
        "id": "1a56b2e2.87e36d",
        "type": "function",
        "z": "18d6e383.86da7c",
        "name": "id_abgleich",
        "func": "msg.topic = \"SELECT * FROM data WHERE id=\"+ msg.payload.id +\"\";\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "x": 330,
        "y": 160,
        "wires": [
            [
                "2e6617d8.418ad8"
            ]
        ]
    },
    {
        "id": "e39e15fb.2f6538",
        "type": "debug",
        "z": "18d6e383.86da7c",
        "name": "",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 1310,
        "y": 260,
        "wires": []
    },
    {
        "id": "2e6617d8.418ad8",
        "type": "mysql",
        "z": "18d6e383.86da7c",
        "mydb": "92414223.53143",
        "name": "",
        "x": 500,
        "y": 160,
        "wires": [
            [
                "218cf7bc.ae3588"
            ]
        ]
    },
    {
        "id": "218cf7bc.ae3588",
        "type": "join",
        "z": "18d6e383.86da7c",
        "name": "zusammenfuegen",
        "mode": "custom",
        "build": "array",
        "property": "payload",
        "propertyType": "msg",
        "key": "topic",
        "joiner": "\\n",
        "joinerType": "str",
        "accumulate": false,
        "timeout": "0.5",
        "count": "",
        "reduceRight": false,
        "reduceExp": "",
        "reduceInit": "",
        "reduceInitType": "",
        "reduceFixup": "",
        "x": 510,
        "y": 280,
        "wires": [
            [
                "4fb2e6d3.4343a8"
            ]
        ]
    },
    {
        "id": "aff27e9e.b2c5d",
        "type": "debug",
        "z": "18d6e383.86da7c",
        "name": "",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 910,
        "y": 280,
        "wires": []
    },
    {
        "id": "495c6ac7.cda3a4",
        "type": "function",
        "z": "18d6e383.86da7c",
        "name": "daten_funktion",
        "func": "msg.date = new Date();\nmsg.payload[0].ref = msg.payload[0].ref/100;\nmsg.payload[0].temp = msg.payload[0].temp/100;\nif(msg.payload[0].stat == \"0\")\n{\n    msg.payload[0].stat = \"Fehlerhaft\";\n}\nif(msg.payload[0].stat == \"1\")\n{\n    msg.payload[0].stat = \"i.O.\";\n}\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "x": 740,
        "y": 160,
        "wires": [
            [
                "aff27e9e.b2c5d",
                "41f9c592.aae0ec"
            ]
        ]
    },
    {
        "id": "4fb2e6d3.4343a8",
        "type": "switch",
        "z": "18d6e383.86da7c",
        "name": "if",
        "property": "payload[1]",
        "propertyType": "msg",
        "rules": [
            {
                "t": "empty"
            },
            {
                "t": "else"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 2,
        "x": 690,
        "y": 280,
        "wires": [
            [
                "495c6ac7.cda3a4"
            ],
            []
        ]
    },
    {
        "id": "4ec49cc0.b77134",
        "type": "debug",
        "z": "18d6e383.86da7c",
        "name": "status",
        "active": true,
        "tosidebar": false,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 330,
        "y": 580,
        "wires": []
    },
    {
        "id": "fa657030.3233a",
        "type": "comment",
        "z": "18d6e383.86da7c",
        "name": "stellt Verbindung zur SPS via IP und Port her",
        "info": "",
        "x": 210,
        "y": 120,
        "wires": []
    },
    {
        "id": "11d9fdfe.565a52",
        "type": "comment",
        "z": "18d6e383.86da7c",
        "name": "Abgleich ob der Datensatz neu ist",
        "info": "",
        "x": 530,
        "y": 120,
        "wires": []
    },
    {
        "id": "763d626c.d50b5c",
        "type": "comment",
        "z": "18d6e383.86da7c",
        "name": "Daten in das richtige Format bringen",
        "info": "",
        "x": 840,
        "y": 120,
        "wires": []
    },
    {
        "id": "67381332.7262dc",
        "type": "comment",
        "z": "18d6e383.86da7c",
        "name": "SQL Eintrag, welcher an die Datenbank gesendet wird",
        "info": "",
        "x": 1260,
        "y": 120,
        "wires": []
    },
    {
        "id": "c206ffa.51ce8",
        "type": "comment",
        "z": "18d6e383.86da7c",
        "name": "liest den Verbindungsstatus der SPS aus",
        "info": "",
        "x": 200,
        "y": 380,
        "wires": []
    },
    {
        "id": "41f9c592.aae0ec",
        "type": "moment",
        "z": "18d6e383.86da7c",
        "name": "datum_formatieren",
        "topic": "",
        "input": "date",
        "inputType": "msg",
        "inTz": "Europe/Berlin",
        "adjAmount": "2",
        "adjType": "hours",
        "adjDir": "add",
        "format": "",
        "locale": "de-DE",
        "output": "date",
        "outputType": "msg",
        "outTz": "Europe/Berlin",
        "x": 950,
        "y": 160,
        "wires": [
            [
                "f6309448.1fc528"
            ]
        ]
    },
    {
        "id": "ea94110c.9a824",
        "type": "ui_text",
        "z": "18d6e383.86da7c",
        "group": "64dba6a2.57e538",
        "order": 6,
        "width": 1,
        "height": 1,
        "name": "text_status",
        "label": "",
        "format": "{{msg.payload}}",
        "layout": "row-spread",
        "x": 510,
        "y": 520,
        "wires": []
    },
    {
        "id": "ec1a241b.198dd8",
        "type": "ui_led",
        "z": "18d6e383.86da7c",
        "order": 5,
        "group": "64dba6a2.57e538",
        "width": 3,
        "height": 1,
        "label": "SPS:",
        "labelPlacement": "left",
        "labelAlignment": "left",
        "colorForValue": [
            {
                "color": "#ff0000",
                "value": "Offline",
                "valueType": "str"
            },
            {
                "color": "#008000",
                "value": "Online",
                "valueType": "str"
            },
            {
                "color": "#ffff00",
                "value": "Verbinde...",
                "valueType": "str"
            }
        ],
        "allowColorForValueInMessage": false,
        "shape": "circle",
        "showGlow": true,
        "name": "led_status",
        "x": 510,
        "y": 420,
        "wires": []
    },
    {
        "id": "768d34f7.c887ec",
        "type": "s7 endpoint",
        "transport": "iso-on-tcp",
        "address": "172.30.50.33",
        "port": "102",
        "rack": "0",
        "slot": "1",
        "localtsaphi": "01",
        "localtsaplo": "00",
        "remotetsaphi": "01",
        "remotetsaplo": "00",
        "connmode": "rack-slot",
        "adapter": "",
        "busaddr": "2",
        "cycletime": "500",
        "timeout": "2000",
        "name": "ET200SP",
        "vartable": [
            {
                "addr": "DB6,WORD0",
                "name": "id"
            },
            {
                "addr": "DB6,WORD2",
                "name": "ref"
            },
            {
                "addr": "DB6,WORD4",
                "name": "temp"
            },
            {
                "addr": "DB6,WORD6",
                "name": "stat"
            }
        ]
    },
    {
        "id": "92414223.53143",
        "type": "MySQLdatabase",
        "name": "db",
        "host": "127.0.0.1",
        "port": "3306",
        "db": "test_daten",
        "tz": "Europe/Berlin",
        "charset": "UTF8"
    },
    {
        "id": "64dba6a2.57e538",
        "type": "ui_group",
        "name": "Suche",
        "tab": "4af2ffba.9d14c",
        "order": 2,
        "disp": true,
        "width": "6",
        "collapse": false
    },
    {
        "id": "4af2ffba.9d14c",
        "type": "ui_tab",
        "name": "Home",
        "icon": "dashboard",
        "order": 1,
        "disabled": false,
        "hidden": false
    }
]