Hello,
I'm building a weather dashboard with OpenWeatherMap API. Users can select if they want to give input as country/ city or latitude/ longitude.
By default, weather updates at 30-second intervals (requirement of the project) but, the user can set the update interval to anytime he wants (under the "Settings" tab).
Dashboard updates at 30-second intervals. But, I cannot figure out how to connect the user-defined update interval to this flow.
Can someone please help me?
[
{
"id": "def84d61.37252",
"type": "ui_text_input",
"z": "58e87bcc.806654",
"name": "city",
"label": "City",
"tooltip": "Enter the city name",
"group": "4f271a00.762388",
"order": 2,
"width": 0,
"height": 0,
"passthru": true,
"mode": "text",
"delay": 300,
"topic": "",
"sendOnBlur": true,
"className": "",
"topicType": "str",
"x": 130,
"y": 80,
"wires": [
[
"cdc7ca82.5179f8"
]
]
},
{
"id": "52306173.91c4e",
"type": "ui_text_input",
"z": "58e87bcc.806654",
"name": "country",
"label": "Country",
"tooltip": "Enter the country name",
"group": "4f271a00.762388",
"order": 1,
"width": 0,
"height": 0,
"passthru": true,
"mode": "text",
"delay": 300,
"topic": "",
"sendOnBlur": true,
"className": "",
"topicType": "str",
"x": 140,
"y": 40,
"wires": [
[
"43d8938.909c86c"
]
]
},
{
"id": "cdc7ca82.5179f8",
"type": "function",
"z": "58e87bcc.806654",
"name": "",
"func": "flow.set(\"city\", msg.payload);\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 320,
"y": 80,
"wires": [
[]
]
},
{
"id": "43d8938.909c86c",
"type": "function",
"z": "58e87bcc.806654",
"name": "",
"func": "flow.set(\"country\", msg.payload);\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 320,
"y": 40,
"wires": [
[]
]
},
{
"id": "82922ca9.078af",
"type": "ui_text_input",
"z": "58e87bcc.806654",
"name": "lat",
"label": "Latitudes",
"tooltip": "Enter the country name",
"group": "212c669d.fce9ba",
"order": 1,
"width": 0,
"height": 0,
"passthru": true,
"mode": "text",
"delay": 300,
"topic": "",
"x": 130,
"y": 140,
"wires": [
[
"d4a591df.5b009"
]
]
},
{
"id": "d4a591df.5b009",
"type": "function",
"z": "58e87bcc.806654",
"name": "",
"func": "flow.set(\"lat\", msg.payload);\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 320,
"y": 140,
"wires": [
[]
]
},
{
"id": "8e84afb1.d7ef2",
"type": "ui_text_input",
"z": "58e87bcc.806654",
"name": "lon",
"label": "Longitudes",
"tooltip": "Enter the city name",
"group": "212c669d.fce9ba",
"order": 2,
"width": 0,
"height": 0,
"passthru": true,
"mode": "text",
"delay": 300,
"topic": "",
"x": 130,
"y": 180,
"wires": [
[
"dd853b0f.6acb68"
]
]
},
{
"id": "dd853b0f.6acb68",
"type": "function",
"z": "58e87bcc.806654",
"name": "",
"func": "flow.set(\"lon\", msg.payload);\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"x": 340,
"y": 180,
"wires": [
[]
]
},
{
"id": "76ea833b.a1b88c",
"type": "ui_dropdown",
"z": "58e87bcc.806654",
"name": "",
"label": "",
"tooltip": "",
"place": "Select option",
"group": "ecd479fa.1d4d48",
"order": 2,
"width": 0,
"height": 0,
"passthru": true,
"multiple": false,
"options": [
{
"label": "City/Country",
"value": 0,
"type": "num"
},
{
"label": "Coordinates",
"value": 1,
"type": "num"
}
],
"payload": "",
"topic": "",
"topicType": "str",
"className": "",
"x": 140,
"y": 240,
"wires": [
[
"6f773aa1.fc53f4"
]
]
},
{
"id": "6f773aa1.fc53f4",
"type": "function",
"z": "58e87bcc.806654",
"name": "",
"func": "flow.set(\"val\", msg.payload);\nif(msg.payload == 0){\n msg.payload = {\"group\":{\"hide\":[\"Weather_Input_latitude/longitude\"],\"show\":[\"Weather_Input_city/country\"]}};\n}else{\n msg.payload = {\"group\":{\"hide\":[\"Weather_Input_city/country\"],\"show\":[\"Weather_Input_latitude/longitude\"]}};\n}\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 320,
"y": 240,
"wires": [
[
"e7e4025b.cdb6",
"b4a00bb1.c6ce98"
]
]
},
{
"id": "b4a00bb1.c6ce98",
"type": "ui_ui_control",
"z": "58e87bcc.806654",
"name": "",
"events": "all",
"x": 500,
"y": 200,
"wires": [
[]
]
},
{
"id": "e7e4025b.cdb6",
"type": "ui_text",
"z": "58e87bcc.806654",
"group": "ecd479fa.1d4d48",
"order": 1,
"width": 0,
"height": 0,
"name": "",
"label": "Select whether you enter coordinates as city/country or coordinates.",
"format": "",
"layout": "row-left",
"className": "",
"x": 680,
"y": 240,
"wires": []
},
{
"id": "d857e292.d9feb",
"type": "ui_numeric",
"z": "58e87bcc.806654",
"name": "",
"label": "Update Interval (s)",
"tooltip": "",
"group": "ecd479fa.1d4d48",
"order": 6,
"width": "6",
"height": "1",
"wrap": false,
"passthru": true,
"topic": "topic",
"topicType": "msg",
"format": "{{payload}}",
"min": "5",
"max": "50",
"step": "2",
"className": "",
"x": 170,
"y": 540,
"wires": [
[
"2aebe2adc587c941"
]
]
},
{
"id": "2aebe2adc587c941",
"type": "function",
"z": "58e87bcc.806654",
"name": "Delay",
"func": "if (msg.payload) {\n flow.set(\"delay\", msg.payload)\n \n return {\n delay: msg.payload\n }\n} ",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 350,
"y": 540,
"wires": [
[
"96b335f44ddebf4e"
]
]
},
{
"id": "b9a073da.96b51",
"type": "ui_button",
"z": "58e87bcc.806654",
"name": "",
"group": "4f271a00.762388",
"order": 0,
"width": 0,
"height": 0,
"passthru": false,
"label": "Submit",
"tooltip": "",
"color": "",
"bgcolor": "",
"className": "",
"icon": "",
"payload": "true",
"payloadType": "bool",
"topic": "",
"topicType": "str",
"x": 140,
"y": 660,
"wires": [
[
"3bff49e4.cede06"
]
]
},
{
"id": "3bff49e4.cede06",
"type": "function",
"z": "58e87bcc.806654",
"name": "",
"func": "if(msg.payload){\n return{\n location : {\n country : flow.get(\"country\"),\n city : flow.get(\"city\")\n }\n }\n}",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 300,
"y": 660,
"wires": [
[
"51c93547576fdd44",
"3e4f6f3df436778b"
]
]
},
{
"id": "51c93547576fdd44",
"type": "trigger",
"z": "58e87bcc.806654",
"name": "Trigger",
"op1": "stop",
"op2": "",
"op1type": "str",
"op2type": "payl",
"duration": "50",
"extend": false,
"overrideDelay": false,
"units": "ms",
"reset": "",
"bytopic": "all",
"topic": "topic",
"outputs": 1,
"x": 80,
"y": 760,
"wires": [
[
"f5ac289be727292e"
]
]
},
{
"id": "f5ac289be727292e",
"type": "trigger",
"z": "58e87bcc.806654",
"name": "Resend 30s",
"op1": "",
"op2": "0",
"op1type": "pay",
"op2type": "str",
"duration": "-30",
"extend": false,
"overrideDelay": true,
"units": "s",
"reset": "stop",
"bytopic": "all",
"topic": "topic",
"outputs": 1,
"x": 250,
"y": 760,
"wires": [
[
"f40fd0836cba2058",
"fa7a2c62c4f39386"
]
]
},
{
"id": "880489b6.8264e8",
"type": "ui_button",
"z": "58e87bcc.806654",
"name": "",
"group": "212c669d.fce9ba",
"order": 4,
"width": "6",
"height": "1",
"passthru": false,
"label": "Submit",
"tooltip": "",
"color": "",
"bgcolor": "",
"icon": "",
"payload": "true",
"payloadType": "bool",
"topic": "",
"x": 140,
"y": 860,
"wires": [
[
"e4190363.4d1d7"
]
]
},
{
"id": "e4190363.4d1d7",
"type": "function",
"z": "58e87bcc.806654",
"name": "",
"func": "if(msg.payload){\n return{\n location : {\n lat : flow.get(\"lat\"),\n lon : flow.get(\"lon\")\n }\n }\n}\n",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 300,
"y": 860,
"wires": [
[
"3e4f6f3df436778b",
"51c93547576fdd44"
]
]
},
{
"id": "f40fd0836cba2058",
"type": "function",
"z": "58e87bcc.806654",
"name": "Input",
"func": "let v;\n\nlet k = msg.location\n\nif (k.hasOwnProperty('country')) {\n v = \"1\"\n} else if (k.hasOwnProperty('lat')) {\n v = \"2\"\n} else {\n v = \"3\"\n}\n\nflow.set(\"type\", v)\n\nreturn {\n v: v,\n location: k\n}",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 410,
"y": 760,
"wires": [
[
"6d9ca8be7f39cbad"
]
]
},
{
"id": "6d9ca8be7f39cbad",
"type": "switch",
"z": "58e87bcc.806654",
"name": "",
"property": "v",
"propertyType": "msg",
"rules": [
{
"t": "eq",
"v": "1",
"vt": "str"
},
{
"t": "eq",
"v": "2",
"vt": "str"
}
],
"checkall": "true",
"repair": false,
"outputs": 2,
"x": 450,
"y": 700,
"wires": [
[
"f185e542.8805d8"
],
[
"d67f1526.df33d8"
]
]
},
{
"id": "f185e542.8805d8",
"type": "openweathermap",
"z": "58e87bcc.806654",
"name": "",
"wtype": "current",
"lon": "",
"lat": "",
"city": "",
"country": "",
"language": "en",
"x": 650,
"y": 620,
"wires": [
[
"b40b4212.24744",
"2a93c6c.1de5b3a",
"f1e080e1.05dd7",
"49e145d4.08f73c",
"185166fe.2e4809",
"b9e23bd0.ea7e08",
"901e6ec.4740a9",
"805abd3a.ac498",
"dd02eca8.d6e4f",
"11219d2e62e0dbf6",
"9446411facaa23a2",
"8625b310c621b660",
"ce1897ce20bb7c44"
]
]
},
{
"id": "d67f1526.df33d8",
"type": "openweathermap",
"z": "58e87bcc.806654",
"name": "",
"wtype": "current",
"lon": "",
"lat": "",
"city": "",
"country": "",
"language": "en",
"x": 650,
"y": 900,
"wires": [
[
"49e145d4.08f73c",
"11219d2e62e0dbf6",
"b40b4212.24744",
"9446411facaa23a2",
"2a93c6c.1de5b3a",
"f1e080e1.05dd7",
"901e6ec.4740a9",
"805abd3a.ac498",
"dd02eca8.d6e4f",
"185166fe.2e4809",
"b9e23bd0.ea7e08",
"8625b310c621b660",
"2e167ba0884b26be"
]
]
},
{
"id": "b40b4212.24744",
"type": "ui_gauge",
"z": "58e87bcc.806654",
"name": "Humidity",
"group": "dc265c9b.5850a",
"order": 4,
"width": "6",
"height": "4",
"gtype": "gage",
"title": "",
"label": "%",
"format": "{{msg.payload.humidity}}",
"min": "0",
"max": "100",
"colors": [
"#00b500",
"#e6e600",
"#ca3838"
],
"seg1": "",
"seg2": "",
"className": "",
"x": 960,
"y": 580,
"wires": []
},
{
"id": "4f271a00.762388",
"type": "ui_group",
"name": "Input city/country",
"tab": "152c952d.14cc0b",
"order": 1,
"disp": true,
"width": "5",
"collapse": false
},
{
"id": "212c669d.fce9ba",
"type": "ui_group",
"name": "Input latitude/longitude",
"tab": "152c952d.14cc0b",
"order": 2,
"disp": true,
"width": "6",
"collapse": false
},
{
"id": "ecd479fa.1d4d48",
"type": "ui_group",
"name": "Input method",
"tab": "674b6dad.b573d4",
"order": 1,
"disp": true,
"width": "6",
"collapse": false
},
{
"id": "dc265c9b.5850a",
"type": "ui_group",
"name": "Humidity",
"tab": "152c952d.14cc0b",
"order": 8,
"disp": true,
"width": "6",
"collapse": false
},
{
"id": "152c952d.14cc0b",
"type": "ui_tab",
"name": "Weather",
"icon": "dashboard",
"order": 1,
"disabled": false,
"hidden": false
},
{
"id": "674b6dad.b573d4",
"type": "ui_tab",
"name": "Settings",
"icon": "dashboard",
"order": 3,
"disabled": false,
"hidden": false
}
]