mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-01-31 06:39:11 +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:
parent
f2ea7c9768
commit
0333ea753b
@ -1,5 +1,6 @@
|
||||
# Add changes at the top of the list. Keep it in ASCII
|
||||
- SVN
|
||||
- feature: setreading command added
|
||||
- change: DbLog: by using DbLog a new Attribute DbLogExclude will be propagated
|
||||
to all Devices. DbLogExclue will work as regexp to exclude
|
||||
defined readings to log
|
||||
|
@ -56,6 +56,7 @@
|
||||
<a href="#save">save</a>
|
||||
<a href="#set">set</a>
|
||||
<a href="#setdefaultattr">setdefaultattr</a>
|
||||
<a href="#setreading">setreading</a>
|
||||
<a href="#setstate">setstate</a>
|
||||
<a href="#shutdown">shutdown</a>
|
||||
<a href="#sleep">sleep</a>
|
||||
@ -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="#list">list</a>,
|
||||
<a href="#set">set</a>,
|
||||
<a href="#setreading">setreading</a>,
|
||||
<a href="#setstate">setstate</a>,
|
||||
<a href="#trigger">trigger</a>
|
||||
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>
|
||||
|
||||
|
||||
<a name="setreading"></a>
|
||||
<h3>setreading</h3>
|
||||
<ul>
|
||||
<code>setreading <devspec> <reading> <value></code>
|
||||
<br><br>
|
||||
Set the reading <reading> for the device <code><name></code> to
|
||||
<value> 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>
|
||||
<h3>setstate</h3>
|
||||
<ul>
|
||||
<code>setstate <devspec> <value></code>
|
||||
<br><br>
|
||||
Set the "STATE" for <code><name></code> as shown in paranthesis in the
|
||||
<a href="#list">list</a> command
|
||||
to <code><value></code> without sending any signals to the device
|
||||
itself. This command is also used in the <a href="#statefile">statefile</a>.
|
||||
Set the STATE entry for the device specified by <code><devspec></code>,
|
||||
which is used for displaying the device state in different frontends.
|
||||
No signals will be sent to the device, no events will be generated, and no
|
||||
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
|
||||
<devspec>.
|
||||
<br><br>
|
||||
@ -952,11 +970,6 @@ A line ending with \ will be concatenated with the next one, so long lines
|
||||
<ul>
|
||||
setstate lamp on
|
||||
</ul>
|
||||
Note:
|
||||
<ul>
|
||||
<li>The statefile uses another version of this command, don't be surprised.
|
||||
</li>
|
||||
</ul>
|
||||
</ul>
|
||||
|
||||
|
||||
|
@ -55,6 +55,7 @@
|
||||
<a href="#save">save</a>
|
||||
<a href="#set">set</a>
|
||||
<a href="#setdefaultattr">setdefaultattr</a>
|
||||
<a href="#setreading">setreading</a>
|
||||
<a href="#setstate">setstate</a>
|
||||
<a href="#shutdown">shutdown</a>
|
||||
<a href="#sleep">sleep</a>
|
||||
@ -981,26 +982,40 @@ Zeilen erstreckende Befehle, indem man keine \ am Zeilenende eingeben muss.</p>
|
||||
</ul>
|
||||
|
||||
|
||||
<a name="setreading"></a>
|
||||
<h3>setreading</h3>
|
||||
<ul>
|
||||
<code>setstate <devspec> <reading> <value></code>
|
||||
<br><br>
|
||||
Der Befehl setzt das Reading <reading> auf den Wert <value> ohne
|
||||
Signale an das betroffene Gerät zu senden, generiert aber Ereignisse und
|
||||
die übliche eventMap und stateFormat Umwandlung wird auch
|
||||
durchgeführt.
|
||||
<br>
|
||||
Siehe den Abschnitt über <a href="#devspec">Geräte-Spezifikation</a>
|
||||
für Details der <devspec>.<br>
|
||||
<br>
|
||||
Beispiel:
|
||||
<ul>
|
||||
setreading lampe state on
|
||||
</ul>
|
||||
</ul>
|
||||
|
||||
<a name="setstate"></a>
|
||||
<h3>setstate</h3>
|
||||
<ul>
|
||||
<code>setstate <devspec> <value></code>
|
||||
<br><br>
|
||||
Der Befehl setzt den "STATUS" für <code><name></code> , wie im Befehl
|
||||
<a href="#list">list</a> beschrieben, auf den Wert <code><value></code>
|
||||
ohne an das Gerät ein Signal zu senden. Dieser Befehl wird auch im <a href="#statefile">statefile</a>
|
||||
benutzt.<br>
|
||||
Der Befehl setzt den STATE Eintrag des Ger&aauml;tes direkt, ohne Ereignisse zu
|
||||
generieren oder ein Signal an das Gerät zu senden. Dieser Eintrag ist
|
||||
maßgebend für die Status-Anzeige in diversen Frontends.
|
||||
Dieser Befehl wird auch im <a href="#statefile">statefile</a> benutzt.<br>
|
||||
Siehe den Abschnitt über <a href="#devspec">Geräte-Spezifikation</a>
|
||||
für Details der <devspec>.<br>
|
||||
<br>
|
||||
Examples:
|
||||
Beispiel:
|
||||
<ul>
|
||||
setstate lamp on
|
||||
</ul>
|
||||
Note:
|
||||
<ul>
|
||||
<li>The statefile uses another version of this command, don't be surprised.
|
||||
</li>
|
||||
setstate lampe An
|
||||
</ul>
|
||||
</ul>
|
||||
|
||||
@ -1025,9 +1040,11 @@ Zeilen erstreckende Befehle, indem man keine \ am Zeilenende eingeben muss.</p>
|
||||
<a name="trigger"></a>
|
||||
<h3>trigger</h3>
|
||||
<ul>
|
||||
<code>trigger <devspec> <state></code>
|
||||
<code>trigger <devspec> <event></code>
|
||||
<br><br>
|
||||
Triggert eine <a href="#notify">notify</a> Definition.<br>
|
||||
Generiert das Ereignis <event>, was z.Bsp. ein <a
|
||||
href="#notify">notify</a> anstoßen kann, oder den FileLog zum
|
||||
protokollieren dieser Zeile bewegen kann.<br>
|
||||
Siehe den Abschnitt über <a href="#devspec">Geräte-Spezifikation</a>
|
||||
für Details der <devspec>.<br>
|
||||
<br>
|
||||
|
23
fhem/fhem.pl
23
fhem/fhem.pl
@ -267,6 +267,8 @@ $readingFnAttributes = "event-on-change-reading event-on-update-reading ".
|
||||
Hlp=>"[configfile],write the configfile and the statefile" },
|
||||
"set" => { Fn=>"CommandSet",
|
||||
Hlp=>"<devspec> <type dependent>,transmit code for <devspec>" },
|
||||
"setreading" => { Fn=>"CommandSetReading",
|
||||
Hlp=>"<devspec> <reading> <value>,set reading for <devspec>" },
|
||||
"setstate"=> { Fn=>"CommandSetstate",
|
||||
Hlp=>"<devspec> <state>,set the state shown in the command list" },
|
||||
"setdefaultattr" => { Fn=>"CommandDefaultAttr",
|
||||
@ -1595,6 +1597,27 @@ CommandDeleteReading($$)
|
||||
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
|
||||
PrintHash($$)
|
||||
|
Loading…
Reference in New Issue
Block a user