diff --git a/fhem/CHANGED b/fhem/CHANGED index 7d24adb7c..0b5af1d61 100644 --- a/fhem/CHANGED +++ b/fhem/CHANGED @@ -1,5 +1,6 @@ # 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. + - feature: 98_monitoring: - add "$listFuncAdded" function - bugfix: 22_HOMEMODE: - fix illegal division by zero in HOMEMODE_Luminance - renamed attribute name HomeYahooWeatherDevice to HomeWeatherDevic diff --git a/fhem/FHEM/98_monitoring.pm b/fhem/FHEM/98_monitoring.pm index 6c4158a49..c14382ab2 100644 --- a/fhem/FHEM/98_monitoring.pm +++ b/fhem/FHEM/98_monitoring.pm @@ -40,6 +40,7 @@ sub monitoring_modify($); sub monitoring_RemoveInternalTimer($); sub monitoring_return($$); sub monitoring_setActive($); +sub monitoring_setInactive($); # initialize ################################################################## sub monitoring_Initialize($) { @@ -59,12 +60,15 @@ sub monitoring_Initialize($) { "disable:1,0 ". "disabledForIntervals ". "errorFuncAdd:textField-long ". + "errorFuncAdded:textField-long ". "errorFuncRemove:textField-long ". "errorWait ". "errorReturn:textField-long ". "getDefault:all,error,warning ". "setActiveFunc:textField-long ". + "setInactiveFunc:textField-long ". "warningFuncAdd:textField-long ". + "warningFuncAdded:textField-long ". "warningFuncRemove:textField-long ". "warningWait ". "warningReturn:textField-long ". @@ -90,6 +94,7 @@ sub monitoring_Define($$) { sub monitoring_Undefine($$) { my ($hash, $arg) = @_; + monitoring_setInactive($hash); monitoring_RemoveInternalTimer($hash); return; @@ -125,6 +130,7 @@ sub monitoring_Set($@) { monitoring_setActive($hash); } elsif($argument eq "inactive"){ + monitoring_setInactive($hash); readingsSingleUpdate($hash, "state", $argument, 0); Log3($SELF, 3, "$SELF ($TYPE) set $SELF inactive"); @@ -251,6 +257,7 @@ sub monitoring_Attr(@) { monitoring_setActive($hash); } else{ + monitoring_setInactive($hash); readingsSingleUpdate($hash, "state", "disabled", 0); 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) ; + if ($operation eq "add") { + my $name = $value; + my $listFuncAdded = AttrVal($SELF, $list."FuncAdded", ""); + $listFuncAdded = $listFuncAdded =~ /^\{.*\}$/s ? eval($listFuncAdded) : fhem($listFuncAdded); + } + readingsBeginUpdate($hash); readingsBulkUpdate($hash, "state", "$list $operation: $value"); readingsBulkUpdate($hash, $list, join(",", sort(keys %readings))); @@ -541,6 +554,16 @@ sub monitoring_setActive($) { return; } +sub monitoring_setInactive($) { + my ($hash) = @_; + my $SELF = $hash->{NAME}; + my $TYPE = $hash->{TYPE}; + + AnalyzeCommandChain(undef, AttrVal($SELF, "setInactiveFunc", "preset")); + + return; +} + 1; # commandref ################################################################## @@ -630,7 +653,9 @@ sub monitoring_setActive($) {
inactive
disable (1|0)
$addMatch
.
errorFuncAdded {<perl code>}
$name
$SELF
errorFuncRemove {<perl code>}
warningFuncAdd {<perl code>}
warningFuncAdd {<perl code>}
warningFuncRemove {<perl code>}
$addMatch
geprüft.
errorFuncAdded {<perl code>}
$name
$SELF
errorFuncRemove {<perl code>}
warningFuncAdd {<perl code>}
warningFuncAdded {<perl code>}
warningFuncRemove {<perl code>}