mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-03-13 17:26:34 +00:00
DEFINED & INITIALIZED Macros
git-svn-id: https://svn.fhem.de/fhem/trunk@502 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
41e92d68d0
commit
90345b7a72
@ -552,3 +552,4 @@
|
|||||||
- bugfix: Path in the examples fixed (got corrupted)
|
- bugfix: Path in the examples fixed (got corrupted)
|
||||||
- bugfix: PachLog fixes from Axel
|
- bugfix: PachLog fixes from Axel
|
||||||
- bugfix: HOWTO/Examples revisited for correctness
|
- bugfix: HOWTO/Examples revisited for correctness
|
||||||
|
- bugfix: DEFINED & INITIALIZED triggers.
|
||||||
|
@ -3722,6 +3722,20 @@ A line ending with \ will be concatenated with the next one, so long lines
|
|||||||
<li>Each undefined device (FS20, HMS, FHT) will be reported with the
|
<li>Each undefined device (FS20, HMS, FHT) will be reported with the
|
||||||
device name "UNDEFINED". The % parameter will contain the type (FS20,
|
device name "UNDEFINED". The % parameter will contain the type (FS20,
|
||||||
HMS100T, etc) and device number, separated by a space.</li>
|
HMS100T, etc) and device number, separated by a space.</li>
|
||||||
|
|
||||||
|
<li>After defining a device, the event "DEFINED" will be triggered. This
|
||||||
|
can be used in the fhem.cfg to set some values of the device.</li>
|
||||||
|
|
||||||
|
<li>After initialization finished, the event "INITIALIZED" for the device
|
||||||
|
"global" will be triggered.</li>
|
||||||
|
|
||||||
|
<li>Notify can be used to store macros for manual execution. Use the <a
|
||||||
|
href="#trigger">trigger</a> command to execute the macro. E.g.<br>
|
||||||
|
<pre>
|
||||||
|
fhem> define MyMacro notify MyMacro { Log 1, "Hello"}
|
||||||
|
fhem> trigger MyMacro</pre>
|
||||||
|
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
</ul>
|
</ul>
|
||||||
<br>
|
<br>
|
||||||
@ -4356,6 +4370,15 @@ isday</pre>
|
|||||||
<a name="perl"></a>
|
<a name="perl"></a>
|
||||||
<h3>Perl specials</h3>
|
<h3>Perl specials</h3>
|
||||||
<ul>
|
<ul>
|
||||||
|
<li>To test perl oneliners, type them on the prompt by enclosing it in {}, e.g.<br>
|
||||||
|
<ul>
|
||||||
|
{ Log 1, "Hallo" }
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li>To store some macros, see the Notes in the <a href="#notify">notify</a>
|
||||||
|
description.</li>
|
||||||
|
|
||||||
<li>To use fhem commands from the perl expression, use the function "fhem",
|
<li>To use fhem commands from the perl expression, use the function "fhem",
|
||||||
which takes a string argument, this string will be evaluated as a fhem
|
which takes a string argument, this string will be evaluated as a fhem
|
||||||
command chain.<br>
|
command chain.<br>
|
||||||
|
@ -48,6 +48,7 @@ sub CallFn(@);
|
|||||||
sub CommandChain($$);
|
sub CommandChain($$);
|
||||||
sub CheckDuplicate($$);
|
sub CheckDuplicate($$);
|
||||||
sub DoClose($);
|
sub DoClose($);
|
||||||
|
sub DoTrigger($$);
|
||||||
sub Dispatch($$$);
|
sub Dispatch($$$);
|
||||||
sub FmtDateTime($);
|
sub FmtDateTime($);
|
||||||
sub FmtTime($);
|
sub FmtTime($);
|
||||||
@ -155,7 +156,7 @@ my $nextat; # Time when next timer will be triggered.
|
|||||||
my $intAtCnt=0;
|
my $intAtCnt=0;
|
||||||
my %duplicate; # Pool of received msg for multi-fhz/cul setups
|
my %duplicate; # Pool of received msg for multi-fhz/cul setups
|
||||||
my $duplidx=0; # helper for the above pool
|
my $duplidx=0; # helper for the above pool
|
||||||
my $cvsid = '$Id: fhem.pl,v 1.89 2009-12-01 22:41:17 rudolfkoenig Exp $';
|
my $cvsid = '$Id: fhem.pl,v 1.90 2009-12-09 13:15:16 rudolfkoenig Exp $';
|
||||||
my $namedef =
|
my $namedef =
|
||||||
"where <name> is either:\n" .
|
"where <name> is either:\n" .
|
||||||
"- a single device name\n" .
|
"- a single device name\n" .
|
||||||
@ -286,6 +287,7 @@ if($pfn) {
|
|||||||
close(PID);
|
close(PID);
|
||||||
}
|
}
|
||||||
$init_done = 1;
|
$init_done = 1;
|
||||||
|
DoTrigger("global", "INITIALIZED");
|
||||||
|
|
||||||
Log 0, "Server started (version $attr{global}{version}, pid $$)";
|
Log 0, "Server started (version $attr{global}{version}, pid $$)";
|
||||||
|
|
||||||
@ -1041,6 +1043,7 @@ CommandDefine($$)
|
|||||||
CommandAttr($cl, "$a[0] $da $defaultattr{$da}");
|
CommandAttr($cl, "$a[0] $da $defaultattr{$da}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
DoTrigger($a[0], "DEFINED");
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1572,7 +1575,8 @@ CommandTrigger($$)
|
|||||||
my ($cl, $param) = @_;
|
my ($cl, $param) = @_;
|
||||||
|
|
||||||
my ($dev, $state) = split(" ", $param, 2);
|
my ($dev, $state) = split(" ", $param, 2);
|
||||||
return "Usage: trigger <name> <state>\n$namedef" if(!$state);
|
return "Usage: trigger <name> <state>\n$namedef" if(!$dev);
|
||||||
|
$state = "" if(!$state);
|
||||||
|
|
||||||
my @rets;
|
my @rets;
|
||||||
foreach my $sdev (devspec2array($dev)) {
|
foreach my $sdev (devspec2array($dev)) {
|
||||||
@ -1873,6 +1877,7 @@ DoTrigger($$)
|
|||||||
my $ret = "";
|
my $ret = "";
|
||||||
foreach my $n (sort keys %defs) {
|
foreach my $n (sort keys %defs) {
|
||||||
next if(!defined($defs{$n})); # Was deleted in a previous notify
|
next if(!defined($defs{$n})); # Was deleted in a previous notify
|
||||||
|
next if($n eq $dev && defined($ns) && $ns eq "DEFINED");
|
||||||
if(defined($modules{$defs{$n}{TYPE}})) {
|
if(defined($modules{$defs{$n}{TYPE}})) {
|
||||||
if($modules{$defs{$n}{TYPE}}{NotifyFn}) {
|
if($modules{$defs{$n}{TYPE}}{NotifyFn}) {
|
||||||
Log 5, "$dev trigger: Checking $n for notify";
|
Log 5, "$dev trigger: Checking $n for notify";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user