patch-specials #10

Merged
marko merged 10 commits from patch-specials into dev 2022-12-30 11:12:17 +00:00
2 changed files with 13 additions and 14 deletions
Showing only changes of commit 18fb5aaada - Show all commits

View File

@ -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},

View File

@ -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,
}
);