diff --git a/fhem/CHANGED b/fhem/CHANGED index 2f25fbd7e..7744d87da 100644 --- a/fhem/CHANGED +++ b/fhem/CHANGED @@ -1,5 +1,6 @@ # Add changes at the top of the list. Keep it in ASCII, and 80-char wide. # Do not insert empty lines here, update check depends on it. + - bugfix: 59_Weather: return missing perl modules message - bugfix: 59_Weather: fix Undefined subroutine - feature: 74_AutomowerConnect: rework detail view getter for MowerData and StatisticsData diff --git a/fhem/lib/FHEM/Core/Weather.pm b/fhem/lib/FHEM/Core/Weather.pm index 58951d83b..2408121ed 100644 --- a/fhem/lib/FHEM/Core/Weather.pm +++ b/fhem/lib/FHEM/Core/Weather.pm @@ -32,9 +32,18 @@ package FHEM::Core::Weather; use strict; use warnings; -use Time::HiRes qw(gettimeofday); +my $missingModul = ''; + +eval { use Time::HiRes qw /gettimeofday/; 1 } + or $missingModul .= "libtime-hires-perl "; + +eval { use Readonly; 1 } + or $missingModul .= "libreadonly-perl "; + +#use Time::HiRes qw(gettimeofday); use experimental qw /switch/; -use Readonly; + +#use Readonly; use FHEM::Meta; @@ -318,7 +327,6 @@ sub _ReturnWithError { } sub DeleteForecastreadings { - my $hash = shift; my $name = $hash->{NAME}; @@ -769,6 +777,12 @@ sub Define { return $@ unless ( FHEM::Meta::SetInternals($hash) ); use version 0.60; our $VERSION = FHEM::Meta::Get( $hash, 'version' ); + return + 'Cannot define Weather device. Please use "apt install ' + . ${missingModul} + . ' to install missing perl modules' + if ($missingModul); + my $usage = "syntax: define Weather [API=] [apikey=] [location=] [interval=] [lang=]";