[{"id":"90487385.d672c","type":"mqtt in","z":"b65b2107.5eee2","name":"","topic":"node26/reading/#","qos":"2","broker":"a86115be.40797","x":130,"y":420,"wires":[["8e20bf67.3009d8"]]},{"id":"b7644050.fe88f8","type":"mqtt out","z":"b65b2107.5eee2","name":"","topic":"node26/cmd","qos":"","retain":"","broker":"a86115be.40797","x":470,"y":160,"wires":[]},{"id":"4a3bf8da.129df8","type":"inject","z":"b65b2107.5eee2","name":"","topic":"","payload":"event,activate","payloadType":"str","repeat":"900","crontab":"","once":true,"onceDelay":0.1,"x":140,"y":160,"wires":[["b7644050.fe88f8","d0f1da76.259378","71b3be93.0519f8"]]},{"id":"8e20bf67.3009d8","type":"json","z":"b65b2107.5eee2","name":"","property":"payload","action":"","pretty":false,"x":310,"y":420,"wires":[["6f2bf8b6.ceb368"]]},{"id":"21c0d0c7.7039d","type":"mqtt in","z":"b65b2107.5eee2","name":"","topic":"node26/status/#","qos":"2","broker":"a86115be.40797","x":120,"y":340,"wires":[["98e3758b.824498"]]},{"id":"58d969.107eb698","type":"ui_gauge","z":"b65b2107.5eee2","name":"Basil gauge","group":"7ff60025.11e29","order":2,"width":"4","height":"3","gtype":"gage","title":"PAW","label":"","format":"{{value}}","min":0,"max":10,"colors":["#ff8000","#008000","#400040"],"seg1":"3","seg2":"7","x":1130,"y":120,"wires":[]},{"id":"c8f93c80.81c9","type":"ui_text","z":"b65b2107.5eee2","group":"7ff60025.11e29","order":3,"width":"7","height":"1","name":"Basil condition","label":"","format":" {{msg.payload}} ","layout":"row-center","x":1140,"y":160,"wires":[]},{"id":"85112efe.5a2d18","type":"ui_text","z":"b65b2107.5eee2","group":"7ff60025.11e29","order":4,"width":"7","height":"1","name":"Basil action","label":"","format":" {{msg.payload}} ","layout":"row-center","x":1130,"y":220,"wires":[]},{"id":"7a70b2ff.03bb2c","type":"function","z":"b65b2107.5eee2","name":"Condition","func":"var msg_condition = {};\nvar msg_action = {};\nvar msg_time_date = {};\nvar msg_color = {};\n\nvar status = flow.get(\"basil_watchdog\");\n if (status == \"expired\")\n {\n msg.payload = 0;\n msg_condition = \"The soil sensor appears to be OFFLINE\";\n msg_action = \"Please check the battery and connections\";\n msg_color = \"red\";\n }\n else {\n\nif (msg.payload < 3) \n {\n msg_condition = \"The soil in my plant pot is very DRY\";\n msg_action = \"Please water me URGENTLY!\";\n msg_color = \"red\";\n } \nelse if (msg.payload < 4) \n {\n msg_condition = \"The soil in my plant pot is getting DRY\";\n msg_action = \"Please water me!\";\n msg_color = \"brown\";\n } \n \nelse if (msg.payload < 8)\n {\n msg_condition =\"The soil in my plant pot is still MOIST\";\n msg_action = \"You can sit back and relax... I'm OK\"\n msg_color = \"green\";\n }\nelse \n {\n msg_condition =\"The soil in my plant pot is WET\";\n msg_action = \"Please, please DO NOT water me\";\n msg_color = \"blue\";\n }\n}\nvar now = new Date();\nvar yyyy = now.getFullYear();\nvar mm = now.getMonth() < 9 ? \"0\" + (now.getMonth() + 1) : (now.getMonth() + 1); // getMonth() is zero-based\nvar dd = now.getDate() < 10 ? \"0\" + now.getDate() : now.getDate();\nvar hh = now.getHours() < 10 ? \"0\" + now.getHours() : now.getHours();\nvar mmm = now.getMinutes() < 10 ? \"0\" + now.getMinutes() : now.getMinutes();\nvar ss = now.getSeconds() < 10 ? \"0\" + now.getSeconds() : now.getSeconds();\nnode.status({fill:\"blue\",shape:\"ring\",text:\"Last update was on: \"+dd + \"/\" + mm + \"/\" + yyyy + \" at \" + hh + \":\" + mmm + \" hrs\"}); \nmsg_time_date =\"The last update was on \" + dd + \"/\" + mm + \"/\" + yyyy + \" at \" + hh + \":\" + mmm + \" hrs\";\n\n\nreturn [ [{payload:msg_condition, color:msg_color}], [{payload:msg_action, color:msg_color}], [{payload:msg_time_date, color:msg_color}] ];\n","outputs":3,"noerr":0,"x":960,"y":220,"wires":[["c8f93c80.81c9"],["85112efe.5a2d18"],["317b5bc2.412ec4"]]},{"id":"74457573.905834","type":"ui_template","z":"b65b2107.5eee2","group":"7ff60025.11e29","name":"Basil photo","order":1,"width":"3","height":"3","format":"
\n
\n
","storeOutMessages":true,"fwdInMessages":true,"templateScope":"local","x":1130,"y":80,"wires":[[]]},{"id":"2648d4a.06fd5ac","type":"function","z":"b65b2107.5eee2","name":"","func":"var status = flow.get(\"basil_watchdog\");\nif (status == \"expired\")\n{\n msg.payload = 0;\n}\nelse\n{\n var reading = flow.get(\"basil_reading\");\n msg.payload = reading;\n}\n\nreturn msg;","outputs":1,"noerr":0,"x":790,"y":120,"wires":[["7a70b2ff.03bb2c","58d969.107eb698","1fcc8999.8de89e","a69ae8f4.05db38"]]},{"id":"a69ae8f4.05db38","type":"function","z":"b65b2107.5eee2","name":"","func":"if (msg.payload < 3) \n {\n msg.payload=\"Basil plant needs water. PAW=\"+msg.payload;\n return msg;\n } \n","outputs":1,"noerr":0,"x":950,"y":340,"wires":[[]]},{"id":"317b5bc2.412ec4","type":"ui_text","z":"b65b2107.5eee2","group":"7ff60025.11e29","order":4,"width":"7","height":"1","name":"Basil time-date","label":"","format":" {{msg.payload}} ","layout":"row-center","x":1140,"y":280,"wires":[]},{"id":"1fcc8999.8de89e","type":"debug","z":"b65b2107.5eee2","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":1130,"y":40,"wires":[]},{"id":"752ab3c3.d4571c","type":"inject","z":"b65b2107.5eee2","name":"","topic":"","payload":"2","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":750,"y":260,"wires":[["a69ae8f4.05db38"]]},{"id":"d0f1da76.259378","type":"delay","z":"b65b2107.5eee2","name":"","pauseType":"delay","timeout":"10","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":460,"y":120,"wires":[["2648d4a.06fd5ac"]]},{"id":"71b3be93.0519f8","type":"function","z":"b65b2107.5eee2","name":"","func":"flow.set(\"basil_watchdog\",\"expired\");\nflow.set(\"basil_reading\",0);\nreturn msg;","outputs":0,"noerr":0,"x":450,"y":220,"wires":[]},{"id":"87f60bd8.a27ce8","type":"function","z":"b65b2107.5eee2","name":"","func":"flow.set(\"basil_watchdog\",\"reset\");\nreturn msg;","outputs":1,"noerr":0,"x":450,"y":340,"wires":[["24a27c9e.4d1dd4"]]},{"id":"6f2bf8b6.ceb368","type":"function","z":"b65b2107.5eee2","name":"","func":"flow.set(\"basil_reading\",msg.payload.paw);\nmsg.payload = msg.payload.paw;\nreturn msg;","outputs":1,"noerr":0,"x":450,"y":420,"wires":[["badde9f9.62e66"]]},{"id":"badde9f9.62e66","type":"debug","z":"b65b2107.5eee2","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":610,"y":420,"wires":[]},{"id":"24a27c9e.4d1dd4","type":"debug","z":"b65b2107.5eee2","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":610,"y":340,"wires":[]},{"id":"98e3758b.824498","type":"json","z":"b65b2107.5eee2","name":"","property":"payload","action":"","pretty":false,"x":310,"y":340,"wires":[["87f60bd8.a27ce8"]]},{"id":"f421128f.0c7dd","type":"comment","z":"b65b2107.5eee2","name":"Send to Telegram","info":"","x":1110,"y":340,"wires":[]},{"id":"a86115be.40797","type":"mqtt-broker","z":"","name":"","broker":"192.168.1.142","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"7ff60025.11e29","type":"ui_group","z":"","name":"Basil plant","tab":"d69f5d37.5f45c8","order":1,"disp":true,"width":"14","collapse":false},{"id":"d69f5d37.5f45c8","type":"ui_tab","z":"","name":"SMART Home - plant monitor","icon":"dashboard","order":3}]