UK (Met Office) Pollen forecast

Simple flow to grab the 5 day pollen forcast from the UK Met Office web site, and display on dashboard.

image

NOTE:

  1. This flow requires node-red-contrib-string

  2. Visit the web site and select your region, note the region code in the address and modify the inject node to match.

https://www.metoffice.gov.uk/weather/warnings-and-advice/seasonal-advice/pollen-forecast

[{"id":"0de486ed3e6db083","type":"group","z":"2312d8b035d206a2","name":"Pollen","style":{"fill":"#bfdbef","label":true,"color":"#000000"},"nodes":["55e8b092dbf10e2f","15f6234cf8d2d707","5462f38b10d587a0","1061b0626d11fb31","852efe4a17e380c4","dd866f3884b9b15d","f5a05203829466e3","57618df4d726f5dc","8d2aa2302b819e13","e4f22f10fd014189","1132dccd281d62fd","937db3656b1fc54b","1e2b54a9258a295f","5cdac96d7a189e4d"],"x":214,"y":259,"w":1392,"h":142},{"id":"55e8b092dbf10e2f","type":"http request","z":"2312d8b035d206a2","g":"0de486ed3e6db083","name":"http","method":"GET","ret":"txt","paytoqs":"ignore","url":"https://www.metoffice.gov.uk/weather/warnings-and-advice/seasonal-advice/pollen-forecast#","tls":"","persist":false,"proxy":"","authType":"","senderr":false,"x":670,"y":340,"wires":[["1e2b54a9258a295f"]]},{"id":"15f6234cf8d2d707","type":"inject","z":"2312d8b035d206a2","g":"0de486ed3e6db083","name":"region code","props":[{"p":"payload"}],"repeat":"3600","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"yh","payloadType":"str","x":340,"y":340,"wires":[["937db3656b1fc54b"]]},{"id":"5462f38b10d587a0","type":"html","z":"2312d8b035d206a2","g":"0de486ed3e6db083","name":"Pollen Type","property":"payload","outproperty":"payload","tag":"","ret":"text","as":"single","x":970,"y":320,"wires":[["8d2aa2302b819e13"]]},{"id":"1061b0626d11fb31","type":"html","z":"2312d8b035d206a2","g":"0de486ed3e6db083","name":"Pollen Level","property":"payload","outproperty":"payload","tag":"","ret":"text","as":"multi","x":970,"y":360,"wires":[["dd866f3884b9b15d"]]},{"id":"852efe4a17e380c4","type":"ui_template","z":"2312d8b035d206a2","g":"0de486ed3e6db083","group":"514b19cf7fb14ce6","name":"pollen","order":1,"width":6,"height":2,"format":"<style>\n    #pollen_table {\n        table-layout: fixed;\n        text-align: center;\n    }\n\n    .vhigh {\n        background-color: #d72921;\n        color: white !important;\n    }\n\n    .high {\n        background-color: #ff950c;\n    }\n\n    .med {\n        background-color: #f8e71c;\n    }\n\n    .low {\n        background-color: #71b466;\n    }\n\n    #pollen {\n        display: inline-block;\n        color: black;\n        border: 2px solid black;\n        border-radius: 50%;\n        line-height: 2.4em;\n        font-weight: 700;\n        height: 40px;\n        width: 40px;\n    }\n</style>\n\n<table id=\"pollen_table\">\n\n    <thead>\n\n        <tr>\n            <th ng-repeat=\"col in msg.payload track by $index\"> {{col.day}}</th>\n        </tr>\n\n    </thead>\n\n    <tbody>\n\n        <tr>\n            <td ng-repeat=\"item in msg.payload track by $index\">\n                <span id=\"pollen\"  ng-class=\"{vhigh: item.level == 'VH',high: item.level == 'H',med: item.level == 'M',low: item.level == 'L',}\">  {{item.level}} </span>\n            </td>\n        </tr>\n\n    </tbody>\n\n</table>","storeOutMessages":false,"fwdInMessages":false,"resendOnRefresh":true,"templateScope":"local","className":"","x":1530,"y":360,"wires":[[]],"info":"<style>\r\n    table {\r\n\r\n        justify-content: center;\r\n        align-items: center;\r\n        color: #FFF;\r\n        text-transform: uppercase;\r\n    }\r\n\r\n    .high {\r\n        background-color: #ff950c;\r\n    }\r\n\r\n    .med {\r\n        background-color: #f8e71c;\r\n    }\r\n\r\n    .low {\r\n        background-color: #71b466;\r\n    }\r\n</style>\r\n\r\n<table>\r\n    <tr>\r\n        <td>\r\n            <div ng-repeat=\"item in msg.payload\">\r\n                {{item.day}}\r\n                <span ng-class=\"{high: item.level == 'H',med: item.level == 'M',low: item.level == 'L',}\"> {{item.level}} </span>\r\n            </div>\r\n\r\n        </td>\r\n\r\n    </tr>\r\n</table>\r\n\r\n\r\n\r\nheight: 52px;\r\n        width: 20%;\r\n        vertical-align: middle;\r\n        font-size: 28px;"},{"id":"dd866f3884b9b15d","type":"string","z":"2312d8b035d206a2","g":"0de486ed3e6db083","name":"space","methods":[{"name":"collapseWhitespace","params":[]},{"name":"stripPunctuation","params":[]}],"prop":"payload","propout":"payload","object":"msg","objectout":"msg","x":1110,"y":360,"wires":[["5cdac96d7a189e4d"]]},{"id":"f5a05203829466e3","type":"function","z":"2312d8b035d206a2","g":"0de486ed3e6db083","name":"Build payload","func":"let pollen = []\nconst dayNames = [\"Sun\", \"Mon\", \"Tue\", \"Wed\", \"Thu\", \"Fri\", \"Sat\"];\n\nfor (let index = 0; index < msg.payload.length; index++) {\n    pollen[index] = { day: (dayNames[(new Date().getDay() + index) % 7]), level: msg.payload[index] }\n}\n\nmsg.payload = pollen\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1380,"y":360,"wires":[["852efe4a17e380c4"]]},{"id":"57618df4d726f5dc","type":"ui_text","z":"2312d8b035d206a2","g":"0de486ed3e6db083","group":"514b19cf7fb14ce6","order":2,"width":6,"height":2,"name":"","label":"","format":"{{msg.payload}}","layout":"row-spread","className":"","x":1530,"y":320,"wires":[]},{"id":"8d2aa2302b819e13","type":"string","z":"2312d8b035d206a2","g":"0de486ed3e6db083","name":"space","methods":[{"name":"collapseWhitespace","params":[]}],"prop":"payload","propout":"payload","object":"msg","objectout":"msg","x":1110,"y":320,"wires":[["e4f22f10fd014189"]]},{"id":"e4f22f10fd014189","type":"switch","z":"2312d8b035d206a2","g":"0de486ed3e6db083","name":"","property":"payload.length","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"num"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":1230,"y":320,"wires":[["1132dccd281d62fd"],["57618df4d726f5dc"]]},{"id":"1132dccd281d62fd","type":"change","z":"2312d8b035d206a2","g":"0de486ed3e6db083","name":"blank","rules":[{"t":"set","p":"payload","pt":"msg","to":"","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1370,"y":300,"wires":[["57618df4d726f5dc"]]},{"id":"937db3656b1fc54b","type":"change","z":"2312d8b035d206a2","g":"0de486ed3e6db083","name":"","rules":[{"t":"set","p":"region","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":520,"y":340,"wires":[["55e8b092dbf10e2f"]]},{"id":"1e2b54a9258a295f","type":"function","z":"2312d8b035d206a2","g":"0de486ed3e6db083","name":"add region","func":"let region = flow.get(\"region\")\n\nlet msg1 = {\n    \"payload\": msg.payload,\n    \"select\": \"#\" + region + \"-paras\"\n}\n\nlet msg2 = {\n    \"payload\": msg.payload,\n    \"select\": \"#\" + region + \" td\"\n}\n\nreturn [msg1, msg2];","outputs":2,"noerr":0,"initialize":"","finalize":"","libs":[],"x":810,"y":340,"wires":[["5462f38b10d587a0"],["1061b0626d11fb31"]]},{"id":"5cdac96d7a189e4d","type":"join","z":"2312d8b035d206a2","g":"0de486ed3e6db083","name":"","mode":"custom","build":"array","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":1230,"y":360,"wires":[["f5a05203829466e3"]]},{"id":"514b19cf7fb14ce6","type":"ui_group","name":"Pollen","tab":"575545d5645126b6","order":3,"disp":true,"width":"6","collapse":false,"className":""},{"id":"575545d5645126b6","type":"ui_tab","name":"Weather","icon":"dashboard","disabled":false,"hidden":false}]

Flow Info

Created 2 years, 9 months ago
Updated 2 years, 8 months ago
Rating: not yet rated

Owner

Actions

Rate:

Node Types

Core
  • change (x2)
  • function (x2)
  • html (x2)
  • http request (x1)
  • inject (x1)
  • join (x1)
  • switch (x1)
Other

Tags

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