1
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-05-07 22:29:19 +00:00

fhem.pl: setreading command added

git-svn-id: https://svn.fhem.de/fhem/trunk@3765 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2013-08-22 15:13:44 +00:00
parent f2ea7c9768
commit 0333ea753b
4 changed files with 76 additions and 22 deletions

View File

@ -1,5 +1,6 @@
# Add changes at the top of the list. Keep it in ASCII # Add changes at the top of the list. Keep it in ASCII
- SVN - SVN
- feature: setreading command added
- change: DbLog: by using DbLog a new Attribute DbLogExclude will be propagated - change: DbLog: by using DbLog a new Attribute DbLogExclude will be propagated
to all Devices. DbLogExclue will work as regexp to exclude to all Devices. DbLogExclue will work as regexp to exclude
defined readings to log defined readings to log

View File

@ -56,6 +56,7 @@
<a href="#save">save</a> &nbsp; <a href="#save">save</a> &nbsp;
<a href="#set">set</a> &nbsp; <a href="#set">set</a> &nbsp;
<a href="#setdefaultattr">setdefaultattr</a> &nbsp; <a href="#setdefaultattr">setdefaultattr</a> &nbsp;
<a href="#setreading">setreading</a> &nbsp;
<a href="#setstate">setstate</a> &nbsp; <a href="#setstate">setstate</a> &nbsp;
<a href="#shutdown">shutdown</a> &nbsp; <a href="#shutdown">shutdown</a> &nbsp;
<a href="#sleep">sleep</a> &nbsp; <a href="#sleep">sleep</a> &nbsp;
@ -257,6 +258,7 @@ A line ending with \ will be concatenated with the next one, so long lines
<a href="#get">get</a>, <a href="#get">get</a>,
<a href="#list">list</a>, <a href="#list">list</a>,
<a href="#set">set</a>, <a href="#set">set</a>,
<a href="#setreading">setreading</a>,
<a href="#setstate">setstate</a>, <a href="#setstate">setstate</a>,
<a href="#trigger">trigger</a> <a href="#trigger">trigger</a>
can take a more complex device specification as argument, which will be can take a more complex device specification as argument, which will be
@ -936,15 +938,31 @@ A line ending with \ will be concatenated with the next one, so long lines
</ul> </ul>
<a name="setreading"></a>
<h3>setreading</h3>
<ul>
<code>setreading &lt;devspec&gt; &lt;reading&gt; &lt;value&gt;</code>
<br><br>
Set the reading &lt;reading&gt; for the device <code>&lt;name&gt;</code> to
&lt;value&gt; without sending out commands to the device, but triggering
events and eventMap/stateFormat transformations as usual.
<br><br>
Examples:
<ul>
setreading lamp state on
</ul>
</ul>
<a name="setstate"></a> <a name="setstate"></a>
<h3>setstate</h3> <h3>setstate</h3>
<ul> <ul>
<code>setstate &lt;devspec&gt; &lt;value&gt;</code> <code>setstate &lt;devspec&gt; &lt;value&gt;</code>
<br><br> <br><br>
Set the "STATE" for <code>&lt;name&gt;</code> as shown in paranthesis in the Set the STATE entry for the device specified by <code>&lt;devspec&gt;</code>,
<a href="#list">list</a> command which is used for displaying the device state in different frontends.
to <code>&lt;value&gt;</code> without sending any signals to the device No signals will be sent to the device, no events will be generated, and no
itself. This command is also used in the <a href="#statefile">statefile</a>. eventMap or stateFormat translation will be done either.
This command is also used in the <a href="#statefile">statefile</a>.
See the <a href="#devspec">Device specification</a> section for details on See the <a href="#devspec">Device specification</a> section for details on
&lt;devspec&gt;. &lt;devspec&gt;.
<br><br> <br><br>
@ -952,11 +970,6 @@ A line ending with \ will be concatenated with the next one, so long lines
<ul> <ul>
setstate lamp on setstate lamp on
</ul> </ul>
Note:
<ul>
<li>The statefile uses another version of this command, don't be surprised.
</li>
</ul>
</ul> </ul>

View File

