-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
open up the data source apicast.hiveeyes/beeflight/forecast.
and bring it improvised on Screen. Thanks to amotl.
- Loading branch information
Showing
6 changed files
with
240 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
.venv* | ||
.pio | ||
.vscode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
##################################### | ||
Apicast HTTP to Json data export for Arduino | ||
##################################### | ||
|
||
|
||
***** | ||
About | ||
***** | ||
This code fetches data from the Apicast-Hiveeyes-Platform. | ||
It converts data from the bee flight forecast of the German Weather Service (DWD)into the .Json format | ||
Manny Thanks to Andreas Mot | ||
|
||
Example of the API: | ||
http://apicast.hiveeyes.org/beeflight/forecast/germany/berlin_brandenburg/potsdam | ||
|
||
available locations for the forecast: | ||
|
||
baden-wuerttemberg, Baden-Württemberg | ||
freudenstadt, Freudenstadt im Schwarzwald | ||
konstanz, Konstanz am Bodensee | ||
lahr, Lahr | ||
mannheim, Mannheim | ||
oehringen, Öhringen | ||
rheinstetten, Rheinstetten | ||
stoetten, Stötten (Geislingen an der Steige) | ||
stuttgart, Stuttgart (Flughafen) | ||
bayern, Bayern | ||
augsburg, Augsburg | ||
bamberg, Bamberg | ||
fuerstenzell, Fürstenzell | ||
hof, Hof | ||
hohenpeissenberg, Hohenpeißenberg | ||
kempten, Kempten (Allgäu) | ||
muenchen, München (Flughafen) | ||
nuernberg, Nürnberg (Flughafen) | ||
oberstdorf, Oberstdorf (Allgäu) | ||
regensburg, Regensburg | ||
straubing, Straubing | ||
weiden, Weiden in der Oberpfalz | ||
wuerzburg, Würzburg | ||
berlin_brandenburg, Berlin und Brandenburg | ||
angermuende, Angermünde | ||
berlin, Berlin-Tempelhof | ||
cottbus, Cottbus | ||
lindenberg, Lindenberg (Tauche) | ||
neuruppin, Neuruppin | ||
potsdam, Potsdam | ||
hessen, Hessen | ||
frankfurt, Frankfurt/Main (Flughafen) | ||
fritzlar, Fritzlar | ||
offenbach, Offenbach/Main (Wetterpark) | ||
wasserkuppe, Wasserkuppe | ||
wettenberg, Wettenberg bei Gießen | ||
mecklenburg-vorpommern, Mecklenburg-Vorpommern | ||
arkona, Arkona (Putgarten) | ||
greifswald, Greifswald | ||
marnitz, Marnitz | ||
rostock, Rostock-Warnemünde | ||
schwerin, Schwerin | ||
niedersachsen_bremen, Niedersachsen und Bremen | ||
bremen, Bremen (Flughafen) | ||
cuxhaven, Cuxhaven | ||
emden, Emden | ||
hannover, Hannover (Flughafen) | ||
norderney, Norderney | ||
nordrhein-westfalen, Nordrhein-Westfalen | ||
aachen, Aachen-Orsbach | ||
lippspringe, Bad Lippspringe | ||
duesseldorf, Düsseldorf (Flughafen) | ||
greven, Greven (Flughafen Münster/Osnabrück) | ||
kahler_asten, Kahler Asten (Winterberg) | ||
koeln, Köln (Flughafen Köln/Bonn) | ||
rheinland-pfalz_saarland, Rheinland-Pfalz und Saarland | ||
hahn, Hahn (Flughafen) | ||
nuerburg, Nürburg-Barweiler | ||
saarbruecken, Saarbrücken (Flughafen) | ||
trier, Trier-Petrisberg | ||
sachsen, Sachsen Sachsen-Anhalt | ||
dresden, Dresden (Flughafen) | ||
goerlitz, Görlitz | ||
leipzig, Leipzig (Flughafen Leipzig/Halle) | ||
sachsen-anhalt, Sachsen-Anhalt | ||
magdeburg, Magdeburg | ||
schleswig-holstein_hamburg, Schleswig-Holstein und Hamburg | ||
fehmarn, Fehmarn | ||
hamburg, Hamburg (Flughafen) | ||
helgoland, Helgoland | ||
kiel, Kiel-Holtenau | ||
list, List auf Sylt | ||
schleswig, Schleswig | ||
thueringen, Thüringen | ||
erfurt, Erfurt (Flughafen Erfurt-Weimar) | ||
gera, Gera | ||
meiningen, Meiningen | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
#ifndef APICAST_CLIENT_H_ | ||
#define APICAST_CLIENT_H_ | ||
|
||
#include <Arduino.h> | ||
#include <ArduinoJson.h> | ||
#include <HTTPClient.h> | ||
|
||
bool decode_beeflight(WiFiClient& json) { | ||
|
||
// Allocate the JsonDocument | ||
DynamicJsonDocument doc(5 * 1024); | ||
|
||
// Deserialize the JSON document. | ||
DeserializationError error = deserializeJson(doc, json); | ||
|
||
// Test if parsing succeeds. | ||
if (error) { | ||
Serial.print(F("deserializeJson() failed: ")); | ||
Serial.println(error.c_str()); | ||
return false; | ||
} | ||
|
||
Serial.println(" Decoding Apicast data"); | ||
|
||
JsonArray data = doc["data"]; | ||
int api_readings = data.size(); | ||
|
||
for (int i = 0; i < api_readings; i++) { | ||
|
||
JsonObject reading = data[i]; | ||
|
||
beeflight[i].date = reading["Datum"].as<char*>(); | ||
beeflight[i].morning = reading["morgens"].as<char*>(); | ||
beeflight[i].noon = reading["mittags"].as<char*>(); | ||
beeflight[i].evening = reading["abends"].as<char*>(); | ||
} | ||
|
||
return true; | ||
} | ||
|
||
bool obtain_apicast_data(WiFiClient& client) { | ||
|
||
// Define URI. | ||
// https://getkotori.org/docs/handbook/export/ | ||
HTTPClient http; | ||
http.useHTTP10(true); | ||
String server = apicast_server; | ||
|
||
// TODO: Improve Kotori by requesting only last reading. | ||
String uri = apicast_uri; | ||
|
||
// Make HTTP request. | ||
//http.begin(uri, test_root_ca); // HTTPS example connection | ||
bool success; | ||
http.begin(client, server, 80, uri); | ||
int httpCode = http.GET(); | ||
if (httpCode == HTTP_CODE_OK) { | ||
if (!decode_beeflight(http.getStream())) return false; | ||
success = true; | ||
Serial.println("Connection Apicast OK"); | ||
} else { | ||
Serial.printf("Connection failed, error: %s", http.errorToString(httpCode).c_str()); | ||
success = false; | ||
} | ||
|
||
client.stop(); | ||
http.end(); | ||
return success; | ||
} | ||
|
||
#endif /* ifndef APCAST_CLIENT_H_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#ifndef APICAST_RECORD_H_ | ||
#define APICAST_RECORD_H_ | ||
|
||
#include <Arduino.h> | ||
|
||
typedef struct { | ||
String date; | ||
String morning; | ||
String noon; | ||
String evening; | ||
} Apicast_record_type; | ||
|
||
#endif /* ifndef APICAST_RECORD_H_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters