2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-01-31 06:39:11 +00:00

fhem.pl: userreading name may contain -

git-svn-id: https://svn.fhem.de/fhem/trunk@5498 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2014-04-09 16:12:49 +00:00
parent bc2851ed36
commit 02102ff8af
3 changed files with 40 additions and 30 deletions

View File

@ -469,32 +469,38 @@ A line ending with \ will be concatenated with the next one, so long lines
energy1:counters.A { ReadingsVal("myMultiMeter","counters.A",0)/1250.0;; },
energy2:counters.B { ReadingsVal("myMultiMeter","counters.B",0)/1250.0;; }
</code></ul>
<code>&lt;modifier&gt;</code> can take one of these values:
<ul>
<li>none: the same as it would not have been given at all.</li>
<li>difference: the reading is set to the difference between the current
and the previously evaluated value.</li>
<li>differential: the reading is set to the difference between the
current and the previously evaluated value divided by the time in
seconds between the current and the previous evaluation. Granularity
of time is one second. No value is calculated if the time past is
below one second. Useful to calculate rates.</li>
<li>offset: if the current evaluated value is smaler than the previously
evaluated value the reading is incremented by the previous value.
the reading can then be used as an offset correct for a counter that
is reset for example due to a power loss.</li>
<li>monotonic: if the difference between the current and the previously
evaluated value is positive the reading is incremented by this difference.
this allows to derive a monotonic growing counter from an original counter
even if the original will be rest by a power loss</li>
</ul>
Example:<br>
<ul><code>attr myPowerMeter userReadings power
differential { ReadingsVal("myPowerMeter","counters.A",0)/1250.0;; }
</code></ul>
Note: user readings with modifiers difference and differential store the
calculated values internally. The user reading is set earliest at the
second evaluation. Beware of stale values when changing definitions!
<code>&lt;modifier&gt;</code> can take one of these values:
<ul>
<li>none: the same as it would not have been given at all.</li>
<li>difference: the reading is set to the difference between the current
and the previously evaluated value.</li>
<li>differential: the reading is set to the difference between the
current and the previously evaluated value divided by the time in
seconds between the current and the previous evaluation. Granularity
of time is one second. No value is calculated if the time past is
below one second. Useful to calculate rates.</li>
<li>offset: if the current evaluated value is smaler than the previously
evaluated value the reading is incremented by the previous value.
the reading can then be used as an offset correct for a counter that
is reset for example due to a power loss.</li>
<li>monotonic: if the difference between the current and the previously
evaluated value is positive the reading is incremented by this difference.
this allows to derive a monotonic growing counter from an original counter
even if the original will be rest by a power loss</li>
</ul>
Example:<br>
<ul><code>attr myPowerMeter userReadings power
differential { ReadingsVal("myPowerMeter","counters.A",0)/1250.0;; }
</code></ul>
Notes:
<ul>
<li>user readings with modifiers difference and differential store the
calculated values internally. The user reading is set earliest at the
second evaluation. Beware of stale values when changing
definitions!</li>
<li>the name of the defined Readings consists of alphanumeric characters
with underscore (_) and the minus (-) sign.</li>
</ul>
</li><br>
</ul>
<br>

View File

@ -508,9 +508,13 @@ Zeilen erstreckende Befehle, indem man keine \ am Zeilenende eingeben muss.</p>
attr myPowerMeter userReadings power differential
{ ReadingsVal("myPowerMeter","counters.A",0)/1250.0}
</code></ul>
Achtung: Falls difference oder differential spezifiziert ist, dann werden
f&uuml;r die Berechnung &auml;ltere Werte ben&ouml;tigt, d.h. der Wert wird
fr&uuml;hestens beim zweiten &Auml;nderung gesetzt.
Achtung:<ul>
<li>Falls difference oder differential spezifiziert ist, dann werden
f&uuml;r die Berechnung &auml;ltere Werte ben&ouml;tigt, d.h. der Wert
wird fr&uuml;hestens beim zweiten &Auml;nderung gesetzt.</li>
<li>der Name der definierten Readings besteht aus alphanumerischen
Zeichen, Unterstrich (_) und Minus-Zeichen (-).</li>
</ul>
</li><br>

View File

@ -2166,7 +2166,7 @@ CommandAttr($$)
my $arg= $a[2];
# matches myReading1[:trigger2] { codecode1 }
my $regexi= '\s*(\w+)(:\S*)?\s+((\w+)\s+)?({.*?})\s*';
my $regexi= '\s*([\w-]+)(:\S*)?\s+((\w+)\s+)?({.*?})\s*';
my $regexo= '^(' . $regexi . ')(,\s*(.*))*$';
#Log 1, "arg is $arg";