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