OpenWeatherMapAPI - Weiterentwicklung

Begonnen von CoolTux, 19 November 2022, 13:24:19

Vorheriges Thema - Nächstes Thema

vbs

Danke für die fixe Antwort! Ja tatsächlich, hourly forecasts funktionieren. Hätte aber lieber daily forecasts und hab es jetzt mit Proplanta hinbekommen.

CoolTux

Wie sehen denn Deine aktuellen Attribute aus?
Du musst nicht wissen wie es geht! Du musst nur wissen wo es steht, wie es geht.
Support me to buy new test hardware for development: https://www.paypal.com/paypalme/MOldenburg
My FHEM Git: https://git.cooltux.net/FHEM/
Das TuxNet Wiki:
https://www.cooltux.net

betateilchen

Bei mir waren nicht die Attribute ausschlaggebend, sondern die api-Option version:3.0 im DEF, um die daily forecasts zu bekommen.
-----------------------
Formuliere die Aufgabe möglichst einfach und
setze die Lösung richtig um - dann wird es auch funktionieren.
-----------------------
Lesen gefährdet die Unwissenheit!

slupus

Hallo CoolTux,
in der One Call API 3.0 gibt es seit gestern ein neues Feature:
We will add the proper human-readable text description of the daily forecast, for example, "The day will start with rain through the late morning hours, transitioning to partly cloudy".

The new field summary will be available for each day in the "daily forecast" section for all 8 days. It will describe the weather conditions for the whole day. We prepared the test version of the One Call API 3.0 with the newly added field to help you softly migrate to the new version and test your services with the real data we have added.

Wäre es möglich, dass du das Feld summary auch ausgibst? Bei mir zumindest wird es noch nicht angezeigt.
Rufe ich die API direkt auf, bekomme ich den Wert.

Danke und Grüße


Anbei ein teil des Response, den ich mit https://demo.openweathermap.org/data/3.0/onecall?lat={lat}&lon={lon}&appid={API key} erhalten habe:
{"dt":1685617200,"sunrise":1685589907,"sunset":1685647038,"moonrise":1685636520,"moonset":1685584020,"moon_phase":0.4,"summary":"There will be clear sky until morning, then partly cloudy","temp":{"day":297.01,"min":284.69,"max":298.25,"night":289.96,"eve":296.21,"morn":286.59},"feels_like":{"day":296.52,"night":289.58,"eve":295.82,"morn":285.92},"pressure":1017,"humidity":41,"dew_point":282.41,"wind_speed":3.49,"wind_deg":18,"wind_gust":4.67,"weather":[{"id":802,"main":"Clouds","description":"Mäßig bewölkt","icon":"03d"}],"clouds":25,"pop":0,"uvi":7.28},

CoolTux

Leider bin ich aktuell zeitlich eingespannt. Gerne nehme ich Patches an die ich dann kurzzeitig einbringen kann. Ansonsten muss das noch etwas dauern fürchte ich.
Du musst nicht wissen wie es geht! Du musst nur wissen wo es steht, wie es geht.
Support me to buy new test hardware for development: https://www.paypal.com/paypalme/MOldenburg
My FHEM Git: https://git.cooltux.net/FHEM/
Das TuxNet Wiki:
https://www.cooltux.net

CoolTux

Zitat von: slupus am 31 Mai 2023, 22:12:35Hallo CoolTux,
in der One Call API 3.0 gibt es seit gestern ein neues Feature:
We will add the proper human-readable text description of the daily forecast, for example, "The day will start with rain through the late morning hours, transitioning to partly cloudy".

The new field summary will be available for each day in the "daily forecast" section for all 8 days. It will describe the weather conditions for the whole day. We prepared the test version of the One Call API 3.0 with the newly added field to help you softly migrate to the new version and test your services with the real data we have added.

Wäre es möglich, dass du das Feld summary auch ausgibst? Bei mir zumindest wird es noch nicht angezeigt.
Rufe ich die API direkt auf, bekomme ich den Wert.

Danke und Grüße


Anbei ein teil des Response, den ich mit https://demo.openweathermap.org/data/3.0/onecall?lat={lat}&lon={lon}&appid={API key} erhalten habe:
{"dt":1685617200,"sunrise":1685589907,"sunset":1685647038,"moonrise":1685636520,"moonset":1685584020,"moon_phase":0.4,"summary":"There will be clear sky until morning, then partly cloudy","temp":{"day":297.01,"min":284.69,"max":298.25,"night":289.96,"eve":296.21,"morn":286.59},"feels_like":{"day":296.52,"night":289.58,"eve":295.82,"morn":285.92},"pressure":1017,"humidity":41,"dew_point":282.41,"wind_speed":3.49,"wind_deg":18,"wind_gust":4.67,"weather":[{"id":802,"main":"Clouds","description":"Mäßig bewölkt","icon":"03d"}],"clouds":25,"pop":0,"uvi":7.28},


https://git.cooltux.net/FHEM/mod-Weather/issues/56
Du musst nicht wissen wie es geht! Du musst nur wissen wo es steht, wie es geht.
Support me to buy new test hardware for development: https://www.paypal.com/paypalme/MOldenburg
My FHEM Git: https://git.cooltux.net/FHEM/
Das TuxNet Wiki:
https://www.cooltux.net

slupus

Hallo CoolTux,
vielen Dank für die Anpassung! So schnell hatte ich nicht damit gerechnet  :)
Wer den Text übersetzen möchte:
    my $input = ReadingsVal("Wetter","fc1_summary","none");
    my $output;
    my $source = 'en';
    my $target = 'de';
    my $url = "https://translate.googleapis.com/translate_a/single?client=gtx&sl=".$source."&tl=".$target."&dt=t&q=".uri_escape_utf8($input);
    my $ua = LWP::UserAgent->new;
    my $response = $ua->get($url);
    if ($response->is_success) {
        my $content = $response->decoded_content;
        my $result = decode_json($content);
        $output = $result->[0]->[0]->[0];
    }
    else {
        # die "Translation request failed: " . $response->status_line;
        $output = $input;
    }
    $output = encode('utf8', $output);

Flachzange

Zitat von: vbs am 01 Mai 2023, 16:32:38Ich wollte hier jetzt auch gerne mitspielen und eigentlich sieht das soweit ganz gut aus. Aber: ich kriege überhaupt keine Forecast-Daten. Hab jetzt noch händisch auf "daily" und "4" gestellt, aber trotzdem nur aktuelle Readings, aber keine fc-Readings.
Kann mir jemand nen Tip geben? Danke!

Zitat von: betateilchen am 12 Mai 2023, 18:49:56Bei mir waren nicht die Attribute ausschlaggebend, sondern die api-Option version:3.0 im DEF, um die daily forecasts zu bekommen.


Ich hatte das gleiche Problem. Am Ende habe ich auch mit version:3.0 im DEF die daily forecast UND die hourly forecasts bekommen.Hinzu kam aber, dass ein einfaches set <name> update nicht gereicht hat. Erst als ich das forecast-Attribut gesetzt habe und danach nochmal mit "modify <name>" die DEF neu gesetzt habe, kamen die Readings.