Node-Red Dosing Sequence

Home Assistant automation projects, questions, etc. go here.
Post Reply
jaysal
LED Enthusiast
LED Enthusiast
Reactions:
Posts: 75
Joined: Sat May 30, 2020 7:49 am

Hey Everyone,
I would like to see if I can get some feedback at my attempt at nutrient dosing through Node-Red. Ill provide some background info:
I use Node-Red for all of my automations and basically use Home Assistant for the front end and for push notifications to my iPhone.

Here is the front end
Front ENd.png
Here is the sequence behind it in Node-Red

Code: Select all

[{"id":"a5f899af6f39c852","type":"server-state-changed","z":"e68e0e7d0532f2ea","name":"Start Dosing","server":"db25b3f8.bea35","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"input_boolean.begin_nutrient_dosing","entityidfiltertype":"exact","outputinitially":true,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":70,"y":1280,"wires":[["0798f47957c80fd3"]]},{"id":"1a9e7aa6a578243b","type":"api-call-service","z":"e68e0e7d0532f2ea","name":"Stop Dosing (Button Reset)","server":"db25b3f8.bea35","version":3,"debugenabled":false,"service_domain":"input_boolean","service":"turn_off","entityId":"input_boolean.begin_nutrient_dosing","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1440,"y":1940,"wires":[[]]},{"id":"71a203d2625e5bdb","type":"switch","z":"e68e0e7d0532f2ea","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":870,"y":1280,"wires":[["7622d7e68d3144c8"],["3eb3c4e31ae74013","c3da6b16cc66063c"]]},{"id":"879054dfee476838","type":"server-state-changed","z":"e68e0e7d0532f2ea","name":"Pump 1 ml input","server":"db25b3f8.bea35","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"input_number.dose_pump_1","entityidfiltertype":"exact","outputinitially":true,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":80,"y":1220,"wires":[["829d71b09a2bebfa"]]},{"id":"0798f47957c80fd3","type":"function","z":"e68e0e7d0532f2ea","name":"ml to secs - Pump 1","func":"//var timeouttime = 10;\n// or whatever data source you want like:\nvar timeouttime = flow.get('dosing_pump_1');\n// then simply\nmsg.timeout = timeouttime;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":380,"y":1280,"wires":[["e3ef786dea7ccbc0"]]},{"id":"e3ef786dea7ccbc0","type":"mytimeout","z":"e68e0e7d0532f2ea","name":"","outtopic":"","outsafe":"on","outwarning":"","outunsafe":"off","warning":"5","timer":"30","debug":false,"ndebug":false,"ignoreCase":false,"repeat":false,"again":false,"x":710,"y":1280,"wires":[["71a203d2625e5bdb"],["244a3e7b2ac49d24"]]},{"id":"829d71b09a2bebfa","type":"change","z":"e68e0e7d0532f2ea","name":"Pump 1 Payload Variable","rules":[{"t":"set","p":"dosing_pump_1","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":310,"y":1220,"wires":[[]]},{"id":"2cebd7d325614c99","type":"server-state-changed","z":"e68e0e7d0532f2ea","name":"Pump 2 ml input","server":"db25b3f8.bea35","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"input_number.dose_pump_2","entityidfiltertype":"exact","outputinitially":true,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":80,"y":1380,"wires":[["656286728de064c5"]]},{"id":"656286728de064c5","type":"change","z":"e68e0e7d0532f2ea","name":"Pump 2 Payload Variable","rules":[{"t":"set","p":"dosing_pump_2","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":490,"y":1380,"wires":[[]]},{"id":"5cf822d33b516ad5","type":"function","z":"e68e0e7d0532f2ea","name":"ml to secs - Pump 2","func":"//var timeouttime = 10;\n// or whatever data source you want like:\nvar timeouttime = flow.get('dosing_pump_2');\n// then simply\nmsg.timeout = timeouttime;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":840,"y":1440,"wires":[["3ba694f68a273c4c"]]},{"id":"3ba694f68a273c4c","type":"mytimeout","z":"e68e0e7d0532f2ea","name":"","outtopic":"","outsafe":"on","outwarning":"","outunsafe":"off","warning":"5","timer":"30","debug":false,"ndebug":false,"ignoreCase":false,"repeat":false,"again":false,"x":1050,"y":1440,"wires":[["ad9d1b0b53a7841e"],["7b92437a2f8ebb3d"]]},{"id":"ad9d1b0b53a7841e","type":"switch","z":"e68e0e7d0532f2ea","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":1230,"y":1400,"wires":[["91c533394335f3b3"],["b545cb98b28b3d75","a07e8f3e46810a0f"]]},{"id":"d581c8ce96de38bd","type":"comment","z":"e68e0e7d0532f2ea","name":"Dosing Pump 1","info":"","x":80,"y":1180,"wires":[]},{"id":"983df505e3c37c34","type":"comment","z":"e68e0e7d0532f2ea","name":"Dosing Pump 2","info":"","x":80,"y":1340,"wires":[]},{"id":"c50f17b601c34720","type":"change","z":"e68e0e7d0532f2ea","name":"Off -> On","rules":[{"t":"change","p":"payload","pt":"msg","from":"off","fromt":"str","to":"on","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":660,"y":1440,"wires":[["5cf822d33b516ad5"]]},{"id":"91c533394335f3b3","type":"debug","z":"e68e0e7d0532f2ea","name":"Pump 2 On","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1390,"y":1340,"wires":[]},{"id":"b545cb98b28b3d75","type":"debug","z":"e68e0e7d0532f2ea","name":"Pump 2 Off","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1410,"y":1440,"wires":[]},{"id":"7622d7e68d3144c8","type":"debug","z":"e68e0e7d0532f2ea","name":"Pump 1 On","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1070,"y":1220,"wires":[]},{"id":"c3da6b16cc66063c","type":"debug","z":"e68e0e7d0532f2ea","name":"Pump 1 Off","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1070,"y":1300,"wires":[]},{"id":"3eb3c4e31ae74013","type":"delay","z":"e68e0e7d0532f2ea","name":"","pauseType":"delay","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":100,"y":1460,"wires":[["d09f9d521f081145"]]},{"id":"d09f9d521f081145","type":"api-current-state","z":"e68e0e7d0532f2ea","name":"Check Begin Nutrient Dosing","server":"db25b3f8.bea35","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"input_boolean.begin_nutrient_dosing","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":0,"forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":320,"y":1460,"wires":[["0561572435535374"]]},{"id":"0561572435535374","type":"switch","z":"e68e0e7d0532f2ea","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":510,"y":1460,"wires":[["c50f17b601c34720"],[]]},{"id":"8e87827565d48e62","type":"server-state-changed","z":"e68e0e7d0532f2ea","name":"Pump 3 ml input","server":"db25b3f8.bea35","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"input_number.dose_pump_3","entityidfiltertype":"exact","outputinitially":true,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":80,"y":1560,"wires":[["7fd52d5a418abd4d"]]},{"id":"7fd52d5a418abd4d","type":"change","z":"e68e0e7d0532f2ea","name":"Pump 3 Payload Variable","rules":[{"t":"set","p":"dosing_pump_3","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":490,"y":1560,"wires":[[]]},{"id":"e2361ac97e488ace","type":"function","z":"e68e0e7d0532f2ea","name":"ml to sec - Pump 3","func":"//var timeouttime = 10;\n// or whatever data source you want like:\nvar timeouttime = flow.get('dosing_pump_3');\n// then simply\nmsg.timeout = timeouttime;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":850,"y":1620,"wires":[["0014ac73dfc0683b"]]},{"id":"0014ac73dfc0683b","type":"mytimeout","z":"e68e0e7d0532f2ea","name":"","outtopic":"","outsafe":"on","outwarning":"","outunsafe":"off","warning":"5","timer":"30","debug":false,"ndebug":false,"ignoreCase":false,"repeat":false,"again":false,"x":1050,"y":1620,"wires":[["d43c01783999abc4"],["039fc15a7a938270"]]},{"id":"d43c01783999abc4","type":"switch","z":"e68e0e7d0532f2ea","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":1230,"y":1580,"wires":[["1da99af57c2339b0"],["91a296877ddaf246","975e9b161f2cd379"]]},{"id":"072510b69cab3cd7","type":"comment","z":"e68e0e7d0532f2ea","name":"Dosing Pump 3","info":"","x":80,"y":1520,"wires":[]},{"id":"6125d070d705ca6f","type":"change","z":"e68e0e7d0532f2ea","name":"Off -> On","rules":[{"t":"change","p":"payload","pt":"msg","from":"off","fromt":"str","to":"on","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":660,"y":1620,"wires":[["e2361ac97e488ace"]]},{"id":"1da99af57c2339b0","type":"debug","z":"e68e0e7d0532f2ea","name":"Pump 3 On","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1390,"y":1520,"wires":[]},{"id":"91a296877ddaf246","type":"debug","z":"e68e0e7d0532f2ea","name":"Pump 3 Off","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1390,"y":1620,"wires":[]},{"id":"a07e8f3e46810a0f","type":"delay","z":"e68e0e7d0532f2ea","name":"","pauseType":"delay","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":100,"y":1640,"wires":[["993404963fefdce4"]]},{"id":"993404963fefdce4","type":"api-current-state","z":"e68e0e7d0532f2ea","name":"Check Begin Nutrient Dosing","server":"db25b3f8.bea35","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"input_boolean.begin_nutrient_dosing","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":0,"forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":320,"y":1640,"wires":[["65e0e5574fb0265a"]]},{"id":"65e0e5574fb0265a","type":"switch","z":"e68e0e7d0532f2ea","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":530,"y":1640,"wires":[["6125d070d705ca6f"],[]]},{"id":"211b39aef759d0a9","type":"server-state-changed","z":"e68e0e7d0532f2ea","name":"Pump 4 ml input","server":"db25b3f8.bea35","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"input_number.dose_pump_4","entityidfiltertype":"exact","outputinitially":true,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":80,"y":1780,"wires":[["48ef40762ce8a2b4"]]},{"id":"48ef40762ce8a2b4","type":"change","z":"e68e0e7d0532f2ea","name":"Pump 4 Payload Variable ","rules":[{"t":"set","p":"dosing_pump_4","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":490,"y":1780,"wires":[[]]},{"id":"5e1dc4d7220ce658","type":"function","z":"e68e0e7d0532f2ea","name":"ml to sec - Pump 4","func":"//var timeouttime = 10;\n// or whatever data source you want like:\nvar timeouttime = flow.get('dosing_pump_4');\n// then simply\nmsg.timeout = timeouttime;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":850,"y":1840,"wires":[["77fe0359411d8115"]]},{"id":"77fe0359411d8115","type":"mytimeout","z":"e68e0e7d0532f2ea","name":"","outtopic":"","outsafe":"on","outwarning":"","outunsafe":"off","warning":"5","timer":"30","debug":false,"ndebug":false,"ignoreCase":false,"repeat":false,"again":false,"x":1070,"y":1840,"wires":[["56b95437dddb628f"],["40949363ef8fe404"]]},{"id":"56b95437dddb628f","type":"switch","z":"e68e0e7d0532f2ea","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":1230,"y":1800,"wires":[["48b1b09e2a187bcb"],["d727b91a2bb7dfae","1a9e7aa6a578243b","3ea798dd3bf669b5","2999353bc681dde5"]]},{"id":"5849f9ac72ccb726","type":"change","z":"e68e0e7d0532f2ea","name":"Off -> On","rules":[{"t":"change","p":"payload","pt":"msg","from":"off","fromt":"str","to":"on","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":660,"y":1840,"wires":[["5e1dc4d7220ce658"]]},{"id":"48b1b09e2a187bcb","type":"debug","z":"e68e0e7d0532f2ea","name":"Pump 4 On","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1390,"y":1740,"wires":[]},{"id":"d727b91a2bb7dfae","type":"debug","z":"e68e0e7d0532f2ea","name":"Pump 4 Off","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1390,"y":1840,"wires":[]},{"id":"975e9b161f2cd379","type":"delay","z":"e68e0e7d0532f2ea","name":"","pauseType":"delay","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":100,"y":1860,"wires":[["804f09c3e0e1c993"]]},{"id":"804f09c3e0e1c993","type":"api-current-state","z":"e68e0e7d0532f2ea","name":"Check Begin Nutrient Dosing","server":"db25b3f8.bea35","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"input_boolean.begin_nutrient_dosing","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":0,"forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":320,"y":1860,"wires":[["258e85523f5d16b6"]]},{"id":"258e85523f5d16b6","type":"switch","z":"e68e0e7d0532f2ea","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":510,"y":1860,"wires":[["5849f9ac72ccb726"],[]]},{"id":"a8afa0bcad96811c","type":"comment","z":"e68e0e7d0532f2ea","name":"Dosing Pump 4","info":"","x":80,"y":1720,"wires":[]},{"id":"6ab50e00c593135a","type":"api-call-service","z":"e68e0e7d0532f2ea","name":"Turn pH Up Control On","server":"db25b3f8.bea35","version":3,"debugenabled":false,"service_domain":"input_boolean","service":"turn_on","entityId":"input_boolean.ph_down","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1960,"y":1780,"wires":[[]]},{"id":"4a46ee74c14cce0b","type":"delay","z":"e68e0e7d0532f2ea","name":"","pauseType":"delay","timeout":"10","timeoutUnits":"minutes","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":1730,"y":1800,"wires":[["ab2a3e03618c642e"]]},{"id":"3ea798dd3bf669b5","type":"change","z":"e68e0e7d0532f2ea","name":"","rules":[{"t":"change","p":"payload","pt":"msg","from":"off","fromt":"str","to":"on","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1500,"y":1800,"wires":[["4a46ee74c14cce0b"]]},{"id":"ab2a3e03618c642e","type":"debug","z":"e68e0e7d0532f2ea","name":"Turn Ph Up Control","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1960,"y":1840,"wires":[]},{"id":"244a3e7b2ac49d24","type":"mqtt out","z":"e68e0e7d0532f2ea","name":"Dose Pump 1 Readout","topic":"Dose Pump 1 Readout","qos":"","retain":"","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"6435d43e.84026c","x":940,"y":1340,"wires":[]},{"id":"7b92437a2f8ebb3d","type":"mqtt out","z":"e68e0e7d0532f2ea","name":"Dose Pump 2 Readout","topic":"Dose Pump 2 Readout","qos":"","retain":"","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"6435d43e.84026c","x":1180,"y":1520,"wires":[]},{"id":"039fc15a7a938270","type":"mqtt out","z":"e68e0e7d0532f2ea","name":"Dose Pump 3 Readout","topic":"Dose Pump 3 Readout","qos":"","retain":"","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"6435d43e.84026c","x":1160,"y":1700,"wires":[]},{"id":"40949363ef8fe404","type":"mqtt out","z":"e68e0e7d0532f2ea","name":"Dose Pump 4 Readout","topic":"Dose Pump 4 Readout","qos":"","retain":"","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"6435d43e.84026c","x":1180,"y":1920,"wires":[]},{"id":"2999353bc681dde5","type":"api-call-service","z":"e68e0e7d0532f2ea","name":"Res Change Done","server":"db25b3f8.bea35","version":3,"debugenabled":false,"service_domain":"notify","service":"mobile_app_iphone_12_pro","entityId":"","data":"{\t\"title\": \"Nutrient Change Done\",\t\"message\":\"Plants have fresh Nutrients!\"\t}","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1390,"y":2020,"wires":[[]]},{"id":"db25b3f8.bea35","type":"server","name":"Home Assistant","version":2,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":false,"cacheJson":true,"heartbeat":false,"heartbeatInterval":30},{"id":"6435d43e.84026c","type":"mqtt-broker","name":"Home Assistant","broker":"192.168.1.70","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]
There is always a million ways to get things done in node-red so wanted to see if anyone can see any drawbacks from my design.

It does not have calibration features so I will have to do that manually my self by adjusting the PWM on the pumps, example would be to run the pump for 100 seconds to get 100ml of solution in the res. I am using this method for my pH dosing however that's a little easier because I dose a little at a time until I reach the pH target.
User avatar
gvbz
LED Enthusiast
LED Enthusiast
Reactions:
Posts: 37
Joined: Thu Apr 02, 2020 3:30 pm

Here's my take on it using regular delay nodes and a chemical dosing calc:

Code: Select all

[
    {
        "id": "cf03bbc76da69883",
        "type": "delay",
        "z": "5dfa8e8e1b6066f9",
        "name": "",
        "pauseType": "delayv",
        "timeout": "2",
        "timeoutUnits": "minutes",
        "rate": "1",
        "nbRateUnits": "1",
        "rateUnits": "second",
        "randomFirst": "1",
        "randomLast": "5",
        "randomUnits": "seconds",
        "drop": false,
        "allowrate": false,
        "outputs": 1,
        "x": 600,
        "y": 2560,
        "wires": [
            [
                "04cf914bd8f74b89",
                "a4fcc399b2da8302"
            ]
        ]
    },
    {
        "id": "0fd9407abf3a0f0d",
        "type": "ui_button",
        "z": "5dfa8e8e1b6066f9",
        "name": "",
        "group": "df3be1ea66fec5b3",
        "order": 13,
        "width": 0,
        "height": 0,
        "passthru": false,
        "label": "Start Dosing",
        "tooltip": "",
        "color": "",
        "bgcolor": "",
        "className": "",
        "icon": "",
        "payload": "1",
        "payloadType": "str",
        "topic": "topic",
        "topicType": "msg",
        "x": 210,
        "y": 2560,
        "wires": [
            [
                "a08597436f6bfb44",
                "76fffd62d50aa009"
            ]
        ]
    },
    {
        "id": "a08597436f6bfb44",
        "type": "function",
        "z": "5dfa8e8e1b6066f9",
        "name": "cal_mag",
        "func": "var calmag_dose = Number(global.get('fertigationSP.calmag_dose'));\nvar calmag_calib_time = Number(global.get('fertigationSP.calmag_calib_time'));\nvar calmag_calib_result = Number(global.get('fertigationSP.calmag_calib_result'));\n\nmsg.delay = (calmag_calib_time * calmag_dose / calmag_calib_result)*1000;\nreturn msg;\n",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 440,
        "y": 2560,
        "wires": [
            [
                "cf03bbc76da69883"
            ]
        ]
    },
    {
        "id": "04cf914bd8f74b89",
        "type": "change",
        "z": "5dfa8e8e1b6066f9",
        "name": "stop calmag pump",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "0",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 790,
        "y": 2560,
        "wires": [
            [
                "76fffd62d50aa009"
            ]
        ]
    },
    {
        "id": "4203b8631a36b319",
        "type": "delay",
        "z": "5dfa8e8e1b6066f9",
        "name": "",
        "pauseType": "delayv",
        "timeout": "2",
        "timeoutUnits": "minutes",
        "rate": "1",
        "nbRateUnits": "1",
        "rateUnits": "second",
        "randomFirst": "1",
        "randomLast": "5",
        "randomUnits": "seconds",
        "drop": false,
        "allowrate": false,
        "outputs": 1,
        "x": 600,
        "y": 2720,
        "wires": [
            [
                "218fddb462c4c3b6"
            ]
        ]
    },
    {
        "id": "a99b086d07b50df3",
        "type": "function",
        "z": "5dfa8e8e1b6066f9",
        "name": "flowerA",
        "func": "var flowerA_dose = Number(global.get('fertigationSP.flowerA_dose'));\nvar flowerA_calib_time = Number(global.get('fertigationSP.flowerA_calib_time'));\nvar flowerA_calib_result = Number(global.get('fertigationSP.flowerA_calib_result'));\n\nmsg.delay = (flowerA_calib_time * flowerA_dose / flowerA_calib_result)*1000;\nreturn msg;\n",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 440,
        "y": 2720,
        "wires": [
            [
                "4203b8631a36b319"
            ]
        ]
    },
    {
        "id": "218fddb462c4c3b6",
        "type": "change",
        "z": "5dfa8e8e1b6066f9",
        "name": "stop flowerA pump",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "0",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 770,
        "y": 2720,
        "wires": [
            [
                "52681ea5c461480d"
            ]
        ]
    },
    {
        "id": "52681ea5c461480d",
        "type": "switch",
        "z": "5dfa8e8e1b6066f9",
        "name": "1/0",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "1",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "0",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 2,
        "x": 600,
        "y": 2640,
        "wires": [
            [
                "08554097f078653e"
            ],
            [
                "08554097f078653e"
            ]
        ]
    },
    {
        "id": "a4fcc399b2da8302",
        "type": "delay",
        "z": "5dfa8e8e1b6066f9",
        "name": "",
        "pauseType": "delay",
        "timeout": "5",
        "timeoutUnits": "seconds",
        "rate": "1",
        "nbRateUnits": "1",
        "rateUnits": "second",
        "randomFirst": "1",
        "randomLast": "5",
        "randomUnits": "seconds",
        "drop": false,
        "allowrate": false,
        "outputs": 1,
        "x": 260,
        "y": 2640,
        "wires": [
            [
                "a99b086d07b50df3",
                "52681ea5c461480d"
            ]
        ]
    },
    {
        "id": "0933f9fd9d071cfd",
        "type": "inject",
        "z": "5dfa8e8e1b6066f9",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payloadType": "date",
        "x": 210,
        "y": 2440,
        "wires": [
            [
                "903e972ed7161f9d"
            ]
        ]
    },
    {
        "id": "903e972ed7161f9d",
        "type": "change",
        "z": "5dfa8e8e1b6066f9",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "fertigationSP.calmag_dose",
                "pt": "global",
                "to": "11",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "fertigationSP.calmag_calib_time",
                "pt": "global",
                "to": "60",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "fertigationSP.calmag_calib_result",
                "pt": "global",
                "to": "60",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "fertigationSP.flowerA_dose",
                "pt": "global",
                "to": "15",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "fertigationSP.flowerA_calib_time",
                "pt": "global",
                "to": "60",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "fertigationSP.flowerA_calib_result",
                "pt": "global",
                "to": "30",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 420,
        "y": 2440,
        "wires": [
            []
        ]
    },
    {
        "id": "76fffd62d50aa009",
        "type": "switch",
        "z": "5dfa8e8e1b6066f9",
        "name": "1/0",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "1",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "0",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 2,
        "x": 600,
        "y": 2480,
        "wires": [
            [
                "08554097f078653e"
            ],
            [
                "08554097f078653e"
            ]
        ]
    },
    {
        "id": "08554097f078653e",
        "type": "debug",
        "z": "5dfa8e8e1b6066f9",
        "name": "test",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 730,
        "y": 2880,
        "wires": []
    },
    {
        "id": "2bae310cfb036e8c",
        "type": "comment",
        "z": "5dfa8e8e1b6066f9",
        "name": "",
        "info": "dashboard setpoints placed into global or flow context",
        "x": 410,
        "y": 2400,
        "wires": []
    },
    {
        "id": "a196a5e311d9a027",
        "type": "comment",
        "z": "5dfa8e8e1b6066f9",
        "name": "",
        "info": "sets msg.delay based on dose required, calibration time/result used for calc.\ntime = how long calibration was performed for in sec\nresult = pump volume result in mL\ndose = desired dose in mL\n\n",
        "x": 440,
        "y": 2520,
        "wires": []
    },
    {
        "id": "07e5276162b36939",
        "type": "comment",
        "z": "5dfa8e8e1b6066f9",
        "name": "",
        "info": "pump control output",
        "x": 620,
        "y": 2440,
        "wires": []
    },
    {
        "id": "cc5ae33e08e59752",
        "type": "comment",
        "z": "5dfa8e8e1b6066f9",
        "name": "",
        "info": "button node from node-red dashboard\n\n",
        "x": 200,
        "y": 2520,
        "wires": []
    },
    {
        "id": "df3be1ea66fec5b3",
        "type": "ui_group",
        "name": "Fertigation",
        "tab": "300c838c78e475c0",
        "order": 2,
        "disp": true,
        "width": 7,
        "collapse": true,
        "className": ""
    },
    {
        "id": "300c838c78e475c0",
        "type": "ui_tab",
        "name": "Flower Room",
        "icon": "dashboard",
        "order": 3,
        "disabled": false,
        "hidden": false
    }
]
480W Bridgelux EB Gen3 Parallel Build: https://bit.ly/2NfoVyE
Grow Room Automation w/ Node Red: https://bit.ly/3hOm5yK
Github: https://github.com/gvbz/gardenbro
Instagram: @loudfarms_ca
jaysal
LED Enthusiast
LED Enthusiast
Reactions:
Posts: 75
Joined: Sat May 30, 2020 7:49 am

Hey thanks @gvbz , I will work on getting my pumps installed and see if I can implement your sequence. It would be great if I can get the calibration working.

It looks like the function nodes does some quick math and tells the pump to turn off using the delay node.

I have questions regarding the variables;
var calmag_dose = This is the amount in ml that I want to dose ?
var calmag_calib_time = This is amount of time in seconds that I want the pump to run for calibration?
var calmag_calib_result = I am lost on this one, where does this variable come from ?
mikeyB
LED-Curious
LED-Curious
Reactions:
Posts: 24
Joined: Wed Jan 19, 2022 11:45 pm

Just an idea but once I get tge setup and automation done I was going to setup a pump to water and time how long it took to pump ml to a measuring cup.

For now I utilize the delay nodes to function like the ml of the what’s being input/gal

It says 3 ml /gal I made the delay 3 seconds …for now

More of final calibration
User avatar
gvbz
LED Enthusiast
LED Enthusiast
Reactions:
Posts: 37
Joined: Thu Apr 02, 2020 3:30 pm

jaysal wrote:
Mon Jan 24, 2022 2:39 am
Hey thanks @gvbz , I will work on getting my pumps installed and see if I can implement your sequence. It would be great if I can get the calibration working.

It looks like the function nodes does some quick math and tells the pump to turn off using the delay node.

I have questions regarding the variables;
var calmag_dose = This is the amount in ml that I want to dose ?
var calmag_calib_time = This is amount of time in seconds that I want the pump to run for calibration?
var calmag_calib_result = I am lost on this one, where does this variable come from ?
var calmag_calib_result = the volume of water dispensed after running the pump for a specified calmag_calib_time, let's say you run the pump for 60s and get 60mL:

ex. 1:1 ratio - 60mL/60s = 1mL/s

60s * 11mL / 60mL = 11s

ex. 1:0.5 ratio - 30mL/60s = 0.5mL/s

60s * 11mL / 30mL = 22s
480W Bridgelux EB Gen3 Parallel Build: https://bit.ly/2NfoVyE
Grow Room Automation w/ Node Red: https://bit.ly/3hOm5yK
Github: https://github.com/gvbz/gardenbro
Instagram: @loudfarms_ca
Post Reply