mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-07 06:48:43 +00:00
59_Weather: reject data with wrong units
git-svn-id: https://svn.fhem.de/fhem/trunk@11149 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
65cf5ad5ea
commit
efc5ed8bad
@ -143,6 +143,9 @@ sub Weather_RetrieveDataFinished($$$) {
|
|||||||
my $name= $hash->{NAME};
|
my $name= $hash->{NAME};
|
||||||
my $doTrigger= $argsRef->{blocking} ? 0 : 1;
|
my $doTrigger= $argsRef->{blocking} ? 0 : 1;
|
||||||
|
|
||||||
|
|
||||||
|
# the next 4 stanzas need to be rewritten, they are too repetitive for my taste
|
||||||
|
|
||||||
# check for error from retrieving data
|
# check for error from retrieving data
|
||||||
if($err) {
|
if($err) {
|
||||||
Log3 $hash, 3, "$name: $err";
|
Log3 $hash, 3, "$name: $err";
|
||||||
@ -195,6 +198,21 @@ sub Weather_RetrieveDataFinished($$$) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# units
|
||||||
|
my $units= YahooWeatherAPI_units($data); # units hash reference
|
||||||
|
if($units->{temperature} ne "C") {
|
||||||
|
$err= "wrong units received";
|
||||||
|
Log3 $hash, 3, "$name: $err";
|
||||||
|
readingsBeginUpdate($hash);
|
||||||
|
readingsBulkUpdate($hash, "lastError", $err);
|
||||||
|
readingsBulkUpdate($hash, "pubDateComment", $pubDateComment);
|
||||||
|
readingsBulkUpdate($hash, "pubDateRemote", $pubDate);
|
||||||
|
readingsBulkUpdate($hash, "validity", "stale");
|
||||||
|
readingsEndUpdate($hash, $doTrigger);
|
||||||
|
Weather_RearmTimer($hash, gettimeofday()+$hash->{INTERVAL});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
# from here on we assume that $data is complete and correct
|
# from here on we assume that $data is complete and correct
|
||||||
#
|
#
|
||||||
@ -240,7 +258,6 @@ sub Weather_RetrieveDataFinished($$$) {
|
|||||||
readingsBulkUpdate($hash, "validity", "up-to-date");
|
readingsBulkUpdate($hash, "validity", "up-to-date");
|
||||||
|
|
||||||
# units
|
# units
|
||||||
my $units= YahooWeatherAPI_units($data); # units hash reference
|
|
||||||
readingsBulkUpdate($hash, "unit_distance", $units->{distance});
|
readingsBulkUpdate($hash, "unit_distance", $units->{distance});
|
||||||
readingsBulkUpdate($hash, "unit_speed", $units->{speed});
|
readingsBulkUpdate($hash, "unit_speed", $units->{speed});
|
||||||
readingsBulkUpdate($hash, "unit_pressuree", $units->{pressure});
|
readingsBulkUpdate($hash, "unit_pressuree", $units->{pressure});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user