Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [
- {
- "id": "a9972f50.75ddb8",
- "type": "tab",
- "label": "RPI to OS",
- "disabled": false,
- "info": "Flow for using the API calls from opensprinkler\nwith interacting buttons on GPIO ports from the RPI"
- },
- {
- "id": "f960f681.b3fbe",
- "type": "debug",
- "z": "a9972f50.75ddb8",
- "name": "api debugger",
- "active": true,
- "tosidebar": true,
- "console": false,
- "tostatus": false,
- "complete": "true",
- "targetType": "full",
- "x": 1190,
- "y": 330,
- "wires": []
- },
- {
- "id": "a759d49b.f4c6a8",
- "type": "comment",
- "z": "a9972f50.75ddb8",
- "name": "start button (commit)",
- "info": "receive input from a case mounted rotary switch.\nsend input to GPIO (high=1) ",
- "x": 210,
- "y": 255,
- "wires": []
- },
- {
- "id": "ede329cf.d67af",
- "type": "rpi-gpio in",
- "z": "a9972f50.75ddb8",
- "name": "rotary stand 1 [PI/35]",
- "pin": "35",
- "intype": "down",
- "debounce": "300",
- "read": false,
- "x": 295,
- "y": 300,
- "wires": [
- [
- "9d322817.71844"
- ]
- ]
- },
- {
- "id": "b0fe5293.002868",
- "type": "rpi-gpio in",
- "z": "a9972f50.75ddb8",
- "name": "rotary stand 2 [PI/31]",
- "pin": "31",
- "intype": "down",
- "debounce": "25",
- "read": false,
- "x": 295,
- "y": 345,
- "wires": [
- [
- "9d322817.71844"
- ]
- ]
- },
- {
- "id": "b9c402b4.00f7b8",
- "type": "rpi-gpio in",
- "z": "a9972f50.75ddb8",
- "name": "rotary stand 3 [PI/29]",
- "pin": "29",
- "intype": "down",
- "debounce": "25",
- "read": false,
- "x": 295,
- "y": 390,
- "wires": [
- [
- "9d322817.71844"
- ]
- ]
- },
- {
- "id": "44e70bf4.e03e8c",
- "type": "rpi-gpio in",
- "z": "a9972f50.75ddb8",
- "name": "rotary stand 4 [PI/36]",
- "pin": "36",
- "intype": "down",
- "debounce": "25",
- "read": false,
- "x": 295,
- "y": 435,
- "wires": [
- [
- "9d322817.71844"
- ]
- ]
- },
- {
- "id": "9d322817.71844",
- "type": "function",
- "z": "a9972f50.75ddb8",
- "name": "Create Opensprinkler call",
- "func": "// NOTE: The OS API has all the variables in the URL not in the body (payload) or header!\nvar counter = {};\nvar api = {};\nvar load = {}; \nvar zone = flow.get('OSZONE');\n\nvar password=flow.get('pass') || 'NO-PASSWORD'; // get password from flow variable\nvar url =flow.get(\"OSurl\") || 'http://LOCALHOST:8080'; // get url from variable\n\n\nif (msg.payload == 1) \n{\n switch (msg.topic )\n {\n case \"pi/35\":\n api.load = url+\"/cm?pw=\"+password+\"&sid=0&en=1&t=300\"; // zone 1\n counter.payload = 'on';\n counter.timeout = 300;\n zone = \"Garden West\";\n flow.set('OSZONE',zone);\n // flow.set(\"blinker\",1,function(err){110,110})\n break;\n case \"pi/31\":\n api.load = url+\"/cm?pw=\"+password+\"&sid=1&en=1&t=303600\"; // zone 2\n counter.payload = 'on';\n counter.timeout = 360;//300;\n zone = \"Garden South\";\n flow.set('OSZONE',zone);\n break;\n case \"pi/29\":\n api.load = url+\"/cm?pw=\"+password+\"&sid=2&en=1&t=360\"; // zone 3 - border zuid\n counter.payload = 'on';\n counter.timeout = 360;//600;\n zone = \"Borders South\";\n flow.set('OSZONE',zone);\n break;\n case \"pi/36\":\n api.load = url+\"/cm?pw=\"+password+\"&sid=3&en=1&t=300\"; // zone 4\n counter.payload = 'on';\n counter.timeout = 300;//600;\n zone = \"Borders South\";\n flow.set('OSZONE',zone);\n break;\n case \"pi/38\":\n api.load = url+\"/mp?pw=\"+password+\"&pid=1&uwt=0\"; // RUN PROGRAM \"1 Borders\"\n counter.payload = 'on';\n counter.timeout = 15;//900;\n zone = \"PROGR. alle borders\";\n flow.set('OSZONE',zone);\n break;\n case \"pi/40\":\n api.load = url+\"/mp?pw=\"+password+\"&pid=2&uwt=0\"; // RUN PROGRAM \"2 Gazon los\"\n counter.payload = 'on';\n counter.timeout = 15;//900;\n zone = \"PROGR. Gazon totaal\";\n flow.set('OSZONE',zone);\n break; \n case \"pi/37\":\n api.load = url+\"/cv?pw=\"+password+\"&rsn=1\"; // STOP ALL BUTTON!\n counter.payload = 'cancel';\n counter.timeout = 5;\n zone = \"All STOP NOW!\";\n flow.set('OSZONE',zone);\n break; \n } //switch\n \nflow.set('OSZONE',zone);\n} //if\nelse {return;} \napi.url = api.load;\nreturn [api, counter];\n\n",
- "outputs": 2,
- "noerr": 0,
- "x": 595,
- "y": 340,
- "wires": [
- [
- "b4a47b65.bee658",
- "4370a181.474fd8"
- ],
- [
- "8f8284e3.a4093",
- "be45f9aa.f81a88"
- ]
- ],
- "info": "NOTE: The OS API has all the variables in the URL not in the body (payload) or header!\n"
- },
- {
- "id": "5a718039.eb1b58",
- "type": "http request",
- "z": "a9972f50.75ddb8",
- "name": "API opensprinkler",
- "method": "GET",
- "ret": "txt",
- "paytoqs": false,
- "url": "",
- "tls": "",
- "proxy": "",
- "authType": "basic",
- "x": 990,
- "y": 330,
- "wires": [
- [
- "f960f681.b3fbe"
- ]
- ],
- "icon": "font-awesome/fa-spinner"
- },
- {
- "id": "7679d483.824c54",
- "type": "md5",
- "z": "a9972f50.75ddb8",
- "name": "md5 password hash",
- "fieldToHash": "payload",
- "fieldTypeToHash": "msg",
- "hashField": "pass",
- "hashFieldType": "flow",
- "x": 505,
- "y": 165,
- "wires": [
- [
- "19e68d08.1d8ab3"
- ]
- ]
- },
- {
- "id": "aefdef62.fa8ad",
- "type": "inject",
- "z": "a9972f50.75ddb8",
- "name": "SET PASSWORD",
- "topic": "http://YOUR-OS-URL:8080",
- "payload": "YOUR-PASSWORD",
- "payloadType": "str",
- "repeat": "",
- "crontab": "",
- "once": true,
- "onceDelay": 0.1,
- "x": 255,
- "y": 165,
- "wires": [
- [
- "7679d483.824c54",
- "f282ba39.d7be2"
- ]
- ]
- },
- {
- "id": "78fa639d.139314",
- "type": "debug",
- "z": "a9972f50.75ddb8",
- "name": "set URL",
- "active": true,
- "tosidebar": true,
- "console": false,
- "tostatus": false,
- "complete": "true",
- "targetType": "full",
- "x": 725,
- "y": 205,
- "wires": []
- },
- {
- "id": "19e68d08.1d8ab3",
- "type": "debug",
- "z": "a9972f50.75ddb8",
- "name": "password hash",
- "active": true,
- "tosidebar": true,
- "console": false,
- "tostatus": false,
- "complete": "true",
- "targetType": "full",
- "x": 745,
- "y": 165,
- "wires": []
- },
- {
- "id": "8fb9b426.c1f44",
- "type": "inject",
- "z": "a9972f50.75ddb8",
- "name": "debug insert GPIO29",
- "topic": "pi/35",
- "payload": "1",
- "payloadType": "str",
- "repeat": "",
- "crontab": "",
- "once": false,
- "onceDelay": 0.1,
- "x": 150,
- "y": 300,
- "wires": [
- [
- "9d322817.71844"
- ]
- ],
- "icon": "node-red/rpi.png",
- "l": false,
- "info": "run rotary 1"
- },
- {
- "id": "f282ba39.d7be2",
- "type": "function",
- "z": "a9972f50.75ddb8",
- "name": "flow.set('OSurl', OSURL);",
- "func": "var OSURL = msg.topic\nflow.set('OSurl', OSURL);\nreturn msg;",
- "outputs": 1,
- "noerr": 0,
- "x": 515,
- "y": 205,
- "wires": [
- [
- "78fa639d.139314"
- ]
- ]
- },
- {
- "id": "7548e7a4.a9088",
- "type": "rpi-gpio in",
- "z": "a9972f50.75ddb8",
- "name": "rotary stand 5 [PI/38]",
- "pin": "38",
- "intype": "down",
- "debounce": "25",
- "read": false,
- "x": 293,
- "y": 481,
- "wires": [
- [
- "9d322817.71844"
- ]
- ]
- },
- {
- "id": "2d8c0888.b32198",
- "type": "rpi-gpio in",
- "z": "a9972f50.75ddb8",
- "name": "rotary stand 6 [PI/40]",
- "pin": "40",
- "intype": "down",
- "debounce": "25",
- "read": false,
- "x": 295,
- "y": 525,
- "wires": [
- [
- "9d322817.71844"
- ]
- ]
- },
- {
- "id": "ab3fc1db.8f7f28",
- "type": "rpi-gpio in",
- "z": "a9972f50.75ddb8",
- "name": "CANCEL [PI/37]",
- "pin": "37",
- "intype": "down",
- "debounce": "250",
- "read": false,
- "x": 285,
- "y": 620,
- "wires": [
- [
- "9d322817.71844",
- "3ec3f5f0.50369a",
- "c8911ca6.fb87b"
- ]
- ]
- },
- {
- "id": "c462179f.25df38",
- "type": "inject",
- "z": "a9972f50.75ddb8",
- "name": "debug insert GPIO37",
- "topic": "pi/37",
- "payload": "1",
- "payloadType": "str",
- "repeat": "",
- "crontab": "",
- "once": false,
- "onceDelay": 0.1,
- "x": 160,
- "y": 620,
- "wires": [
- [
- "9d322817.71844",
- "3ec3f5f0.50369a"
- ]
- ],
- "icon": "font-awesome/fa-stop-circle",
- "l": false
- },
- {
- "id": "b4a47b65.bee658",
- "type": "debug",
- "z": "a9972f50.75ddb8",
- "name": "function",
- "active": false,
- "tosidebar": true,
- "console": false,
- "tostatus": false,
- "complete": "true",
- "targetType": "full",
- "x": 765,
- "y": 285,
- "wires": [],
- "l": false
- },
- {
- "id": "be45f9aa.f81a88",
- "type": "mytimeout",
- "z": "a9972f50.75ddb8",
- "name": "LCD countdown",
- "outtopic": "",
- "outsafe": "on",
- "outwarning": "Warning",
- "outunsafe": "off",
- "warning": "5",
- "timer": "",
- "debug": false,
- "ndebug": false,
- "ignoreCase": false,
- "repeat": false,
- "again": false,
- "x": 605,
- "y": 520,
- "wires": [
- [
- "d69cc523.bb7c18",
- "3ec3f5f0.50369a"
- ],
- [
- "d4a53368.bd1aa",
- "8c8b93df.69955"
- ]
- ],
- "outputLabels": [
- "stats",
- "counter"
- ],
- "info": "lcd counter"
- },
- {
- "id": "d69cc523.bb7c18",
- "type": "debug",
- "z": "a9972f50.75ddb8",
- "name": "status",
- "active": true,
- "tosidebar": true,
- "console": false,
- "tostatus": false,
- "complete": "true",
- "targetType": "full",
- "x": 820,
- "y": 500,
- "wires": [],
- "l": false
- },
- {
- "id": "d4a53368.bd1aa",
- "type": "debug",
- "z": "a9972f50.75ddb8",
- "name": "counter",
- "active": false,
- "tosidebar": true,
- "console": false,
- "tostatus": false,
- "complete": "true",
- "targetType": "full",
- "x": 820,
- "y": 600,
- "wires": [],
- "l": false
- },
- {
- "id": "8c8b93df.69955",
- "type": "function",
- "z": "a9972f50.75ddb8",
- "name": "LCD message",
- "func": "\nvar String01 =flow.get('OSZONE') ||'abc';\nvar sString02 = msg.payload;\n\nif (msg.state === 1) // RUN state\n{\nmsg.payload = \n {\n\tmsgs: [\n\t\t {\n\t\t\tmsg:String01,\n\t\t\t//msg:\"zone test\" ,\n\t\t\tpos:1,\n\t\t\tcenter:false\n\t\t },\n\t\t {\n\t\t\tmsg:sString02 + \" seconden\",\n\t\t\tpos:1,\n\t\t\tcenter:true\n\t\t }\n\t\t\t]\n }\n}//if\nelse if (msg.state === 2 ) // warning state\n{ \n msg.payload = \n {\n\tmsgs: [\n\t \t\t {\n\t\t\tmsg:String01,\n\t\t\tpos:1,\n\t\t\tcenter:true\n\t\t },\n\t\t {\n\t\t\tmsg: \"Bijna nog \" +sString02+ \" sec.\",\n\t\t\tpos:1,\n\t\t\tcenter:false\n\t\t }\n\t ]\n }\n}\n\nelse if (msg.state === 0 && msg.payload === 0) //DONE state\n{ \n msg.payload = \n {\n \tmsgs: [\n \t\t {\n \t\t\tmsg: \"|------------------|\",\n \t\t\tpos:1,\n \t\t\tcenter:false\n \t\t },\n \t\t {\n \t\t\tmsg: \"| Sproeibeurt |\",\n \t\t\tpos:1,\n \t\t\tcenter:false\n \t\t },\n \t\t {\n \t\t\tmsg: \"| afgerond! |\",\n \t\t\tpos:1,\n \t\t\tcenter:false\n \t\t },\n \t\t {\n \t\t\tmsg: \"|------------------|\",\n \t\t\tpos:1,\n \t\t\tcenter:false\n \t\t }\n \t ]\n }\n}\nelse if (msg.state === 0 && msg.payload === -1) //cancel state\n{ \n msg.payload = \n {\n \tmsgs: [\n \t\t {\n \t\t\tmsg: \"|------------------|\",\n \t\t\tpos:1,\n \t\t\tcenter:false\n \t\t },\n \t\t {\n \t\t\tmsg: \"| \"+String01+ \" |\",\n \t\t\tpos:1,\n \t\t\tcenter:false\n \t\t },\n \t\t {\n \t\t\tmsg: \"| |\",\n \t\t\tpos:1,\n \t\t\tcenter:false\n \t\t },\n \t\t {\n \t\t\tmsg: \"|------------------|\",\n \t\t\tpos:1,\n \t\t\tcenter:false\n \t\t }\n \t ]\n }\n}\nelse {return;} \nreturn msg;\n\n",
- "outputs": 1,
- "noerr": 0,
- "x": 890,
- "y": 555,
- "wires": [
- [
- "b38021.02e81fe",
- "bde95634.1e63d"
- ]
- ]
- },
- {
- "id": "8f8284e3.a4093",
- "type": "debug",
- "z": "a9972f50.75ddb8",
- "name": "",
- "active": false,
- "tosidebar": true,
- "console": false,
- "tostatus": false,
- "complete": "true",
- "targetType": "full",
- "x": 765,
- "y": 375,
- "wires": [],
- "l": false
- },
- {
- "id": "3d326806.274e28",
- "type": "delay",
- "z": "a9972f50.75ddb8",
- "name": "clear LCD after run",
- "pauseType": "delayv",
- "timeout": "15",
- "timeoutUnits": "seconds",
- "rate": "1",
- "nbRateUnits": "1",
- "rateUnits": "second",
- "randomFirst": "1",
- "randomLast": "5",
- "randomUnits": "seconds",
- "drop": false,
- "x": 1055,
- "y": 460,
- "wires": [
- [
- "bde95634.1e63d"
- ]
- ]
- },
- {
- "id": "3ec3f5f0.50369a",
- "type": "function",
- "z": "a9972f50.75ddb8",
- "name": "clear lcd",
- "func": "if (msg.topic === \"pi/37\" ) // if cancel button is pressed\n{\nmsg.delay = 15000 // 10 sec.\nmsg.topic = \"flush\" //send this message now regardless of the old delay timer\nmsg.payload = {\n\tmsgs:[\n\t\t{\n\t\t\tmsg:'',\n\t\t\tpos:1,\n\t\t\tcenter:true\n\t\t}\n\t\t\n\t]\n};\n\n} //if\nelse {\n msg.delay = (msg.timeout*1000)+15000 \nmsg.payload = {\n\tmsgs:[\n\t\t{\n\t\t\tmsg:'',\n\t\t\tpos:1,\n\t\t\tcenter:true\n\t\t}\n\t\t\n\t]\n};\n} //else\nreturn msg;",
- "outputs": 1,
- "noerr": 0,
- "x": 865,
- "y": 460,
- "wires": [
- [
- "3d326806.274e28"
- ]
- ],
- "info": "clears the LCD after a run"
- },
- {
- "id": "b38021.02e81fe",
- "type": "debug",
- "z": "a9972f50.75ddb8",
- "name": "lcd debug",
- "active": false,
- "tosidebar": true,
- "console": false,
- "tostatus": false,
- "complete": "payload",
- "targetType": "msg",
- "x": 1085,
- "y": 560,
- "wires": []
- },
- {
- "id": "c8911ca6.fb87b",
- "type": "debug",
- "z": "a9972f50.75ddb8",
- "name": "",
- "active": true,
- "tosidebar": true,
- "console": false,
- "tostatus": false,
- "complete": "true",
- "targetType": "full",
- "x": 575,
- "y": 620,
- "wires": []
- },
- {
- "id": "ba1ee891.4b909",
- "type": "inject",
- "z": "a9972f50.75ddb8",
- "name": "debug insert GPIO29",
- "topic": "pi/38",
- "payload": "1",
- "payloadType": "str",
- "repeat": "",
- "crontab": "",
- "once": false,
- "onceDelay": 0.1,
- "x": 150,
- "y": 480,
- "wires": [
- [
- "9d322817.71844"
- ]
- ],
- "icon": "node-red/rpi.png",
- "l": false,
- "info": "run rotary 1"
- },
- {
- "id": "4c3c20b6.02e71",
- "type": "inject",
- "z": "a9972f50.75ddb8",
- "name": "debug insert GPIO31",
- "topic": "pi/31",
- "payload": "1",
- "payloadType": "str",
- "repeat": "",
- "crontab": "",
- "once": false,
- "onceDelay": 0.1,
- "x": 150,
- "y": 345,
- "wires": [
- [
- "9d322817.71844"
- ]
- ],
- "icon": "node-red/rpi.png",
- "l": false,
- "info": "run rotary 1"
- },
- {
- "id": "bf8292cb.8b9768",
- "type": "inject",
- "z": "a9972f50.75ddb8",
- "name": "",
- "topic": "pi/29",
- "payload": "1",
- "payloadType": "str",
- "repeat": "",
- "crontab": "",
- "once": false,
- "onceDelay": 0.1,
- "x": 150,
- "y": 390,
- "wires": [
- [
- "9d322817.71844"
- ]
- ],
- "icon": "node-red/rpi.png",
- "l": false,
- "info": "run rotary 1"
- },
- {
- "id": "979e2ddc.5b917",
- "type": "inject",
- "z": "a9972f50.75ddb8",
- "name": "",
- "topic": "pi/36",
- "payload": "1",
- "payloadType": "str",
- "repeat": "",
- "crontab": "",
- "once": false,
- "onceDelay": 0.1,
- "x": 150,
- "y": 435,
- "wires": [
- [
- "9d322817.71844"
- ]
- ],
- "icon": "node-red/rpi.png",
- "l": false,
- "info": "run rotary 1"
- },
- {
- "id": "4370a181.474fd8",
- "type": "delay",
- "z": "a9972f50.75ddb8",
- "name": "delay API",
- "pauseType": "delay",
- "timeout": "4",
- "timeoutUnits": "seconds",
- "rate": "1",
- "nbRateUnits": "1",
- "rateUnits": "second",
- "randomFirst": "1",
- "randomLast": "5",
- "randomUnits": "seconds",
- "drop": false,
- "x": 810,
- "y": 330,
- "wires": [
- [
- "5a718039.eb1b58"
- ]
- ],
- "info": " delay API call for sync with LCD"
- },
- {
- "id": "373804fa.5e64ac",
- "type": "inject",
- "z": "a9972f50.75ddb8",
- "name": "debug insert",
- "topic": "pi/40",
- "payload": "1",
- "payloadType": "str",
- "repeat": "",
- "crontab": "",
- "once": false,
- "onceDelay": 0.1,
- "x": 150,
- "y": 525,
- "wires": [
- [
- "9d322817.71844"
- ]
- ],
- "icon": "node-red/rpi.png",
- "l": false,
- "info": "run rotary 1"
- },
- {
- "id": "b0cbc4f1.a9af8",
- "type": "comment",
- "z": "a9972f50.75ddb8",
- "name": "set system variables here",
- "info": "type your password into the **payload**\ntype your OpenSprinkler URL into the **topic**",
- "x": 245,
- "y": 105,
- "wires": []
- },
- {
- "id": "c546008b.3dba9",
- "type": "comment",
- "z": "a9972f50.75ddb8",
- "name": "example GET API calls",
- "info": "beaware that your password \nmust be encrypted with a MD5 hash",
- "x": 235,
- "y": 720,
- "wires": []
- },
- {
- "id": "69e6c543.fd29b4",
- "type": "inject",
- "z": "a9972f50.75ddb8",
- "name": "get all config",
- "topic": "",
- "payload": "http://localhost:8080/jc?pw=6e216f3999d808ce106ae63446b60031",
- "payloadType": "str",
- "repeat": "",
- "crontab": "",
- "once": false,
- "onceDelay": 0.1,
- "x": 220,
- "y": 795,
- "wires": [
- [
- "b96aef88.dbd92"
- ]
- ]
- },
- {
- "id": "b96aef88.dbd92",
- "type": "http request",
- "z": "a9972f50.75ddb8",
- "name": "API opensprinkler",
- "method": "GET",
- "ret": "txt",
- "paytoqs": false,
- "url": "",
- "tls": "",
- "proxy": "",
- "authType": "basic",
- "x": 450,
- "y": 795,
- "wires": [
- [
- "8689f6a.f771208"
- ]
- ],
- "icon": "font-awesome/fa-spinner"
- },
- {
- "id": "8689f6a.f771208",
- "type": "debug",
- "z": "a9972f50.75ddb8",
- "name": "api debugger",
- "active": true,
- "tosidebar": true,
- "console": false,
- "tostatus": false,
- "complete": "true",
- "targetType": "full",
- "x": 680,
- "y": 795,
- "wires": []
- },
- {
- "id": "bde95634.1e63d",
- "type": "LCD20x4-I2C",
- "z": "a9972f50.75ddb8",
- "name": "",
- "speed": "3",
- "size": "20x4",
- "x": 1350,
- "y": 510,
- "wires": []
- },
- {
- "id": "5f26df7c.62d18",
- "type": "comment",
- "z": "a9972f50.75ddb8",
- "name": "LCD",
- "info": "connected to a LCD 2004.\nwith i2c connected to the opensprinkler board and a raspberry pi",
- "x": 1310,
- "y": 450,
- "wires": []
- }
- ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement