modifiers for userReadings

git-svn-id: https://fhem.svn.sourceforge.net/svnroot/fhem/trunk/fhem@2679 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
borisneubert
2013-02-10 09:57:02 +00:00
parent 5b587ea8f6
commit 920b59ed5e
4 changed files with 77 additions and 23 deletions

View File

@@ -384,18 +384,30 @@ A line ending with \ will be concatenated with the next one, so long lines
<a name="userReadings"></a>
<li>userReadings<br>
A comma-separated list of user-defined readings. Each definition has the form
<code>&lt;reading&gt; { &lt;perl code&gt; }</code>. After a single or bulk
A comma-separated list of definitions of user-defined readings. Each definition has the form
<code>&lt;reading&gt; [&lt;modifier&gt;] { &lt;perl code&gt; }</code>. After a single or bulk
readings update, the user-defined readings are set by evaluating the <a href="#perl">
perl code</a>
<code>{ &lt;perl code&gt; }</code> for all definitions and setting the value of
the respective user-defined reading <code>&lt;reading&gt;</code> to the result.<br><br>
Examples:<br>
<code>attr myPowerMeter userReadings power { ReadingsVal("myPowerMeter","count.A",0)/1250.0;; }</code><br>
<code>attr myMultiMeter userReadings power1 { ReadingsVal("myMultiMeter","count.A",0)/1250.0;; },
power2 { ReadingsVal("myMultiMeter","count.B",0)/1250.0;; }</code>
<code>attr myEnergyMeter userReadings energy { ReadingsVal("myEnergyMeter","counters.A",0)/1250.0;; }</code><br>
<code>attr myMultiMeter userReadings energy1 { ReadingsVal("myMultiMeter","counters.A",0)/1250.0;; },
energy2 { ReadingsVal("myMultiMeter","counters.B",0)/1250.0;; }</code>
<br><br>
<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>
</ul><br>
Example:<br>
<code>attr myPowerMeter userReadings power differential { ReadingsVal("myPowerMeter","counters.A",0)/1250.0;; }</code><br><br>
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!
</li><br>
</ul>
<br>