Quelle: https://brightsky.dev/docs/#/operations/getWeather
Code: Alles auswählen
! --- Aussentemp (brightsky.dev/DWD) ---
string stdout;
string stderr;
string CARET = "%5E".UriDecode();
string URL = 'https://api.brightsky.dev/weather?lat=' # system.Latitude().ToString(3) # '&lon=' # system.Longitude().ToString(3)
# '&date=' # system.Date( "%Y-%m-%dT%H:00" ) # '&last_date=' # system.Date( "%Y-%m-%dT%H:00" ) # '&tz=Europe%2FBerlin';
WriteLine( '# URL: "' # URL # '"' );
system.Exec( 'curl -s --max-time 10 "' # URL # '" | grep -o "\\"temperature\\":['#CARET#',}]*" | cut -d: -f2;', &stdout, &stderr );
if( stdout != "" ) {
dom.GetObject(ID_SYSTEM_VARIABLES).Get( "log" ).State( "Aussentemp (brightsky.dev): " # stdout.Trim( ).ToString(0) # " C" );
WriteLine( dom.GetObject(ID_SYSTEM_VARIABLES).Get( "log" ).Value() );
} else {
WriteLine( "failed!" );
}
WriteLine( "--- Ende ---" );
# URL: "https://api.brightsky.dev/weather?lat=4 ... e%2FBerlin"
Aussentemp (brightsky.dev): 16 C
--- Ende ---
weitere Werte die abrufbar sind - außer der Temperatur - sind zB Niederschlagsmenge und -Wahrscheinlichkeit, Windgeschwindigkeit usw:
Code: Alles auswählen
"weather": [
{
"timestamp": "2023-09-29T09:00:00+02:00",
"source_id": 1625,
"precipitation": 0.0,
"pressure_msl": 1019.5,
"sunshine": 28.0,
"temperature": 15.9,
"wind_direction": 183,
"wind_speed": 3.7,
"cloud_cover": 57,
"dew_point": 12.4,
"relative_humidity": null,
"visibility": 32300,
"wind_gust_direction": null,
"wind_gust_speed": 7.4,
"condition": "dry",
"precipitation_probability": 1,
"precipitation_probability_6h": null,
"solar": 0.081,
"icon": "partly-cloudy-day"
}
],
"sources": [
{
...
"first_record": "2023-09-29T05:00:00+00:00",
"last_record": "2023-10-09T10:00:00+00:00",
...
}
]
Mehrere Werte aus einem curl-Result ginge zB so:
Code: Alles auswählen
! --- Aussentemp (brightsky.dev/DWD) ---
string stdout;
string stderr;
string CARET = "%5E".UriDecode();
string URL = 'https://api.brightsky.dev/weather?lat=' # system.Latitude().ToString(3) # '&lon=' # system.Longitude().ToString(3)
# '&date=' # system.Date( "%Y-%m-%dT%H:00" ) # '&last_date=' # system.Date( "%Y-%m-%dT%H:00" ) # '&tz=Europe%2FBerlin';
WriteLine( '# URL: "' # URL # '"' );
system.Exec( '
JSON=$( curl -s --max-time 10 "' # URL # '" );
echo "$JSON" | grep -o "\\"timestamp\\":\\"['#CARET#'\\"]*\\"";
echo "$JSON" | grep -o "\\"temperature\\":['#CARET#',}]*";
echo "$JSON" | grep -o "\\"precipitation\\":['#CARET#',}]*";
echo "$JSON" | grep -o "\\"wind_speed\\":['#CARET#',}]*";
', &stdout, &stderr );
if( stdout != "" ) {
WriteLine( stdout.Trim() );
} else {
WriteLine( "failed!" );
}
WriteLine( "--- Ende ---" );
# URL: "https://api.brightsky.dev/weather?lat=4 ... e%2FBerlin"
"timestamp":"2023-09-29T13:00:00+02:00"
"temperature":25.7
"precipitation":0.0
"wind_speed":20.4
--- Ende ---