Hallo zusammen!
Mit meinem ersten Beitrag möchte ich gleich behilflich sein
Ich habe mir eigens Plugin für wetter.com geschrieben.
Als Beispiel/Vorlage habe ich Plugin von yr.no genommen (vielen dank dafür an Martin Gleiß!)
Voraussetzung:
Account bei wetter.com
Projekt anlegen (API :: Für Ihre Homepage :: Apps & mehr bei wetter.com)
Vorhersage auf Tage umstellen und Vorhersageantwort anpassen: w,pc,tn,tx,wd,ws
Dieser Plugin liefert:
1. aktuelles Wetter
2. Übersicht für heute
3. Vorhersage für 3 Tage
für die Punkte 1 und 3 muss man nur neues Plugin einbinden und language-Datei ergänzen.
für Punkt 2, muss man an mehreren Stellen zusätzliche Anpassungen durchführen.
in der wetter.com.php muss man noch Projektname und ApiKey ergänzen.
Plugin: wetter.com.php (lib/weather/service/)
Ergänzungen im lang_de.txt (lang/)
für Punkt 2:
Ergänzungen in weather.html (widgets/)
Ergänzungen in jdigiweather.css (lib/weather/)
Optional, damit die 3-Tages-Vorhersage mittig platziert wird (wie auf dem Bild)
in jdigiweather.css noch von 25% auf 33% ändern:
die Höhe der Zeilen habe ich auch geändert, damit es besser aussieht:
In den smartVISU Einstellungen Location so eingeben: DE0001020
Diese id findet man in URL: Wetter aktuell in Berlin, Berlin, Deutschland auf wetter.com.
Mit meinem ersten Beitrag möchte ich gleich behilflich sein

