Importing flow from website

Hi
i want to import the flow in link below but the import not show as active in node red dashboard

please advise

Hi - it looks the flow has been 'formatted' by the website - making it invalid json.

After swapping some 'smart quotes' for normal quotes, and inserting some \n instead of newlines, this is the importable version of the flow:

[{"id":"14bf53f7.3fe83c","type":"rpi-srf","z":"368819c8.13b4b6","name":"Sensor","pins":"13,11","x":66,"y":104,"wires":[["c25630c9.c2d08"]]},{"id":"c25630c9.c2d08","type":"function","z":"368819c8.13b4b6","name":"Calculate Percentage","func":"var distance = parseInt(msg.payload);\nvar EmptyDist = 108 – distance;\nmsg.payload = parseInt((EmptyDist/108)*100);\n//msg.payload =(100- parseInt((temp/125)*100));\nreturn msg;","outputs":1,"noerr":0,"x":267,"y":104,"wires":[["cd8cf3db.151e4","c3900b65.a67de8"]]},{"id":"cd8cf3db.151e4","type":"debug","z":"368819c8.13b4b6","name":"","active":false,"console":"false","complete":"false","x":621,"y":145,"wires":[]},{"id":"c3900b65.a67de8","type":"ui_gauge","z":"368819c8.13b4b6","name":"","group":"f8c28556.6c7c98","order":0,"width":0,"height":0,"gtype":"gage","title":"Tank Filled","label":"Percentage","format":"{{value}}","min":0,"max":"100","colors":["#b52100","#e6e600","#42ca38"],"seg1":"","seg2":"","x":606,"y":55,"wires":[]},{"id":"f8c28556.6c7c98","type":"ui_group","z":"","name":"Default","tab":"8caefc37.2e2b3","disp":true,"width":"6"},{"id":"8caefc37.2e2b3","type":"ui_tab","z":"","name":"Home","icon":"dashboard"}]

If you are interested i have a similar solution - but use a Waterproof Ultrasonic sensor (same HC-SR04) but it only has a single emitter/receiver so it has a minimum measuring distance of 20cm

I have this hooked to a NodeMCU unit running ESPEasy firmware and reporting back through MQTT to Node-Red

The Node-MCU is powered through a 240V to USB (phone charger) - it presents 5V on one of its output pins - this is wired to the Trigger of the Sensor and the return comes in on a standard 3.3V tolerant pin with no issues.

Has been running for a couple of months fine now

Flow below

