forked from futureshocked/NodeRed-ESP32-TerrariumController
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TerrariumController-Flow-v4.json
1 lines (1 loc) · 10.3 KB
/
TerrariumController-Flow-v4.json
1
[{"id":"9fd96cff.fbfd68","type":"tab","label":"Terrarium Controller v4","disabled":true,"info":""},{"id":"de536ffb.1ef4e","type":"ui_switch","z":"9fd96cff.fbfd68","name":"Manual pump control","label":"Manual pump control","tooltip":"","group":"4c9b7e83.a15c88","order":1,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"","style":"","onvalue":"1","onvalueType":"str","onicon":"","oncolor":"","offvalue":"0","offvalueType":"str","officon":"","offcolor":"","x":280,"y":380,"wires":[["e153377d.13de4"]]},{"id":"bf869085.3cbf48","type":"mqtt out","z":"9fd96cff.fbfd68","name":"Publish pump state","topic":"techexplorations/terrarium/pump-control","qos":"0","retain":"","broker":"ac3817ea.826db8","x":1250,"y":380,"wires":[]},{"id":"7389996b.971fd","type":"ui_text","z":"9fd96cff.fbfd68","group":"582e5eea.e3645","order":3,"width":0,"height":0,"name":"Pump state","label":"Pump state is...","format":"{{msg.payload}}","layout":"row-spread","x":1230,"y":320,"wires":[]},{"id":"edcd605a.7ce108","type":"debug","z":"9fd96cff.fbfd68","name":"Pump state","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1230,"y":280,"wires":[]},{"id":"d88b422.182bec","type":"mqtt in","z":"9fd96cff.fbfd68","name":"Get soil humidity","topic":"techexplorations/terrarium/soil-humidity","qos":"0","datatype":"auto","broker":"ac3817ea.826db8","x":260,"y":220,"wires":[["ea203978.2a809","cdadc3e4.9c85f8","ca128f52.0e47e"]]},{"id":"ea203978.2a809","type":"ui_gauge","z":"9fd96cff.fbfd68","name":"Soil humidity raw","group":"c76544b.1f79338","order":1,"width":0,"height":0,"gtype":"gage","title":"Soil humidity raw","label":"units","format":"{{value}}","min":0,"max":"1023","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":590,"y":180,"wires":[]},{"id":"cdadc3e4.9c85f8","type":"function","z":"9fd96cff.fbfd68","name":"Pump operation","func":"var pump_state = '0';\n\nvar device_string = msg.payload.split(\",\"); // The data is coming in like this: \"167,ESP32_client_2\"\n // The actual sensor value is in device_string[0]\nvar raw_humidity_value = device_string[0];\nvar device_name = device_string[1];\n\nflow.set(\"raw_humidity_value\",raw_humidity_value);\nflow.set(\"device_name\",device_name);\n\nif (raw_humidity_value > flow.get(\"soil_humidity_threshold\"))\n{\n pump_state = '1';\n flow.set(\"pump_state\",\"On\");\n} else\n{\n pump_state = '0';\n flow.set(\"pump_state\",\"Off\");\n}\n\n\nreturn {payload: pump_state};","outputs":1,"noerr":0,"initialize":"","finalize":"","x":580,"y":260,"wires":[["e153377d.13de4"]]},{"id":"e153377d.13de4","type":"rbe","z":"9fd96cff.fbfd68","name":"Update if pump state changed","func":"rbe","gap":"","start":"","inout":"out","property":"payload","x":900,"y":320,"wires":[["bf869085.3cbf48","edcd605a.7ce108","7389996b.971fd","41c82302.b6c574"]]},{"id":"4b9877df.94efd","type":"mqtt in","z":"9fd96cff.fbfd68","name":"Get MCU voltage","topic":"techexplorations/terrarium/mcu_voltage","qos":"0","datatype":"auto","broker":"ac3817ea.826db8","x":280,"y":640,"wires":[["72302948.558f5","d7865a79.41894"]]},{"id":"ad934fc2.37c31","type":"mqtt in","z":"9fd96cff.fbfd68","name":"Get motor voltage","topic":"techexplorations/terrarium/motor_voltage","qos":"2","datatype":"auto","broker":"ac3817ea.826db8","x":290,"y":820,"wires":[["1098a816.875db8","65fd404b.d8c378"]]},{"id":"72302948.558f5","type":"debug","z":"9fd96cff.fbfd68","name":"MCU Voltage","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":850,"y":640,"wires":[]},{"id":"1098a816.875db8","type":"debug","z":"9fd96cff.fbfd68","name":"Motor Voltage","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":860,"y":820,"wires":[]},{"id":"30453c7f.fe678c","type":"ui_gauge","z":"9fd96cff.fbfd68","name":"MCU Voltage","group":"8a1febd1.228ed8","order":0,"width":"6","height":"6","gtype":"gage","title":"MCU Voltage","label":"V","format":"{{value | number:1}} V","min":0,"max":"5","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":850,"y":700,"wires":[]},{"id":"c5616b3.4628018","type":"ui_gauge","z":"9fd96cff.fbfd68","name":"Motor Voltage","group":"8a1febd1.228ed8","order":0,"width":"6","height":"6","gtype":"gage","title":"Motor Voltage","label":"V","format":"{{value | number:1}} V","min":0,"max":"9","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":860,"y":880,"wires":[]},{"id":"ca128f52.0e47e","type":"debug","z":"9fd96cff.fbfd68","name":"Soil humidity raw","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":600,"y":120,"wires":[]},{"id":"99ccb2c9.8476b","type":"GSheet","z":"9fd96cff.fbfd68","creds":"90d14cf4.d152d8","method":"append","action":"","sheet":"1fpasYEjoUoExPwptcmerV0R0TpTfTBmzWGNcPcOMTMc","cells":"Sheet1!A2","name":"Log data to GSheet","x":1750,"y":560,"wires":[["3f17d36e.25227c"]]},{"id":"5c3f82c9.1bfc2c","type":"inject","z":"9fd96cff.fbfd68","name":"Hello!","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"2020-7-16 2:1:7,ESP32_client_1,831,On,0.7,4.7","payloadType":"str","x":1470,"y":580,"wires":[["99ccb2c9.8476b"]]},{"id":"d29e14c.0e15ee8","type":"function","z":"9fd96cff.fbfd68","name":"Prepare Sheet Payload","func":"var today = new Date();\n\nvar date = today.getFullYear()+\n '-'+ (today.getMonth()+1)+\n '-'+ today.getDate() + \n ' ' + today.getHours() + \n \":\" + today.getMinutes() + \n \":\" + today.getSeconds();\n\nvar new_payload = date;\nnew_payload += \",\";\nnew_payload += flow.get(\"device_name\");\nnew_payload += \",\";\nnew_payload += flow.get(\"raw_humidity_value\");\nnew_payload += \",\";\nnew_payload += flow.get(\"pump_state\");\nnew_payload += \",\";\nnew_payload += flow.get(\"motor_voltage\");\nnew_payload += \",\";\nnew_payload += flow.get(\"mcu_voltage\");\n\n\nreturn { payload: new_payload };","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1460,"y":480,"wires":[["99ccb2c9.8476b","541a76.5b46758c"]]},{"id":"d7865a79.41894","type":"function","z":"9fd96cff.fbfd68","name":"Set MCU Voltage flow variable","func":"flow.set(\"mcu_voltage\",msg.payload);\n\nreturn {payload: msg.payload};","outputs":1,"noerr":0,"initialize":"","finalize":"","x":590,"y":700,"wires":[["30453c7f.fe678c"]]},{"id":"65fd404b.d8c378","type":"function","z":"9fd96cff.fbfd68","name":"Set Motor Voltage flow variable","func":"flow.set(\"motor_voltage\",msg.payload);\n\nreturn {payload: msg.payload};","outputs":1,"noerr":0,"initialize":"","finalize":"","x":590,"y":880,"wires":[["c5616b3.4628018"]]},{"id":"41c82302.b6c574","type":"trigger","z":"9fd96cff.fbfd68","name":"Update log","op1":"1","op2":"0","op1type":"str","op2type":"str","duration":"-1","extend":false,"units":"min","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":1230,"y":480,"wires":[["d29e14c.0e15ee8"]]},{"id":"541a76.5b46758c","type":"debug","z":"9fd96cff.fbfd68","name":"GSheet function","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1740,"y":480,"wires":[]},{"id":"3f17d36e.25227c","type":"debug","z":"9fd96cff.fbfd68","name":"GSheet payload","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":2000,"y":560,"wires":[]},{"id":"576ed7d5.6da35","type":"ui_numeric","z":"9fd96cff.fbfd68","name":"Pump threshold","label":"Pump threshold","tooltip":"Set a raw humidity value above wich the pump is turned on","group":"702fced4.928518","order":0,"width":"6","height":"1","wrap":false,"passthru":true,"topic":"","format":"{{value}}","min":0,"max":"1023","step":"10","x":300,"y":500,"wires":[["17d28da7.b58af2"]]},{"id":"17d28da7.b58af2","type":"function","z":"9fd96cff.fbfd68","name":"Set humidity threshold flow variable","func":"flow.set(\"soil_humidity_threshold\", msg.payload);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":600,"y":500,"wires":[["e75b412f.9a76d","84910b03.c53018"]]},{"id":"e75b412f.9a76d","type":"mqtt out","z":"9fd96cff.fbfd68","name":"Set MQTT soil_humidity_threshold","topic":"techexplorations/terrarium/soil_humidity_threshold","qos":"0","retain":"","broker":"ac3817ea.826db8","x":960,"y":460,"wires":[]},{"id":"84910b03.c53018","type":"debug","z":"9fd96cff.fbfd68","name":"Current humidity threshold","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":950,"y":540,"wires":[]},{"id":"9ba13fca.f95448","type":"inject","z":"9fd96cff.fbfd68","name":"Set default threshold","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":"0.1","topic":"","payload":"500","payloadType":"num","x":140,"y":440,"wires":[["576ed7d5.6da35"]]},{"id":"4c9b7e83.a15c88","type":"ui_group","z":"","name":"Manual Pump Control","tab":"7d9d0a00.14e178","order":1,"disp":true,"width":"4","collapse":false},{"id":"ac3817ea.826db8","type":"mqtt-broker","z":"","name":"MQTT client on NodeRed.local","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthRetain":"false","birthPayload":"","closeTopic":"","closeQos":"0","closeRetain":"false","closePayload":"","willTopic":"","willQos":"0","willRetain":"false","willPayload":""},{"id":"582e5eea.e3645","type":"ui_group","z":"","name":"Pump","tab":"7d9d0a00.14e178","order":2,"disp":true,"width":"4","collapse":false},{"id":"c76544b.1f79338","type":"ui_group","z":"","name":"Soil humidity","tab":"7d9d0a00.14e178","order":5,"disp":true,"width":"6","collapse":false},{"id":"8a1febd1.228ed8","type":"ui_group","z":"","name":"Voltages","tab":"7d9d0a00.14e178","order":7,"disp":true,"width":"6","collapse":false},{"id":"90d14cf4.d152d8","type":"gauth","z":""},{"id":"702fced4.928518","type":"ui_group","z":"","name":"Set the pump threshhold","tab":"7d9d0a00.14e178","order":3,"disp":true,"width":"6","collapse":false},{"id":"7d9d0a00.14e178","type":"ui_tab","z":"","name":"Terrarium","icon":"dashboard","disabled":false,"hidden":false}]