mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-05-04 22:19:38 +00:00
98_monitoring: add function
git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@18801 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
cf82ec927a
commit
76231a4a8d
1
CHANGED
1
CHANGED
@ -1,5 +1,6 @@
|
|||||||
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide.
|
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide.
|
||||||
# Do not insert empty lines here, update check depends on it.
|
# Do not insert empty lines here, update check depends on it.
|
||||||
|
- feature: 98_monitoring: - add "$listFuncAdded" function
|
||||||
- bugfix: 22_HOMEMODE: - fix illegal division by zero in HOMEMODE_Luminance
|
- bugfix: 22_HOMEMODE: - fix illegal division by zero in HOMEMODE_Luminance
|
||||||
- renamed attribute name HomeYahooWeatherDevice to
|
- renamed attribute name HomeYahooWeatherDevice to
|
||||||
HomeWeatherDevic
|
HomeWeatherDevic
|
||||||
|
@ -40,6 +40,7 @@ sub monitoring_modify($);
|
|||||||
sub monitoring_RemoveInternalTimer($);
|
sub monitoring_RemoveInternalTimer($);
|
||||||
sub monitoring_return($$);
|
sub monitoring_return($$);
|
||||||
sub monitoring_setActive($);
|
sub monitoring_setActive($);
|
||||||
|
sub monitoring_setInactive($);
|
||||||
|
|
||||||
# initialize ##################################################################
|
# initialize ##################################################################
|
||||||
sub monitoring_Initialize($) {
|
sub monitoring_Initialize($) {
|
||||||
@ -59,12 +60,15 @@ sub monitoring_Initialize($) {
|
|||||||
"disable:1,0 ".
|
"disable:1,0 ".
|
||||||
"disabledForIntervals ".
|
"disabledForIntervals ".
|
||||||
"errorFuncAdd:textField-long ".
|
"errorFuncAdd:textField-long ".
|
||||||
|
"errorFuncAdded:textField-long ".
|
||||||
"errorFuncRemove:textField-long ".
|
"errorFuncRemove:textField-long ".
|
||||||
"errorWait ".
|
"errorWait ".
|
||||||
"errorReturn:textField-long ".
|
"errorReturn:textField-long ".
|
||||||
"getDefault:all,error,warning ".
|
"getDefault:all,error,warning ".
|
||||||
"setActiveFunc:textField-long ".
|
"setActiveFunc:textField-long ".
|
||||||
|
"setInactiveFunc:textField-long ".
|
||||||
"warningFuncAdd:textField-long ".
|
"warningFuncAdd:textField-long ".
|
||||||
|
"warningFuncAdded:textField-long ".
|
||||||
"warningFuncRemove:textField-long ".
|
"warningFuncRemove:textField-long ".
|
||||||
"warningWait ".
|
"warningWait ".
|
||||||
"warningReturn:textField-long ".
|
"warningReturn:textField-long ".
|
||||||
@ -90,6 +94,7 @@ sub monitoring_Define($$) {
|
|||||||
sub monitoring_Undefine($$) {
|
sub monitoring_Undefine($$) {
|
||||||
my ($hash, $arg) = @_;
|
my ($hash, $arg) = @_;
|
||||||
|
|
||||||
|
monitoring_setInactive($hash);
|
||||||
monitoring_RemoveInternalTimer($hash);
|
monitoring_RemoveInternalTimer($hash);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -125,6 +130,7 @@ sub monitoring_Set($@) {
|
|||||||
monitoring_setActive($hash);
|
monitoring_setActive($hash);
|
||||||
}
|
}
|
||||||
elsif($argument eq "inactive"){
|
elsif($argument eq "inactive"){
|
||||||
|
monitoring_setInactive($hash);
|
||||||
readingsSingleUpdate($hash, "state", $argument, 0);
|
readingsSingleUpdate($hash, "state", $argument, 0);
|
||||||
|
|
||||||
Log3($SELF, 3, "$SELF ($TYPE) set $SELF inactive");
|
Log3($SELF, 3, "$SELF ($TYPE) set $SELF inactive");
|
||||||
@ -251,6 +257,7 @@ sub monitoring_Attr(@) {
|
|||||||
monitoring_setActive($hash);
|
monitoring_setActive($hash);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
monitoring_setInactive($hash);
|
||||||
readingsSingleUpdate($hash, "state", "disabled", 0);
|
readingsSingleUpdate($hash, "state", "disabled", 0);
|
||||||
Log3($SELF, 3, "$hash->{TYPE} ($SELF) attr $SELF disabled");
|
Log3($SELF, 3, "$hash->{TYPE} ($SELF) attr $SELF disabled");
|
||||||
}
|
}
|
||||||
@ -461,6 +468,12 @@ sub monitoring_modify($) {
|
|||||||
ReadingsNum($SELF, ($list eq "warning" ? "error" : "warning")."Count", 0)
|
ReadingsNum($SELF, ($list eq "warning" ? "error" : "warning")."Count", 0)
|
||||||
;
|
;
|
||||||
|
|
||||||
|
if ($operation eq "add") {
|
||||||
|
my $name = $value;
|
||||||
|
my $listFuncAdded = AttrVal($SELF, $list."FuncAdded", "");
|
||||||
|
$listFuncAdded = $listFuncAdded =~ /^\{.*\}$/s ? eval($listFuncAdded) : fhem($listFuncAdded);
|
||||||
|
}
|
||||||
|
|
||||||
readingsBeginUpdate($hash);
|
readingsBeginUpdate($hash);
|
||||||
readingsBulkUpdate($hash, "state", "$list $operation: $value");
|
readingsBulkUpdate($hash, "state", "$list $operation: $value");
|
||||||
readingsBulkUpdate($hash, $list, join(",", sort(keys %readings)));
|
readingsBulkUpdate($hash, $list, join(",", sort(keys %readings)));
|
||||||
@ -541,6 +554,16 @@ sub monitoring_setActive($) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub monitoring_setInactive($) {
|
||||||
|
my ($hash) = @_;
|
||||||
|
my $SELF = $hash->{NAME};
|
||||||
|
my $TYPE = $hash->{TYPE};
|
||||||
|
|
||||||
|
AnalyzeCommandChain(undef, AttrVal($SELF, "setInactiveFunc", "preset"));
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|
||||||
# commandref ##################################################################
|
# commandref ##################################################################
|
||||||
@ -630,7 +653,9 @@ sub monitoring_setActive($) {
|
|||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<code>inactive</code><br>
|
<code>inactive</code><br>
|
||||||
Inactivates the current device. Note the slight difference to the
|
Two things will happen:<br>
|
||||||
|
1. Executes the commands specified under the "setInactiveFunc" attribute.<br>
|
||||||
|
2. Inactivates the current device. Note the slight difference to the
|
||||||
disable attribute: using set inactive the state is automatically saved
|
disable attribute: using set inactive the state is automatically saved
|
||||||
to the statefile on shutdown, there is no explicit save necesary.
|
to the statefile on shutdown, there is no explicit save necesary.
|
||||||
</li>
|
</li>
|
||||||
@ -726,7 +751,8 @@ sub monitoring_setActive($) {
|
|||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<code>disable (1|0)</code><br>
|
<code>disable (1|0)</code><br>
|
||||||
1: Disables the monitoring.<br>
|
1: Executes the commands specified under the "setInactiveFunc" attribute
|
||||||
|
and disables the monitoring.<br>
|
||||||
0: see "set active"
|
0: see "set active"
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
@ -766,6 +792,22 @@ sub monitoring_setActive($) {
|
|||||||
If the attribute is not set, it will be checked for
|
If the attribute is not set, it will be checked for
|
||||||
<code>$addMatch</code>.
|
<code>$addMatch</code>.
|
||||||
</li>
|
</li>
|
||||||
|
<li>
|
||||||
|
<code>errorFuncAdded {<perl code>}</code><br>
|
||||||
|
The following variables are available in this function:
|
||||||
|
<br>
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
<code>$name</code><br>
|
||||||
|
Name of the event triggering device
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<code>$SELF</code><br>
|
||||||
|
Name of the monitoring
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
This function will be executed when a device is added to the error list.
|
||||||
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<code>errorFuncRemove {<perl code>}</code><br>
|
<code>errorFuncRemove {<perl code>}</code><br>
|
||||||
This function provides the same variables as for "errorFuncAdd".<br>
|
This function provides the same variables as for "errorFuncAdd".<br>
|
||||||
@ -817,6 +859,10 @@ sub monitoring_setActive($) {
|
|||||||
<code>warningFuncAdd {<perl code>}</code><br>
|
<code>warningFuncAdd {<perl code>}</code><br>
|
||||||
Like errorFuncAdd, just for the warning list.
|
Like errorFuncAdd, just for the warning list.
|
||||||
</li>
|
</li>
|
||||||
|
<li>
|
||||||
|
<code>warningFuncAdd {<perl code>}</code><br>
|
||||||
|
Like errorFuncAdded, just for the warning list.
|
||||||
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<code>warningFuncRemove {<perl code>}</code><br>
|
<code>warningFuncRemove {<perl code>}</code><br>
|
||||||
Like errorFuncRemove, just for the warning list.
|
Like errorFuncRemove, just for the warning list.
|
||||||
@ -1252,6 +1298,22 @@ attr BeamerFilter_monitoring warningFuncRemove {return}</pre>
|
|||||||
Wenn das Attribut nicht gesetzt ist wird auf <code>$addMatch</code>
|
Wenn das Attribut nicht gesetzt ist wird auf <code>$addMatch</code>
|
||||||
geprüft.
|
geprüft.
|
||||||
</li>
|
</li>
|
||||||
|
<li>
|
||||||
|
<code>errorFuncAdded {<perl code>}</code><br>
|
||||||
|
In dieser Funktion stehen die folgende Variablen zur Verfügung:
|
||||||
|
<br>
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
<code>$name</code><br>
|
||||||
|
Name des Event auslösenden Gerätes
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<code>$SELF</code><br>
|
||||||
|
Eigenname des monitoring
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
Diese Funktion wird ausgeführt, wenn ein Gerät in die Fehlerliste aufgenommen wird.
|
||||||
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<code>errorFuncRemove {<perl code>}</code><br>
|
<code>errorFuncRemove {<perl code>}</code><br>
|
||||||
In dieser Funktion stehen die selben Variablen wie bei "errorFuncAdd"
|
In dieser Funktion stehen die selben Variablen wie bei "errorFuncAdd"
|
||||||
@ -1305,6 +1367,10 @@ attr BeamerFilter_monitoring warningFuncRemove {return}</pre>
|
|||||||
<code>warningFuncAdd {<perl code>}</code><br>
|
<code>warningFuncAdd {<perl code>}</code><br>
|
||||||
Wie errorFuncAdd, nur für die warning-Liste.
|
Wie errorFuncAdd, nur für die warning-Liste.
|
||||||
</li>
|
</li>
|
||||||
|
<li>
|
||||||
|
<code>warningFuncAdded {<perl code>}</code><br>
|
||||||
|
Wie errorFuncAdded, nur für die warning-Liste.
|
||||||
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<code>warningFuncRemove {<perl code>}</code><br>
|
<code>warningFuncRemove {<perl code>}</code><br>
|
||||||
Wie errorFuncRemove, nur für die warning-Liste.
|
Wie errorFuncRemove, nur für die warning-Liste.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user