[ { "id": "91d5c13c.e4d55", "type": "tab", "label": "Web request", "disabled": false, "info": "## Flow to retrieve data from website\n**By Anders Lukic**\n\n---\n\nFlow for retrieving data from Met.no API. \n\nRuns every hour to retrieve forecasted rain for the next hour in Copenhagen (using Latitude and \nLongitude).\n\nRemember to change Latitude and \nLongitude in the \"Set header\" node to retrieve date for your desired location.\n\nPlease refer to Met.no API documentation here:\nhttps://api.met.no/weatherapi/" }, { "id": "6d2f10bb.e4881", "type": "inject", "z": "91d5c13c.e4d55", "name": "Run every hour", "props": [ { "p": "payload" } ], "repeat": "3600", "crontab": "", "once": true, "onceDelay": "0.1", "topic": "", "payloadType": "date", "x": 150, "y": 100, "wires": [ [ "27c8b902.cf20a6" ] ] }, { "id": "34f89784.60b3f8", "type": "http request", "z": "91d5c13c.e4d55", "name": "Met.no API request", "method": "GET", "ret": "txt", "paytoqs": "query", "url": "https://api.met.no/weatherapi/locationforecast/2.0/complete", "tls": "", "persist": false, "proxy": "", "authType": "", "x": 510, "y": 100, "wires": [ [ "e4d9037a.38784" ] ] }, { "id": "e4d9037a.38784", "type": "json", "z": "91d5c13c.e4d55", "name": "To Array", "property": "payload", "action": "", "pretty": true, "x": 680, "y": 100, "wires": [ [ "b05960f3.50e2b" ] ] }, { "id": "b05960f3.50e2b", "type": "change", "z": "91d5c13c.e4d55", "name": "Get forecasted rain", "rules": [ { "t": "set", "p": "forecasted_rain_next1hour", "pt": "msg", "to": "payload.properties.timeseries[0].data.next_1_hours.details.precipitation_amount", "tot": "msg" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 850, "y": 100, "wires": [ [ "fbbcaa31.fe3408", "b080bd18.c9d93", "24d3f959.8b4f36" ] ] }, { "id": "c793daa6.6a7ea8", "type": "comment", "z": "91d5c13c.e4d55", "name": "Get forecasted rain for next hour", "info": "", "x": 170, "y": 40, "wires": [] }, { "id": "fbbcaa31.fe3408", "type": "debug", "z": "91d5c13c.e4d55", "name": "Full data", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "payload", "targetType": "msg", "statusVal": "", "statusType": "auto", "x": 1020, "y": 40, "wires": [] }, { "id": "27c8b902.cf20a6", "type": "function", "z": "91d5c13c.e4d55", "name": "Set header", "func": "msg.headers = {\n \"Content-Type\": \"application/json\",\n \"Accept\": \"text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9\",\n \"User-Agent\": \"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.66 Safari/537.36\"\n}\nmsg.payload = { \"lat\": \"55.719437\", \"lon\": \"13.197304\"}\nreturn msg;", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "x": 330, "y": 100, "wires": [ [ "34f89784.60b3f8" ] ] }, { "id": "b080bd18.c9d93", "type": "debug", "z": "91d5c13c.e4d55", "name": "Forecasted rain", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "forecasted_rain_next1hour", "targetType": "msg", "statusVal": "", "statusType": "auto", "x": 1040, "y": 160, "wires": [] }, { "id": "24d3f959.8b4f36", "type": "ha-entity", "z": "91d5c13c.e4d55", "name": "forecasted_rain_next1hour", "server": "3bebce79.1e0962", "version": 1, "debugenabled": false, "outputs": 1, "entityType": "sensor", "config": [ { "property": "name", "value": "forecasted_rain_next1hour" }, { "property": "device_class", "value": "" }, { "property": "icon", "value": "mdi:weather-rainy" }, { "property": "unit_of_measurement", "value": "mm" } ], "state": "forecasted_rain_next1hour", "stateType": "msg", "attributes": [], "resend": true, "outputLocation": "", "outputLocationType": "none", "inputOverride": "allow", "x": 1080, "y": 100, "wires": [ [] ] }, { "id": "3bebce79.1e0962", "type": "server", "name": "Home Assistant", "addon": true } ]