diff --git a/fhem/FHEM/98_THRESHOLD.pm b/fhem/FHEM/98_THRESHOLD.pm
index f9f198d84..bcd2c9bba 100644
--- a/fhem/FHEM/98_THRESHOLD.pm
+++ b/fhem/FHEM/98_THRESHOLD.pm
@@ -35,7 +35,7 @@ THRESHOLD_Initialize($)
$hash->{SetFn} = "THRESHOLD_Set";
$hash->{AttrFn} = "THRESHOLD_Attr";
$hash->{NotifyFn} = "THRESHOLD_Notify";
- $hash->{AttrList} = "disable:0,1 loglevel:0,1,2,3,4,5,6 state_format state_cmd1_gt state_cmd2_lt target_func number_format";
+ $hash->{AttrList} = "disable:0,1 loglevel:0,1,2,3,4,5,6 state_format state_cmd1_gt state_cmd2_lt target_func number_format setOnDeactivated:cmd1_gt,cmd2_lt";
}
@@ -269,6 +269,7 @@ THRESHOLD_Set($@)
my $offset = $hash->{offset};
my $mode;
my $state_format = AttrVal($pn, "state_format", "_m _dv");
+ my $cmd = AttrVal($pn, "setOnDeactivated", "");
if ($arg eq "desired" ) {
return "$pn: set desired value:$value, desired value needs a numeric parameter" if(@a != 3 || $value !~ m/^[-\d\.]*$/);
@@ -293,21 +294,22 @@ THRESHOLD_Set($@)
readingsEndUpdate ($hash, 1);
return THRESHOLD_Check($hash);
} elsif ($arg eq "deactivated" ) {
- if ($value ne "") {
- if ($value eq "cmd1_gt" ) {
+ $cmd = $value if ($value ne "");
+ if ($cmd ne "") {
+ if ($cmd eq "cmd1_gt" ) {
readingsBeginUpdate ($hash);
THRESHOLD_setValue ($hash,1);
THRESHOLD_set_state ($hash);
readingsEndUpdate ($hash, 1);
- } elsif ($value eq "cmd2_lt" ) {
+ } elsif ($cmd eq "cmd2_lt" ) {
readingsBeginUpdate ($hash);
THRESHOLD_setValue ($hash,2);
THRESHOLD_set_state ($hash);
readingsEndUpdate ($hash, 1);
} else {
- return "$pn: set deactivated: $value, unknown command";
+ return "$pn: set deactivated: $cmd, unknown command, use: cmd1_gt or cmd2_lt";
}
- }
+ }
$ret=CommandAttr(undef, "$pn disable 1");
} elsif ($arg eq "active" ) {
return "$pn: set active, set desired value first" if ($desired_value eq "");
@@ -915,6 +917,8 @@ THRESHOLD_setValue($$)
The sensor value is given as "_tv" in the expression.
Example:
attr TH_heating target_func -0.578*_tv+33.56
+