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
    - Inactivates the current device. Note the slight difference to the + Two things will happen:
    + 1. Executes the commands specified under the "setInactiveFunc" attribute.
    + 2. Inactivates the current device. Note the slight difference to the disable attribute: using set inactive the state is automatically saved to the statefile on shutdown, there is no explicit save necesary.
  • @@ -726,7 +751,8 @@ sub monitoring_setActive($) {
  • disable (1|0)
    - 1: Disables the monitoring.
    + 1: Executes the commands specified under the "setInactiveFunc" attribute + and disables the monitoring.
            0: see "set active"
  • @@ -766,6 +792,22 @@ sub monitoring_setActive($) { If the attribute is not set, it will be checked for $addMatch.
  • +
  • + errorFuncAdded {<perl code>}
    + The following variables are available in this function: +
    + + This function will be executed when a device is added to the error list. +
  • errorFuncRemove {<perl code>}
    This function provides the same variables as for "errorFuncAdd".
    @@ -817,6 +859,10 @@ sub monitoring_setActive($) { warningFuncAdd {<perl code>}
    Like errorFuncAdd, just for the warning list.
  • +
  • + warningFuncAdd {<perl code>}
    + Like errorFuncAdded, just for the warning list. +
  • warningFuncRemove {<perl code>}
    Like errorFuncRemove, just for the warning list. @@ -1252,6 +1298,22 @@ attr BeamerFilter_monitoring warningFuncRemove {return} Wenn das Attribut nicht gesetzt ist wird auf $addMatch geprüft.
  • +
  • + errorFuncAdded {<perl code>}
    + In dieser Funktion stehen die folgende Variablen zur Verfügung: +
    + + Diese Funktion wird ausgeführt, wenn ein Gerät in die Fehlerliste aufgenommen wird. +
  • errorFuncRemove {<perl code>}
    In dieser Funktion stehen die selben Variablen wie bei "errorFuncAdd" @@ -1305,6 +1367,10 @@ attr BeamerFilter_monitoring warningFuncRemove {return} warningFuncAdd {<perl code>}
    Wie errorFuncAdd, nur für die warning-Liste.
  • +
  • + warningFuncAdded {<perl code>}
    + Wie errorFuncAdded, nur für die warning-Liste. +
  • warningFuncRemove {<perl code>}
    Wie errorFuncRemove, nur für die warning-Liste.