mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-01-31 06:39:11 +00:00
fhem.pl: timestamp-on-change-reading from justme1968 (Forum #52483)
git-svn-id: https://svn.fhem.de/fhem/trunk@11308 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
98f0e3eed0
commit
b82ecd7c4d
@ -478,6 +478,15 @@ attribute list if you want to know if a device supports these attributes. <br>
|
||||
</ol>
|
||||
<p>
|
||||
|
||||
<a name="timestamp-on-change-reading"></a>
|
||||
<li>timestamp-on-change-reading<br>
|
||||
The attribute takes a comma-separated list of readings. You may use regular
|
||||
expressions in that list. If set, the timestamps of the listed readings will
|
||||
not be changed if event-on-change-reading is also set and it would not create
|
||||
an event for this reading.
|
||||
</li>
|
||||
<p>
|
||||
|
||||
<a name="event-aggregator"></a>
|
||||
<li>event-aggregator</li>
|
||||
The primary uses of this attribute are to calculate (time-weighted) averages of
|
||||
|
@ -450,6 +450,15 @@ Gerät dokumentiert.
|
||||
"reading" auch in event-on-change-reading aufgelistet ist.</li>
|
||||
</ol>
|
||||
|
||||
<a name="timestamp-on-change-reading"></a>
|
||||
<li>timestamp-on-change-reading<br>
|
||||
Dieses Attribut enthält eine durch Kommata getrennte Liste von
|
||||
"readings". Wenn gesetzt, werden die Zeitstempel der gelisteten "readings"
|
||||
nicht aktualisiert wenn durch ein ebenfalls gesetztes event-on-change-reading
|
||||
für dieses "reading" kein Ereignis erzeugen würde.
|
||||
</li>
|
||||
<p>
|
||||
|
||||
<a name="event-aggregator"></a>
|
||||
<li>event-aggregator</li>
|
||||
The primary uses of this attribute are to calculate (time-weighted) averages of
|
||||
@ -686,7 +695,7 @@ Die folgenden lokalen Attribute werden von mehreren Geräten verwendet:
|
||||
<a name="cancel"></a>
|
||||
<h3>cancel</h3>
|
||||
<ul>
|
||||
<code>cancel [<id> [quiet]]</code>
|
||||
<code>cancel [<id> [quiet]]</code>
|
||||
<br><br>
|
||||
Entfernt ein benanntes <a href="#sleep">sleep</a>.
|
||||
|
||||
|
30
fhem/fhem.pl
30
fhem/fhem.pl
@ -308,7 +308,8 @@ $modules{Global}{AttrFn} = "GlobalAttr";
|
||||
|
||||
use vars qw($readingFnAttributes);
|
||||
$readingFnAttributes = "event-on-change-reading event-on-update-reading ".
|
||||
"event-aggregator event-min-interval stateFormat";
|
||||
"event-aggregator event-min-interval stateFormat ".
|
||||
"timestamp-on-change-reading";
|
||||
|
||||
|
||||
%cmds = (
|
||||
@ -3843,6 +3844,13 @@ readingsBeginUpdate($)
|
||||
$hash->{".attreour"} = \@a;
|
||||
}
|
||||
|
||||
my $attrtocr= AttrVal($name, "timestamp-on-change-reading", undef);
|
||||
if($attrtocr) {
|
||||
my @a = split(/,/,$attrtocr);
|
||||
$hash->{".attrtocr"} = \@a;
|
||||
}
|
||||
|
||||
|
||||
$hash->{CHANGED}= () if(!defined($hash->{CHANGED}));
|
||||
return $fmtDateTime;
|
||||
}
|
||||
@ -3959,6 +3967,7 @@ readingsEndUpdate($$)
|
||||
delete $hash->{".attreocr"};
|
||||
delete $hash->{".attraggr"};
|
||||
delete $hash->{".attrminint"};
|
||||
delete $hash->{".attrtocr"};
|
||||
|
||||
|
||||
# propagate changes
|
||||
@ -3993,15 +4002,18 @@ readingsBulkUpdate($$$@)
|
||||
}
|
||||
|
||||
# shorthand
|
||||
my $readings= $hash->{READINGS}{$reading};
|
||||
my $readings = $hash->{READINGS}{$reading};
|
||||
|
||||
if(!defined($changed)) {
|
||||
$changed = (substr($reading,0,1) ne "."); # Dont trigger dot-readings
|
||||
}
|
||||
$changed = 0 if($hash->{".ignoreEvent"});
|
||||
|
||||
# check for changes only if reading already exists
|
||||
if($changed && defined($readings)) {
|
||||
# if reading does not exist yet: fake entry to allow filtering
|
||||
$readings = { VAL => "" } if( !defined($readings) );
|
||||
|
||||
my $update_timestamp = 1;
|
||||
if($changed) {
|
||||
|
||||
# these flags determine if any of the "event-on" attributes are set
|
||||
my $attreocr = $hash->{".attreocr"};
|
||||
@ -4069,7 +4081,13 @@ readingsBulkUpdate($$$@)
|
||||
$changed = 1 if($eocrExists);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if( $attreocr ) {
|
||||
if( my $attrtocr = $hash->{".attrtocr"} ) {
|
||||
$update_timestamp = $changed if( $attrtocr && grep($reading =~ m/^$_$/, @{$attrtocr}) );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if($changed) {
|
||||
@ -4103,7 +4121,7 @@ readingsBulkUpdate($$$@)
|
||||
}
|
||||
|
||||
|
||||
setReadingsVal($hash, $reading, $value, $hash->{".updateTimestamp"});
|
||||
setReadingsVal($hash, $reading, $value, $hash->{".updateTimestamp"}) if( $update_timestamp );
|
||||
|
||||
my $rv = "$reading: $value";
|
||||
if($changed) {
|
||||
|
Loading…
Reference in New Issue
Block a user