FHEM Forum

FHEM => fhem-users => Thema gestartet von: Guest am 29 September 2012, 10:43:59

Titel: 59_Weather.pm Bug?
Beitrag von: Guest am 29 September 2012, 10:43:59
Originally posted by: <email address deleted>

Boris, All,

I'm trying to get 59_Weather.pm live on OpenWRT (TP-Link WDR4300 router,
Alternate Attitude [latest bleeding edge] release).
It needed a lot of module which are not included into the distribution on
AR71xx architecture, so I grab them from the web and created a files
manually.

Now 59_Weather.pm compiling, running, but printing errors, which I assume
is not because of my downloaded perl modules.

In this function it dies on the line marked as bold:

*###################################
sub Weather_GetUpdate($)
{
  my ($hash) = @_;

  if(!$hash->{LOCAL}) {
    InternalTimer(gettimeofday()+$hash->{INTERVAL}, "Weather_GetUpdate",
$hash, 1);
  }

  readingsBeginUpdate($hash);

  Weather_RetrieveData($hash);

  my $temperature= $hash->{READINGS}{temperature}{VAL};
  my $humidity= $hash->{READINGS}{humidity}{VAL};
  my $wind= $hash->{READINGS}{wind}{VAL};
  my $val= "T: $temperature  H: $humidity  W: $wind";
  Log GetLogLevel($hash->{NAME},4), "Weather ". $hash->{NAME} . ": $val";
  $hash->{STATE}= $val;
  addEvent($hash, $val);
  readingsEndUpdate($hash, defined($hash->{LOCAL} ? 0 : 1)); # DoTrigger,
because sub is called by a timer instead of dispatch
     
  return 1;
}*

Error message in the log:

*Use of uninitialized value $temperature in concatenation (.) or string at
/usr/share/fhem/FHEM/59_Weather.pm line 329, <$fh> line 165.
Use of uninitialized value $humidity in concatenation (.) or string at
/usr/share/fhem/FHEM/59_Weather.pm line 329, <$fh> line 165.
Use of uninitialized value $wind in concatenation (.) or string at
/usr/share/fhem/FHEM/59_Weather.pm line 329, <$fh> line 165.

*It had right, the initialization and validity of variables
$temperature,$humidity,$wind is not checked.

My personal issue is the values are not getting from Google Weather, but
besides that could you please enhance the code with more safe value
handling?

(my fhem.cfg cut is:

*define Kulso Weather Debrecen,HU 1800 en
define FileLog_Kulso FileLog /var/log/fhem/Kulso-%Y.log Kulso
*
)

Please recommend.

Thank you in advance,

Szabi

--
To unsubscribe from this group, send email to
fhem-users+unsubscribe@googlegroups.com
Titel: Re: 59_Weather.pm Bug?
Beitrag von: Dr. Boris Neubert am 29 September 2012, 20:36:37
                                             

Dear Szabi,

Am 29.09.2012 10:43, schrieb Szabolcs Hodosi:
> Error message in the log:
>
> It had right, the initialization and validity of variables
> $temperature,$humidity,$wind is not checked.
>
You are right, they are not checked. Many sanity checks are absent in
code all over fhem since most of such checks are only needed in rare
cases as this one.
> (my fhem.cfg cut is:
>
> /define Kulso Weather Debrecen,HU 1800 en
> define FileLog_Kulso FileLog /var/log/fhem/Kulso-%Y.log Kulso
> /
> )
>
Well, the problem could be that you still use the old module which
relies on Google Weather and that had evaporated lately. But if you use
the current module (please see http://fhem.de/commandref.html#Weather)
then you have to update your definition to use the WOEID instead of the
name of your home town (go to http://weather.yahoo.com to find it out
for your location).

Kind regards
Boris

--
To unsubscribe from this group, send email to
fhem-users+unsubscribe@googlegroups.com