Node Red examples

Steves beginners guide

NTP or system time to Hopf string

Code Export
[
    {
        "id": "3d728d58202a0eb7",
        "type": "comment",
        "z": "644da187fa49c850",
        "name": "Additional node: node-red-contrib-iiot-ntptime",
        "info": "",
        "x": 210,
        "y": 60,
        "wires": []
    },
    {
        "id": "9481e791d8d3890c",
        "type": "iiot-ntptime",
        "z": "644da187fa49c850",
        "ntpserver": "time.google.com",
        "ampm": false,
        "tupdate": "1000",
        "tout": 5000,
        "x": 100,
        "y": 180,
        "wires": [
            [
                "9c9de38a7f23fa21",
                "8f44daa22489f864",
                "c0c5ec8791ad0a88"
            ]
        ]
    },
    {
        "id": "b20c02adb7d73384",
        "type": "function",
        "z": "644da187fa49c850",
        "name": "GMT to Hopf time string to CMC70",
        "func": "var d = new Date();\nvar character03 = d.getDay() + 8; // weekday as a number  1-7 (M>S) + 8 for UTC time\n\nif (d.getDay() === 1) character03 = 57;\nif (d.getDay() === 2) character03 = 65;\nif (d.getDay() === 3) character03 = 66;\nif (d.getDay() === 4) character03 = 67;\nif (d.getDay() === 5) character03 = 68;\nif (d.getDay() === 6) character03 = 69;\nif (d.getDay() === 7) character03 = 70;\n\nmsg.payload = String.fromCharCode(0x02)         // STX\n//    + String.fromCharCode(0x21)                 // \n    + String.fromCharCode(0x43)                 // status clock 0x43 in winter 0x44 in summer\n//    + String.fromCharCode(0x21)                 //\n    + String.fromCharCode(character03)            \n//    + String.fromCharCode(0x21)                 //      \n    + String(msg.payload[2]).padStart(2, \"0\")   // Hour\n//    + String.fromCharCode(0x21)                 //\n    + String(msg.payload[1]).padStart(2, \"0\")   // Minute\n//    + String.fromCharCode(0x21)                 //\n    + String(msg.payload[0]).padStart(2, \"0\")   // Seconds\n//    + String.fromCharCode(0x21)                 //\n    + String(msg.payload[5]).padStart(2, \"0\")   // day\n//    + String.fromCharCode(0x21)                 //\n    + String(msg.payload[6]).padStart(2, \"0\")   // month\n//    + String.fromCharCode(0x21)                 //\n    + String(msg.payload[7])                    // Year\n//    + String.fromCharCode(0x21)                 //\n    + String.fromCharCode(0x0A)                 // Line Feed\n//    + String.fromCharCode(0x21)                 //\n    + String.fromCharCode(0x0D)                 // Carriage return\n//    + String.fromCharCode(0x21)                 //\n    + String.fromCharCode(0x03);                // ETX\n//    + String.fromCharCode(0x21)                 //\n\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 580,
        "y": 420,
        "wires": [
            [
                "262c9bcb3b460e60"
            ]
        ]
    },
    {
        "id": "9c9de38a7f23fa21",
        "type": "delay",
        "z": "644da187fa49c850",
        "name": "",
        "pauseType": "rate",
        "timeout": "5",
        "timeoutUnits": "seconds",
        "rate": "1",
        "nbRateUnits": "1",
        "rateUnits": "minute",
        "randomFirst": "1",
        "randomLast": "5",
        "randomUnits": "seconds",
        "drop": true,
        "allowrate": false,
        "outputs": 1,
        "x": 270,
        "y": 420,
        "wires": [
            [
                "b20c02adb7d73384"
            ]
        ]
    },
    {
        "id": "262c9bcb3b460e60",
        "type": "debug",
        "z": "644da187fa49c850",
        "name": "Serial device",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 830,
        "y": 420,
        "wires": []
    },
    {
        "id": "8f44daa22489f864",
        "type": "function",
        "z": "644da187fa49c850",
        "name": "Pass at specific time",
        "func": "if(msg.payload[0] == 0){\n    return msg;\n}\n",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 300,
        "y": 300,
        "wires": [
            [
                "f0aeb2d061553d52"
            ]
        ]
    },
    {
        "id": "f0aeb2d061553d52",
        "type": "function",
        "z": "644da187fa49c850",
        "name": "GMT to Hopf time string to CMC70",
        "func": "var d = new Date();\nvar character03 = d.getDay() + 8; // weekday as a number  1-7 (M>S) + 8 for UTC time\n\nif (d.getDay() === 1) character03 = 57;\nif (d.getDay() === 2) character03 = 65;\nif (d.getDay() === 3) character03 = 66;\nif (d.getDay() === 4) character03 = 67;\nif (d.getDay() === 5) character03 = 68;\nif (d.getDay() === 6) character03 = 69;\nif (d.getDay() === 7) character03 = 70;\n\nmsg.payload = String.fromCharCode(0x02)         // STX\n//    + String.fromCharCode(0x21)                 // \n    + String.fromCharCode(0x43)                 // status clock 0x43 in winter 0x44 in summer\n//    + String.fromCharCode(0x21)                 //\n    + String.fromCharCode(character03)            \n//    + String.fromCharCode(0x21)                 //      \n    + String(msg.payload[2]).padStart(2, \"0\")   // Hour\n//    + String.fromCharCode(0x21)                 //\n    + String(msg.payload[1]).padStart(2, \"0\")   // Minute\n//    + String.fromCharCode(0x21)                 //\n    + String(msg.payload[0]).padStart(2, \"0\")   // Seconds\n//    + String.fromCharCode(0x21)                 //\n    + String(msg.payload[5]).padStart(2, \"0\")   // day\n//    + String.fromCharCode(0x21)                 //\n    + String(msg.payload[6]).padStart(2, \"0\")   // month\n//    + String.fromCharCode(0x21)                 //\n    + String(msg.payload[7])                    // Year\n//    + String.fromCharCode(0x21)                 //\n    + String.fromCharCode(0x0A)                 // Line Feed\n//    + String.fromCharCode(0x21)                 //\n    + String.fromCharCode(0x0D)                 // Carriage return\n//    + String.fromCharCode(0x21)                 //\n    + String.fromCharCode(0x03);                // ETX\n//    + String.fromCharCode(0x21)                 //\n\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 580,
        "y": 300,
        "wires": [
            [
                "80b1c72242fe159e"
            ]
        ]
    },
    {
        "id": "c0c5ec8791ad0a88",
        "type": "function",
        "z": "644da187fa49c850",
        "name": "GMT to Hopf time string to CMC70",
        "func": "var d = new Date();\nvar character03 = d.getDay() + 8; // weekday as a number  1-7 (M>S) + 8 for UTC time\n\nif (d.getDay() === 1) character03 = 57;\nif (d.getDay() === 2) character03 = 65;\nif (d.getDay() === 3) character03 = 66;\nif (d.getDay() === 4) character03 = 67;\nif (d.getDay() === 5) character03 = 68;\nif (d.getDay() === 6) character03 = 69;\nif (d.getDay() === 7) character03 = 70;\n\nmsg.payload = String.fromCharCode(0x02)         // STX\n//    + String.fromCharCode(0x21)                 // \n    + String.fromCharCode(0x43)                 // status clock 0x43 in winter 0x44 in summer\n//    + String.fromCharCode(0x21)                 //\n    + String.fromCharCode(character03)            \n//    + String.fromCharCode(0x21)                 //      \n    + String(msg.payload[2]).padStart(2, \"0\")   // Hour\n//    + String.fromCharCode(0x21)                 //\n    + String(msg.payload[1]).padStart(2, \"0\")   // Minute\n//    + String.fromCharCode(0x21)                 //\n    + String(msg.payload[0]).padStart(2, \"0\")   // Seconds\n//    + String.fromCharCode(0x21)                 //\n    + String(msg.payload[5]).padStart(2, \"0\")   // day\n//    + String.fromCharCode(0x21)                 //\n    + String(msg.payload[6]).padStart(2, \"0\")   // month\n//    + String.fromCharCode(0x21)                 //\n    + String(msg.payload[7])                    // Year\n//    + String.fromCharCode(0x21)                 //\n    + String.fromCharCode(0x0A)                 // Line Feed\n//    + String.fromCharCode(0x21)                 //\n    + String.fromCharCode(0x0D)                 // Carriage return\n//    + String.fromCharCode(0x21)                 //\n    + String.fromCharCode(0x03);                // ETX\n//    + String.fromCharCode(0x21)                 //\n\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 580,
        "y": 180,
        "wires": [
            [
                "c2863baacb02dc88"
            ]
        ]
    },
    {
        "id": "f33f1e7ca96b094f",
        "type": "comment",
        "z": "644da187fa49c850",
        "name": "According the update time NTP node",
        "info": "",
        "x": 340,
        "y": 140,
        "wires": []
    },
    {
        "id": "29b0493b0980ed51",
        "type": "comment",
        "z": "644da187fa49c850",
        "name": "At a specific second",
        "info": "",
        "x": 290,
        "y": 260,
        "wires": []
    },
    {
        "id": "8d7c08c1ba8651a0",
        "type": "comment",
        "z": "644da187fa49c850",
        "name": "Limited rate",
        "info": "",
        "x": 270,
        "y": 380,
        "wires": []
    },
    {
        "id": "c2863baacb02dc88",
        "type": "debug",
        "z": "644da187fa49c850",
        "name": "Serial device",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 830,
        "y": 180,
        "wires": []
    },
    {
        "id": "80b1c72242fe159e",
        "type": "debug",
        "z": "644da187fa49c850",
        "name": "Serial device",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 830,
        "y": 300,
        "wires": []
    }
]

