diff --git a/fhem/CHANGED b/fhem/CHANGED index f13ed666e..e1091bcfc 100644 --- a/fhem/CHANGED +++ b/fhem/CHANGED @@ -552,3 +552,4 @@ - bugfix: Path in the examples fixed (got corrupted) - bugfix: PachLog fixes from Axel - bugfix: HOWTO/Examples revisited for correctness + - bugfix: DEFINED & INITIALIZED triggers. diff --git a/fhem/docs/commandref.html b/fhem/docs/commandref.html index 41d5d1fb5..cfc7466a5 100644 --- a/fhem/docs/commandref.html +++ b/fhem/docs/commandref.html @@ -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 device name "UNDEFINED". The % parameter will contain the type (FS20, 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> <br> @@ -4356,6 +4370,15 @@ isday</pre> <a name="perl"></a> <h3>Perl specials</h3> <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", which takes a string argument, this string will be evaluated as a fhem command chain.<br> diff --git a/fhem/fhem.pl b/fhem/fhem.pl index 6ae41a70f..dc88f6e55 100755 --- a/fhem/fhem.pl +++ b/fhem/fhem.pl @@ -48,6 +48,7 @@ sub CallFn(@); sub CommandChain($$); sub CheckDuplicate($$); sub DoClose($); +sub DoTrigger($$); sub Dispatch($$$); sub FmtDateTime($); sub FmtTime($); @@ -155,7 +156,7 @@ my $nextat; # Time when next timer will be triggered. my $intAtCnt=0; my %duplicate; # Pool of received msg for multi-fhz/cul setups 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 = "where <name> is either:\n" . "- a single device name\n" . @@ -286,6 +287,7 @@ if($pfn) { close(PID); } $init_done = 1; +DoTrigger("global", "INITIALIZED"); Log 0, "Server started (version $attr{global}{version}, pid $$)"; @@ -1041,6 +1043,7 @@ CommandDefine($$) CommandAttr($cl, "$a[0] $da $defaultattr{$da}"); } } + DoTrigger($a[0], "DEFINED"); return $ret; } @@ -1572,7 +1575,8 @@ CommandTrigger($$) my ($cl, $param) = @_; 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; foreach my $sdev (devspec2array($dev)) { @@ -1873,6 +1877,7 @@ DoTrigger($$) my $ret = ""; foreach my $n (sort keys %defs) { 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($modules{$defs{$n}{TYPE}}{NotifyFn}) { Log 5, "$dev trigger: Checking $n for notify";