Skip to content

Commit f5f9c58

Browse files
committed
updated external API example
1 parent d4019da commit f5f9c58

File tree

7 files changed

+128
-42
lines changed

7 files changed

+128
-42
lines changed

WriteLocationToAsset/readme.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ https://user-images.githubusercontent.com/90254123/166235568-542ba4b4-f1ab-4f04-
2020

2121
You do not have to write all information (e.g. postal code, street address, country, ...) for the map to be functional. Writing longitude and latitude is sufficient. However, if you only sent longitude and latitude information, Asset Manager will show *now location available*. The Asset Map is still functional.
2222

23-
> Take a look at the [MindSphere Documentation](https://documentation.mindsphere.io/MindSphere/apis/advanced-assetmanagement/api-assetmanagement-api.html) if you want to know more about the Asset Management API.
23+
> Take a look at the [Insights Hub Documentation](https://documentation.mindsphere.io/MindSphere/apis/advanced-assetmanagement/api-assetmanagement-api.html) if you want to know more about the Asset Management API.
91.2 KB
Loading
-9.55 KB
Binary file not shown.
52.3 KB
Loading

integrateExternalApi/externalApi.json

+111-33
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,153 @@
11
[
22
{
3-
"id": "9b3d196c.670518",
4-
"type": "comment",
5-
"z": "f91e2e34.2ae5d",
6-
"name": "Procedure",
7-
"info": "Double click the City node. Pick a city name for which weather information is available.\nCreate an account in https://openweathermap.org/ for free. \nThen create API Key from https://home.openweathermap.org/api_keys.\nThis example uses Current Weather API documented at: 'https://openweathermap.org/current'.",
8-
"sticky": 1,
9-
"x": 490,
10-
"y": 380,
11-
"wires": []
3+
"id": "27d9cd3.b828732",
4+
"type": "group",
5+
"z": "216044f1.bc512c",
6+
"name": "Get weather data from external service",
7+
"style": {
8+
"label": true
9+
},
10+
"nodes": [
11+
"c0346697.e8ead8",
12+
"c5938bad.c5fa38",
13+
"ad0608a8.b597a8",
14+
"8ae6a14c.c24fd",
15+
"ad0dfb26.1fd928",
16+
"b50d362b.e41418",
17+
"99cd1a17.a81548"
18+
],
19+
"x": 75,
20+
"y": 581,
21+
"w": 1170,
22+
"h": 418
1223
},
1324
{
14-
"id": "e4ded4eb.b27c98",
15-
"type": "debug",
16-
"z": "f91e2e34.2ae5d",
25+
"id": "c0346697.e8ead8",
26+
"type": "function",
27+
"z": "216044f1.bc512c",
28+
"g": "27d9cd3.b828732",
29+
"name": "parse for desired data",
30+
"func": "const data = msg.payload;\n\nmsg.topic = \"5f634f70df3d484baabbbc361f5b9b9e/weather_data\";\n\nmsg.payload = {\n temperature: data.main.temp,\n pressure: data.main.pressure,\n humidity: data.main.humidity,\n wind_speed: data.wind.speed,\n wind_direction: data.wind.deg\n }\n\nreturn msg;",
31+
"outputs": 1,
32+
"language": "javascript",
33+
"noerr": 0,
34+
"x": 700,
35+
"y": 780,
36+
"wires": [
37+
[
38+
"c5938bad.c5fa38"
39+
]
40+
],
41+
"_type": "node"
42+
},
43+
{
44+
"id": "c5938bad.c5fa38",
45+
"type": "write timeseries",
46+
"z": "216044f1.bc512c",
47+
"g": "27d9cd3.b828732",
1748
"name": "",
18-
"active": true,
19-
"console": "false",
20-
"xaxis": "_time",
21-
"complete": "false",
22-
"x": 650,
23-
"y": 460,
49+
"topic": "",
50+
"topicData": "",
51+
"topicLabel": "",
52+
"assetName": "",
53+
"aspectName": "",
54+
"useMerging": false,
55+
"x": 1160,
56+
"y": 780,
2457
"wires": []
2558
},
2659
{
27-
"id": "ae6137a3.572a98",
60+
"id": "ad0608a8.b597a8",
61+
"type": "comment",
62+
"z": "216044f1.bc512c",
63+
"g": "27d9cd3.b828732",
64+
"name": "Parses data from WeatherAPI",
65+
"info": "...just some metrics and forwards to write TS node\n+ temperature\n+ pressure\n+ humidity\n+ wind_speed\n+ wind_direction",
66+
"sticky": 1,
67+
"x": 790,
68+
"y": 900,
69+
"wires": [],
70+
"_type": "node"
71+
},
72+
{
73+
"id": "8ae6a14c.c24fd",
2874
"type": "http request",
29-
"z": "f91e2e34.2ae5d",
75+
"z": "216044f1.bc512c",
76+
"g": "27d9cd3.b828732",
3077
"name": "Get Weather",
3178
"method": "GET",
32-
"ret": "txt",
33-
"url": "https://api.openweathermap.org/data/2.5/weather?q={{CITY}}&appid={{API_KEY}}",
79+
"ret": "obj",
80+
"url": "https://api.openweathermap.org/data/2.5/weather?q={{CITY}}&appid={{API_KEY}}&units=metric",
3481
"timeout": "",
3582
"mindspherePath": "",
3683
"useMindsphereAuth": false,
3784
"isAdmin": false,
3885
"secretHeaders": "",
39-
"x": 450,
40-
"y": 460,
86+
"x": 430,
87+
"y": 780,
4188
"wires": [
4289
[
43-
"e4ded4eb.b27c98"
90+
"b50d362b.e41418",
91+
"c0346697.e8ead8"
4492
]
4593
],
4694
"_type": "node"
4795
},
4896
{
49-
"id": "c6c9622d.3aa6b",
97+
"id": "ad0dfb26.1fd928",
5098
"type": "inject",
51-
"z": "f91e2e34.2ae5d",
52-
"name": "City",
99+
"z": "216044f1.bc512c",
100+
"g": "27d9cd3.b828732",
101+
"name": "Config: CITY & API_KEY",
53102
"topic": "",
54103
"payload": "",
55104
"payloadType": "date",
56105
"repeat": "",
57106
"repeatEnd": "0",
58107
"endTime": "0",
59108
"crontab": "",
109+
"offset": "NaN",
60110
"once": false,
61-
"properties": "[{\"name\":\"CITY\",\"value\":\"Erlangen\"},{\"name\":\"API_KEY\",\"value\":\"Replace this with API KEY\"}]",
111+
"properties": "[{\"name\":\"CITY\",\"value\":\"Erlangen\"},{\"name\":\"API_KEY\",\"value\":\"<put-your-API_KEY-here>\"}]",
62112
"timezone": "utc",
63113
"betweentimesunit": "m",
64-
"enableRuleEngine": false,
65114
"showNextExecution": false,
66-
"x": 250,
67-
"y": 460,
115+
"powerMode": false,
116+
"x": 220,
117+
"y": 780,
68118
"wires": [
69119
[
70-
"ae6137a3.572a98"
120+
"8ae6a14c.c24fd"
71121
]
72122
],
73123
"_type": "node"
124+
},
125+
{
126+
"id": "b50d362b.e41418",
127+
"type": "debug",
128+
"z": "216044f1.bc512c",
129+
"g": "27d9cd3.b828732",
130+
"name": "",
131+
"active": true,
132+
"console": "false",
133+
"xaxis": "_time",
134+
"complete": "payload",
135+
"x": 670,
136+
"y": 740,
137+
"wires": [],
138+
"_type": "node"
139+
},
140+
{
141+
"id": "99cd1a17.a81548",
142+
"type": "comment",
143+
"z": "216044f1.bc512c",
144+
"g": "27d9cd3.b828732",
145+
"name": "Get weather data from OpenWeather.org // Procedure",
146+
"info": "Double click the City node. Pick a city name for which weather information is available.\nCreate an account in https://openweathermap.org/ for free. \nThen create API Key from https://home.openweathermap.org/api_keys.\nThis example uses Current Weather API documented at: 'https://openweathermap.org/current'.",
147+
"sticky": 1,
148+
"x": 490,
149+
"y": 660,
150+
"wires": [],
151+
"_type": "node"
74152
}
75153
]

integrateExternalApi/readme.md

+15-7
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
11
# Integrate an external API
22

3-
Your business case may require to use external services over HTTP. Visual Flow Creator provides a means to consume such services. The example here demonstrates consuming a service from [Openweathermap](https://openweathermap.org) to bring weather information of a city.
3+
Your business case may require to use external services over HTTP. Visual Flow Creator provides a means to consume such services.
44

5-
![image](./doc/externalApi.png)
5+
## Example based on external weather data
6+
The example here demonstrates consuming a service from [OpenWeathermap](https://openweathermap.org) to bring weather information of a city.
7+
8+
![image](./doc/external_API_image.png)
69

710
## Setup & Configuration
811
1. Import the flow into Visual Flow Creator.
912
2. Obtain the API Key from [OpenWeather](https://home.openweathermap.org/api_keys). This will require a free account to be created, if not already done.
10-
3. Double click the node named **City**.
13+
3. Double click the node named **Config: CITY & API_KEY**.
1114
4. Replace the value field of `API_KEY` with the newly obtained API KEY from the above URL.
1215
5. Change the value of the `CITY` field to a city name. The API supports limited set of cities. Please look in to their documentation.
1316
6. Save the flow after completing the needed changes.
14-
7. Click the inject node to trigger the sequence.
15-
8. Output in the debug window shows the weather data for the chosen city.
17+
7. Adopt the processing of the received information based on your needs. The example focuses on the weather details specified in the flow comment.
18+
8. Click the inject node to trigger the sequence.
19+
9. Output in the debug window shows the weather data for the chosen city.
1620

1721
## How does this flow work
1822

@@ -22,7 +26,11 @@ Your business case may require to use external services over HTTP. Visual Flow C
2226
- Then HTTP request node fetches the data synchronously from Openweather service endpoint.
2327
- It converts the recieved response to JSON format and sets it as value for the payload field of the msg object.
2428
- Debug node in the end displays the contents of payload field to the debug window.
25-
29+
30+
## Attachements
31+
Here the `API_KEY` can get obtained from the external weather service.
32+
![image](./doc/API_KEY_details.png)
33+
2634

2735
## See also
28-
- [Openweathermap Website](https://openweathermap.org)
36+
- [OpenWeathermap Website](https://openweathermap.org)

virtualMachineSimulator/readme.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Using this flow, you can generate virtual machine data consisting of both a simu
33
- machine states
44
- product counter
55

6-
It can be used if no physical assets are available or to learn about the features on MindSphere to explore VFC and other apps using the data stored in the Asset Management. The data generated can also be used further to calculate the machine OEE, Availability or Quality of the virtual products produced.
6+
It can be used if no physical assets are available or to learn about the features on Insights Hub to explore VFC and other apps using the data stored in the Asset Management. The data generated can also be used further to calculate the machine OEE, Availability or Quality of the virtual products produced.
77

88
![image](./doc/virtualMachineSimulator.png)
99

0 commit comments

Comments
 (0)