Functionblock status

For a single status

// Single status notification
node.status({text:msg.payload});

// Multiple status notifications
node.status({ text: flow.get('Loop') + "  " + msg.payload});

return msg;

TIME

msg.payload = Date.now(); > Unix time
msg.payload = Date();     > Readable date and time

Divide long code in multiple lines

After a function you can start a new line.

var var1 = true;
var var2 = false;
if (var1 === true &&
    var2 !== true) {
msg.payload = true;
}
return msg;

Conversion between number and string

"function node"

// Number to string
msg.payload = String(msg.payload);
return msg;
// OR
// String to number
msg.payload = Number(msg.payload);
return msg;

If with multiple conditions

"function node"

var var1 = true;
var var2 = false;
if (var1 === true  && var2 === !true) {
   msg.payload = true;
}
return msg;

// && = AND
// || = OR
// !  = NOT

Output True Only (Function)

"Code in function node"

if (msg.payload===true){
   return msg;
}

Output on change only (Function)

"Code in function node"

var payload_prev=context.get('payload_prev') || false;
if (msg.payload !==  payload_prev){
    payload_prev=context.set('payload_prev',msg.payload);
    return msg;
}

Delay with variable time and reset (Example)

"Code in function node"

if (msg.payload===true){
return msg;
}
if (msg.payload===false){
msg.reset=true;
return msg;
}
if (msg.topic === "delay"){
msg.delay=2000;
msg.payload = true;
return msg;
}
[{"id":"26f197ec.17dda8","type":"inject","z":"c18c524.4d65cb","name":"","topic":"","payload":"true","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":110,"y":60,"wires":[["80ac08dc.3832d8"]]},{"id":"f1a05bf9.606ed8","type":"debug","z":"c18c524.4d65cb","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":810,"y":100,"wires":[]},{"id":"215bd5ad.fb8aaa","type":"inject","z":"c18c524.4d65cb","name":"reset","topic":"","payload":"false","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":110,"y":100,"wires":[["80ac08dc.3832d8"]]},{"id":"80ac08dc.3832d8","type":"function","z":"c18c524.4d65cb","name":"True only","func":"if (msg.payload===true){\n   return msg;\n}\nif (msg.payload===false){\nmsg.reset=true;\n   return msg;\n}\nif (msg.topic === \"delay\"){\nmsg.delay=2000;\nmsg.payload = true;\n   return msg;\n}","outputs":1,"noerr":0,"x":440,"y":100,"wires":[["595bb3a9.c1f3cc"]]},{"id":"595bb3a9.c1f3cc","type":"delay","z":"c18c524.4d65cb","name":"","pauseType":"delayv","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"15","rateUnits":"minute","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":620,"y":100,"wires":[["f1a05bf9.606ed8"]]},{"id":"902547e4.1d9188","type":"inject","z":"c18c524.4d65cb","name":"delay 2000 ms","topic":"delay","payload":"2000","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":140,"y":140,"wires":[["80ac08dc.3832d8"]]}]
[{"id":"26f197ec.17dda8","type":"inject","z":"c18c524.4d65cb","name":"","topic":"","payload":"true","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":110,"y":60,"wires":[["80ac08dc.3832d8"]]},{"id":"f1a05bf9.606ed8","type":"debug","z":"c18c524.4d65cb","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":810,"y":100,"wires":[]},{"id":"215bd5ad.fb8aaa","type":"inject","z":"c18c524.4d65cb","name":"reset","topic":"","payload":"false","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":110,"y":100,"wires":[["80ac08dc.3832d8"]]},{"id":"80ac08dc.3832d8","type":"function","z":"c18c524.4d65cb","name":"True only","func":"if (msg.payload===true){\n   return msg;\n}\nif (msg.payload===false){\nmsg.reset=true;\n   return msg;\n}\nif (msg.topic === \"delay\"){\nmsg.delay=2000;\nmsg.payload = true;\n   return msg;\n}","outputs":1,"noerr":0,"x":440,"y":100,"wires":[["595bb3a9.c1f3cc"]]},{"id":"595bb3a9.c1f3cc","type":"delay","z":"c18c524.4d65cb","name":"","pauseType":"delayv","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"15","rateUnits":"minute","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":620,"y":100,"wires":[["f1a05bf9.606ed8"]]},{"id":"902547e4.1d9188","type":"inject","z":"c18c524.4d65cb","name":"delay 2000 ms","topic":"delay","payload":"2000","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":140,"y":140,"wires":[["80ac08dc.3832d8"]]}]

Pi top relay board

[{"id":"d116e250.10a96","type":"rpi-gpio out","z":"c18c524.4d65cb","name":"","pin":"37","set":true,"level":"1","freq":"","out":"out","x":820,"y":1200,"wires":[]},{"id":"c1310dc.a0343f","type":"ui_switch","z":"c18c524.4d65cb","name":"","label":"CH1","group":"355fd775.1ea9a8","order":0,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"x","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","x":170,"y":1200,"wires":[["7ae63ce8.3a1814"]]},{"id":"7b8f3bf1.e5df74","type":"rpi-gpio out","z":"c18c524.4d65cb","name":"","pin":"38","set":true,"level":"1","freq":"","out":"out","x":820,"y":1280,"wires":[]},{"id":"aea142c6.909bd","type":"ui_switch","z":"c18c524.4d65cb","name":"","label":"CH2","group":"355fd775.1ea9a8","order":0,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"y","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","x":170,"y":1280,"wires":[["9e88609e.1b92a"]]},{"id":"db1dcbd3.7b81d8","type":"rpi-gpio out","z":"c18c524.4d65cb","name":"","pin":"40","set":true,"level":"1","freq":"","out":"out","x":820,"y":1360,"wires":[]},{"id":"9eb28f38.0093e","type":"ui_switch","z":"c18c524.4d65cb","name":"","label":"CH3","group":"355fd775.1ea9a8","order":0,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"z","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","x":170,"y":1360,"wires":[["97c6c8c8.ee19e8"]]},{"id":"7ae63ce8.3a1814","type":"Invert","z":"c18c524.4d65cb","name":"Invert","x":350,"y":1200,"wires":[["d116e250.10a96"]]},{"id":"9e88609e.1b92a","type":"Invert","z":"c18c524.4d65cb","name":"Invert","x":350,"y":1280,"wires":[["7b8f3bf1.e5df74"]]},{"id":"97c6c8c8.ee19e8","type":"Invert","z":"c18c524.4d65cb","name":"Invert","x":350,"y":1360,"wires":[["db1dcbd3.7b81d8"]]},{"id":"355fd775.1ea9a8","type":"ui_group","z":"","name":"relais","tab":"f10b3415.ca1968","disp":true,"width":"6","collapse":false},{"id":"f10b3415.ca1968","type":"ui_tab","z":"","name":"Testing","icon":"dashboard","order":2}] 

Text with different color in dashboard

[{"id":"596ea23d.8b3ddc","type":"ui_text","z":"dca74cfa.b923","group":"c956f7dd.fc59a8","order":2,"width":0,"height":0,"name":"","label":"<font color=\"DeepSkyBlue\">RoCa</font>","format":"","layout":"row-spread","x":180,"y":40,"wires":[]},{"id":"c956f7dd.fc59a8","type":"ui_group","z":"","name":"Audio","tab":"f10b3415.ca1968","disp":false,"width":"10","collapse":false},{"id":"f10b3415.ca1968","type":"ui_tab","z":"","name":"Testing","icon":"dashboard","order":2}] 

Additional info about formating


node-red-contrib-boolean-logic

[{"id":"ebea07f7.7f0bb8","type":"BooleanLogic","z":"bedf37a.c87b7c8","name":"","operation":"XOR","inputCount":2,"topic":"result","x":340,"y":220,"wires":[["a568f1e7.ce434"]]},{"id":"59f06757.1feca8","type":"inject","z":"bedf37a.c87b7c8","name":"","topic":"uit1","payload":"true","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":150,"y":140,"wires":[["ebea07f7.7f0bb8"]]},{"id":"c15cad4f.00376","type":"debug","z":"bedf37a.c87b7c8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":690,"y":220,"wires":[]},{"id":"bf469fb8.dc3b3","type":"inject","z":"bedf37a.c87b7c8","name":"","topic":"uit2","payload":"true","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":150,"y":260,"wires":[["ebea07f7.7f0bb8"]]},{"id":"57a1a3f3.8f402c","type":"inject","z":"bedf37a.c87b7c8","name":"","topic":"uit1","payload":"false","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":140,"y":180,"wires":[["ebea07f7.7f0bb8"]]},{"id":"f9b67158.18b7a","type":"inject","z":"bedf37a.c87b7c8","name":"","topic":"uit2","payload":"false","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":140,"y":300,"wires":[["ebea07f7.7f0bb8"]]},{"id":"a568f1e7.ce434","type":"Invert","z":"bedf37a.c87b7c8","name":"Invert","x":510,"y":220,"wires":[["c15cad4f.00376"]]}] 

node-red-dashboard


LED in Dasboard

The function node  "Test"

msg.color = (msg.payload === true)?"lime":"red";
return msg;
"The text output node (Value format)"

<font color={{msg.color}} ></font>

[{"id":"258cc5a2.6360da","type":"ui_text","z":"8a471771.6831f8","group":"b57c0d23.72627","order":8,"width":0,"height":0,"name":"","label":"LED","format":"<font color={{msg.color}} ><i class=\"fa fa-circle\" style=\"font-size:24px;\"></i></font>","layout":"row-spread","x":640,"y":940,"wires":[]},{"id":"cc77528.82f25b","type":"function","z":"8a471771.6831f8","name":"Test","func":"msg.color = (msg.payload === true)?\"lime\":\"red\";\nreturn msg;","outputs":1,"noerr":0,"x":430,"y":940,"wires":[["258cc5a2.6360da"]]},{"id":"4dee0966.86f698","type":"inject","z":"8a471771.6831f8","name":"ON","topic":"","payload":"true","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":230,"y":920,"wires":[["cc77528.82f25b"]]},{"id":"fb224601.a67988","type":"inject","z":"8a471771.6831f8","name":"OFF","topic":"","payload":"false","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":230,"y":960,"wires":[["cc77528.82f25b"]]},{"id":"b57c0d23.72627","type":"ui_group","z":"","name":"Verwarming","tab":"7d7001f.66e66","order":1,"disp":true,"width":"6","collapse":false},{"id":"7d7001f.66e66","type":"ui_tab","z":"","name":"Loose End","icon":"dashboard","disabled":false,"hidden":false}]

Data

In the function node “Data naar I/O”


var temp = msg.payload.buienradar.temperatuurGC;
var hum = msg.payload.buienradar.luchtvochtigheid;
var tekst = msg.payload.buienradar.icoonzin;
return[{payload:temp},{payload:hum},{payload:tekst}]

 [{"id":"22e602d2.2b09de","type":"buienradar","z":"bedf37a.c87b7c8","name":"Weerstation","station":"6278","interval":"60000","x":310,"y":160,"wires":[["4f7ccb50.18fe24"]]},{"id":"4f7ccb50.18fe24","type":"function","z":"bedf37a.c87b7c8","name":"Data naar I/O","func":"var temp = msg.payload.buienradar.temperatuurGC;\nvar hum = msg.payload.buienradar.luchtvochtigheid;\nvar tekst = msg.payload.buienradar.icoonzin;\n\nreturn[{payload:temp},{payload:hum},{payload:tekst}]","outputs":3,"noerr":0,"x":500,"y":160,"wires":[["2c513c84.6b3644"],["fc51cb3e.fbc908"],["b201c8c4.50acb8"]]},{"id":"2c513c84.6b3644","type":"ui_gauge","z":"bedf37a.c87b7c8","name":"Temperatuur","group":"a51fadcf.dfe96","order":0,"width":0,"height":0,"gtype":"gage","title":"Temperatuur","label":"%","format":"{{value}}","min":"-10","max":"40","colors":["#00b500","#e6e600","#ca3838"],"seg1":"15","seg2":"30","x":710,"y":120,"wires":[]},{"id":"fc51cb3e.fbc908","type":"ui_gauge","z":"bedf37a.c87b7c8","name":"Luchtvochtigheid","group":"a51fadcf.dfe96","order":0,"width":0,"height":0,"gtype":"donut","title":"Luchtvochtigheid","label":"%","format":"{{value}}","min":"10","max":"98","colors":["#00ffff","#0080ff","#0000ff"],"seg1":"40","seg2":"60","x":730,"y":160,"wires":[]},{"id":"b201c8c4.50acb8","type":"ui_text","z":"bedf37a.c87b7c8","group":"a51fadcf.dfe96","order":0,"width":0,"height":0,"name":"Weer tekst","label":"","format":"{{msg.payload}}","layout":"row-spread","x":710,"y":200,"wires":[]},{"id":"a51fadcf.dfe96","type":"ui_group","z":"","name":"LED Testing","tab":"d4ea4b61.e095f8","order":2,"disp":true,"width":"16","collapse":false},{"id":"d4ea4b61.e095f8","type":"ui_tab","z":"","name":"Testing","icon":"dashboard","order":3}] 

Counter (storage of a value)

In the function node "Counter"

// initialise the counter to 0 if it doesn't exist already
var count = context.get('count')||0;
count = count + 1;
// store the value back
context.set('count',count);
// make it part of the outgoing msg object
msg.count = count;
return msg;

The SUM of two values

"In the function node Sum"

// initialise the value01 to 0 if it doesn't exist already
var value01 = context.get('value01')||0;
// initialise the value02 to 0 if it doesn't exist already
var value02 = context.get('value02')||0;
if (msg.topic === "value01"){
     value01 = msg.payload;
     context.set('value01',value01);
 }
 if (msg.topic === "value02"){
     value02 = msg.payload;
     context.set('value02',value02);
 }
var sum = value02 + value01;
msg.payload = sum;
return[{payload:value01},{payload:value02},{payload:sum}] 

CountDown timer

"function node countdown timer"

var starttime = context.get('starttime')
var endtime = context.get('endtime')
if (msg.topic === 'currenttime'){
context.set('starttime',msg.payload);
context.set('endtime', msg.payload + 20000);
msg.payload = 'start';
}
if (msg.topic === 'cycle'){
if (endtime - msg.payload>0){
msg.payload = (endtime - msg.payload)/1000;
}
else{
msg.payload = 0;
}
}
return msg;
[{"id":"6a8ddf79.003a5","type":"inject","z":"8a471771.6831f8","name":"start","topic":"currenttime","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":150,"y":440,"wires":[["dfee3193.78d5a"]]},{"id":"b7f4c638.c040e8","type":"inject","z":"8a471771.6831f8","name":"","topic":"cycle","payload":"","payloadType":"date","repeat":"1","crontab":"","once":true,"onceDelay":0.1,"x":190,"y":500,"wires":[["dfee3193.78d5a"]]},{"id":"dfee3193.78d5a","type":"function","z":"8a471771.6831f8","name":"countdown timer","func":"var starttime = context.get('starttime')\nvar endtime = context.get('endtime')\nif (msg.topic === 'currenttime'){\n    context.set('starttime',msg.payload);\n    context.set('endtime', msg.payload + 20000);\n    msg.payload = 'start';\n    }\n    if (msg.topic === 'cycle'){\n        if (endtime - msg.payload>0){\n            msg.payload = (endtime - msg.payload)/1000;\n            }\n            else{\n                msg.payload = 0;\n                }\n            }\nreturn msg;\n","outputs":1,"noerr":0,"x":400,"y":480,"wires":[["d07a8b0c.5eae28"]]},{"id":"d07a8b0c.5eae28","type":"debug","z":"8a471771.6831f8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":570,"y":480,"wires":[]}]

LCD Thermostat display


[{"id":"d27e5434.86fc18","type":"comment","z":"2f9aaa6e.f9dda6","name":"","info":"RPI LCD node  (node-red-node-pilcd)\n\nRS,EN,D4,D5,D6,D7\n19,16,21,18,23,24   /Board pins\n10,23,09,24,11,08   /GPIO\n","x":1080,"y":120,"wires":[]},{"id":"52d28cd3.504a84","type":"inject","z":"2f9aaa6e.f9dda6","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"3","crontab":"","once":false,"onceDelay":"0.3","topic":"line_1","payload":"Tw=21.0  Tc=22.2","payloadType":"str","x":150,"y":220,"wires":[["121fd65a.7766da"]]},{"id":"ad5f49ce.5eaed8","type":"inject","z":"2f9aaa6e.f9dda6","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"3","crontab":"","once":false,"onceDelay":"0.3","topic":"line_2","payload":"2:Ta=28.0  Tr=19.6","payloadType":"str","x":150,"y":280,"wires":[["eba7056c.d8df48"]]},{"id":"62380345.d13e8c","type":"debug","z":"2f9aaa6e.f9dda6","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":950,"y":220,"wires":[]},{"id":"121fd65a.7766da","type":"switch","z":"2f9aaa6e.f9dda6","name":"Context based routing","property":"state","propertyType":"flow","rules":[{"t":"eq","v":"1","vt":"num"}],"checkall":"true","repair":false,"outputs":1,"x":560,"y":220,"wires":[["b53a188e.a6d2f8"]]},{"id":"1f345a1d.02df56","type":"trigger","z":"2f9aaa6e.f9dda6","name":"","op1":"0","op2":"1","op1type":"num","op2type":"num","duration":"10","extend":true,"overrideDelay":false,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":350,"y":60,"wires":[["61b4da74.82f784","e943a127.e79cd"]]},{"id":"61b4da74.82f784","type":"change","z":"2f9aaa6e.f9dda6","name":"Set flow.state","rules":[{"t":"set","p":"state","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":530,"y":60,"wires":[[]]},{"id":"e9e8e75b.5b50a8","type":"inject","z":"2f9aaa6e.f9dda6","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"true","payloadType":"bool","x":90,"y":60,"wires":[["1f345a1d.02df56","4f69ef39.1d571"]]},{"id":"eba7056c.d8df48","type":"switch","z":"2f9aaa6e.f9dda6","name":"Context based routing","property":"state","propertyType":"flow","rules":[{"t":"eq","v":"1","vt":"num"}],"checkall":"true","repair":false,"outputs":1,"x":560,"y":280,"wires":[["1c7a71ad.17248e","b53a188e.a6d2f8"]]},{"id":"1c7a71ad.17248e","type":"debug","z":"2f9aaa6e.f9dda6","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":950,"y":280,"wires":[]},{"id":"b53a188e.a6d2f8","type":"rpi-lcd","z":"2f9aaa6e.f9dda6","name":"lcd","pins":"19,16,21,18,23,24","x":950,"y":120,"wires":[]},{"id":"e943a127.e79cd","type":"change","z":"2f9aaa6e.f9dda6","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"clr:","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":540,"y":100,"wires":[["b53a188e.a6d2f8","37de9ac6.07a1a6"]]},{"id":"37de9ac6.07a1a6","type":"debug","z":"2f9aaa6e.f9dda6","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":950,"y":60,"wires":[]},{"id":"a72ccdde.0578c","type":"function","z":"2f9aaa6e.f9dda6","name":"","func":"msg.payload ='Tw=21.1'\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":520,"y":140,"wires":[["b53a188e.a6d2f8"]]},{"id":"4f69ef39.1d571","type":"delay","z":"2f9aaa6e.f9dda6","name":"","pauseType":"delay","timeout":"500","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":310,"y":140,"wires":[["a72ccdde.0578c"]]}]

Storing variables

  • The context object -stores data for a node
  • The flow object – stores data for a flow
  • The global object -stores data for the canvas

Send Public IP

See export below
[
    {
        "id": "a6a028d9e5ef43b1",
        "type": "tab",
        "label": "Flow 2",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "10febc52.c63164",
        "type": "debug",
        "z": "a6a028d9e5ef43b1",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 630,
        "y": 400,
        "wires": []
    },
    {
        "id": "24b6dbdd.881184",
        "type": "exec",
        "z": "a6a028d9e5ef43b1",
        "command": "curl http://whatismyip.akamai.com",
        "addpay": false,
        "append": "",
        "useSpawn": "false",
        "timer": "",
        "winHide": false,
        "oldrc": false,
        "name": "curl http://whatismyip.akamai.com",
        "x": 200,
        "y": 180,
        "wires": [
            [
                "5530cb08.8135e4"
            ],
            [],
            []
        ]
    },
    {
        "id": "4adfd71d.23f778",
        "type": "inject",
        "z": "a6a028d9e5ef43b1",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 100,
        "y": 100,
        "wires": [
            [
                "24b6dbdd.881184"
            ]
        ]
    },
    {
        "id": "be3dc4cd.323588",
        "type": "function",
        "z": "a6a028d9e5ef43b1",
        "name": "Compare IP",
        "func": "context.lastip = context.lastip || 'initial';\nvar currentip = msg.payload;\n\nif (context.lastip == 'initial') {\ncontext.lastip = currentip;\n}\nelse if (context.lastip != currentip) {\nmsg.payload = \"My current IP is \"+currentip;\ncontext.lastip = currentip;\nreturn msg;\n}",
        "outputs": 1,
        "x": 350,
        "y": 400,
        "wires": [
            [
                "10febc52.c63164"
            ]
        ]
    },
    {
        "id": "5530cb08.8135e4",
        "type": "switch",
        "z": "a6a028d9e5ef43b1",
        "name": "Integrity check",
        "property": "payload",
        "rules": [
            {
                "t": "regex",
                "v": "\\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\b"
            },
            {
                "t": "else"
            }
        ],
        "checkall": "true",
        "outputs": 2,
        "x": 320,
        "y": 300,
        "wires": [
            [
                "be3dc4cd.323588"
            ],
            []
        ]
    }
]

PID controller to ESPEASY with PWM output

[
    {
        "id": "b4973237.46ab6",
        "type": "subflow",
        "name": "Process Simulation",
        "info": "",
        "in": [
            {
                "x": 37,
                "y": 103,
                "wires": [
                    {
                        "id": "ec719d4d.0d54f8"
                    }
                ]
            }
        ],
        "out": [
            {
                "x": 728.5,
                "y": 294,
                "wires": [
                    {
                        "id": "ae1a6e5.d4c0d9",
                        "port": 0
                    }
                ]
            }
        ]
    },
    {
        "id": "7fe4b5c3.32e58c",
        "type": "function",
        "z": "b4973237.46ab6",
        "name": "30 sec RC + 20",
        "func": "// Applies a simple RC low pass filter to incoming payload values\nvar tc = 30*1000;       // time constant in milliseconds\n\nvar lastValue = context.get('lastValue');\nif (typeof lastValue == \"undefined\") lastValue = msg.payload;\nvar lastTime = context.get('lastTime') || null;\nvar now = new Date();\nvar currentValue = msg.payload;\nif (lastTime === null) {\n    // first time through\n    newValue = currentValue;\n} else {\n    var dt = now - lastTime;\n    var newValue;\n    \n    if (dt > 0) {\n        var dtotc = dt / tc;\n        newValue = lastValue * (1 - dtotc) + currentValue * dtotc;\n    } else {\n        // no time has elapsed leave output the same as last time\n        newValue = lastValue;\n    }\n}\ncontext.set('lastValue', newValue);\ncontext.set('lastTime', now);\n\nmsg.payload = newValue + 20;\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 626.5,
        "y": 207,
        "wires": [
            [
                "ae1a6e5.d4c0d9"
            ]
        ]
    },
    {
        "id": "1bacd004.9753c",
        "type": "inject",
        "z": "b4973237.46ab6",
        "name": "Inject -0.2 at start",
        "repeat": "",
        "crontab": "",
        "once": true,
        "topic": "",
        "payload": "-0.2",
        "payloadType": "num",
        "x": 134.5,
        "y": 30,
        "wires": [
            [
                "ec719d4d.0d54f8"
            ]
        ]
    },
    {
        "id": "999a52c2.f465f",
        "type": "function",
        "z": "b4973237.46ab6",
        "name": "10 sec RC",
        "func": "// Applies a simple RC low pass filter to incoming payload values\nvar tc = 10*1000;       // time constant in milliseconds\n\nvar lastValue = context.get('lastValue');\nif (typeof lastValue == \"undefined\") lastValue = msg.payload;\nvar lastTime = context.get('lastTime') || null;\nvar now = new Date();\nvar currentValue = msg.payload;\nif (lastTime === null) {\n    // first time through\n    newValue = currentValue;\n} else {\n    var dt = now - lastTime;\n    var newValue;\n    \n    if (dt > 0) {\n        var dtotc = dt / tc;\n        newValue = lastValue * (1 - dtotc) + currentValue * dtotc;\n    } else {\n        // no time has elapsed leave output the same as last time\n        newValue = lastValue;\n    }\n}\ncontext.set('lastValue', newValue);\ncontext.set('lastTime', now);\n\nmsg.payload = newValue;\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 451,
        "y": 207,
        "wires": [
            [
                "7fe4b5c3.32e58c"
            ]
        ]
    },
    {
        "id": "ec719d4d.0d54f8",
        "type": "delay",
        "z": "b4973237.46ab6",
        "name": "",
        "pauseType": "delay",
        "timeout": "1",
        "timeoutUnits": "seconds",
        "rate": "1",
        "rateUnits": "second",
        "randomFirst": "1",
        "randomLast": "5",
        "randomUnits": "seconds",
        "drop": false,
        "outputs": 1,
        "x": 268,
        "y": 104,
        "wires": [
            [
                "ede39236.1961f8"
            ]
        ]
    },
    {
        "id": "a823c9cf.2a6178",
        "type": "function",
        "z": "b4973237.46ab6",
        "name": "2 msg transport delay",
        "func": "// stores messages in a fifo until the specified number have been received, \n// then releases them as new messages are received.\n// during the filling phase the earliest message is passed on each time \n// a message is received, but it is also left in the fifo\nvar fifoMaxLength = 2;\nvar fifo = context.get('fifo') || [];\n// push the new message onto the top of the array, messages are shifted down and\n// drop off the front\nvar length = fifo.push(msg);  // returns new length\nif (length > fifoMaxLength) {\n    newMsg = fifo.shift();\n} else {\n    // not full yet, make a copy of the msg and pass it on\n    var newMsg = JSON.parse(JSON.stringify(fifo[0]));\n}\ncontext.set('fifo', fifo);\nreturn newMsg;",
        "outputs": 1,
        "noerr": 0,
        "x": 258,
        "y": 208,
        "wires": [
            [
                "999a52c2.f465f"
            ]
        ]
    },
    {
        "id": "ae1a6e5.d4c0d9",
        "type": "function",
        "z": "b4973237.46ab6",
        "name": "Clear all except payload",
        "func": "msg2 = {payload: msg.payload};\nreturn msg2;",
        "outputs": 1,
        "noerr": 0,
        "x": 545,
        "y": 293,
        "wires": [
            []
        ]
    },
    {
        "id": "ede39236.1961f8",
        "type": "range",
        "z": "b4973237.46ab6",
        "minin": "0",
        "maxin": "1",
        "minout": "0",
        "maxout": "100",
        "action": "scale",
        "round": false,
        "name": "",
        "x": 87,
        "y": 208,
        "wires": [
            [
                "a823c9cf.2a6178"
            ]
        ]
    },
    {
        "id": "00b63e888082ba6b",
        "type": "tab",
        "label": "Flow 2",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "f70949c8.aab988",
        "type": "change",
        "z": "00b63e888082ba6b",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "topic",
                "pt": "msg",
                "to": "op",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 610,
        "y": 320,
        "wires": [
            [
                "9f58a52d.076dd"
            ]
        ]
    },
    {
        "id": "2792f805.066c78",
        "type": "inject",
        "z": "00b63e888082ba6b",
        "name": "Setpoint 30",
        "props": [
            {
                "p": "payload",
                "v": "30",
                "vt": "num"
            },
            {
                "p": "topic",
                "v": "setpoint",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "topic": "setpoint",
        "payload": "30",
        "payloadType": "num",
        "x": 112.5,
        "y": 268,
        "wires": [
            [
                "e0cb2a8c.4402a8"
            ]
        ]
    },
    {
        "id": "1bf3ce16.c3ae02",
        "type": "inject",
        "z": "00b63e888082ba6b",
        "name": "Setpoint 80",
        "repeat": "",
        "crontab": "",
        "once": false,
        "topic": "setpoint",
        "payload": "80",
        "payloadType": "num",
        "x": 111,
        "y": 317,
        "wires": [
            [
                "e0cb2a8c.4402a8"
            ]
        ]
    },
    {
        "id": "f69bbf05.bdd49",
        "type": "inject",
        "z": "00b63e888082ba6b",
        "name": "enable",
        "repeat": "",
        "crontab": "",
        "once": false,
        "topic": "enable",
        "payload": "true",
        "payloadType": "bool",
        "x": 103.5,
        "y": 153,
        "wires": [
            [
                "e0cb2a8c.4402a8"
            ]
        ]
    },
    {
        "id": "143523b2.2f165c",
        "type": "inject",
        "z": "00b63e888082ba6b",
        "name": "disable",
        "repeat": "",
        "crontab": "",
        "once": false,
        "topic": "enable",
        "payload": "false",
        "payloadType": "bool",
        "x": 104,
        "y": 203,
        "wires": [
            [
                "e0cb2a8c.4402a8"
            ]
        ]
    },
    {
        "id": "5ec4239b.34e174",
        "type": "subflow:b4973237.46ab6",
        "z": "00b63e888082ba6b",
        "x": 370.5,
        "y": 165,
        "wires": [
            [
                "de738fc5.75e4c8",
                "e0cb2a8c.4402a8"
            ]
        ]
    },
    {
        "id": "de738fc5.75e4c8",
        "type": "change",
        "z": "00b63e888082ba6b",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "topic",
                "pt": "msg",
                "to": "pv",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 590.5,
        "y": 165,
        "wires": [
            [
                "9f58a52d.076dd"
            ]
        ]
    },
    {
        "id": "e94f888a.130a88",
        "type": "range",
        "z": "00b63e888082ba6b",
        "minin": "0",
        "maxin": "1",
        "minout": "0",
        "maxout": "25",
        "action": "scale",
        "round": false,
        "property": "payload",
        "name": "Scale power",
        "x": 435.5,
        "y": 320,
        "wires": [
            [
                "f70949c8.aab988"
            ]
        ]
    },
    {
        "id": "bef0a1f8.2e2cf",
        "type": "inject",
        "z": "00b63e888082ba6b",
        "name": "Clear chart on deploy",
        "repeat": "",
        "crontab": "",
        "once": true,
        "topic": "",
        "payload": "{\"data\":[]}",
        "payloadType": "json",
        "x": 360.5,
        "y": 388,
        "wires": [
            [
                "9079ffaf.4a096"
            ]
        ]
    },
    {
        "id": "9079ffaf.4a096",
        "type": "change",
        "z": "00b63e888082ba6b",
        "name": "",
        "rules": [
            {
                "t": "move",
                "p": "payload.data",
                "pt": "msg",
                "to": "payload",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 596.5,
        "y": 388,
        "wires": [
            [
                "9f58a52d.076dd"
            ]
        ]
    },
    {
        "id": "e0cb2a8c.4402a8",
        "type": "PID",
        "z": "00b63e888082ba6b",
        "name": "",
        "setpoint": "50",
        "pb": "200",
        "ti": "4",
        "td": "0",
        "integral_default": "0",
        "smooth_factor": "0",
        "max_interval": 600,
        "enable": "1",
        "disabled_op": "0",
        "x": 370,
        "y": 240,
        "wires": [
            [
                "5ec4239b.34e174",
                "e94f888a.130a88",
                "4ea6b8f29447f026"
            ]
        ]
    },
    {
        "id": "9f58a52d.076dd",
        "type": "ui_chart",
        "z": "00b63e888082ba6b",
        "name": "",
        "group": "c45a83a3.d00908",
        "order": 0,
        "width": "6",
        "height": "6",
        "label": "chart",
        "chartType": "line",
        "legend": "true",
        "xformat": "HH:mm:ss",
        "interpolate": "linear",
        "nodata": "",
        "dot": false,
        "ymin": "0",
        "ymax": "100",
        "removeOlder": "3",
        "removeOlderPoints": "",
        "removeOlderUnit": "60",
        "cutout": 0,
        "useOneColor": false,
        "useUTC": false,
        "colors": [
            "#1f77b4",
            "#cf0005",
            "#ff7f0e",
            "#2ca02c",
            "#98df8a",
            "#d62728",
            "#ff9896",
            "#9467bd",
            "#c5b0d5"
        ],
        "outputs": 1,
        "useDifferentColor": false,
        "className": "",
        "x": 830.5,
        "y": 165,
        "wires": [
            []
        ]
    },
    {
        "id": "84189c5eb1039477",
        "type": "ui_slider",
        "z": "00b63e888082ba6b",
        "name": "",
        "label": "slider",
        "tooltip": "",
        "group": "c45a83a3.d00908",
        "order": 1,
        "width": 0,
        "height": 0,
        "passthru": true,
        "outs": "all",
        "topic": "setpoint",
        "topicType": "msg",
        "min": 0,
        "max": "100",
        "step": 1,
        "className": "",
        "x": 90.5,
        "y": 465,
        "wires": [
            [
                "c6d2ca83d29701ed",
                "b2d1ad31e73d302b"
            ]
        ]
    },
    {
        "id": "c6d2ca83d29701ed",
        "type": "change",
        "z": "00b63e888082ba6b",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "topic",
                "pt": "msg",
                "to": "setpoint",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 130.5,
        "y": 365,
        "wires": [
            [
                "e0cb2a8c.4402a8",
                "9f58a52d.076dd"
            ]
        ]
    },
    {
        "id": "b2d1ad31e73d302b",
        "type": "ui_numeric",
        "z": "00b63e888082ba6b",
        "name": "",
        "label": "numeric",
        "tooltip": "",
        "group": "c45a83a3.d00908",
        "order": 2,
        "width": 0,
        "height": 0,
        "wrap": false,
        "passthru": true,
        "topic": "topic",
        "topicType": "msg",
        "format": "{{value}}",
        "min": 0,
        "max": 10,
        "step": 1,
        "className": "",
        "x": 260.5,
        "y": 465,
        "wires": [
            []
        ]
    },
    {
        "id": "48087abbc67f2b7f",
        "type": "function",
        "z": "00b63e888082ba6b",
        "name": "",
        "func": "msg.payload = \"http://192.168.166.104/control?cmd=PWM,2,\" + (1023 - parseInt(msg.payload));\n//msg.payload = \"control?cmd=PWM,2,\" + msg.payload;\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 820,
        "y": 240,
        "wires": [
            [
                "413c77ce8752d63d",
                "1dcd690fc1746fc9",
                "70154cd4.de1444"
            ]
        ]
    },
    {
        "id": "413c77ce8752d63d",
        "type": "debug",
        "z": "00b63e888082ba6b",
        "name": "",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 990,
        "y": 200,
        "wires": []
    },
    {
        "id": "1dcd690fc1746fc9",
        "type": "ui_text_input",
        "z": "00b63e888082ba6b",
        "name": "",
        "label": "",
        "tooltip": "",
        "group": "c45a83a3.d00908",
        "order": 4,
        "width": 0,
        "height": 0,
        "passthru": true,
        "mode": "text",
        "delay": 300,
        "topic": "topic",
        "sendOnBlur": true,
        "className": "",
        "topicType": "msg",
        "x": 980,
        "y": 240,
        "wires": [
            []
        ]
    },
    {
        "id": "b36aa30.3a7276",
        "type": "http request",
        "z": "00b63e888082ba6b",
        "name": "",
        "method": "GET",
        "ret": "txt",
        "paytoqs": "ignore",
        "url": "",
        "tls": "",
        "persist": false,
        "proxy": "",
        "authType": "",
        "senderr": false,
        "x": 1150,
        "y": 280,
        "wires": [
            [
                "1ef9987c.956c78"
            ]
        ]
    },
    {
        "id": "70154cd4.de1444",
        "type": "change",
        "z": "00b63e888082ba6b",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "url",
                "pt": "msg",
                "to": "payload",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 990,
        "y": 280,
        "wires": [
            [
                "b36aa30.3a7276"
            ]
        ]
    },
    {
        "id": "1ef9987c.956c78",
        "type": "debug",
        "z": "00b63e888082ba6b",
        "name": "",
        "active": true,
        "console": "false",
        "complete": "false",
        "x": 1310,
        "y": 280,
        "wires": []
    },
    {
        "id": "4ea6b8f29447f026",
        "type": "range",
        "z": "00b63e888082ba6b",
        "minin": "0",
        "maxin": "1",
        "minout": "0",
        "maxout": "1023",
        "action": "scale",
        "round": false,
        "property": "payload",
        "name": "Scale power",
        "x": 650,
        "y": 240,
        "wires": [
            [
                "48087abbc67f2b7f"
            ]
        ]
    },
    {
        "id": "c45a83a3.d00908",
        "type": "ui_group",
        "name": "PID",
        "tab": "80cd4062.93a5",
        "order": 1,
        "disp": true,
        "width": "14",
        "collapse": false,
        "className": ""
    },
    {
        "id": "80cd4062.93a5",
        "type": "ui_tab",
        "name": "Home",
        "icon": "dashboard"
    }
]

DMX IN

[
    {
        "id": "161d05dbd8248d2c",
        "type": "tab",
        "label": "DMX IN",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "08fc41344dd70c3f",
        "type": "serial in",
        "z": "161d05dbd8248d2c",
        "name": "DMX in",
        "serial": "b4f848f3282821e9",
        "x": 90,
        "y": 60,
        "wires": [
            [
                "04f8f728897d87e0",
                "11258af0b87a75f8"
            ]
        ]
    },
    {
        "id": "11258af0b87a75f8",
        "type": "debug",
        "z": "161d05dbd8248d2c",
        "name": "debug 1",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 620,
        "y": 60,
        "wires": []
    },
    {
        "id": "04f8f728897d87e0",
        "type": "function",
        "z": "161d05dbd8248d2c",
        "name": "Filter 1 address",
        "func": "msg.payload = msg.payload[5];\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 260,
        "y": 100,
        "wires": [
            [
                "e342005563117c86",
                "960c44cc5f8cc5b7"
            ]
        ]
    },
    {
        "id": "960c44cc5f8cc5b7",
        "type": "debug",
        "z": "161d05dbd8248d2c",
        "name": "debug 2",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 620,
        "y": 100,
        "wires": []
    },
    {
        "id": "e342005563117c86",
        "type": "function",
        "z": "161d05dbd8248d2c",
        "name": "Change Only",
        "func": "var payload_prev = context.get('payload_prev')// || false;\nif (msg.payload !== payload_prev) {\n    payload_prev = context.set('payload_prev', msg.payload);\n    return msg;\n}\n",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 450,
        "y": 140,
        "wires": [
            [
                "bf0f7bcc97c3426c"
            ]
        ]
    },
    {
        "id": "bf0f7bcc97c3426c",
        "type": "debug",
        "z": "161d05dbd8248d2c",
        "name": "debug 3",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 620,
        "y": 140,
        "wires": []
    },
    {
        "id": "b4f848f3282821e9",
        "type": "serial-port",
        "serialport": "/dev/ttyUSB0",
        "serialbaud": "250000",
        "databits": "8",
        "parity": "none",
        "stopbits": "1",
        "waitfor": "",
        "dtr": "none",
        "rts": "none",
        "cts": "none",
        "dsr": "none",
        "newline": "\\n",
        "bin": "bin",
        "out": "char",
        "addchar": "",
        "responsetimeout": "10000"
    }
]