-
Notifications
You must be signed in to change notification settings - Fork 7
/
TerrariumController-Flow-v6.json
1 lines (1 loc) · 13.8 KB
/
TerrariumController-Flow-v6.json
1
[{"id":"2a83ac4d.aa1714","type":"tab","label":"Terrarium Controller v6","disabled":false,"info":"This flow receives air tempereture and humidity, displays the values in the dashboard, and logs them in GSheet."},{"id":"ca29e64.e3c6f18","type":"ui_switch","z":"2a83ac4d.aa1714","name":"Manual pump control","label":"Manual pump control","tooltip":"","group":"f55951e9.1bc2b","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":440,"y":380,"wires":[["d3efc6a6.cf23a"]]},{"id":"49521b2d.5d1804","type":"mqtt out","z":"2a83ac4d.aa1714","name":"Publish pump state","topic":"techexplorations/terrarium/pump-control","qos":"0","retain":"","broker":"ac3817ea.826db8","x":1410,"y":380,"wires":[]},{"id":"908299f5.648d68","type":"ui_text","z":"2a83ac4d.aa1714","group":"33590577.3d1f2a","order":3,"width":0,"height":0,"name":"Pump state","label":"Pump state is...","format":"{{msg.payload}}","layout":"row-spread","x":1390,"y":320,"wires":[]},{"id":"45efd339.36f5ac","type":"debug","z":"2a83ac4d.aa1714","name":"Pump state","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1390,"y":280,"wires":[]},{"id":"d8e4d11d.29e708","type":"mqtt in","z":"2a83ac4d.aa1714","name":"Get soil humidity","topic":"techexplorations/terrarium/soil-humidity","qos":"0","datatype":"auto","broker":"ac3817ea.826db8","x":420,"y":220,"wires":[["519bc147.a5773","c921e3f3.5d8ce","4734de5d.99c02"]]},{"id":"519bc147.a5773","type":"ui_gauge","z":"2a83ac4d.aa1714","name":"Soil humidity raw","group":"95487361.ac119","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":750,"y":180,"wires":[]},{"id":"c921e3f3.5d8ce","type":"function","z":"2a83ac4d.aa1714","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,"x":740,"y":260,"wires":[["d3efc6a6.cf23a"]]},{"id":"d3efc6a6.cf23a","type":"rbe","z":"2a83ac4d.aa1714","name":"Update if pump state changed","func":"rbe","gap":"","start":"","inout":"out","property":"payload","x":1060,"y":320,"wires":[["49521b2d.5d1804","45efd339.36f5ac","908299f5.648d68","4ab6772f.fef2d"]]},{"id":"83fd2c59.5debd","type":"mqtt in","z":"2a83ac4d.aa1714","name":"Get MCU voltage","topic":"techexplorations/terrarium/mcu_voltage","qos":"0","datatype":"auto","broker":"ac3817ea.826db8","x":440,"y":540,"wires":[["eb1655cc.ab79d8","e8c0ebc2.8a4aa"]]},{"id":"646232f2.2141ac","type":"mqtt in","z":"2a83ac4d.aa1714","name":"Get motor voltage","topic":"techexplorations/terrarium/motor_voltage","qos":"2","datatype":"auto","broker":"ac3817ea.826db8","x":450,"y":720,"wires":[["7636dbc3.9457bc","9aa6dc18.3f7198"]]},{"id":"eb1655cc.ab79d8","type":"debug","z":"2a83ac4d.aa1714","name":"MCU Voltage","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1010,"y":540,"wires":[]},{"id":"7636dbc3.9457bc","type":"debug","z":"2a83ac4d.aa1714","name":"Motor Voltage","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1020,"y":720,"wires":[]},{"id":"644f6f52.d1fb78","type":"ui_gauge","z":"2a83ac4d.aa1714","name":"MCU Voltage","group":"af67a6b6.aae228","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":1010,"y":600,"wires":[]},{"id":"f9a1129.ce387f","type":"ui_gauge","z":"2a83ac4d.aa1714","name":"Motor Voltage","group":"af67a6b6.aae228","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":1020,"y":780,"wires":[]},{"id":"4734de5d.99c02","type":"debug","z":"2a83ac4d.aa1714","name":"Soil humidity raw","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":760,"y":120,"wires":[]},{"id":"ad6c7353.7ebc78","type":"GSheet","z":"2a83ac4d.aa1714","creds":"90d14cf4.d152d8","method":"append","action":"","sheet":"1fpasYEjoUoExPwptcmerV0R0TpTfTBmzWGNcPcOMTMc","cells":"Sheet1!A2","name":"Log data to GSheet","x":1910,"y":560,"wires":[["e61dc780.078a98"]]},{"id":"3785ab48.5afc74","type":"inject","z":"2a83ac4d.aa1714","name":"Hello!","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":1630,"y":580,"wires":[["ad6c7353.7ebc78"]]},{"id":"b2de72ff.50dc2","type":"function","z":"2a83ac4d.aa1714","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\");\nnew_payload += \",\";\nnew_payload += flow.get(\"air_temperature\");\nnew_payload += \",\";\nnew_payload += flow.get(\"air_humidity\");\n\n\nreturn { payload: new_payload };","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1620,"y":480,"wires":[["ad6c7353.7ebc78","b38efcdc.f034a"]]},{"id":"e8c0ebc2.8a4aa","type":"function","z":"2a83ac4d.aa1714","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":750,"y":600,"wires":[["644f6f52.d1fb78","2bc392cd.5a7a1e"]]},{"id":"9aa6dc18.3f7198","type":"function","z":"2a83ac4d.aa1714","name":"Set Motor Voltage flow variable","func":"flow.set(\"motor_voltage\",msg.payload);\n\nreturn {payload: msg.payload};","outputs":1,"noerr":0,"x":750,"y":780,"wires":[["f9a1129.ce387f"]]},{"id":"4ab6772f.fef2d","type":"trigger","z":"2a83ac4d.aa1714","name":"Update log","op1":"1","op2":"0","op1type":"str","op2type":"str","duration":"-1","extend":false,"units":"min","reset":"","bytopic":"all","outputs":1,"x":1390,"y":480,"wires":[["b2de72ff.50dc2"]]},{"id":"b38efcdc.f034a","type":"debug","z":"2a83ac4d.aa1714","name":"GSheet function","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1900,"y":480,"wires":[]},{"id":"e61dc780.078a98","type":"debug","z":"2a83ac4d.aa1714","name":"GSheet payload","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":2160,"y":560,"wires":[]},{"id":"c2b83714.12f798","type":"ui_numeric","z":"2a83ac4d.aa1714","name":"","label":"Pump threshold","tooltip":"Set a raw humidity value above which the pump is turned on","group":"3a47e0e0.e385b","order":0,"width":"6","height":"1","wrap":false,"passthru":true,"topic":"","format":"{{value}}","min":0,"max":"1023","step":"10","x":420,"y":460,"wires":[["9d40dd19.0eff6"]]},{"id":"9d40dd19.0eff6","type":"function","z":"2a83ac4d.aa1714","name":"Set soil_humidity_threshold","func":"flow.set(\"soil_humidity_threshold\", msg.payload);\nreturn msg;","outputs":1,"noerr":0,"x":740,"y":460,"wires":[["47e7951a.a5c734","885e8b96.3440a"]]},{"id":"47e7951a.a5c734","type":"debug","z":"2a83ac4d.aa1714","name":"set soil_humidity_threshold","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1060,"y":480,"wires":[]},{"id":"885e8b96.3440a","type":"mqtt out","z":"2a83ac4d.aa1714","name":"Set MQTT soil_humidity_threshold","topic":"techexplorations/terrarium/soil_humidity_threshold","qos":"0","retain":"","broker":"ac3817ea.826db8","x":1080,"y":420,"wires":[]},{"id":"ae461fd1.069ae","type":"inject","z":"2a83ac4d.aa1714","name":"Set default threshold","repeat":"","crontab":"","once":true,"onceDelay":"1","topic":"","payload":"500","payloadType":"num","x":160,"y":460,"wires":[["c2b83714.12f798"]],"info":"This trigger will fire automatically 1 second after the flow starts."},{"id":"be7ed3bc.a69b48","type":"mqtt in","z":"2a83ac4d.aa1714","name":"Get air temperature","topic":"techexplorations/terrarium/air-temperature","qos":"0","datatype":"auto","broker":"ac3817ea.826db8","x":470,"y":960,"wires":[["459d7a98.1eea9c","57b33b62.90d054"]]},{"id":"459d7a98.1eea9c","type":"function","z":"2a83ac4d.aa1714","name":"Set air temperature variable","func":"flow.set(\"air_temperature\", msg.payload);\n\n\nreturn {payload: msg.payload};","outputs":1,"noerr":0,"x":790,"y":1000,"wires":[["4a5aa3b1.e011dc"]]},{"id":"57b33b62.90d054","type":"debug","z":"2a83ac4d.aa1714","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":740,"y":940,"wires":[]},{"id":"4a5aa3b1.e011dc","type":"ui_gauge","z":"2a83ac4d.aa1714","name":"Air temperature","group":"76869ed2.cdc838","order":0,"width":"6","height":"6","gtype":"gage","title":"Air temperature","label":"°C","format":"{{value | number:1}}°C","min":0,"max":"50","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":1100,"y":1000,"wires":[]},{"id":"c03b8064.b98e3","type":"mqtt in","z":"2a83ac4d.aa1714","name":"Get air humidity","topic":"techexplorations/terrarium/air-humidity","qos":"0","datatype":"auto","broker":"ac3817ea.826db8","x":460,"y":1140,"wires":[["1dda24e8.0ef0c3","e5e3508.fb8ab3"]]},{"id":"1dda24e8.0ef0c3","type":"function","z":"2a83ac4d.aa1714","name":"Set air humidity variable","func":"flow.set(\"air_humidity\", msg.payload);\n\n\nreturn {payload: msg.payload};","outputs":1,"noerr":0,"initialize":"","finalize":"","x":780,"y":1180,"wires":[["832ab308.c2306"]]},{"id":"e5e3508.fb8ab3","type":"debug","z":"2a83ac4d.aa1714","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":740,"y":1120,"wires":[]},{"id":"832ab308.c2306","type":"ui_gauge","z":"2a83ac4d.aa1714","name":"Air humidity","group":"76869ed2.cdc838","order":0,"width":"6","height":"6","gtype":"gage","title":"Air humidity","label":"%","format":"{{value | number:1}}%","min":0,"max":"100","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":1090,"y":1180,"wires":[]},{"id":"2bc392cd.5a7a1e","type":"switch","z":"2a83ac4d.aa1714","name":"Trigger alert?","property":"payload","propertyType":"msg","rules":[{"t":"lte","v":"3.1","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":1010,"y":660,"wires":[["85c3e6f0.fd9fc8"]]},{"id":"b458b4c0.8efc","type":"delay","z":"2a83ac4d.aa1714","name":"Limit email rate","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"10","rateUnits":"minute","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":1460,"y":660,"wires":[["e761e595.d92548"]]},{"id":"e761e595.d92548","type":"http request","z":"2a83ac4d.aa1714","name":"MCU Voltage alert email","method":"POST","ret":"txt","paytoqs":"ignore","url":"https://maker.ifttt.com/trigger/MCU_Voltage_low/with/key/<your_key>","tls":"","persist":false,"proxy":"","authType":"","x":1690,"y":660,"wires":[["984dd46e.186aa8"]]},{"id":"984dd46e.186aa8","type":"debug","z":"2a83ac4d.aa1714","name":"Sending MCU voltage alert email","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1980,"y":660,"wires":[]},{"id":"85c3e6f0.fd9fc8","type":"function","z":"2a83ac4d.aa1714","name":"Create MCU voltage alert","func":"return {payload: {\"value1\": flow.get(\"mcu_voltage\")}};","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1230,"y":660,"wires":[["b458b4c0.8efc"]]},{"id":"f55951e9.1bc2b","type":"ui_group","z":"","name":"Manual Pump Control","tab":"ab58d2f8.4e174","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":"33590577.3d1f2a","type":"ui_group","z":"","name":"Pump","tab":"ab58d2f8.4e174","order":2,"disp":true,"width":"4","collapse":false},{"id":"95487361.ac119","type":"ui_group","z":"","name":"Soil humidity","tab":"ab58d2f8.4e174","order":4,"disp":true,"width":"6","collapse":false},{"id":"af67a6b6.aae228","type":"ui_group","z":"","name":"Voltages","tab":"ab58d2f8.4e174","order":6,"disp":true,"width":"6","collapse":false},{"id":"90d14cf4.d152d8","type":"gauth","z":""},{"id":"3a47e0e0.e385b","type":"ui_group","z":"","name":"Set the pump threshhold","tab":"ab58d2f8.4e174","order":3,"disp":true,"width":"6","collapse":false},{"id":"76869ed2.cdc838","type":"ui_group","z":"","name":"Air sensor","tab":"ab58d2f8.4e174","order":5,"disp":true,"width":"6","collapse":false},{"id":"ab58d2f8.4e174","type":"ui_tab","z":"","name":"Terrarium","icon":"dashboard","disabled":false,"hidden":false}]