removed dead or deprecated code, updated commandref
This commit is contained in:
parent
975f741947
commit
9656d8da49
428
59_Weather.pm
428
59_Weather.pm
@ -152,46 +152,11 @@ sub degrees_to_direction($@) {
|
||||
return $directions_txt_i18n[$mod];
|
||||
}
|
||||
|
||||
###################################
|
||||
# sub Weather_RetrieveData($$) {
|
||||
# my ($name, $blocking) = @_;
|
||||
# my $hash = $defs{$name};
|
||||
#
|
||||
# # WOEID [WHERE-ON-EARTH-ID], go to http://weather.yahoo.com to find out
|
||||
# my $location= $hash->{LOCATION};
|
||||
# my $units= $hash->{UNITS};
|
||||
#
|
||||
# my %args= (
|
||||
# woeid => $location,
|
||||
# format => "json",
|
||||
# blocking => $blocking,
|
||||
# callbackFnRef => \&Weather_RetrieveDataFinished,
|
||||
# hash => $hash,
|
||||
# );
|
||||
#
|
||||
# # this needs to be finalized to use the APIOPTIONS
|
||||
# my $maxage= $hash->{fhem}->{allowCache} ? 600 : 0; # use cached data if allowed
|
||||
# $hash->{fhem}->{allowCache}= 1;
|
||||
# YahooWeatherAPI_RetrieveDataWithCache($maxage, \%args);
|
||||
#
|
||||
#
|
||||
# $hash->{fhem}->{api}->setRetrieveData;
|
||||
# }
|
||||
|
||||
sub Weather_ReturnWithError($$) {
|
||||
my ($hash, $responseRef)= @_;
|
||||
my $name= $hash->{NAME};
|
||||
|
||||
# $hash->{fhem}->{allowCache}= 0; # do not use cache on next try
|
||||
#
|
||||
# Log3 $hash, 3, "$name: $err";
|
||||
# readingsBeginUpdate($hash);
|
||||
# readingsBulkUpdate($hash, "lastError", $err);
|
||||
# readingsBulkUpdate($hash, "pubDateComment", $pubDateComment) if(defined($pubDateComment));
|
||||
# readingsBulkUpdate($hash, "pubDateRemote", $pubDate) if(defined($pubDate));
|
||||
# readingsBulkUpdate($hash, "validity", "stale");
|
||||
# readingsEndUpdate($hash, $doTrigger);
|
||||
|
||||
readingsBeginUpdate($hash);
|
||||
readingsBulkUpdate($hash, 'lastError', $responseRef->{status});
|
||||
|
||||
@ -207,132 +172,6 @@ sub Weather_ReturnWithError($$) {
|
||||
return;
|
||||
}
|
||||
|
||||
# sub Weather_RetrieveDataFinished($$$) {
|
||||
#
|
||||
# my ($argsRef, $err, $response)= @_;
|
||||
#
|
||||
# my $hash= $argsRef->{hash};
|
||||
# my $name= $hash->{NAME};
|
||||
# my $doTrigger= $argsRef->{blocking} ? 0 : 1;
|
||||
#
|
||||
# # check for error from retrieving data
|
||||
# return Weather_ReturnWithError($hash, $doTrigger, $err, undef, undef) if($err);
|
||||
#
|
||||
# # decode JSON data from Weather Channel
|
||||
# my $data;
|
||||
# ($err, $data)= YahooWeatherAPI_JSONReturnChannelData($response);
|
||||
# return Weather_ReturnWithError($hash, $doTrigger, $err, undef, undef) if($err);
|
||||
#
|
||||
# # check if up-to-date
|
||||
# my ($pubDateComment, $pubDate, $pubDateTs)= YahooWeatherAPI_pubDate($data);
|
||||
# return Weather_ReturnWithError($hash, $doTrigger, $pubDateComment, $pubDate, $pubDateComment)
|
||||
# unless(defined($pubDateTs));
|
||||
# my $ts= defined($hash->{READINGS}->{pubDateTs}) ? $hash->{READINGS}->{pubDateTs}->{VAL} : 0;
|
||||
# return Weather_ReturnWithError($hash, $doTrigger, "stale data received", $pubDate, $pubDateComment)
|
||||
# if($ts> $pubDateTs);
|
||||
#
|
||||
#
|
||||
# #
|
||||
# # from here on we assume that $data is complete and correct
|
||||
# #
|
||||
# my $lang= $hash->{LANG};
|
||||
#
|
||||
# my @YahooCodes_i18n= YahooWeatherAPI_getYahooCodes($lang);
|
||||
#
|
||||
# my $item= $data->{item};
|
||||
#
|
||||
# readingsBeginUpdate($hash);
|
||||
#
|
||||
# # delete some unused readings
|
||||
# delete($hash->{READINGS}->{temp_f}) if(defined($hash->{READINGS}->{temp_f}));
|
||||
# delete($hash->{READINGS}->{unit_distance}) if(defined($hash->{READINGS}->{unit_distance}));
|
||||
# delete($hash->{READINGS}->{unit_speed}) if(defined($hash->{READINGS}->{unit_speed}));
|
||||
# delete($hash->{READINGS}->{unit_pressuree}) if(defined($hash->{READINGS}->{unit_pressuree}));
|
||||
# delete($hash->{READINGS}->{unit_temperature}) if(defined($hash->{READINGS}->{unit_temperature}));
|
||||
#
|
||||
# # convert to metric units as far as required
|
||||
# my $isConverted= YahooWeatherAPI_ConvertChannelData($data);
|
||||
#
|
||||
# # housekeeping information
|
||||
# readingsBulkUpdate($hash, "lastError", "");
|
||||
# readingsBulkUpdate($hash, "pubDateComment", $pubDateComment);
|
||||
# readingsBulkUpdate($hash, "pubDate", $pubDate);
|
||||
# readingsBulkUpdate($hash, "pubDateRemote", $pubDate);
|
||||
# readingsBulkUpdate($hash, "pubDateTs", $pubDateTs);
|
||||
# readingsBulkUpdate($hash, "isConverted", $isConverted);
|
||||
# readingsBulkUpdate($hash, "validity", "up-to-date");
|
||||
#
|
||||
# # description
|
||||
# readingsBulkUpdate($hash, "description", $data->{description});
|
||||
#
|
||||
# # location
|
||||
# readingsBulkUpdate($hash, "city", $data->{location}->{city});
|
||||
# readingsBulkUpdate($hash, "region", $data->{location}->{region});
|
||||
# readingsBulkUpdate($hash, "country", $data->{location}->{country});
|
||||
# readingsBulkUpdate($hash, "lat", $item->{lat});
|
||||
# readingsBulkUpdate($hash, "long", $item->{long});
|
||||
#
|
||||
# # wind
|
||||
# my $windspeed= int($data->{wind}->{speed}+0.5);
|
||||
# readingsBulkUpdate($hash, "wind", $windspeed);
|
||||
# readingsBulkUpdate($hash, "wind_speed", $windspeed);
|
||||
# readingsBulkUpdate($hash, "wind_chill", $data->{wind}->{chill});
|
||||
# my $winddir= $data->{wind}->{direction};
|
||||
# readingsBulkUpdate($hash, "wind_direction", $winddir);
|
||||
# my $wdir= degrees_to_direction($winddir, @directions_txt_i18n);
|
||||
# readingsBulkUpdate($hash, "wind_condition", "Wind: $wdir $windspeed km/h");
|
||||
#
|
||||
# # atmosphere
|
||||
# my $humidity= $data->{atmosphere}->{humidity};
|
||||
# readingsBulkUpdate($hash, "humidity", $humidity);
|
||||
# my $pressure= $data->{atmosphere}->{pressure};
|
||||
# readingsBulkUpdate($hash, "pressure", $pressure);
|
||||
# readingsBulkUpdate($hash, "visibility", int($data->{atmosphere}->{visibility}+0.5));
|
||||
# my $pressure_trend= $data->{atmosphere}->{rising};
|
||||
# readingsBulkUpdate($hash, "pressure_trend", $pressure_trend);
|
||||
# readingsBulkUpdate($hash, "pressure_trend_txt", $pressure_trend_txt_i18n{$pressure_trend});
|
||||
# readingsBulkUpdate($hash, "pressure_trend_sym", $pressure_trend_sym{$pressure_trend});
|
||||
#
|
||||
# # condition
|
||||
# my $date= $item->{condition}->{date};
|
||||
# readingsBulkUpdate($hash, "current_date_time", $date);
|
||||
# readingsBulkUpdate($hash, "day_of_week", $wdays_txt_i18n{substr($date,0,3)});
|
||||
# my $code= $item->{condition}->{code};
|
||||
# readingsBulkUpdate($hash, "code", $code);
|
||||
# readingsBulkUpdate($hash, "condition", $YahooCodes_i18n[$code]);
|
||||
# readingsBulkUpdate($hash, "icon", $iconlist[$code]);
|
||||
# my $temp= $item->{condition}->{temp};
|
||||
# readingsBulkUpdate($hash, "temp_c", $temp);
|
||||
# readingsBulkUpdate($hash, "temperature", $temp);
|
||||
#
|
||||
# # forecast
|
||||
# my $forecast= $item->{forecast};
|
||||
# my $i= 0;
|
||||
# foreach my $fc (@{$forecast}) {
|
||||
# $i++;
|
||||
# my $f= "fc" . $i ."_";
|
||||
# readingsBulkUpdate($hash, $f . "day_of_week", $wdays_txt_i18n{$fc->{day}});
|
||||
# readingsBulkUpdate($hash, $f . "date", $fc->{date});
|
||||
# readingsBulkUpdate($hash, $f . "low_c", $fc->{low});
|
||||
# readingsBulkUpdate($hash, $f . "high_c", $fc->{high});
|
||||
# my $fccode= $fc->{code};
|
||||
# readingsBulkUpdate($hash, $f . "code", $fccode);
|
||||
# readingsBulkUpdate($hash, $f . "condition", $YahooCodes_i18n[$fccode]);
|
||||
# readingsBulkUpdate($hash, $f . "icon", $iconlist[$fccode]);
|
||||
# }
|
||||
#
|
||||
# #my $val= "T:$temp°C " . substr($status_items_txt_i18n{1}, 0, 1) .":$humidity% " . substr($status_items_txt_i18n{0}, 0, 1) . ":$windspeed km/h P:$pressure mbar";
|
||||
# my $val= "T: $temp H: $humidity W: $windspeed P: $pressure";
|
||||
# Log3 $hash, 4, "$name: $val";
|
||||
# readingsBulkUpdate($hash, "state", $val);
|
||||
#
|
||||
# readingsEndUpdate($hash, $doTrigger);
|
||||
#
|
||||
# Weather_RearmTimer($hash, gettimeofday()+$hash->{INTERVAL});
|
||||
# return;
|
||||
#
|
||||
# }
|
||||
|
||||
sub Weather_RetrieveCallbackFn($) {
|
||||
|
||||
my $name = shift;
|
||||
@ -565,49 +404,29 @@ sub Weather_Define($$) {
|
||||
|
||||
my ($hash, $def) = @_;
|
||||
|
||||
# define <name> Weather <location> [interval]
|
||||
# define MyWeather Weather "Maintal,HE" 3600
|
||||
my $usage= "syntax: define <name> Weather [API=<API>] [apikey=<apikey>] [location=<location>] [interval=<interval>] [lang=<lang>]";
|
||||
|
||||
# define <name> Weather location=<location> [API=<API>] [interval=<interval>] [lang=<lang>]
|
||||
|
||||
my $name;
|
||||
# defaults
|
||||
my $API="DarkSkyAPI,cachemaxage:600";
|
||||
my $location;
|
||||
my $apikey;
|
||||
my $interval = 3600;
|
||||
my $lang;
|
||||
|
||||
if($def =~ /=/) {
|
||||
|
||||
my $usage= "syntax: define <name> Weather location=<location> [API=<API>] [lang=<lang>]";
|
||||
|
||||
# parse parameters
|
||||
my ($arrayref, $hashref)= parseParams($def);
|
||||
my @a= @{$arrayref};
|
||||
my %h= %{$hashref};
|
||||
|
||||
# check minimum syntax
|
||||
return $usage unless(scalar @a == 2);
|
||||
$name= $a[0];
|
||||
my $name= $a[0];
|
||||
|
||||
#return $usage unless exists $h{location};
|
||||
$location= $h{location};
|
||||
$apikey = $h{apikey} if exists $h{apikey};
|
||||
$lang= $h{lang} if exists $h{lang};
|
||||
|
||||
my $location= $h{location} if exists $h{location};
|
||||
my $apikey = $h{apikey} if exists $h{apikey};
|
||||
my $lang= $h{lang} if exists $h{lang};
|
||||
$interval= $h{interval} if exists $h{interval};
|
||||
$API = $h{API} if exists $h{API};
|
||||
|
||||
} else {
|
||||
my @a = split("[ \t][ \t]*", $def);
|
||||
|
||||
return "syntax: define <name> Weather <location> [interval [en|de|nl|fr|pl|it]]"
|
||||
if(int(@a) < 3 && int(@a) > 5);
|
||||
|
||||
$name = $a[0];
|
||||
$location = $a[2];
|
||||
if(int(@a)>=4) { $interval= $a[3]; }
|
||||
if(int(@a)==5) { $lang= $a[4]; }
|
||||
|
||||
}
|
||||
|
||||
# evaluate API options
|
||||
my ($api,$apioptions)= split(',', $API, 2);
|
||||
$apioptions= "" unless(defined($apioptions));
|
||||
eval {
|
||||
@ -779,52 +598,95 @@ sub WeatherAsHtmlD($;$)
|
||||
|
||||
=pod
|
||||
=item device
|
||||
=item summary provides current weather condition and forecast (source: Yahoo Weather API)
|
||||
=item summary_DE stellt Wetterbericht und -vorhersage bereit (Quelle: Yahoo Weather API)
|
||||
=item summary provides current weather condition and forecast
|
||||
=item summary_DE stellt Wetterbericht und -vorhersage bereit
|
||||
=begin html
|
||||
|
||||
<a name="Weather"></a>
|
||||
<h3>Weather</h3>
|
||||
<ul>
|
||||
You need the JSON perl module. Use <code>apt-get install libjson-perl</code> on Debian and derivatives.<br><br>
|
||||
Note: you need the JSON perl module. Use <code>apt-get install
|
||||
libjson-perl</code> on Debian and derivatives.<p><p>
|
||||
|
||||
The Weather module works with various weather APIs:
|
||||
<ul>
|
||||
<li>DarkSky (<a href="https://darksky.net">web site</a>, standard)</li>
|
||||
<li>OpenWeatherMap (<a href="https://openweathermap.org/">web site)</a></li>
|
||||
</ul>
|
||||
<br>
|
||||
Such a virtual Weather device periodically gathers current and forecast
|
||||
weather conditions from the chosen weather API.<br><br>
|
||||
|
||||
<a name="Weatherdefine"></a>
|
||||
<b>Define</b>
|
||||
<b>Define</b><br><br>
|
||||
<ul>
|
||||
<code>define <name> Weather <location> [<interval> [<language>]]</code><br>
|
||||
<br>
|
||||
Defines a virtual device for weather forecasts.<br><br>
|
||||
<code>define <name> Weather [API=<API>[,<apiotions>]] [apikey=<apikey>]
|
||||
[location=<location>] [interval=<interval>] [lang=<lang>]</code><br><br>
|
||||
|
||||
A Weather device periodically gathers current and forecast weather conditions
|
||||
from the Yahoo Weather API.<br><br>
|
||||
|
||||
The parameter <code>location</code> is the WOEID (WHERE-ON-EARTH-ID), go to
|
||||
<a href="http://weather.yahoo.com">http://weather.yahoo.com</a> to find it out for your location.<br><br>
|
||||
The parameters have the following meanings:<br>
|
||||
|
||||
The optional parameter <code>interval</code> is the time between subsequent updates
|
||||
in seconds. It defaults to 3600 (1 hour).<br><br>
|
||||
<table border="1">
|
||||
<tr><td><code>API</code></td><td>name of the weather API, e.g. <code>DarkSkyAPI</code></td></tr>
|
||||
<tr><td><code>apioptions</code></td><td>indivual options for the chosen API</td></tr>
|
||||
<tr><td><code>apikey</code></td><td>key for the chosen API</td></tr>
|
||||
<tr><td><code>location</code></td><td>location for the weather forecast;
|
||||
e.g. coordinates, a town name or an ID, depending on the chosen API</td></tr>
|
||||
<tr><td><code>interval</code></td><td>duration in seconds between updates</td></tr>
|
||||
<tr><td><code>lang</code></td><td>language of the forecast: <code>de</code>,
|
||||
<code>en</code>, <code>pl</code>, <code>fr</code>, <code>it</code> or <code>nl</code></td></tr>
|
||||
</table>
|
||||
<p>
|
||||
|
||||
The optional language parameter may be one of
|
||||
<code>de</code>,
|
||||
<code>en</code>,
|
||||
<code>pl</code>,
|
||||
<code>fr</code>,
|
||||
<code>nl</code>,
|
||||
<code>it</code>,
|
||||
|
||||
It determines the natural language in which the forecast information appears.
|
||||
It defaults to <code>en</code>. If you want to set the language you also have to set the interval.<br><br>
|
||||
A very simple definition is:<br><br>
|
||||
<code>define <name> Weather apikey=<DarkSkyAPISecretKey></code><br><br>
|
||||
This uses the Dark Sky API with an individual key that you need to
|
||||
retrieve from the Dark Sky web site.<p><p>
|
||||
|
||||
Examples:
|
||||
<pre>
|
||||
define MyWeather Weather 673513
|
||||
define Forecast Weather 673513 1800
|
||||
define Forecast Weather apikey=987498ghjgf864
|
||||
define MyWeather Weather api=OpenWeatherMapAPI,cachemaxage:600 apikey=09878945fdskv876 location=52.4545,13.4545 interval=3600 language=de
|
||||
</pre>
|
||||
|
||||
The module provides four additional functions <code>WeatherAsHtml</code>, <code>WeatherAsHtmlV</code>, <code>WeatherAsHtmlH</code> and
|
||||
<code>WeatherAsHtmlD</code>. The former two functions are identical: they return the HTML code for a
|
||||
vertically arranged weather forecast. The third function returns the HTML code for a horizontally arranged weather forecast. The
|
||||
latter function dynamically picks the orientation depending on wether a smallscreen style is set (vertical layout) or not (horizontal layout). Each version accepts an additional paramter to limit the numer of icons to display.<br><br>
|
||||
|
||||
API-specific documentation follows.<p>
|
||||
|
||||
<b>Dark Sky</b><p>
|
||||
|
||||
<table border="1">
|
||||
<tr><td>API</td><td><code>DarkSkyAPI</code></td></tr>
|
||||
<tr><td>apioptions</td><td><code>cachemaxage=<cachemaxage></code><br>duration
|
||||
in seconds to retrieve the forecast from the cache instead from the API</td></tr>
|
||||
<tr><td>location</td><td><code><latitude,longitude></code><br>
|
||||
geographic coordinates in degrees of the location for which the
|
||||
weather is forecast; if missing, the values of the attributes
|
||||
of the <code>global</code> device are taken, if these exist.</td></tr>
|
||||
</table>
|
||||
<p><p>
|
||||
|
||||
<b>OpenWeatherMap</b><p>
|
||||
|
||||
<table border="1">
|
||||
<tr><td>API</td><td><code>OpenWeatherMapAPI</code></td></tr>
|
||||
<tr><td>apioptions</td><td><code>cachemaxage=<cachemaxage></code><br>duration
|
||||
in seconds to retrieve the forecast from the cache instead from the API</td></tr>
|
||||
<tr><td>location</td><td><code><latitude,longitude></code><br>
|
||||
geographic coordinates in degrees of the location for which the
|
||||
weather is forecast; if missing, the values of the attributes
|
||||
of the <code>global</code> device are taken, if these exist.</td></tr>
|
||||
</table>
|
||||
<p><p>
|
||||
|
||||
The module provides four additional functions <code>WeatherAsHtml</code>,
|
||||
<code>WeatherAsHtmlV</code>, <code>WeatherAsHtmlH</code> and
|
||||
<code>WeatherAsHtmlD</code>. The former two functions are identical:
|
||||
they return the HTML code for a vertically arranged weather forecast.
|
||||
The third function returns the HTML code for a horizontally arranged
|
||||
weather forecast. The latter function dynamically picks the orientation
|
||||
depending on wether a smallscreen style is set (vertical layout) or not
|
||||
(horizontal layout). Each version accepts an additional paramter
|
||||
to limit the numer of icons to display.<br><br>
|
||||
Example:
|
||||
<pre>
|
||||
define MyWeatherWeblink weblink htmlCode { WeatherAsHtmlH("MyWeather") }
|
||||
@ -852,6 +714,7 @@ sub WeatherAsHtmlD($;$)
|
||||
Valid readings and their meaning (? can be one of 1, 2, 3, 4, 5 and stands
|
||||
for today, tomorrow, etc.):<br>
|
||||
<table>
|
||||
<tr><td>.locense</td><td>license of the API provider, if available</td></tr>
|
||||
<tr><td>city</td><td>name of town returned for location</td></tr>
|
||||
<tr><td>code</td><td>current condition code</td></tr>
|
||||
<tr><td>condition</td><td>current condition</td></tr>
|
||||
@ -879,13 +742,9 @@ sub WeatherAsHtmlD($;$)
|
||||
<tr><td>wind_speed</td><td>same as wind</td></tr>
|
||||
</table>
|
||||
<br>
|
||||
The following readings help to identify whether a workaround has kicked in to avoid the retrieval of
|
||||
stale data from the remote server:
|
||||
<table>
|
||||
<tr><td>pubDate</td><td>publication time of forecast for current set of readings</td></tr>
|
||||
<tr><td>pubDateRemote</td><td>publication time of forecast as seen on remote server</td></tr>
|
||||
<tr><td>validity</td><td>stale, if publication time as seen on remote server is before that of current set of readings</td></tr>
|
||||
</table>
|
||||
Depending on the chosen API, other readings can be shown as well.
|
||||
The meaning of these readings can be determined from the API provider's
|
||||
documentation.
|
||||
|
||||
</ul>
|
||||
<br>
|
||||
@ -907,47 +766,101 @@ sub WeatherAsHtmlD($;$)
|
||||
<a name="Weather"></a>
|
||||
<h3>Weather</h3>
|
||||
<ul>
|
||||
Es wird das Perl-Modul JSON benötigt. Mit <code>apt-get install libjson-perl</code> kann es unter Debian und Derivaten installiert werden.<br>
|
||||
Das Modul arbeitet mit so genanneten API Modulen zusammen. Welche API Module es gibt wird hier bald stehen<br><br>
|
||||
Hinweis: es wird das Perl-Modul JSON benötigt. Mit <code>apt-get install
|
||||
libjson-perl</code> kann es unter Debian und Derivaten installiert
|
||||
werden.<p><p>
|
||||
|
||||
Das Weather-Modul arbeitet mit verschiedenen Wetter-APIs zusammen:
|
||||
<ul>
|
||||
<li>DarkSky (<a href="https://darksky.net">Webseite</a>, Standard)</li>
|
||||
<li>OpenWeatherMap (<a href="https://openweathermap.org/">Webseite)</a></li>
|
||||
</ul>
|
||||
<br>
|
||||
Eine solche virtuelle Wetterstation sammelt periodisch aktuelle Wetterdaten
|
||||
und Wettervorhersagen aus dem verwendeten API.<br><br>
|
||||
|
||||
|
||||
<a name="Weatherdefine"></a>
|
||||
<b>Define</b>
|
||||
<b>Define</b><br><br>
|
||||
<ul>
|
||||
Eine ganz einfache Definition ist:<br>
|
||||
<code>define <name> Weather</code><br>
|
||||
Bei dieser Definition wird die Standard API von DarkSky verwendet. Diese benötigt einen APIKEY. Folglich muss die Definition entsprechend erweitert werden.<br>
|
||||
<code>define <name> Weather apikey=[APIKEY]</code><br>
|
||||
<br>
|
||||
Was eine API als Übergabeparameter benötigt ist der jeweiligen API Modulbeschreibung zu entnehmen.<br>
|
||||
Die Default API benötigt noch eine location. Also eine Angabe zur Position Deines Ortes (Latitude und Longitude). Diese Informationen werden aus dem globalen Device gelesen, sofern sie nicht mittels der Option location= mit übergeben werden.<br>
|
||||
Es macht generell Sinn diese Informationen eben so wie die Sprache im globalen Device als Attribut zu hinterlegen.<br>
|
||||
Der maximale Aufbau einer Definition lautet:<br>
|
||||
<code>define <name> Weather [<API=OpenWeatherMapAPI:[APIOPTIONEN]>] [<location=[LATITUDE,LONGITUDE] oder ID>] [<interval=INTERVAL>] [<language=LANGUAGE>]</code><br>
|
||||
Die Angaben in [ ] sind immer als Optional an zu sehen. Ein apikey kann genauso gut ein OAuth Token oder ähnliche Authentifizierungmöglichkeit sein.
|
||||
<br>
|
||||
Eine solche virtuelle Wetterstation sammelt periodisch aktuelle und zukünftige Wetterdaten aus dem angegebenen oder standard API-Modul.<br><br>
|
||||
<code>define <name> Weather [API=<API>[,<apiotions>]] [apikey=<apikey>]
|
||||
[location=<location>] [interval=<interval>] [lang=<lang>]</code><br><br>
|
||||
|
||||
Der optionale Parameter <code>location</code> kan der Locationen ID des Anbieters vom API Modul entsprechen, oder im einfachsten Fall der Angabe von Latitude,Longitude.<br>
|
||||
Steht Latitude und Longitude im global Device und wird von der API benötigt ist eine Angabe nicht nötig<br><br>
|
||||
Die Parameter haben die folgende Bedeutung:<br>
|
||||
|
||||
Der optionale Parameter <code>interval</code> gibt die Dauer in Sekunden zwischen den einzelnen Aktualisierungen der Wetterdaten an. Der Standardwert ist 3600 (1 Stunde). Wird kein Wert angegeben, gilt der Standardwert.<br><br>
|
||||
<table border="1">
|
||||
<tr><td><code>API</code></td><td>Name des Wetter-APIs, z.B. <code>DarkSkyAPI</code></td></tr>
|
||||
<tr><td><code>apioptions</code></td><td>Individuelle Optionen für das gewählte API</td></tr>
|
||||
<tr><td><code>apikey</code></td><td>Schlüssel für das gewählte API</td></tr>
|
||||
<tr><td><code>location</code></td><td>Ort, für den das Wetter vorhergesagt wird.
|
||||
Abhängig vom API z.B. die Koordinaten, ein Ortsname oder eine ID.</td></tr>
|
||||
<tr><td><code>interval</code></td><td>Dauer in Sekunden zwischen den einzelnen
|
||||
Aktualisierungen der Wetterdaten</td></tr>
|
||||
<tr><td><code>lang</code></td><td>Sprache der Wettervorhersage: <code>de</code>,
|
||||
<code>en</code>, <code>pl</code>, <code>fr</code>, <code>it</code> oder <code>nl</code></td></tr>
|
||||
</table>
|
||||
<p>
|
||||
|
||||
Der optionale Parameter für die möglichen Sprachen darf einen der folgende Werte annehmen: <code>de</code>, <code>en</code>, <code>pl</code>, <code>fr</code> oder <code>nl</code>. Er bezeichnet die natürliche Sprache, in der die Wetterinformationen dargestellt werden. Der Standardwert ist <code>en</code>. Wird für die Sprache kein Wert angegeben, gilt der Standardwert.<br><br>
|
||||
Eine ganz einfache Definition ist:<br><br>
|
||||
<code>define <name> Weather apikey=<DarkSkyAPISecretKey></code><br><br>
|
||||
|
||||
Bei dieser Definition wird die API von Dark Sky verwendet mit einem
|
||||
individuellen Schlüssel, den man sich auf der Webseite von Dark Sky
|
||||
beschaffen muss.<p><p>
|
||||
|
||||
Beispiele:
|
||||
<pre>
|
||||
define MyWeather Weather api=OpenWeatherMapAPI,cachemaxage:600 apikey=09878945fdskv876 location=52.4545,13.4545 interval=3600 language=de
|
||||
define Forecast Weather apikey=987498ghjgf864
|
||||
define MyWeather Weather api=OpenWeatherMapAPI,cachemaxage:600 apikey=09878945fdskv876 location=52.4545,13.4545 interval=3600 language=de
|
||||
</pre>
|
||||
|
||||
Das Modul unterstützt zusätzlich vier verschiedene Funktionen <code>WeatherAsHtml</code>, <code>WeatherAsHtmlV</code>, <code>WeatherAsHtmlH</code> und <code>WeatherAsHtmlD</code>. Die ersten beiden Funktionen sind identisch: sie erzeugen den HTML-Code für eine vertikale Darstellung des Wetterberichtes. Die dritte Funktion liefert den HTML-Code für eine horizontale Darstellung des Wetterberichtes. Die letztgenannte Funktion wählt automatisch eine Ausrichtung, die abhängig davon ist, ob ein Smallcreen Style ausgewählt ist (vertikale Darstellung) oder nicht (horizontale Darstellung). Alle vier Funnktionen akzeptieren einen zusätzlichen optionalen Paramter um die Anzahl der darzustellenden Icons anzugeben.<br><br>
|
||||
Es folgt die API-spezifische Dokumentation.<p>
|
||||
|
||||
<b>Dark Sky</b><p>
|
||||
|
||||
<table border="1">
|
||||
<tr><td>API</td><td><code>DarkSkyAPI</code></td></tr>
|
||||
<tr><td>apioptions</td><td><code>cachemaxage=<cachemaxage></code><br>Zeitdauer in
|
||||
Sekunden, innerhalb derer die Wettervorhersage nicht neu abgerufen
|
||||
sondern aus dem Cache zurück geliefert wird.</td></tr>
|
||||
<tr><td>location</td><td><code><latitude,longitude></code><br> Geographische Breite
|
||||
und Länge des Ortes in Grad, für den das Wetter vorhergesagt wird.
|
||||
Bei fehlender Angabe werden die Werte aus den gleichnamigen Attributen
|
||||
des <code>global</code>-Device genommen, sofern vorhanden.</td></tr>
|
||||
</table>
|
||||
<p><p>
|
||||
|
||||
<b>OpenWeatherMap</b><p>
|
||||
|
||||
<table border="1">
|
||||
<tr><td>API</td><td><code>OpenWeatherMapAPI</code></td></tr>
|
||||
<tr><td>apioptions</td><td><code>cachemaxage=<cachemaxage></code> Zeitdauer in
|
||||
Sekunden, innerhalb derer die Wettervorhersage nicht neu abgerufen
|
||||
sondern aus dem Cache zurück geliefert wird.</td></tr>
|
||||
<tr><td>location</td><td><code><latitude,longitude></code> Geographische Breite
|
||||
und Länge des Ortes in Grad, für den das Wetter vorhergesagt wird.
|
||||
Bei fehlender Angabe werden die Werte aus den gleichnamigen Attributen
|
||||
des <code>global</code>-Device genommen, sofern vorhanden.</td></tr>
|
||||
</table>
|
||||
<p><p>
|
||||
|
||||
Das Modul unterstützt zusätzlich vier verschiedene Funktionen
|
||||
<code>WeatherAsHtml</code>, <code>WeatherAsHtmlV</code>,
|
||||
<code>WeatherAsHtmlH</code> und <code>WeatherAsHtmlD</code>.
|
||||
Die ersten beiden Funktionen sind identisch: sie erzeugen
|
||||
den HTML-Kode für eine vertikale Darstellung des Wetterberichtes.
|
||||
Die dritte Funktion liefert den HTML-Code für eine horizontale
|
||||
Darstellung des Wetterberichtes. Die letztgenannte Funktion wählt
|
||||
automatisch eine Ausrichtung, die abhängig davon ist, ob ein
|
||||
Smallcreen Style ausgewählt ist (vertikale Darstellung) oder
|
||||
nicht (horizontale Darstellung). Alle vier Funnktionen akzeptieren
|
||||
einen zusätzlichen optionalen Paramter um die Anzahl der
|
||||
darzustellenden Icons anzugeben.<br><br>
|
||||
Beispiel:
|
||||
<pre>
|
||||
define MyWeatherWeblink weblink htmlCode { WeatherAsHtmlH("MyWeather") }
|
||||
</pre>
|
||||
|
||||
|
||||
</ul>
|
||||
<br>
|
||||
|
||||
@ -956,7 +869,9 @@ sub WeatherAsHtmlD($;$)
|
||||
<ul>
|
||||
<code>set <name> update</code><br><br>
|
||||
|
||||
Erzwingt eine Abfrage der Wetterdaten. Die darauffolgende Abfrage wird gemäß dem eingestellten Intervall <code>interval</code> Sekunden später durchgeführt.<br><br>
|
||||
Erzwingt eine Abfrage der Wetterdaten. Die darauffolgende Abfrage
|
||||
wird gemäß dem eingestellten
|
||||
Intervall <code>interval</code> Sekunden später durchgeführt.<br><br>
|
||||
</ul>
|
||||
<br>
|
||||
|
||||
@ -967,8 +882,8 @@ sub WeatherAsHtmlD($;$)
|
||||
|
||||
Gültige ausgelesene Daten (readings) und ihre Bedeutung (das ? kann einen der Werte 1, 2, 3 , 4 oder 5 annehmen und steht für heute, morgen, übermorgen etc.):<br><br>
|
||||
<table>
|
||||
<tr><td>.licens</td><td>Zeigt die Lizense des entsprechenden API Anbieters an, sofern vorhanden</td></tr>
|
||||
<tr><td>city</td><td>Name der Stadt, der aufgrund der location übermittelt wird</td></tr>
|
||||
<tr><td>.license</td><td>Lizenz des jeweiligen API-Anbieters, sofern vorhanden</td></tr>
|
||||
<tr><td>city</td><td>Name der Stadt, der für die location übermittelt wird</td></tr>
|
||||
<tr><td>code</td><td>Code für die aktuellen Wetterverhältnisse</td></tr>
|
||||
<tr><td>condition</td><td>aktuelle Wetterverhältnisse</td></tr>
|
||||
<tr><td>current_date_time</td><td>Zeitstempel der letzten Aktualisierung der Wetterdaten vom Server</td></tr>
|
||||
@ -992,14 +907,17 @@ sub WeatherAsHtmlD($;$)
|
||||
<tr><td>validity</td><td>stale, wenn der Veröffentlichungszeitpunkt auf dem entfernten Server vor dem Zeitpunkt der aktuellen Daten (readings) liegt</td></tr>
|
||||
</table>
|
||||
<br>
|
||||
Je nach verwendeter API ist es durchaus möglich das weitere Readings geschrieben werden. Die Bedeutung dieser Readings kann man der API Beschreibung des Anbieters entnehmen.
|
||||
Je nach verwendeter API ist es durchaus möglich, dass weitere
|
||||
Readings geschrieben werden. Die Bedeutung dieser Readings kann man
|
||||
der API-Beschreibung des Anbieters entnehmen.
|
||||
</ul>
|
||||
<br>
|
||||
|
||||
<a name="Weatherattr"></a>
|
||||
<b>Attribute</b>
|
||||
<ul>
|
||||
<li>disable: stellt die Abfrage der Wetterdaten ab - der Timer läft gemäß Plan doch es werden keine Daten vom
|
||||
<li>disable: stellt die Abfrage der Wetterdaten ab - der Timer läft
|
||||
gemäß Plan doch es werden keine Daten vom
|
||||
API angefordert.</li>
|
||||
<li><a href="#readingFnAttributes">readingFnAttributes</a></li>
|
||||
</ul>
|
||||
|
Loading…
Reference in New Issue
Block a user