[
    {
        "id": "15f71001.075b9",
        "type": "tab",
        "label": "RAPT Webhook to MQTT",
        "disabled": false,
        "info": ""
    },
    {
        "id": "673633eb.67a02c",
        "type": "http in",
        "z": "15f71001.075b9",
        "name": "",
        "url": "/raptstream",
        "method": "post",
        "upload": false,
        "swaggerDoc": "",
        "x": 240,
        "y": 200,
        "wires": [
            [
                "9c9cf3d6.adced",
                "46b7f555.a7837c",
                "1cf410e9.eed4cf"
            ]
        ]
    },
    {
        "id": "9c9cf3d6.adced",
        "type": "debug",
        "z": "15f71001.075b9",
        "name": "",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 590,
        "y": 40,
        "wires": []
    },
    {
        "id": "46b7f555.a7837c",
        "type": "template",
        "z": "15f71001.075b9",
        "name": "Return a status to the post call",
        "field": "payload",
        "fieldType": "msg",
        "format": "handlebars",
        "syntax": "mustache",
        "template": "Accepted",
        "x": 650,
        "y": 100,
        "wires": [
            [
                "85c9aa7e.bfb298"
            ]
        ]
    },
    {
        "id": "85c9aa7e.bfb298",
        "type": "http response",
        "z": "15f71001.075b9",
        "name": "",
        "statusCode": "",
        "headers": {},
        "x": 950,
        "y": 100,
        "wires": []
    },
    {
        "id": "e5628fdd.15f61",
        "type": "mqtt out",
        "z": "15f71001.075b9",
        "name": "Publish to MQTT Server",
        "topic": "",
        "qos": "",
        "retain": "",
        "broker": "607bcc98.0ac294",
        "x": 1430,
        "y": 400,
        "wires": []
    },
    {
        "id": "1cf410e9.eed4cf",
        "type": "function",
        "z": "15f71001.075b9",
        "name": "Create topic root (to device name)",
        "func": "// lowercase the device name \ndevice_name = msg.payload.device_name;\n\nmqttDeviceName = device_name.replace(/\\s/g, '').toLowerCase();\n\nmsg.payload.topic_root = \"house/rapt/\" + mqttDeviceName;\n\nmsg.payload = msg.payload;\n\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "x": 660,
        "y": 340,
        "wires": [
            [
                "50c8c502.071ccc",
                "553f8651.5cf948",
                "81173f33.bc9a9",
                "3c03063f.73607a",
                "366f4e96.1720d2",
                "bbee0acf.536a68",
                "165fc49a.8c7c4b",
                "8082d835.208118",
                "9527ed32.c83c3",
                "2085c63b.41bafa"
            ]
        ]
    },
    {
        "id": "50c8c502.071ccc",
        "type": "debug",
        "z": "15f71001.075b9",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 1010,
        "y": 180,
        "wires": []
    },
    {
        "id": "553f8651.5cf948",
        "type": "function",
        "z": "15f71001.075b9",
        "name": "Publish Device ID",
        "func": "msg.topic = msg.payload.topic_root + \"/device_id\";\nmsg.payload = msg.payload.device_id;\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "x": 1030,
        "y": 260,
        "wires": [
            [
                "e5628fdd.15f61"
            ]
        ]
    },
    {
        "id": "81173f33.bc9a9",
        "type": "function",
        "z": "15f71001.075b9",
        "name": "Publish Device Type",
        "func": "msg.topic = msg.payload.topic_root + \"/device_type\";\nmsg.payload = msg.payload.device_type;\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "x": 1040,
        "y": 300,
        "wires": [
            [
                "e5628fdd.15f61"
            ]
        ]
    },
    {
        "id": "366f4e96.1720d2",
        "type": "function",
        "z": "15f71001.075b9",
        "name": "Publish Temperature",
        "func": "msg.topic = msg.payload.topic_root + \"/temperature\";\nmsg.payload = msg.payload.temperature;\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "x": 1040,
        "y": 460,
        "wires": [
            [
                "e5628fdd.15f61"
            ]
        ]
    },
    {
        "id": "3c03063f.73607a",
        "type": "function",
        "z": "15f71001.075b9",
        "name": "Publish Device Type",
        "func": "msg.topic = msg.payload.topic_root + \"/device_name\";\nmsg.payload = msg.payload.device_name;\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "x": 1040,
        "y": 340,
        "wires": [
            [
                "e5628fdd.15f61"
            ]
        ]
    },
    {
        "id": "bbee0acf.536a68",
        "type": "function",
        "z": "15f71001.075b9",
        "name": "Publish Signal Strength (RSSI)",
        "func": "msg.topic = msg.payload.topic_root + \"/rssi\";\nmsg.payload = msg.payload.rssi;\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "x": 1070,
        "y": 380,
        "wires": [
            [
                "e5628fdd.15f61"
            ]
        ]
    },
    {
        "id": "165fc49a.8c7c4b",
        "type": "function",
        "z": "15f71001.075b9",
        "name": "Publish Created Date",
        "func": "msg.topic = msg.payload.topic_root + \"/created_date\";\nmsg.payload = msg.payload.created_date;\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "x": 1040,
        "y": 420,
        "wires": [
            [
                "e5628fdd.15f61"
            ]
        ]
    },
    {
        "id": "8082d835.208118",
        "type": "function",
        "z": "15f71001.075b9",
        "name": "Publish Target Temperature",
        "func": "// Return Taget Temperature if not a pill/hydrometer\nif (msg.payload.device_type == \"Hydrometer\") {\n    return null;\n} else {\n    msg.topic = msg.payload.topic_root + \"/temperature\";\n    msg.payload = msg.payload.temperature;\n    return msg;\n}",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "x": 1060,
        "y": 660,
        "wires": [
            [
                "e5628fdd.15f61"
            ]
        ]
    },
    {
        "id": "9527ed32.c83c3",
        "type": "function",
        "z": "15f71001.075b9",
        "name": "Publish Gravity for Pill",
        "func": "// Return Gravity if a pill/hydrometer\nif (msg.payload.device_type == \"Hydrometer\") {\n        msg.topic = msg.payload.topic_root + \"/gravity\";\n    msg.payload = msg.payload.gravity;\n    return msg;\n} else {\n return null;\n}",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "x": 1040,
        "y": 540,
        "wires": [
            [
                "e5628fdd.15f61"
            ]
        ]
    },
    {
        "id": "2085c63b.41bafa",
        "type": "function",
        "z": "15f71001.075b9",
        "name": "Publish Battery for Pill",
        "func": "// Return Gravity if a pill/hydrometer\nif (msg.payload.device_type == \"Hydrometer\") {\n        msg.topic = msg.payload.topic_root + \"/battery\";\n    msg.payload = msg.payload.battery;\n    return msg;\n} else {\n return null;\n}",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "x": 1040,
        "y": 580,
        "wires": [
            [
                "e5628fdd.15f61"
            ]
        ]
    },
    {
        "id": "e1bba7ac.47a7d8",
        "type": "comment",
        "z": "15f71001.075b9",
        "name": "Just for Pills",
        "info": "",
        "x": 1010,
        "y": 500,
        "wires": []
    },
    {
        "id": "dd4d30d3.41834",
        "type": "comment",
        "z": "15f71001.075b9",
        "name": "All Device Types",
        "info": "",
        "x": 1020,
        "y": 220,
        "wires": []
    },
    {
        "id": "80002e85.663a9",
        "type": "comment",
        "z": "15f71001.075b9",
        "name": "Not Pills",
        "info": "",
        "x": 1000,
        "y": 620,
        "wires": []
    },
    {
        "id": "607bcc98.0ac294",
        "type": "mqtt-broker",
        "broker": "yourmqttbroker",
        "port": "1883",
        "clientid": "",
        "usetls": false,
        "compatmode": true,
        "keepalive": "60",
        "cleansession": true,
        "birthTopic": "",
        "birthQos": "0",
        "birthPayload": "",
        "willTopic": "",
        "willQos": "0",
        "willPayload": ""
    }
]