[{"id":"c27bb157.46dde","type":"debug","z":"6865126d.1bde1c","name":"Raw MQTT from the Pump Relay","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":480,"y":720,"wires":[]},{"id":"c82a1ddf.22956","type":"mqtt in","z":"6865126d.1bde1c","name":"Incoming MQTT from Tank Pump","topic":"Tank_Top_Up_Pump/Tank_Relay/Switch","qos":"2","broker":"e2ed99fb.aa45d8","x":190,"y":640,"wires":[["c27bb157.46dde","99ce6aa4.7369b8"]]},{"id":"8ddc3312.3b0ff","type":"mqtt out","z":"6865126d.1bde1c","name":"Water Tank Top Up","topic":"Tank_Top_Up_Pump/GPIO/12","qos":"","retain":"","broker":"e2ed99fb.aa45d8","x":1150,"y":500,"wires":[]},{"id":"b1246216.6755b","type":"inject","z":"6865126d.1bde1c","name":"Turn off Relay","topic":"","payload":"0","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":930,"y":420,"wires":[["8ddc3312.3b0ff"]]},{"id":"63fea32f.f1fd2c","type":"inject","z":"6865126d.1bde1c","name":"Turn on Relay","topic":"","payload":"1","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":930,"y":460,"wires":[["8ddc3312.3b0ff"]]},{"id":"7d8236d1.3c4ac8","type":"schedex","z":"6865126d.1bde1c","name":"Timer to Top up Water Tank","suspended":true,"lat":"","lon":"","ontime":"3:15","ontopic":"","onpayload":"1","onoffset":0,"onrandomoffset":0,"offtime":"3:35","offtopic":"","offpayload":"0","offoffset":0,"offrandomoffset":0,"mon":true,"tue":true,"wed":true,"thu":true,"fri":true,"sat":true,"sun":true,"x":480,"y":500,"wires":[["8ddc3312.3b0ff","3c4dd8f5.c34618","e4b7f9a0.8f9b68","a168d9f9.f6fbe8"]]},{"id":"52d9c82b.9fd2f8","type":"comment","z":"6865126d.1bde1c","name":"Manual Control","info":"","x":900,"y":380,"wires":[]},{"id":"2914711a.99b39e","type":"comment","z":"6865126d.1bde1c","name":"Automatic Control","info":"","x":450,"y":460,"wires":[]},{"id":"99ce6aa4.7369b8","type":"function","z":"6865126d.1bde1c","name":"Build Message for LogFile","func":"var topic = msg.topic;\nif (msg.payload === \"1\") {\n    var p = \"On\";\n    } \nelse if (msg.payload === \"0\") { \n    var p = \"Off\";\n    }\nelse var p = \"Unknown\";\n\nvar d = flow.get(\"MyDateTime\") || \"0\";\n//var myCount = flow.get(\"count\", storeName);\n\n//create message to write to the log file\nvar payload1 = (d + \" Tank Pump is \" + p + \" Topic is: \" + msg.topic);\n//Store message so it can be output on output 1\nvar msg1 = { payload:payload1 };\n\n//Create 2nd message for screen writing on scrolling table\nvar payload2 = (d + \" Tank Pump is \" + p);\n//Store message so it can be output on output 2\nvar msg2 = { payload:payload2 };\n\nif (p == \"On\") {\nvar msg3 = { payload:'<i class=\"fa fa-refresh fa-spin fa-3x fa-fw\"></i>' };\n}\n\nif (p == \"Off\") {\nvar msg3 = { payload:'<i class=\"fa fa-stop-circle-o fa-3x fa-fw\"></i>' };\n}\n\n//End Function and return two messages on two outputs\nreturn [msg1, msg2, msg3,];\n\n","outputs":3,"noerr":0,"x":490,"y":640,"wires":[["9fda007f.37ac4","9c9c07be.2df6a8"],["6add9bdb.1edc64"],["abf71e7c.4fb0c"]]},{"id":"9fda007f.37ac4","type":"debug","z":"6865126d.1bde1c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":770,"y":600,"wires":[]},{"id":"9c9c07be.2df6a8","type":"file","z":"6865126d.1bde1c","name":"Log info to the file","filename":"/home/pi/logs/Tank_Pump_Run_Stats","appendNewline":true,"createDir":true,"overwriteFile":"false","x":790,"y":640,"wires":[[]]},{"id":"d6dfc259.d5a88","type":"moment","z":"6865126d.1bde1c","name":"Get the Date and time for the log","topic":"","input":"","inputType":"date","inTz":"Australia/Sydney","adjAmount":0,"adjType":"days","adjDir":"add","format":"DD-MM-YY HH:mm","locale":"en_AU","output":"MyDateTime","outputType":"flow","outTz":"Australia/Sydney","x":410,"y":220,"wires":[[]]},{"id":"c17c2fbe.8c5de","type":"inject","z":"6865126d.1bde1c","name":"Store Date and Time","topic":"","payload":"","payloadType":"date","repeat":"60","crontab":"","once":true,"onceDelay":0.1,"x":140,"y":220,"wires":[["d6dfc259.d5a88"]]},{"id":"d75cde83.6fdc1","type":"comment","z":"6865126d.1bde1c","name":"Setup Flow object with Date and time for logging","info":"","x":260,"y":180,"wires":[]},{"id":"b6bf6503.a904d8","type":"comment","z":"6865126d.1bde1c","name":"Send MQTT to the Sonoff (ESPEasy)","info":"The ESPEasy firmware will echo back when it gets the command\nThats what we are looking for to then log to the file","x":1210,"y":440,"wires":[]},{"id":"c48484b9.6be268","type":"ui_template","z":"6865126d.1bde1c","group":"c4fb7801.2972a8","name":"Water Tank Pump Status","order":0,"width":"10","height":"5","format":"<style>\n\n    #tex1 {\n        font-weight:bolder;\n        font-size: 12;\n        letter-spacing: 4px;\n        fill: white;\n    }\n    \n</style>\n\n\n<svg height=\"300\" width=\"400\" >\n\n<text id=\"tex1\" x=\"10\" y=\"30\" > {{msg.payload[0]}} </text>\n<text id=\"tex1\" x=\"10\" y=\"50\" > {{msg.payload[1]}} </text>\n<text id=\"tex1\" x=\"10\" y=\"70\" > {{msg.payload[2]}} </text>\n<text id=\"tex1\" x=\"10\" y=\"90\" > {{msg.payload[3]}} </text>\n<text id=\"tex1\" x=\"10\" y=\"110\" > {{msg.payload[4]}} </text>\n<text id=\"tex1\" x=\"10\" y=\"130\" > {{msg.payload[5]}} </text>\n<text id=\"tex1\" x=\"10\" y=\"150\" > {{msg.payload[6]}} </text>\n<text id=\"tex1\" x=\"10\" y=\"170\" > {{msg.payload[7]}} </text>\n<text id=\"tex1\" x=\"10\" y=\"190\" > {{msg.payload[8]}} </text>\n<text id=\"tex1\" x=\"10\" y=\"210\" > {{msg.payload[9]}} </text>\n</svg>\n\n","storeOutMessages":false,"fwdInMessages":false,"templateScope":"local","x":1070,"y":680,"wires":[[]]},{"id":"5df88877.028858","type":"function","z":"6865126d.1bde1c","name":"Create table in context","func":"let sctab = [];\nflow.set(\"sctab\", sctab);\nreturn msg;","outputs":"1","noerr":0,"x":320,"y":100,"wires":[[]]},{"id":"d8308393.02982","type":"inject","z":"6865126d.1bde1c","name":"","topic":"","payload":"Start","payloadType":"str","repeat":"","crontab":"","once":true,"onceDelay":"5","x":130,"y":100,"wires":[["5df88877.028858"]]},{"id":"6add9bdb.1edc64","type":"function","z":"6865126d.1bde1c","name":"Add word to scrolling table","func":"let pay = msg.payload;\n\n// Read scrolling table from context\nlet sctab = flow.get(\"sctab\");\n\n// Modify scrolling table by adding msg.payload as first element\nlet size = sctab.unshift(pay);\n\n// Remove last element from scrolling table\nif (size >9) sctab.pop();\n\n// Update context for scrolling text\nflow.set(\"sctab\",sctab);\n\n// Shalow copy updated scrolling table to msg.payload\nmsg.payload = [...sctab];\n\nreturn msg;","outputs":1,"noerr":0,"x":820,"y":680,"wires":[["c48484b9.6be268"]]},{"id":"d24049a0.414bd8","type":"comment","z":"6865126d.1bde1c","name":"Setup Memory table to Store Scrollng Text table entries","info":"","x":260,"y":40,"wires":[]},{"id":"89d5b067.7701c","type":"inject","z":"6865126d.1bde1c","name":"","topic":"press","payload":"<i class=\"fa fa-refresh fa-spin fa-3x fa-fw\"></i>","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":"","x":570,"y":820,"wires":[["abf71e7c.4fb0c"]]},{"id":"abf71e7c.4fb0c","type":"ui_text","z":"6865126d.1bde1c","group":"c4fb7801.2972a8","order":1,"width":"1","height":"1","name":"Water Tank Pump Running Status","label":"","format":"{{msg.payload}}","layout":"row-center","x":840,"y":740,"wires":[]},{"id":"90919ebb.9e648","type":"inject","z":"6865126d.1bde1c","name":"","topic":"","payload":"<i class=\"fa fa-stop-circle-o fa-3x\" aria-hidden=\"true\"</i>","payloadType":"str","repeat":"","crontab":"","once":true,"onceDelay":0.1,"x":570,"y":780,"wires":[["abf71e7c.4fb0c"]]},{"id":"d435769d.e87948","type":"mqtt in","z":"6865126d.1bde1c","name":"Water Level in Tank","topic":"ESP_Tank_Level_Monitor/TankLevel/Distance","qos":"2","broker":"e2ed99fb.aa45d8","x":890,"y":80,"wires":[["2423fba1.f03714"]]},{"id":"2423fba1.f03714","type":"smooth","z":"6865126d.1bde1c","name":"Average the Level of the tank readings","property":"payload","action":"mean","count":"10","round":"","mult":"single","x":1150,"y":80,"wires":[["24fef8ee.5416f8"]]},{"id":"24fef8ee.5416f8","type":"function","z":"6865126d.1bde1c","name":"Calculate Tank Percentage","func":"//Total Tank depth (TTD) = 153 CM\n//Sensor is elevated above level of tank by 29cm\n//This is to allow for the 20cm dead spot in the \n//sensor readings\n//Sensor returns units in CM\n//Calculation needs to be \n//(TTD - Payload)/TTD\nvar SensorReading = msg.payload;\nvar TTD = 153; //allow for raised stand pipe on sensor\nvar TankRemainingCapacity = (TTD - (SensorReading - 29))/TTD; //empirically used 29(cm)\nmsg.payload = Math.round(TankRemainingCapacity * 100);\nflow.set(\"TankRemainingCapacity\", msg.payload);\nreturn msg;","outputs":1,"noerr":0,"x":920,"y":140,"wires":[["659f77dc.fda958","64a0dccf.d5ea04","8d27a951.83a4a8"]]},{"id":"659f77dc.fda958","type":"debug","z":"6865126d.1bde1c","name":"Percentage Remaining","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload","x":1200,"y":140,"wires":[]},{"id":"64a0dccf.d5ea04","type":"ui_gauge","z":"6865126d.1bde1c","name":"Water Tank Level","group":"9252424c.768bd","order":0,"width":0,"height":0,"gtype":"wave","title":"Water Tank Level","label":"%","format":"{{value}}","min":0,"max":"100","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":1190,"y":200,"wires":[]},{"id":"1c033469.37312c","type":"comment","z":"6865126d.1bde1c","name":"Get the Water Tank Level from the Ultrasonic Sensor","info":"","x":990,"y":40,"wires":[]},{"id":"7b3f27b9.cb89d8","type":"inject","z":"6865126d.1bde1c","name":"Output Schedex node Status to Dashboard","topic":"","payload":"info","payloadType":"str","repeat":"60","crontab":"","once":true,"onceDelay":0.1,"x":170,"y":500,"wires":[["7d8236d1.3c4ac8"]]},{"id":"3c4dd8f5.c34618","type":"debug","z":"6865126d.1bde1c","name":"Schedex output","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","x":700,"y":460,"wires":[]},{"id":"e4b7f9a0.8f9b68","type":"ui_text","z":"6865126d.1bde1c","group":"9252424c.768bd","order":0,"width":0,"height":0,"name":"Status of the Scheduled pumping","label":"Schedule State","format":"{{msg.payload.state}}","layout":"row-spread","x":760,"y":540,"wires":[]},{"id":"2c93b1f2.9ead7e","type":"link in","z":"6865126d.1bde1c","name":"Link from Tank Level Reading","links":["e4b56095.308b","8d27a951.83a4a8"],"x":35,"y":340,"wires":[["3d5ca2c3.eaedce"]]},{"id":"4e92428d.fdaabc","type":"change","z":"6865126d.1bde1c","name":"Enable Schedule","rules":[{"t":"set","p":"payload","pt":"msg","to":"suspended false","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":390,"y":340,"wires":[["7d8236d1.3c4ac8","622beeec.f0cef"]]},{"id":"3d5ca2c3.eaedce","type":"switch","z":"6865126d.1bde1c","name":"Check for Water level","property":"payload","propertyType":"msg","rules":[{"t":"lte","v":"25","vt":"num"},{"t":"gt","v":"35","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":160,"y":340,"wires":[["4e92428d.fdaabc"],["d4f08431.e0baf8"]]},{"id":"d4f08431.e0baf8","type":"change","z":"6865126d.1bde1c","name":"Disable Schedule","rules":[{"t":"set","p":"payload","pt":"msg","to":"suspended true","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":390,"y":380,"wires":[["7d8236d1.3c4ac8","d1a04747.dd1b28"]]},{"id":"8d27a951.83a4a8","type":"link out","z":"6865126d.1bde1c","name":"LInk to re-enable Automatic scheduling","links":["2c93b1f2.9ead7e"],"x":1015,"y":200,"wires":[]},{"id":"622beeec.f0cef","type":"debug","z":"6865126d.1bde1c","name":"Enable","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload","x":610,"y":340,"wires":[]},{"id":"d1a04747.dd1b28","type":"debug","z":"6865126d.1bde1c","name":"Disable","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload","x":600,"y":400,"wires":[]},{"id":"2cbb6c5c.8e80d4","type":"comment","z":"6865126d.1bde1c","name":"Keep Water Tank Level between 25% and 35% by enabling/disabling the schedule","info":"","x":320,"y":300,"wires":[]},{"id":"a168d9f9.f6fbe8","type":"change","z":"6865126d.1bde1c","name":"Set Flow variable for daily email","rules":[{"t":"set","p":"PumpSchedulingState","pt":"flow","to":"payload.state","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1170,"y":560,"wires":[[]]},{"id":"e2ed99fb.aa45d8","type":"mqtt-broker","z":"","name":"","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"c4fb7801.2972a8","type":"ui_group","z":"","name":"Status Messages","tab":"7ded32a1.cf8ccc","order":2,"disp":true,"width":"10","collapse":false},{"id":"9252424c.768bd","type":"ui_group","z":"","name":"Water Tank Level","tab":"7ded32a1.cf8ccc","order":2,"disp":true,"width":"6","collapse":false},{"id":"7ded32a1.cf8ccc","type":"ui_tab","z":"","name":"Water Tank","icon":"","order":2}]

The basic premise is that we have a 4000 litre water tank that is our primary tank for water for showers and flushing toilets, this tank is supplemented by 20,000 litres of additional water further down our property.

I am happy to keep the primary (4000) litre tank at between 25-35% capacity - with the hope that rain events will top it up (when full it overflows down to the back tanks to replenish them.

I have a schedex node that runs for 15m per day from 2AM to perform this top up operation - howevr if the tank level is above 35% this schedule is suspended, once the tank level hits 25% the schedule is re-enabled and does a small amount of pumping each day to maintain that level (between 25 and 35%)

This on off time is record to a text file and also reported to the status window on the dashboard along with the actual level of the tank.

I am sent and email each day with the current water level and the status of the schedule (runinng suspended etc)

I also have manual over rides so i can turn the transfer pump on to move water up from the back tanks - this transfer pump is run on a sonoff basic in a waterproof housing runnng espeasy frimware also

Next up is to monitor the level of the tanks down the back so i have an overall view of the water situtation.

Craig

1 Like

Hi
Would you please assist for the error in below

What does it say after "instead saw an"? It is cut off by the debug window.
Also hit End on that line and make sure there is nothing further along the line

Please see screenshot
image

It seems you ended up with an invalid character. Try to edit the second line deleting the "minus" character and typing it again.

1 Like

Thank you for your support
it is work fine as (var EmptyDist = 200 -distance;)
would you please tell me if I can do a condition in case the gauge less than 10 percent an output of GPIO get active .I'm thinking to use a AND gate but I'm just very new in node red