|
[{"id":"ba386057.845d3","type":"mqtt-broker","broker":"localhost","port":"1883"},{"id":"7b00863b.84ff78","type":"inject","name":"Get forecast","topic":"","payload":"developers-API-key/forecast/q/pws:IFINNING3.xml","payloadType":"string","repeat":"","crontab":"00 12 * * *","once":false,"x":101,"y":310,"z":"3f1992f2.c0e66e","wires":[["7e9298f7.816d68"]]},{"id":"7e9298f7.816d68","type":"httpget","name":"Wunderground.com","baseurl":"http://api.wunderground.com/api/","append":"","x":270,"y":310,"z":"3f1992f2.c0e66e","wires":[["fa439942.05bc68"]]},{"id":"47cdb34a.b8324c","type":"comment","name":"Frost Warnings","info":"","x":79,"y":267,"z":"3f1992f2.c0e66e","wires":[]},{"id":"fa439942.05bc68","type":"mqtt out","name":"Weather Forecast","topic":"weather/forecast","broker":"ba386057.845d3","x":470,"y":310,"z":"3f1992f2.c0e66e","wires":[]},{"id":"ecc47b8e.133b88","type":"mqtt in","name":"Weather Forecast","topic":"weather/forecast","broker":"ba386057.845d3","x":95,"y":355,"z":"3f1992f2.c0e66e","wires":[["91425de6.6ebda"]]},{"id":"91425de6.6ebda","type":"xml2js","useEyes":false,"name":"","x":259.1111145019531,"y":355.11114501953125,"z":"3f1992f2.c0e66e","wires":[["cf5b6cc1.30a49"]]},{"id":"9c1f8db4.63e07","type":"pushbullet","title":"Frost Warning!","name":"","x":626,"y":375,"z":"3f1992f2.c0e66e","wires":[]},{"id":"ada108d8.525ef8","type":"debug","name":"","active":true,"complete":false,"x":624,"y":336,"z":"3f1992f2.c0e66e","wires":[]},{"id":"cf5b6cc1.30a49","type":"function","name":"Temp Calcs","func":"var weatherDATA = msg.payload.response.forecast[0].simpleforecast[0].forecastdays[0].forecastday[0];\nvar lowC = weatherDATA.low[0].celsius[0];\nvar wind = weatherDATA.avewind[0].mph;\nvar cloud = weatherDATA.icon[0];\nvar kvalue = 0;\n\n//This section calculates the kvalue\nif (wind>10) {\n\tif ((cloud == \"clear\")||(cloud == \"partlycloudy\")) {\n\tkvalue = 3;\n\t}\n\t\telse {\n\t\tkvalue = 2;\n\t\t}\n}\n\nelse if ((wind>5) && (wind<=10)) {\n\tif ((cloud == \"clear\")||(cloud == \"partlycloudy\")) {\n\tkvalue = 4;\n\t}\n\t\telse {\n\t\tkvalue = 2;\n\t\t}\n}\n\nelse {\n\tif ((cloud == \"clear\")||(cloud == \"partlycloudy\")) {\n\tkvalue = 5;\n\t}\n\t\telse {\n\t\tkvalue = 3;\n\t\t}\n}\n\n//Deduct the kvalue from lowtemp to get grasstemp\nvar grasstemp = ((lowC) - (kvalue));\n\n//Check if Grass Temp or Air Temp is zero C or below\nif ((lowC <= 0)||(grasstemp <= 0)) {\n//If so, then send out an alert\nmsg.payload= ((\"Air temp forecast \") + (lowC) + (\"C, Grass temp forecast \" ) + (grasstemp) + (\"C, predicted tonight.\")) ;\nreturn [msg];\n}","outputs":1,"x":424,"y":355,"z":"3f1992f2.c0e66e","wires":[["ada108d8.525ef8","9c1f8db4.63e07"]]}] |