Air/ground frost alerts via

The purpose of this flow is to give a early warning of overnight frosts, which for me as a keen gardener allows me to protect tender plants and prevent frost damage, but also to set my alarm clock 15 minutes earlier to clear my windscreen in the morning!

It uses a Met Office weather model, which determines the likelyhood of frost by accessing windspeed, air temperature & cloud cover from for the forthcoming evening, and following analysis fires off a 'push' message via pushbullet at midday if frost is likely (could equally be Twitter or whatever).

A free developers API key is required from to enable access to the XML data feed, and which is inserted where shown in the 'Get forecast' inject node.

Out of the box, that is the only change you will need to make to make this function, although you will probably also wish to change the weather station reference to one nearest to your location (again in the 'Get forecast' node) as it is currently set to 'IFINNING3' which is Doncaster Airport, UK. There are lots to choose from worldwide via, but you need to select one which provides all three data items (some of the smaller stations are limited).

[{"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":"","baseurl":"","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"]]}]

Flow Info

created 4 years, 7 months ago

Node Types

  • comment (x1)
  • debug (x1)
  • function (x1)
  • inject (x1)
  • mqtt in (x1)
  • mqtt out (x1)
  • mqtt-broker (x1)


  • Weather
  • Frost
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option