add hook example #20

Merged
marko merged 1 commits from patch-OpenWeatherMap into testing 2023-01-05 07:19:51 +00:00
4 changed files with 62 additions and 10 deletions
Showing only changes of commit 785f9d07b4 - Show all commits

View File

@ -1204,7 +1204,10 @@ sub Weather_CheckOptions {
<tr><td>apioptions</td><td><code>cachemaxage:&lt;cachemaxage&gt;</code><br>duration
in seconds to retrieve the forecast from the cache instead from the API</td>
<td><code>version:&lt;version&gt;</code> API version which should be used.
2.5 by default, 3.0 is still possible but only with an additional subscription</td></tr>
2.5 by default, 3.0 is still possible but only with an additional subscription</td>
<td><code>endpoint:onecall</code> only to test whether the API key which not
officially for onecall is not supported yet onecall via API version 2.5. IMPORTANT!!!
apioption version must not be set to 3.0</td></tr>
<tr><td>location</td><td><code>&lt;latitude,longitude&gt;</code><br>
geographic coordinates in degrees of the location for which the
weather is forecast; if missing, the values of the attributes
@ -1398,11 +1401,16 @@ sub Weather_CheckOptions {
<table>
<tr><td>API</td><td><code>OpenWeatherMapAPI</code></td></tr>
<tr><td>apioptions</td><td><code>cachemaxage:&lt;cachemaxage&gt;</code> Zeitdauer in
<tr>
<td>apioptions</td><td><code>cachemaxage:&lt;cachemaxage&gt;</code> Zeitdauer in
Sekunden, innerhalb derer die Wettervorhersage nicht neu abgerufen
sondern aus dem Cache zur&uuml;ck geliefert wird.</td>
<td><code>version:&lt;version&gt;</code> API Version welche verwendet werden soll.
Per Default 2.5, m&ouml;glich ist noch 3.0 aber nur mit Zusatzsubscription</td></tr>
Per Default 2.5, m&ouml;glich ist noch 3.0 aber nur mit Zusatzsubscription</td>
<td><code>endpoint:onecall</code> nur zum testen ob der API Key welcher nicht
offiziell für onecall ist nicht doch onecall über die API Version 2.5 unterst&uuml;tzt. WICHTIG!!!
apioption version darf nicht auf 3.0 gesetzt werden</td>
</tr>
<tr><td>location</td><td><code>&lt;latitude,longitude&gt;</code> Geographische Breite
und L&auml;nge des Ortes in Grad, f&uuml;r den das Wetter vorhergesagt wird.
Bei fehlender Angabe werden die Werte aus den gleichnamigen Attributen
@ -1542,7 +1550,7 @@ sub Weather_CheckOptions {
],
"release_status": "stable",
"license": "GPL_2",
"version": "v2.2.11",
"version": "v2.2.15",
"author": [
"Marko Oldenburg <fhemdevelopment@cooltux.net>"
],

View File

@ -1,4 +1,4 @@
UPD 2022-12-30_12:22:17 54815 FHEM/59_Weather.pm
UPD 2022-12-30_12:22:17 49883 lib/FHEM/APIs/Weather/DarkSkyAPI.pm
UPD 2022-12-30_12:22:17 32101 lib/FHEM/APIs/Weather/OpenWeatherMapAPI.pm
UPD 2023-01-02_09:25:12 36090 lib/FHEM/APIs/Weather/wundergroundAPI.pm
UPD 2023-01-05_08:17:10 55320 FHEM/59_Weather.pm
UPD 2023-01-04_16:37:24 49883 lib/FHEM/APIs/Weather/DarkSkyAPI.pm
UPD 2023-01-05_08:05:28 32255 lib/FHEM/APIs/Weather/OpenWeatherMapAPI.pm
UPD 2023-01-04_16:37:24 36090 lib/FHEM/APIs/Weather/wundergroundAPI.pm

41
hooks/pre-commit Executable file
View File

@ -0,0 +1,41 @@
#!/usr/bin/perl -w
use File::Basename;
use POSIX qw(strftime);
use strict;
my @filenames = ( 'FHEM/59_Weather.pm',
'lib/FHEM/APIs/Weather/DarkSkyAPI.pm',
'lib/FHEM/APIs/Weather/OpenWeatherMapAPI.pm',
'lib/FHEM/APIs/Weather/wundergroundAPI.pm',
);
my $controlsfile = 'controls_Weather.txt';
open(FH, ">$controlsfile") || return("Can't open $controlsfile: $!");
for my $filename (@filenames) {
my @statOutput = stat($filename);
if (scalar @statOutput != 13) {
printf 'error: stat has unexpected return value for ' . $filename . "\n";
next;
}
my $mtime = $statOutput[9];
my $date = POSIX::strftime("%Y-%m-%d", localtime($mtime));
my $time = POSIX::strftime("%H:%M:%S", localtime($mtime));
my $filetime = $date."_".$time;
my $filesize = $statOutput[7];
printf FH 'UPD ' . $filetime . ' ' . $filesize . ' ' .$filename . "\n";
}
close(FH);
system("git add $controlsfile");
print 'Create controls File succesfully' . "\n";
exit 0;

View File

@ -213,6 +213,8 @@ sub new {
$self->{apiversion} =
( $apioptions->{version} ? $apioptions->{version} : '2.5' );
$self->{endpointType} =
( $apioptions->{endpoint} ? $apioptions->{endpoint} : 'forecast' );
$self->{cached} = _CreateForecastRef($self);
@ -316,7 +318,8 @@ sub _RetrieveDataFromOpenWeatherMap {
timeout => 15,
self => $self,
endpoint => $self->{endpoint} eq 'none'
? ( $self->{apiversion} == 3.0 ? 'onecall' : 'weather' )
? ( $self->{apiversion} == 3.0
|| $self->{endpointType} eq 'onecall' ? 'onecall' : 'weather' )
: 'forecast',
callback => \&_RetrieveDataFinished,
};
@ -989,7 +992,7 @@ sub _strftimeWrapper {
"abstract": "Wetter API für OpenWeatherMap"
}
},
"version": "v3.0.12",
"version": "v3.0.15",
"author": [
"Marko Oldenburg <fhemdevelopment@cooltux.net>"
],