Du hattest recht, habe nur das erste Modul installiert
Vielen Dank für deine Hilfe
Du hattest recht, habe nur das erste Modul installiert
Vielen Dank für deine Hilfe
Jetzt bekomme ich einen HTTP-Fehler???
Die Instanz Datenabruf holt die Daten ja erfolgreich ab, d.h. der API funktioniert. Weshalb bekomme ich hier den HTTP-Fehler
Habe gerade gesehen, dass Openweather unterscheidet bei den API’s, ich benötige die Subscription für den OneCall Abruf. Hatte aber nur den normalen API beantragt ohne Zahlungsmittelangabe.
API wurde freigeschalten, jetzt funktioniert alles
Moin,
anbei der Debug.
dump OWM oneCall.txt (567,2 KB)
Das ist aus meinem Abruf von gestern 18:24:41.
„https://api.openweathermap.org/data/3.0/onecall?lat=51.412&lon=6.90444&lang=de&&units=metric&&appid=xxx“
Abruf 04.01.25.json.txt (46,8 KB)
Denke das erste Wert werden müsste?
Und das dann die stündlichen Werte?
Hmm … da hatte ich wohl nicht richtig kontrolliert.
Versuch bitte die aktuell 2.5.1 ModulsStore/Beta
Hallo demel42,
mit der Beta funktioniert es wunderbar, vielen Dank für die schnelle Anpassung.
Was ich nicht hinbekomme ist, dass die Spalten der einzelnen Tage breiter werden und die Einheiten hinter den Begriffen wie Regen 1h steht.
Versuch mal in dem Script mit width: ???px (Spaltenbreite) und andererseits font-size: ??px (Schriftgröße) zu spielen.
Habe ich schon, kam nichts berauschendes raus
Moin,
bei den vielen Werten ist das ja auch nicht einfach.
Die Werte werden jetzt geschrieben. Danke.
Vorausgeschickt: ich werde nicht warm mit HTML und auch keinerlei Bezug dazu, habe aber noch heute an dem Script gefummelt.
<?php
declare(strict_types=1);
// Einrichtung:
// String-Variable mit Profil "~HTML-Box" anlegen, VariablenID weiter unten eintragen
//
// ID der Instanz von "OpenWeatherMap - OneCall-Datenabruf" konfigurieren
//
// das Script auslösen bei Änderung einer Variablen, z.B "letzte Messung" ('LastMeasurement')
//
//
// die Einstellungen im Script nach Belieben anpassen
// HTML-Box
$varID = xxxxx;
// Instanz von "OpenWeatherMap - OneCall-Datenabruf"
$instID = yyyyy;
$scriptName = IPS_GetName($_IPS['SELF']) . '(' . $_IPS['SELF'] . ')';
$wday2name = ['Montag', 'Dienstag', 'Mittwoch', 'Donnerstag', 'Freitag', 'Samstag', 'Sonntag'];
$daily_forecast_count = IPS_GetProperty($instID, 'daily_forecast_count');
$temperature = GetValueFormatted(IPS_GetObjectIDByIdent('Temperature', $instID));
$humidity = GetValueFormatted(IPS_GetObjectIDByIdent('Humidity', $instID));
$wind_speed = GetValueFormatted(IPS_GetObjectIDByIdent('WindSpeed', $instID));
$has_rain = GetValue(IPS_GetObjectIDByIdent('Rain_1h', $instID)) > 0;
$rain_1h = GetValueFormatted(IPS_GetObjectIDByIdent('Rain_1h', $instID));
$has_snow = GetValue(IPS_GetObjectIDByIdent('Snow_1h', $instID)) > 0;
$snow_1h = GetValueFormatted(IPS_GetObjectIDByIdent('Snow_1h', $instID));
$clouds = GetValueFormatted(IPS_GetObjectIDByIdent('Cloudiness', $instID));
$icon = GetValueString(IPS_GetObjectIDByIdent('ConditionIcon', $instID));
if ($icon != '') {
$img = '<img src="https://openweathermap.org/img/wn/' . $icon . '@2x.png" style="float: left; padding-left: 10px; padding-right: 5px;" />';
} else {
$img = '';
}
$col_width = 180;
$total_width = $col_width + $daily_forecast_count * ($col_width + 20);
$day_font_size = 15;
$val_font_size = 13;
$html = '';
$html .= '<table style="width: ' . $total_width . 'px;">' . PHP_EOL;
$html .= ' <tbody>' . PHP_EOL;
$html .= ' <tr>' . PHP_EOL;
$html .= ' <td align="center" valign="top" style="width: ' . $col_width . 'px; padding: 0px; padding-left: 5px; font-size: ' . $day_font_size . 'px;">' . 'aktuell' . '<br />' . $img . PHP_EOL;
$html .= ' <div>' . PHP_EOL;
$html .= ' <table border="0"; padding="0"; cellspacing="0"; cellpadding=0;>' . PHP_EOL;
$html .= ' <tbody>' . PHP_EOL;
$html .= ' <tr>' . PHP_EOL;
$html .= ' <td> </td>' . PHP_EOL;
$html .= ' </tr>' . PHP_EOL;
$html .= ' <tr>' . PHP_EOL;
$html .= ' <td style="font-size: ' . $val_font_size . 'px; text-align: right;">' . $temperature . '</td>' . PHP_EOL;
$html .= ' </tr>' . PHP_EOL;
$html .= ' <tr>' . PHP_EOL;
$html .= ' <td style="font-size: ' . $val_font_size . 'px; text-align: right;">' . $humidity . '</td>' . PHP_EOL;
$html .= ' </tr>' . PHP_EOL;
$html .= ' </tbody>' . PHP_EOL;
$html .= ' </table>' . PHP_EOL;
$html .= ' </div>' . PHP_EOL;
$html .= ' <div>' . PHP_EOL;
$html .= ' <table border="0"; padding="0"; cellspacing="0"; cellpadding=0;>' . PHP_EOL;
$html .= ' <tbody>' . PHP_EOL;
$html .= ' <tr>' . PHP_EOL;
$html .= ' <td style="font-size: ' . $val_font_size . 'px;">' . 'Ø Wind' . '</td>' . PHP_EOL;
$html .= ' <td> </td>' . PHP_EOL;
$html .= ' <td style="font-size: ' . $val_font_size . 'px;">' . $wind_speed . '</td>' . PHP_EOL;
$html .= ' </tr>' . PHP_EOL;
if ($has_rain == true || $has_snow == false) {
$html .= ' <tr>' . PHP_EOL;
$html .= ' <td style="font-size: ' . $val_font_size . 'px;">' . 'Regen 1h' . '</td>' . PHP_EOL;
$html .= ' <td> </td>' . PHP_EOL;
$html .= ' <td style="font-size: ' . $val_font_size . 'px;">' . $rain_1h . '</td>' . PHP_EOL;
$html .= ' </tr>' . PHP_EOL;
}
if ($has_snow == true) {
$html .= ' <tr>' . PHP_EOL;
$html .= ' <td style="font-size: ' . $val_font_size . 'px;">' . 'Schnee 1h' . '</td>' . PHP_EOL;
$html .= ' <td> </td>' . PHP_EOL;
$html .= ' <td style="font-size: ' . $val_font_size . 'px;">' . $snow_1h . '</td>' . PHP_EOL;
$html .= ' </tr>' . PHP_EOL;
}
$html .= ' <tr>' . PHP_EOL;
$html .= ' <td style="font-size: ' . $val_font_size . 'px;">' . 'Bewölkung' . '</td>' . PHP_EOL;
$html .= ' <td> </td>' . PHP_EOL;
$html .= ' <td style="font-size: ' . $val_font_size . 'px;">' . $clouds . '</td>' . PHP_EOL;
$html .= ' </tr>' . PHP_EOL;
$html .= ' </tbody>' . PHP_EOL;
$html .= ' </table>' . PHP_EOL;
$html .= ' </div>' . PHP_EOL;
$html .= ' </td>' . PHP_EOL;
$html .= '' . PHP_EOL;
for ($i = 0; $i < $daily_forecast_count; $i++) {
$pre = 'DailyForecast';
$post = '_' . sprintf('%02d', $i);
$timestamp = GetValueInteger(IPS_GetObjectIDByIdent($pre . 'Begin' . $post, $instID));
$temperature_min = GetValueFormatted(IPS_GetObjectIDByIdent($pre . 'TemperatureMin' . $post, $instID));
$temperature_max = GetValueFormatted(IPS_GetObjectIDByIdent($pre . 'TemperatureMax' . $post, $instID));
$wind_speed = GetValueFormatted(IPS_GetObjectIDByIdent($pre . 'WindSpeed' . $post, $instID));
$has_rain = GetValue(IPS_GetObjectIDByIdent($pre . 'Rain' . $post, $instID)) > 0;
$rain = GetValueFormatted(IPS_GetObjectIDByIdent($pre . 'Rain' . $post, $instID));
$has_snow = GetValue(IPS_GetObjectIDByIdent($pre . 'Snow' . $post, $instID)) > 0;
$snow = GetValueFormatted(IPS_GetObjectIDByIdent($pre . 'Snow' . $post, $instID));
$clouds = GetValueFormatted(IPS_GetObjectIDByIdent($pre . 'Cloudiness' . $post, $instID));
$icon = GetValueString(IPS_GetObjectIDByIdent($pre . 'ConditionIcon' . $post, $instID));
$is_today = date('d.m.Y', $timestamp) == date('d.m.Y', time());
$weekDay = $is_today ? 'heute' : $wday2name[date('N', $timestamp) - 1];
if ($icon != '') {
$img = '<img src="https://openweathermap.org/img/wn/' . $icon . '@2x.png" style="float: left; padding-left: 10px; padding-right: 5px;" />';
} else {
$img = '';
}
$html .= ' <td align="center" valign="top" style="width: ' . $col_width . 'px; padding: 0px; padding-left: 5px; font-size: ' . $day_font_size . 'px;">' . $weekDay . '<br />' . $img . PHP_EOL;
$html .= ' <div>' . PHP_EOL;
$html .= ' <table border="0"; padding="0"; cellspacing="0"; cellpadding=0;>' . PHP_EOL;
$html .= ' <tbody>' . PHP_EOL;
$html .= ' <tr>' . PHP_EOL;
$html .= ' <td> </td>' . PHP_EOL;
$html .= ' </tr>' . PHP_EOL;
$html .= ' <tr>' . PHP_EOL;
$html .= ' <td style="font-size: ' . $val_font_size . 'px; text-align: right;">' . $temperature_min . '</td>' . PHP_EOL;
$html .= ' </tr>' . PHP_EOL;
$html .= ' <tr>' . PHP_EOL;
$html .= ' <td style="font-size: ' . $val_font_size . 'px; text-align: right;">' . $temperature_max . '</td>' . PHP_EOL;
$html .= ' </tr>' . PHP_EOL;
$html .= ' </tbody>' . PHP_EOL;
$html .= ' </table>' . PHP_EOL;
$html .= ' </div>' . PHP_EOL;
$html .= ' <div>' . PHP_EOL;
$html .= ' <table border="0"; padding="0"; cellspacing="0"; cellpadding=0;>' . PHP_EOL;
$html .= ' <tbody>' . PHP_EOL;
$html .= ' <tr>' . PHP_EOL;
$html .= ' <td style="font-size: ' . $val_font_size . 'px;">' . 'Ø Wind' . '</td>' . PHP_EOL;
$html .= ' <td> </td>' . PHP_EOL;
$html .= ' <td style="font-size: ' . $val_font_size . 'px;">' . $wind_speed . '</td>' . PHP_EOL;
$html .= ' </tr>' . PHP_EOL;
$html .= ' <tr>' . PHP_EOL;
if ($has_rain == true || $has_snow == false) {
$html .= ' <td style="font-size: ' . $val_font_size . 'px;">' . 'Regen' . '</td>' . PHP_EOL;
$html .= ' <td> </td>' . PHP_EOL;
$html .= ' <td style="font-size: ' . $val_font_size . 'px;">' . $rain . '</td>' . PHP_EOL;
$html .= ' </tr>' . PHP_EOL;
}
if ($has_snow == true) {
$html .= ' <td style="font-size: ' . $val_font_size . 'px;">' . 'Schnee' . '</td>' . PHP_EOL;
$html .= ' <td> </td>' . PHP_EOL;
$html .= ' <td style="font-size: ' . $val_font_size . 'px;">' . $snow . '</td>' . PHP_EOL;
$html .= ' </tr>' . PHP_EOL;
}
$html .= ' <tr>' . PHP_EOL;
$html .= ' <td style="font-size: ' . $val_font_size . 'px;">' . 'Bewölkung' . '</td>' . PHP_EOL;
$html .= ' <td> </td>' . PHP_EOL;
$html .= ' <td style="font-size: ' . $val_font_size . 'px;">' . $clouds . '</td>' . PHP_EOL;
$html .= ' </tr>' . PHP_EOL;
$html .= ' </tbody>' . PHP_EOL;
$html .= ' </table>' . PHP_EOL;
$html .= ' </div>' . PHP_EOL;
$html .= ' </td>' . PHP_EOL;
$html .= '' . PHP_EOL;
}
$html .= ' </tr>' . PHP_EOL;
$html .= ' </tbody>' . PHP_EOL;
$html .= '</table>' . PHP_EOL;
SetValueString($varID, $html);
Neben der Formatierungsanpassung werden nun auch die aktuellen, neuen Icons vom OpenWeather verwendet.
@gossi : ich habe auch eingebaut, das Schnee ausgegeben wird und zwar nach folgender Logik
Es kann ja - gerade wenn man einen ganzen Tag betrachtet, sowohl Regen als auch Schnee fallen
So sieht bei mir jetzt aus
Hey demel42,
sieht super aus, wenn du nicht warm wirst mit HTML, dann bin ich schockgefrostet
Gibt es noch eine Möglichkeit das Schnee/Frost Logo weiß und den Regen blau zu bekommen, auf meinem Hintergrund sieht man dieses nicht
Ansonsten sieht es von dem Layout her so aus wie ich es mir gewünscht hatte.
Die Icons sind die Originale von OpenWeather, da kann man nix dran machen (also ich nicht), vielleicht hat jemand anders eine Idee, wie man den Hintergrund dieser Icons ändern kann.
wundert mich vorhin war der Regen noch blau
Der Link war ein anderer:
http://openweathermap.org/img/w/
du nutzt nun die
http://openweathermap.org/img/wn/
da sind auch die Icon Größen unterschiedlich.
ja, ich hatte ja geschrieben, das sind die neuen offizielle Icons.
kannst natürlich die alten Icons verwenden, wobei die nicht mehr offiziell unterstützt werden (was aber nicht bedeutet wird, das sie zukünftig nicht funktionieren).
Einfach die URL ändern (sind 2 Stellen im Script)
neu: "https://openweathermap.org/img/wn/' . $icon . '@2x.png"
alt: http://openweathermap.org/img/w/' . $icon . '.png"
Habe mich dazu entschlossen, die Hintergrundfarbe im Bereich des Forecast zu erhellen
Finde, dass das farblich immer noch harmoniert.
Hallo,
sehr geil - besten, besten DANK
Schon getestet schaut sehr gut aus
Beim „normalen“ OpenWeatherMap - Datenabruf" - also der 3-Tagesvorherschau:
Komme ich da auch irgendwie vernünftig an die min/max. Tagestemperatur ?
Auf der OpenWeatherMap Seite findet man wohl einen API Aufruf - aber ???
Danke.
Die erstellt das Modul doch mit pro Berichtsperiode der Vorhersage
was meinst du mit 3-Tages-Vorschau?
Es werden diese Abrufe im Modul verwendet:
aktuelle Daten:
Current weather data - OpenWeatherMap
Vorhersage:
5 day weather forecast - OpenWeatherMap
Bei der Vorhersage sind zwar temp_min und temp_max enthalten.
Da diese 2.5-Api ja recht alt ist und vermutlich auch mal abgekündigt wird, müsste ich schin genau wissen, um welche Felder es sich handelt, damit es sich lohnt, das bei Bedarf zu ergänzen - also bitte ein Block in die API