move API files to lib/FHEM/APIs/Weather
This commit is contained in:
parent
0fbe1867bd
commit
18fb5aaada
@ -785,7 +785,7 @@ sub Weather_Define {
|
||||
# evaluate API options
|
||||
my ( $api, $apioptions ) = split( ',', $API, 2 );
|
||||
$apioptions = "" unless ( defined($apioptions) );
|
||||
eval { require $api . '.pm'; };
|
||||
eval { require 'FHEM/APIs/Weather/' . $api . '.pm'; };
|
||||
return "$name: cannot load API $api: $@" if ($@);
|
||||
|
||||
$hash->{NOTIFYDEV} = "global";
|
||||
@ -815,7 +815,7 @@ sub Weather_Define {
|
||||
readingsSingleUpdate( $hash, 'state', 'Initialized', 1 );
|
||||
Weather_LanguageInitialize( $hash->{LANG} );
|
||||
|
||||
my $apistring = $api . '::Weather';
|
||||
my $apistring = 'FHEM::APIs::Weather::' . $api;
|
||||
$hash->{fhem}->{api} = $apistring->new(
|
||||
{
|
||||
devName => $hash->{NAME},
|
||||
|
@ -31,25 +31,25 @@
|
||||
### Beispielaufruf
|
||||
# https://api.openweathermap.org/data/2.5/weather?lat=[lat]&lon=[long]&APPID=[API] Current
|
||||
# https://api.openweathermap.org/data/2.5/forecast?lat=[lat]&lon=[long]&APPID=[API] Forecast
|
||||
# https://api.openweathermap.org/data/2.5/onecall?lat=[lat]&lon=[long]&APPID=[API] Forecast
|
||||
# https://api.openweathermap.org/data/3.0/onecall?lat=[lat]&lon=[long]&APPID=[API] Current,Forecast
|
||||
# https://openweathermap.org/weather-conditions Icons und Conditions ID's
|
||||
|
||||
package OpenWeatherMapAPI;
|
||||
package FHEM::APIs::Weather::OpenWeatherMapAPI;
|
||||
use strict;
|
||||
use warnings;
|
||||
use FHEM::Meta;
|
||||
|
||||
FHEM::Meta::Load(__PACKAGE__);
|
||||
use version 0.50; our $VERSION = $::packages{OpenWeatherMapAPI}{META}{version};
|
||||
|
||||
package OpenWeatherMapAPI::Weather;
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use POSIX;
|
||||
use HttpUtils;
|
||||
use experimental qw /switch/;
|
||||
|
||||
my %META;
|
||||
my $ret = FHEM::Meta::getMetadata( __FILE__, \%META );
|
||||
return "$@" if ($@);
|
||||
return $ret if ($ret);
|
||||
$::packages{OpenWeatherMapAPI}{META} = \%META;
|
||||
use version 0.77; our $VERSION = $::packages{OpenWeatherMapAPI}{META}{version};
|
||||
|
||||
# use Data::Dumper;
|
||||
|
||||
# try to use JSON::MaybeXS wrapper
|
||||
@ -120,7 +120,7 @@ eval { use Readonly; 1 }
|
||||
# Readonly my $URL => 'https://api.openweathermap.org/data/2.5/';
|
||||
Readonly my $URL => 'https://api.openweathermap.org/data/';
|
||||
## URL . 'weather?' for current data
|
||||
## URL . 'onecall?' for forecast data
|
||||
## URL . 'onecall?' for current,forecast data
|
||||
|
||||
my %codes = (
|
||||
200 => 45,
|
||||
@ -881,8 +881,7 @@ sub _CreateForecastRef {
|
||||
long => $self->{long},
|
||||
apiMaintainer =>
|
||||
'Marko Oldenburg (<a href=https://forum.fhem.de/index.php?action=profile;u=13684>CoolTux</a>)',
|
||||
apiVersion =>
|
||||
version->parse( OpenWeatherMapAPI->VERSION() )->normal,
|
||||
apiVersion => version->parse( __PACKAGE__->VERSION() )->normal,
|
||||
}
|
||||
);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user