@ -55,6 +55,7 @@
<a href="#save">save</a> &nbsp; <a href="#save">save</a> &nbsp;
<a href="#set">set</a> &nbsp; <a href="#set">set</a> &nbsp;
<a href="#setdefaultattr">setdefaultattr</a> &nbsp; <a href="#setdefaultattr">setdefaultattr</a> &nbsp;
<a href="#setreading">setreading</a> &nbsp;
<a href="#setstate">setstate</a> &nbsp; <a href="#setstate">setstate</a> &nbsp;
<a href="#shutdown">shutdown</a> &nbsp; <a href="#shutdown">shutdown</a> &nbsp;
<a href="#sleep">sleep</a> &nbsp; <a href="#sleep">sleep</a> &nbsp;
@ -981,26 +982,40 @@ Zeilen erstreckende Befehle, indem man keine \ am Zeilenende eingeben muss.</p>
</ul> </ul>
<a name="setreading"></a>
<h3>setreading</h3>
<ul>
<code>setstate &lt;devspec&gt; &lt;reading&gt; &lt;value&gt;</code>
<br><br>
Der Befehl setzt das Reading &lt;reading&gt; auf den Wert &lt;value&gt; ohne
Signale an das betroffene Ger&auml;t zu senden, generiert aber Ereignisse und
die &uuml;bliche eventMap und stateFormat Umwandlung wird auch
durchgef&uuml;hrt.
<br>
Siehe den Abschnitt &uuml;ber <a href="#devspec">Ger&auml;te-Spezifikation</a>
f&uuml;r Details der &lt;devspec&gt;.<br>
<br>
Beispiel:
<ul>
setreading lampe state on
</ul>
</ul>
<a name="setstate"></a> <a name="setstate"></a>
<h3>setstate</h3> <h3>setstate</h3>
<ul> <ul>
<code>setstate &lt;devspec&gt; &lt;value&gt;</code> <code>setstate &lt;devspec&gt; &lt;value&gt;</code>
<br><br> <br><br>
Der Befehl setzt den "STATUS&quot; f&uuml;r <code>&lt;name&gt;</code> , wie im Befehl Der Befehl setzt den STATE Eintrag des Ger&aauml;tes direkt, ohne Ereignisse zu
<a href="#list">list</a> beschrieben, auf den Wert <code>&lt;value&gt;</code> generieren oder ein Signal an das Ger&auml;t zu senden. Dieser Eintrag ist
ohne an das Ger&auml;t ein Signal zu senden. Dieser Befehl wird auch im <a href="#statefile">statefile</a> ma&szlig;gebend f&uuml;r die Status-Anzeige in diversen Frontends.
benutzt.<br> Dieser Befehl wird auch im <a href="#statefile">statefile</a> benutzt.<br>
Siehe den Abschnitt &uuml;ber <a href="#devspec">Ger&auml;te-Spezifikation</a> Siehe den Abschnitt &uuml;ber <a href="#devspec">Ger&auml;te-Spezifikation</a>
f&uuml;r Details der &lt;devspec&gt;.<br> f&uuml;r Details der &lt;devspec&gt;.<br>
<br> <br>
Examples: Beispiel:
<ul> <ul>
setstate lamp on setstate lampe An
</ul>
Note:
<ul>
<li>The statefile uses another version of this command, don't be surprised.
</li>
</ul> </ul>
</ul> </ul>
@ -1025,9 +1040,11 @@ Zeilen erstreckende Befehle, indem man keine \ am Zeilenende eingeben muss.</p>
<a name="trigger"></a> <a name="trigger"></a>
<h3>trigger</h3> <h3>trigger</h3>
<ul> <ul>
<code>trigger &lt;devspec&gt; &lt;state&gt;</code> <code>trigger &lt;devspec&gt; &lt;event&gt;</code>
<br><br> <br><br>
Triggert eine <a href="#notify">notify</a> Definition.<br> Generiert das Ereignis &lt;event&gt;, was z.Bsp. ein <a
href="#notify">notify</a> ansto&szlig;en kann, oder den FileLog zum
protokollieren dieser Zeile bewegen kann.<br>
Siehe den Abschnitt &uuml;ber <a href="#devspec">Ger&auml;te-Spezifikation</a> Siehe den Abschnitt &uuml;ber <a href="#devspec">Ger&auml;te-Spezifikation</a>
f&uuml;r Details der &lt;devspec&gt;.<br> f&uuml;r Details der &lt;devspec&gt;.<br>
<br> <br>

View File

@ -267,6 +267,8 @@ $readingFnAttributes = "event-on-change-reading event-on-update-reading ".
Hlp=>"[configfile],write the configfile and the statefile" }, Hlp=>"[configfile],write the configfile and the statefile" },
"set" => { Fn=>"CommandSet", "set" => { Fn=>"CommandSet",
Hlp=>"<devspec> <type dependent>,transmit code for <devspec>" }, Hlp=>"<devspec> <type dependent>,transmit code for <devspec>" },
"setreading" => { Fn=>"CommandSetReading",
Hlp=>"<devspec> <reading> <value>,set reading for <devspec>" },
"setstate"=> { Fn=>"CommandSetstate", "setstate"=> { Fn=>"CommandSetstate",
Hlp=>"<devspec> <state>,set the state shown in the command list" }, Hlp=>"<devspec> <state>,set the state shown in the command list" },
"setdefaultattr" => { Fn=>"CommandDefaultAttr", "setdefaultattr" => { Fn=>"CommandDefaultAttr",
@ -1595,6 +1597,27 @@ CommandDeleteReading($$)
return join("\n", @rets); return join("\n", @rets);
} }
sub
CommandSetReading($$)
{
my ($cl, $def) = @_;
my @a = split(" ", $def, 3);
return "Usage: setreading <name> <reading> <value>\n$namedef" if(@a != 3);
my @rets;
foreach my $sdev (devspec2array($a[0])) {
if(!defined($defs{$sdev})) {
push @rets, "Please define $sdev first";
next;
}
readingsSingleUpdate($defs{$sdev}, $a[1], $a[2], 1);
}
return undef;
}
############# #############
sub sub
PrintHash($$) PrintHash($$)