Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [
- {
- "id": "cdc39aa85d9e2b26",
- "type": "function",
- "z": "bf14112.91a86f",
- "name": "Traffic",
- "func": "// Replacement Traffic node as original was nuked in NR13\n\nconst allow = \"ALLOW\"\nconst block = \"BLOCK\"\n\n// create unique storage for each instance using the function node's own ID\nvar uid = \"traffic_\" + node.id + \"_state\"\n\n// retrieve traffic light state from storage\nvar sto = flow.get(uid)\n\n// green: pass message through\nif (sto == allow) {\n node.status({fill:\"green\",shape:\"dot\",text:allow});\n return msg\n}\n\n// red: do no such thing\nif (sto == block) {\n node.status({fill:\"red\",shape:\"dot\",text:block});\n}\n\n// parse control messages\nif (msg.hasOwnProperty(\"control\")) {\n if (msg.control.toUpperCase() == allow) {\n node.status({fill:\"green\",shape:\"dot\",text:allow}); \n flow.set(uid,allow);\n }\n if (msg.control.toUpperCase() == block) {\n node.status({fill:\"red\",shape:\"dot\",text:block}); \n flow.set(uid,block);\n }\n}\n",
- "outputs": 1,
- "noerr": 0,
- "initialize": "// Code added here will be run once\n// whenever the node is started.\n\nconst init_state = \"BLOCK\"\nvar uid = \"traffic_\" + node.id + \"_state\"\nflow.set(uid,init_state)\nnode.status({fill:\"red\",shape:\"dot\",text:init_state});\n",
- "finalize": "",
- "libs": [],
- "x": 330,
- "y": 3580,
- "wires": [
- [
- "e229ced0d3aaa895"
- ]
- ]
- },
- {
- "id": "3ca8bd52927e845f",
- "type": "inject",
- "z": "bf14112.91a86f",
- "name": "Payload",
- "props": [
- {
- "p": "payload"
- }
- ],
- "repeat": "",
- "crontab": "",
- "once": false,
- "onceDelay": 0.1,
- "topic": "",
- "payloadType": "date",
- "x": 160,
- "y": 3580,
- "wires": [
- [
- "cdc39aa85d9e2b26"
- ]
- ]
- },
- {
- "id": "fc2a233ae81b0a7a",
- "type": "inject",
- "z": "bf14112.91a86f",
- "name": "Allow",
- "props": [
- {
- "p": "control",
- "v": "Allow",
- "vt": "str"
- }
- ],
- "repeat": "",
- "crontab": "",
- "once": false,
- "onceDelay": 0.1,
- "topic": "",
- "x": 150,
- "y": 3680,
- "wires": [
- [
- "cdc39aa85d9e2b26"
- ]
- ]
- },
- {
- "id": "f21ba4c1fb2f9247",
- "type": "inject",
- "z": "bf14112.91a86f",
- "name": "Block",
- "props": [
- {
- "p": "control",
- "v": "block",
- "vt": "str"
- }
- ],
- "repeat": "",
- "crontab": "",
- "once": false,
- "onceDelay": 0.1,
- "topic": "",
- "x": 150,
- "y": 3640,
- "wires": [
- [
- "cdc39aa85d9e2b26"
- ]
- ]
- },
- {
- "id": "e229ced0d3aaa895",
- "type": "debug",
- "z": "bf14112.91a86f",
- "name": "OUT",
- "active": true,
- "tosidebar": true,
- "console": false,
- "tostatus": false,
- "complete": "payload",
- "targetType": "msg",
- "statusVal": "",
- "statusType": "auto",
- "x": 470,
- "y": 3580,
- "wires": []
- },
- {
- "id": "5a888fa72fcdbf18",
- "type": "comment",
- "z": "bf14112.91a86f",
- "name": "Replacement for Traffic node",
- "info": "",
- "x": 120,
- "y": 3540,
- "wires": []
- }
- ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement