OpenMarine

Full Version: SubFlows
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Anyone using subflows much? 
Just thinking here - might be nice to have a space somewhere like github to store some useful subflows and brief how to for all to download, for instance I'm just working on one with a dashboard to let you choose a number and a infludb measurement string so you can easily enter data manually into your database. I'll post it once it works. 
Any thoughts?

https://nodered.org/docs/user-guide/edit...e/subflows
Here's one if anyone is interested,  nodered countdown timer, on my system it turns off clementine media player and mpc mp3 player.

Counts down in seconds, set time in minutes plus buttons to turn off and reboot the Pi >
[Image: 6qk02yJ.png]

[Image: HRAuN00.png]



Code:
[
   {
       "id": "93bf7220.2bec2",
       "type": "subflow",
       "name": "Subflow 1",
       "info": "",
       "in": [],
       "out": []
   },
   {
       "id": "26d6c7a0.d43558",
       "type": "ui_slider",
       "z": "93bf7220.2bec2",
       "name": "Auto Turn Off",
       "label": "Minutes",
       "tooltip": "",
       "group": "d4a061b3.6ae9d",
       "order": 2,
       "width": 0,
       "height": 0,
       "passthru": true,
       "outs": "end",
       "topic": "",
       "min": 0,
       "max": "70",
       "step": 1,
       "x": 210,
       "y": 160,
       "wires": [
           [
               "e694c854.c75008"
           ]
       ]
   },
   {
       "id": "ea149bfc.8f3d68",
       "type": "exec",
       "z": "93bf7220.2bec2",
       "command": "sudo killall clementine",
       "addpay": false,
       "append": "",
       "useSpawn": "false",
       "timer": "",
       "oldrc": false,
       "name": "",
       "x": 880,
       "y": 120,
       "wires": [
           [],
           [],
           []
       ]
   },
   {
       "id": "e694c854.c75008",
       "type": "function",
       "z": "93bf7220.2bec2",
       "name": "seconds to minutes",
       "func": "if(msg.topic!=\"countdown\"){\n    msg.timeout=msg.payload*60;\nreturn msg;}",
       "outputs": 1,
       "noerr": 0,
       "x": 410,
       "y": 120,
       "wires": [
           [
               "845b73a0.3c363"
           ]
       ]
   },
   {
       "id": "fddca3e2.bc0fc",
       "type": "exec",
       "z": "93bf7220.2bec2",
       "command": "mpc stop",
       "addpay": false,
       "append": "",
       "useSpawn": "false",
       "timer": "",
       "oldrc": false,
       "name": "",
       "x": 840,
       "y": 180,
       "wires": [
           [],
           [],
           []
       ]
   },
   {
       "id": "b667bd5a.a94f2",
       "type": "inject",
       "z": "93bf7220.2bec2",
       "name": "Inject for testing",
       "props": [
           {
               "p": "payload"
           },
           {
               "p": "topic",
               "vt": "str"
           }
       ],
       "repeat": "",
       "crontab": "",
       "once": false,
       "onceDelay": 0.1,
       "topic": "",
       "payload": "25",
       "payloadType": "num",
       "x": 240,
       "y": 120,
       "wires": [
           [
               "26d6c7a0.d43558"
           ]
       ]
   },
   {
       "id": "845b73a0.3c363",
       "type": "mytimeout",
       "z": "93bf7220.2bec2",
       "name": "",
       "outtopic": "",
       "outsafe": "",
       "outwarning": "",
       "outunsafe": "off",
       "warning": "1",
       "timer": "3",
       "debug": false,
       "ndebug": false,
       "ignoreCase": false,
       "repeat": false,
       "again": false,
       "x": 650,
       "y": 120,
       "wires": [
           [
               "fddca3e2.bc0fc",
               "ea149bfc.8f3d68"
           ],
           [
               "9ea7b2c0.97ad6"
           ]
       ]
   },
   {
       "id": "7ae79492.3b9f3c",
       "type": "ui_text",
       "z": "93bf7220.2bec2",
       "group": "d4a061b3.6ae9d",
       "order": 1,
       "width": 0,
       "height": 0,
       "name": "",
       "label": "Time til turn off",
       "format": "{{msg.payload}}",
       "layout": "row-spread",
       "x": 620,
       "y": 200,
       "wires": []
   },
   {
       "id": "9ea7b2c0.97ad6",
       "type": "function",
       "z": "93bf7220.2bec2",
       "name": "minutesCountdown",
       "func": "var temp = msg.payload;\nvar minutes = parseInt(temp/60);\nvar seconds = temp - minutes*60;\nmsg.payload = minutes.toString() + \":\" + seconds.toString();\nvar newMsg = { payload: minutes};\nnewMsg.topic = \"countdown\";\nreturn [msg, newMsg];",
       "outputs": 2,
       "noerr": 0,
       "x": 410,
       "y": 200,
       "wires": [
           [
               "7ae79492.3b9f3c"
           ],
           [
               "26d6c7a0.d43558"
           ]
       ]
   },
   {
       "id": "d1d09e6b.4fc3d",
       "type": "comment",
       "z": "93bf7220.2bec2",
       "name": "Dashboard off timer",
       "info": "",
       "x": 230,
       "y": 80,
       "wires": []
   },
   {
       "id": "210a837e.f5231c",
       "type": "ui_button",
       "z": "93bf7220.2bec2",
       "name": "",
       "group": "d4a061b3.6ae9d",
       "order": 3,
       "width": "2",
       "height": "1",
       "passthru": false,
       "label": "Reboot",
       "tooltip": "",
       "color": "",
       "bgcolor": "",
       "icon": "",
       "payload": "",
       "payloadType": "str",
       "topic": "",
       "x": 200,
       "y": 240,
       "wires": [
           [
               "81aab8e9.0c53b8"
           ]
       ]
   },
   {
       "id": "81aab8e9.0c53b8",
       "type": "exec",
       "z": "93bf7220.2bec2",
       "command": "sudo reboot",
       "addpay": false,
       "append": "",
       "useSpawn": "false",
       "timer": "",
       "oldrc": false,
       "name": "reboot",
       "x": 330,
       "y": 240,
       "wires": [
           [],
           [],
           []
       ]
   },
   {
       "id": "3ac279ec.11c376",
       "type": "ui_button",
       "z": "93bf7220.2bec2",
       "name": "",
       "group": "d4a061b3.6ae9d",
       "order": 3,
       "width": "2",
       "height": "1",
       "passthru": false,
       "label": "Shutdown",
       "tooltip": "",
       "color": "",
       "bgcolor": "",
       "icon": "",
       "payload": "",
       "payloadType": "str",
       "topic": "",
       "x": 200,
       "y": 280,
       "wires": [
           [
               "6725eec.382e01"
           ]
       ]
   },
   {
       "id": "6725eec.382e01",
       "type": "exec",
       "z": "93bf7220.2bec2",
       "command": "sudo shutdown",
       "addpay": false,
       "append": "",
       "useSpawn": "false",
       "timer": "",
       "oldrc": false,
       "name": "shutdown",
       "x": 340,
       "y": 280,
       "wires": [
           [],
           [],
           []
       ]
   },
   {
       "id": "d4a061b3.6ae9d",
       "type": "ui_group",
       "z": "",
       "name": "Auto Off",
       "tab": "e93ef2b0.f7b94",
       "disp": true,
       "width": "6",
       "collapse": false
   },
   {
       "id": "e93ef2b0.f7b94",
       "type": "ui_tab",
       "z": "",
       "name": "Web Radio",
       "icon": "dashboard",
       "order": 1,
       "disabled": false,
       "hidden": false
   },
   {
       "id": "b7492440.f116f8",
       "type": "subflow:93bf7220.2bec2",
       "z": "346f9605.5900aa",
       "name": "Dashboard Timer",
       "env": [],
       "x": 120,
       "y": 380,
       "wires": []
   }
]