简体   繁体   中英

Retrieving forecast data from OpenWeatherMap in FIWARE ORION

I am trying to get weather forecasts data from OpenWeatherMap and integrate them in Orion by performing a registeration request.

I was able to register and get the API key from OpenWeatherMap, however, the latter returns a JSON file with all the data inside, which is not supported by ORION.

I have followed the step by step tutorial https://fiware-tutorials.readthedocs.io/en/latest/context-providers/index.html#context-provider-ngsi-proxy where they have acquired the data from OpenWeatherMap using NGSI proxy, an API key is required to be indicated in the docker-compose file as an environment variable, however, the data acquired is the "current data" and not forecast and also specific to Berlin.

I have tried to access the files inside the container "fiware/tutorials.context-provider" and try to modify and match the parameters to my needs but I feel like I am taking a long blocked path.

I don't think that's even considered as good practice but I have run out of ideas :(

Can anyone suggest how I could bring the forecast data to Orion and register it as a context provider?

Thank you in advance.

I imagine you aim to implement a context provider, able to speak NGSI with Orion. OpenWeatherMap surely doesn't implement NGSI ...

If you have the data from OpenWeatherMap, as a JSON string, perhaps you should parse the JSON and create your entities using some select key-values from the parsed OpenWeatherMap? Save the entity (entities) locally and then register those keys in Orion.

Alternatively (easier but I wouldn't recommend it), create local entities with the entire OpenWeatherMap data as the value of an attribute of the entity:

{ "id": "id-from-OpenWeatherMap", "type": "OpenWeatherMap", "weatherData": { "value": ... } ... }

Then you register id/weatherData in Orion.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM