mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-16 10:46:03 +00:00
91_watchdog.pm: execOnReactivate (Forum #29671)
git-svn-id: https://svn.fhem.de/fhem/trunk@7108 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
c73a3161b5
commit
b2ffa4aeb9
@ -15,7 +15,7 @@ watchdog_Initialize($)
|
||||
$hash->{DefFn} = "watchdog_Define";
|
||||
$hash->{UndefFn} = "watchdog_Undef";
|
||||
$hash->{NotifyFn} = "watchdog_Notify";
|
||||
$hash->{AttrList} = "disable:0,1 disabledForIntervals execOnActivate ".
|
||||
$hash->{AttrList} = "disable:0,1 disabledForIntervals execOnReactivate ".
|
||||
"regexp1WontReactivate:0,1 addStateEvent:0,1";
|
||||
}
|
||||
|
||||
@ -140,8 +140,7 @@ watchdog_Trigger($)
|
||||
my $exec = SemicolonEscape($watchdog->{CMD});
|
||||
$watchdog->{STATE} = "triggered";
|
||||
|
||||
$watchdog->{READINGS}{Triggered}{TIME} = TimeNow();
|
||||
$watchdog->{READINGS}{Triggered}{VAL} = $watchdog->{STATE};
|
||||
setReadingsVal($watchdog, "Triggered", "triggered", TimeNow());
|
||||
|
||||
my $ret = AnalyzeCommandChain(undef, $exec);
|
||||
Log3 $name, 3, $ret if($ret);
|
||||
@ -156,9 +155,16 @@ watchdog_Activate($)
|
||||
RemoveInternalTimer($watchdog);
|
||||
InternalTimer($nt, "watchdog_Trigger", $watchdog, 0);
|
||||
|
||||
my $eoa = AttrVal($watchdog->{NAME}, "execOnActivate", undef);
|
||||
return if(!$eoa);
|
||||
AnalyzeCommandChain(undef, SemicolonEscape($eoa));
|
||||
my $eor = AttrVal($watchdog->{NAME}, "execOnReactivate", undef);
|
||||
if($eor) {
|
||||
my $wName = $watchdog->{NAME};
|
||||
my $aTime = ReadingsTimestamp($wName, "Activated", "");
|
||||
my $tTime = ReadingsTimestamp($wName, "Triggered", "");
|
||||
$eor = undef if(!$aTime || !$tTime || $aTime ge $tTime)
|
||||
}
|
||||
setReadingsVal($watchdog, "Activated", "activated", TimeNow());
|
||||
|
||||
AnalyzeCommandChain(undef, SemicolonEscape($eor)) if($eor);
|
||||
}
|
||||
|
||||
sub
|
||||
@ -252,9 +258,10 @@ watchdog_Undef($$)
|
||||
When a watchdog is active, a second event matching regexp1 will
|
||||
normally reset the timeout. Set this attribute to prevents this.</li>
|
||||
|
||||
<li><a href="#execOnActivate">execOnActivate</a>
|
||||
<li><a href="#execOnReactivate">execOnActivate</a>
|
||||
If set, its value will be executed as a FHEM command when the watchdog is
|
||||
activated by receiving an event matching regexp1.</li>
|
||||
reactivated (after triggering) by receiving an event matching regexp1.
|
||||
</li>
|
||||
</ul>
|
||||
<br>
|
||||
</ul>
|
||||
@ -359,10 +366,10 @@ watchdog_Undef($$)
|
||||
passt normalerweise den Timer zurücksetzen. Dieses Attribut wird
|
||||
das verhindern.</li>
|
||||
|
||||
<li><a href="#execOnActivate">execOnActivate</a>
|
||||
<li><a href="#execOnReactivate">execOnActivate</a>
|
||||
Falls gesetzt, wird der Wert des Attributes als FHEM Befehl
|
||||
ausgeführt, wenn ein regexp1 Ereignis den Watchdog
|
||||
aktiviert.</li>
|
||||
aktiviert nachdem er ausgelöst wurde.</li>
|
||||
</ul>
|
||||
<br>
|
||||
</ul>
|
||||
|
Loading…
x
Reference in New Issue
Block a user