mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-01-31 06:39:11 +00:00
fhem.pl: add defmod command (Forum #36265)
git-svn-id: https://svn.fhem.de/fhem/trunk@8440 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
86f3b188c2
commit
3d294bff04
@ -43,6 +43,7 @@
|
|||||||
<a href="#copy">copy</a>
|
<a href="#copy">copy</a>
|
||||||
<a href="#createlog">createlog</a>
|
<a href="#createlog">createlog</a>
|
||||||
<a href="#define">define</a>
|
<a href="#define">define</a>
|
||||||
|
<a href="#defmod">defmod</a>
|
||||||
<a href="#delete">delete</a>
|
<a href="#delete">delete</a>
|
||||||
<a href="#deleteattr">deleteattr</a>
|
<a href="#deleteattr">deleteattr</a>
|
||||||
<a href="#deletereading">deletereading</a>
|
<a href="#deletereading">deletereading</a>
|
||||||
@ -710,7 +711,6 @@ The following local attributes are used by a wider range of devices:
|
|||||||
Define a device. You need devices if you want to manipulate them (e.g.
|
Define a device. You need devices if you want to manipulate them (e.g.
|
||||||
set on/off), and the logfile is also more readable if it contains e.g.
|
set on/off), and the logfile is also more readable if it contains e.g.
|
||||||
"lamp off" instead of "Device 5673, Button 00, Code 00 (off)". <br>
|
"lamp off" instead of "Device 5673, Button 00, Code 00 (off)". <br>
|
||||||
Use "define <name> ?" to get a list of possible types.<br>
|
|
||||||
After definition, the global event "DEFINED" will be generated, see the
|
After definition, the global event "DEFINED" will be generated, see the
|
||||||
notify section for details.<br>
|
notify section for details.<br>
|
||||||
<br><br>
|
<br><br>
|
||||||
@ -720,6 +720,23 @@ The following local attributes are used by a wider range of devices:
|
|||||||
<br>
|
<br>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
<a name="defmod"></a>
|
||||||
|
<h3>defmod</h3>
|
||||||
|
<ul>
|
||||||
|
<code>defmod <name> <type> <type-specific></code><br>
|
||||||
|
<br>
|
||||||
|
Define a device or modify it, if it already exists. E.g. to switch off a lamp
|
||||||
|
10 Minutes after the last message from the motion detector, you may use
|
||||||
|
<ul><code>
|
||||||
|
define mdNtfy notify motionDetector defmod mdOff at +00:10 set lamp off
|
||||||
|
</code></ul>
|
||||||
|
Using define here for the mdOff will generate an error if the motion detector
|
||||||
|
triggers within the 10 minutes after the first event, as the mdOff at
|
||||||
|
definition still exists.
|
||||||
|
<br>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
<a name="delete"></a>
|
<a name="delete"></a>
|
||||||
<h3>delete</h3>
|
<h3>delete</h3>
|
||||||
<ul>
|
<ul>
|
||||||
|
@ -734,17 +734,34 @@ Die folgenden lokalen Attribute werden von mehreren Geräten verwendet:
|
|||||||
<ul>
|
<ul>
|
||||||
<code>define <name> <type> <type-specific></code><br>
|
<code>define <name> <type> <type-specific></code><br>
|
||||||
<br>
|
<br>
|
||||||
Definiert ein Gerät. Sie müssen Geräte einrichten um sie zu beeinflussen (z.B.
|
|
||||||
das Kommando set on/off auszuführen). Gleichfalls ist das Logfile besser
|
Definiert ein Gerät. Sie müssen Geräte einrichten um sie zu
|
||||||
lesbar wenn es z.B.
|
beeinflussen (z.B. das Kommando set on/off auszuführen). Gleichfalls
|
||||||
"lamp off" anstatt "Device 5673, Button 00, Code 00 (off)" als Text enthält. <br>
|
ist das Logfile besser lesbar wenn es z.B. "lamp off" anstatt "Device 5673,
|
||||||
Geben Sie an der Befehlszeile "define <name> ?" ein, um eine Liste der
|
Button 00, Code 00 (off)" als Text enthält. <br>
|
||||||
verfügbaren "types" zu erhalten.<br>
|
|
||||||
Nach der Durchführung das globale Ereignis "MODIFIED" wird generiert.
|
Nach der Durchführung wird das globale Ereignis "DEFINED" generiert.
|
||||||
<br><br>
|
<br><br>
|
||||||
|
|
||||||
Jedes Gerät besitzt unterschiedliche hinzufügbare Argumente per Definition,
|
Je nach Typ benötigt man unterscheidliche Argumente, lesen Sie sich
|
||||||
lesen Sie sich bitte die zu dem jeweiligen Gerät gehörenden Abschnitte durch.<br>
|
bitte die zu dem jeweiligen Gerät gehörenden Abschnitte durch.
|
||||||
|
<br>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<a name="defmod"></a>
|
||||||
|
<h3>defmod</h3>
|
||||||
|
<ul>
|
||||||
|
<code>defmod <name> <type> <type-specific></code><br>
|
||||||
|
<br>
|
||||||
|
Definiert ein Gerät, oder ändert es, falls es exisitiert. Um
|
||||||
|
z.Bsp. eine Lampe 10 Minuten nach der letzten Meldung eines Bewegungsmelders
|
||||||
|
abzuschalten, könnte man folgendes definieren:
|
||||||
|
<ul><code>
|
||||||
|
define mdNtfy notify motionDetector defmod mdOff at +00:10 set lamp off
|
||||||
|
</code></ul>
|
||||||
|
Falls man statt defmod ein define verwenden würde, dann würde eine
|
||||||
|
Meldung innerhalb von 10 Minuten nach der letzten Meldung zu einem Fehler
|
||||||
|
führen, da mdOff noch existiert.
|
||||||
<br>
|
<br>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
23
fhem/fhem.pl
23
fhem/fhem.pl
@ -129,6 +129,7 @@ sub utf8ToLatin1($);
|
|||||||
sub CommandAttr($$);
|
sub CommandAttr($$);
|
||||||
sub CommandDefaultAttr($$);
|
sub CommandDefaultAttr($$);
|
||||||
sub CommandDefine($$);
|
sub CommandDefine($$);
|
||||||
|
sub CommandDefMod($$);
|
||||||
sub CommandDelete($$);
|
sub CommandDelete($$);
|
||||||
sub CommandDeleteAttr($$);
|
sub CommandDeleteAttr($$);
|
||||||
sub CommandDeleteReading($$);
|
sub CommandDeleteReading($$);
|
||||||
@ -268,7 +269,9 @@ $readingFnAttributes = "event-on-change-reading event-on-update-reading ".
|
|||||||
Hlp=>"<devspec> <attrname> [<attrval>],set attribute for <devspec>"},
|
Hlp=>"<devspec> <attrname> [<attrval>],set attribute for <devspec>"},
|
||||||
"createlog"=> { ModuleName => "autocreate" },
|
"createlog"=> { ModuleName => "autocreate" },
|
||||||
"define" => { Fn=>"CommandDefine",
|
"define" => { Fn=>"CommandDefine",
|
||||||
Hlp=>"<name> <type> <options>,define a device/at/notify entity" },
|
Hlp=>"<name> <type> <options>,define a device" },
|
||||||
|
"defmod" => { Fn=>"CommandDefMod",
|
||||||
|
Hlp=>"<name> <type> <options>,define or modify a device" },
|
||||||
"deleteattr" => { Fn=>"CommandDeleteAttr",
|
"deleteattr" => { Fn=>"CommandDeleteAttr",
|
||||||
Hlp=>"<devspec> [<attrname>],delete attribute for <devspec>" },
|
Hlp=>"<devspec> [<attrname>],delete attribute for <devspec>" },
|
||||||
"deletereading" => { Fn=>"CommandDeleteReading",
|
"deletereading" => { Fn=>"CommandDeleteReading",
|
||||||
@ -1553,7 +1556,7 @@ sub
|
|||||||
CommandDefine($$)
|
CommandDefine($$)
|
||||||
{
|
{
|
||||||
my ($cl, $def) = @_;
|
my ($cl, $def) = @_;
|
||||||
my @a = split("[ \t][ \t]*", $def, 3);
|
my @a = split("[ \t]+", $def, 3);
|
||||||
my $ignoreErr;
|
my $ignoreErr;
|
||||||
|
|
||||||
# used by RSS in fhem.cfg.demo, with no GD installed
|
# used by RSS in fhem.cfg.demo, with no GD installed
|
||||||
@ -1650,6 +1653,22 @@ CommandModify($$)
|
|||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#####################################
|
||||||
|
sub
|
||||||
|
CommandDefMod($$)
|
||||||
|
{
|
||||||
|
my ($cl, $def) = @_;
|
||||||
|
my @a = split("[ \t]+", $def, 3);
|
||||||
|
return "Usage: defmod <name> <type> <type dependent arguments>"
|
||||||
|
if(int(@a) < 2);
|
||||||
|
if($defs{$a[0]}) {
|
||||||
|
$def = $a[2] ? "$a[0] $a[2]" : $a[0];
|
||||||
|
return CommandModify($cl, $def);
|
||||||
|
} else {
|
||||||
|
return CommandDefine($cl, $def);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#############
|
#############
|
||||||
# internal
|
# internal
|
||||||
sub
|
sub
|
||||||
|
Loading…
Reference in New Issue
Block a user