- corrected versions for fhem.pl and 59_Weather.pm
git-svn-id: https://svn.fhem.de/fhem/trunk@1256 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
@@ -63,7 +63,7 @@ sub Weather_UpdateReading($$$$) {
|
|||||||
if($reading eq "temp_c") {
|
if($reading eq "temp_c") {
|
||||||
readingsUpdate($hash,"temperature",$value); # additional entry for compatability
|
readingsUpdate($hash,"temperature",$value); # additional entry for compatability
|
||||||
}
|
}
|
||||||
if($key eq "wind_condition") {
|
if($reading eq "wind_condition") {
|
||||||
$value=~ s/.*?(\d+).*/$1/; # extract numeric
|
$value=~ s/.*?(\d+).*/$1/; # extract numeric
|
||||||
readingsUpdate($hash,"wind",$value); # additional entry for compatability
|
readingsUpdate($hash,"wind",$value); # additional entry for compatability
|
||||||
}
|
}
|
||||||
|
|||||||
28
fhem/fhem.pl
28
fhem/fhem.pl
@@ -2690,6 +2690,7 @@ readingsBeginUpdate($) {
|
|||||||
|
|
||||||
# get timestamp
|
# get timestamp
|
||||||
$hash->{helper}{updating}{latestUpdate}= TimeNow();
|
$hash->{helper}{updating}{latestUpdate}= TimeNow();
|
||||||
|
$hash->{CHANGED}= ();
|
||||||
|
|
||||||
return $hash->{helper}{updating}{latestUpdate};
|
return $hash->{helper}{updating}{latestUpdate};
|
||||||
|
|
||||||
@@ -2732,20 +2733,25 @@ readingsUpdate($$$) {
|
|||||||
defined($hash->{helper}{updating}) ||
|
defined($hash->{helper}{updating}) ||
|
||||||
die "fhem.pl: readingsUpdateReading: you must call readingsBeginUpdate first.";
|
die "fhem.pl: readingsUpdateReading: you must call readingsBeginUpdate first.";
|
||||||
|
|
||||||
# here we can add a lot of convenient functionality later:
|
# shorthand
|
||||||
# - create CHANGED events only for readings the user has subscribed to (e.g. see repchanged hash in 13_KS300.pm
|
my $readings= $hash->{READINGS};
|
||||||
# - create CHANGED events only for readings whose values have changed (are different from current entry)
|
|
||||||
|
|
||||||
|
# these flags determine if any of the "event-on" attributes are set;
|
||||||
|
my $attreocr= defined($attr{$name}{"event-on-change-reading"});
|
||||||
|
my $attreour= defined($attr{$name}{"event-on-update-reading"});
|
||||||
|
|
||||||
|
# these flags determine whether the reading is listed in any of the attributes
|
||||||
|
my $eocr= $attreocr && grep($_ eq $reading, split /,/,$attr{$name}{"event-on-change-reading"});
|
||||||
|
my $eour= $attreour && grep($_ eq $reading, split /,/,$attr{$name}{"event-on-update-reading"});
|
||||||
|
|
||||||
# determine if an event should be created
|
# determine if an event should be created
|
||||||
my $readings= $hash->{READINGS};
|
my $changed= !($attreocr || $attreour) # always create event if no attribute is set
|
||||||
my $changed= 1;
|
|| $eour # or if the reading is listed in event-on-change-reading
|
||||||
if(defined($attr{$name}{"event-on-change-reading"})) {
|
|| ($eocr && # or if the reading is listed in event-on-update-reading...
|
||||||
$changed= grep($_ eq $reading, split /,/,$attr{$name}{"event-on-change-reading"}) if($value eq $readings->{$reading}{VAL});
|
($value ne $readings->{$reading}{VAL})); # ...and its value has changed.
|
||||||
}
|
|
||||||
if(defined($attr{$name}{"event-on-update-reading"})) {
|
|
||||||
$changed= grep($_ eq $reading, split /,/,$attr{$name}{"event-on-update-reading"});
|
#Log 1, "changed!" if($changed); # DEBUG
|
||||||
}
|
|
||||||
|
|
||||||
# update reading 5.x
|
# update reading 5.x
|
||||||
$readings->{$reading}{TIME}= $hash->{helper}{updating}{latestUpdate};
|
$readings->{$reading}{TIME}= $hash->{helper}{updating}{latestUpdate};
|
||||||
|
|||||||
Reference in New Issue
Block a user