Ich habe mir eigens Plugin für wetter.com geschrieben.
Als Beispiel/Vorlage habe ich Plugin von yr.no genommen (vielen dank dafür an Martin Gleiß!)
Voraussetzung:
Account bei wetter.com
Projekt anlegen (API :: Für Ihre Homepage :: Apps & mehr bei wetter.com)
Vorhersage auf Tage umstellen und Vorhersageantwort anpassen: w,pc,tn,tx,wd,ws
Dieser Plugin liefert:
1. aktuelles Wetter
2. Übersicht für heute
3. Vorhersage für 3 Tage
für die Punkte 1 und 3 muss man nur neues Plugin einbinden und language-Datei ergänzen.
für Punkt 2, muss man an mehreren Stellen zusätzliche Anpassungen durchführen.
in der wetter.com.php muss man noch Projektname und ApiKey ergänzen.
Plugin: wetter.com.php (lib/weather/service/)
PHP-Code:
<?php
require_once '../../../lib/includes.php';
require_once const_path_system.'weather/weather.php';
require_once const_path_system.'class_cache.php';
/**
* This class generates a weather
*/
class weather_wetter extends weather
{
/**
* retrieve the content
*/
public function run()
{
$sForecastUrl = 'http://api.wetter.com/forecast/weather';
$sProjectName = 'projektname_wetter.com'; //ÄNDERN!!!
$sApiKey = 'key_von_der_wetter.com_seite'; //ÄNDERN!!!
$sCityCode = $this->location;
// Generieren der Checksumme, muss für jeden City Code neu berechnet werden
$sChecksum = md5($sProjectName . $sApiKey . $sCityCode);
$sForecastUrl .= '/city/' . $sCityCode;
$sForecastUrl .= '/project/' . $sProjectName;
$sForecastUrl .= '/cs/' . $sChecksum;
// api call
$cache = new class_cache('wetter.com_'.substr(strrchr($this->location, '/'), 1).'.xml');
if ($cache->hit())
$content = $cache->read();
else
{
$content = file_get_contents($sForecastUrl);
}
if (substr($content, 0, 5) == '<?xml')
{
// write cache
$cache->write($content);
$xml = simplexml_load_string($content);
$this->debug($xml);
// today
$this->data['city'] = (string)$xml->name;
// forecast
$i = 0;
$t = 0;
foreach ($xml->forecast->date as $day)
{
if ($i == 0)
{
$this->data['current']['date'] = (string)$day->attributes()->value;
$this->data['current']['conditions'] = (string)$day->w_txt;
$this->data['current']['wind'] = translate((string)$day->wd_txt, 'wetter.com').' '.$day->ws.' km/h';
$this->data['current']['icon'] = $this->icon((string)substr($day->w, 0, 1), $this->icon_sm);
$this->data['current']['temp'] = (float)$day->tx.'° / '.(float)$day->tn.'°';
$this->data['current']['more'] = 'Risiko: '.(string)$day->pc.'%';
foreach ($xml->forecast->date->time as $time)
{
if ($t < 4 )
{
$this->data['forecastday'][$t]['time'] = (string)$time->attributes()->value;
$this->data['forecastday'][$t]['conditions'] = (string)$time->w_txt;
$this->data['forecastday'][$t]['wind'] = translate((string)$day->wd_txt, 'wetter.com').' '.$day->ws.' km/h';
$this->data['forecastday'][$t]['icon'] = $this->icon((string)substr($time->w, 0, 1));
$this->data['forecastday'][$t]['temp'] = (float)$time->tx.'° / '.(float)$time->tn.'°';
$this->data['forecastday'][$t]['more'] = 'Risiko: '.(string)$time->pc.'%';
$t++;
}
}
}
if ($i < 5 )
{
$this->data['forecast'][$i]['date'] = (string)$day->attributes()->value;
$this->data['forecast'][$i]['conditions'] = (string)$day->w_txt;
$this->data['forecast'][$i]['wind'] = translate((string)$day->wd_txt, 'wetter.com').' '.$day->ws.' km/h';
$this->data['forecast'][$i]['icon'] = $this->icon((string)substr($day->w, 0, 1));
$this->data['forecast'][$i]['temp'] = (float)$day->tx.'° / '.(float)$day->tn.'°';
$this->data['forecast'][$i]['more'] = 'Risiko: '.(string)$day->pc.'%';
$i++;
}
}
}
else
$this->error('Weather: wetter.com', 'Read request failed!');
}
/*
* Icon-Mapper
*/
function icon($name, $sm = 'sun_')
{
$ret = '';
$icon[0] = $sm.'1'; //sonnig
$icon[1] = $sm.'2'; //leicht bewölkt
$icon[2] = $sm.'5'; //wolkig
$icon[3] = $sm.'5'; //bedeckt
$icon[4] = 'cloud_6'; //Nebel
$icon[5] = 'cloud_8'; //Sprühregen
$icon[6] = 'cloud_8'; //Regen
$icon[7] = 'cloud_13'; //Schnee
$icon[8] = 'cloud_10'; //Schauer
$icon[9] = 'cloud_10'; //Gewitter
$ret = $icon[$name];
return $ret;
}
}
// -----------------------------------------------------------------------------
// call the service
// -----------------------------------------------------------------------------
$service = new weather_wetter(array_merge($_GET, $_POST));
echo $service->json();
?>
Code:
// ----- wetter.com ----------------------------------------------------------------- $lang['wetter.com']['N'] = 'Nordwind'; $lang['wetter.com']['NO'] = 'Nordostwind'; $lang['wetter.com']['O'] = 'Ostwind'; $lang['wetter.com']['SO'] = 'Südostwind'; $lang['wetter.com']['S'] = 'Südwind'; $lang['wetter.com']['SW'] = 'Südwestwind'; $lang['wetter.com']['W'] = 'Westwind'; $lang['wetter.com']['NW'] = 'Nordwestwind';
für Punkt 2:
Ergänzungen in weather.html (widgets/)
HTML-Code:
{% macro forecastday(id, location) %} {% set uid = uid(page, id) %} {% if once('digiweather') %} <link rel="stylesheet" type="text/css" href="lib/weather/jdigiweather.css" /> {% endif %} <div id="{{ uid }}-forecastday" class="forecastday"> </div> <script type="text/javascript"> $('#{{ page }}').on('pagebeforeshow', function (event, ui) { $.getJSON('lib/weather/service/{{ config_weather_service }}.php?location={{ location|default(config_weather_location) }}', function (data) { var forecastday = ''; for (var i in data.forecastday) { forecastday += '<div class=\'time\'>' forecastday += '<div>' + data.forecastday[i].time + '</div>'; forecastday += '<img src="lib/weather/pics/' + data.forecastday[i].icon + '.png" alt="' + data.forecastday[i].conditions + '" title="' + data.forecastday[i].conditions + '" />'; forecastday += '<div>' + data.forecastday[i].temp + '</div>'; forecastday += '<div>' + data.forecastday[i].more + '</div>'; forecastday += '</div>'; } $('#{{ uid }}-forecastday').html(forecastday); }) .error(notify.json); }); </script> {% endmacro %}
Code:
.forecastday { height: 115px; } .forecastday .time { width: 25%; text-align: center; float: left; } .forecastday img { width: 80px; height: 51px; }
in jdigiweather.css noch von 25% auf 33% ändern:
Code:
.forecastweek .day { width: 33%;
Code:
.forecastweek { height: 115px; }
Diese id findet man in URL: Wetter aktuell in Berlin, Berlin, Deutschland auf wetter.com.
Kommentar