mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-22 08:11:44 +00:00
dummy/ZWave/MQTT2_DEVICE: setExtensionsEvent attr for orig cmds (Forum #95581)
git-svn-id: https://svn.fhem.de/fhem/trunk@19189 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
1bf7167dd8
commit
64d68e6a2f
@ -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.
|
||||
- change: dummy/MQTT2_DEVICE/ZWave: setExtensionsEvent attr (Forum #95581)
|
||||
- change: 93_DbLog: add support for Meta.pm and delayed shutdown, attribute
|
||||
shutdownWait removed, direct attribute help in FHEMWEB,
|
||||
!!! NOTE !!! attr shutdownWait will be deleted it set and
|
||||
|
@ -37,6 +37,7 @@ MQTT2_DEVICE_Initialize($)
|
||||
jsonMap:textField-long
|
||||
model
|
||||
readingList:textField-long
|
||||
setExtensionsEvent:1,0
|
||||
setList:textField-long
|
||||
setStateList
|
||||
);
|
||||
@ -338,27 +339,33 @@ MQTT2_DEVICE_Set($@)
|
||||
{
|
||||
my ($hash, @a) = @_;
|
||||
return "Not enough arguments for set" if(!defined($a[1]));
|
||||
my $name = $hash->{NAME};
|
||||
|
||||
my ($sets,$cmdList) = MQTT2_getCmdHash(AttrVal($hash->{NAME}, "setList", ""));
|
||||
my ($sets,$cmdList) = MQTT2_getCmdHash(AttrVal($name, "setList", ""));
|
||||
my $cmdName = $a[1];
|
||||
return MQTT2_DEVICE_addPos($hash,@a) if($cmdName eq "addPos"); # hidden cmd
|
||||
my $cmd = $sets->{$cmdName};
|
||||
return SetExtensions($hash, $cmdList, @a) if(!$cmd);
|
||||
return undef if(IsDisabled($hash->{NAME}));
|
||||
return undef if(IsDisabled($name));
|
||||
|
||||
my $a1 = (@a > 1 ? $a[1] : '');
|
||||
$cmd = MQTT2_buildCmd($hash, \@a, $cmd);
|
||||
return if(!$cmd);
|
||||
SetExtensionsCancel($hash) if($a1 eq "on" || $a1 eq "off");
|
||||
IOWrite($hash, "publish", $cmd);
|
||||
my $ssl = AttrVal($hash->{NAME}, "setStateList", "");
|
||||
my $ssl = AttrVal($name, "setStateList", "");
|
||||
|
||||
my $cmdSE = $cmdName;
|
||||
$cmdSE = $hash->{SetExtensionsCommand}
|
||||
if($hash->{SetExtensionsCommand} &&
|
||||
AttrVal($name, "setExtensionsEvent", undef));
|
||||
if(!$ssl) {
|
||||
readingsSingleUpdate($hash, "state", $cmdName, 1);
|
||||
readingsSingleUpdate($hash, "state", $cmdSE, 1);
|
||||
|
||||
} else {
|
||||
if($ssl =~ m/\b$cmdName\b/) {
|
||||
$hash->{skipStateFormat} = 1;
|
||||
readingsSingleUpdate($hash, "state", "set_$cmdName", 1);
|
||||
readingsSingleUpdate($hash, "state", "set_$cmdSE", 1);
|
||||
delete($hash->{skipStateFormat});
|
||||
} else {
|
||||
shift(@a);
|
||||
@ -894,6 +901,10 @@ zigbee2mqtt_devStateIcon255($)
|
||||
</ul>
|
||||
</li><br>
|
||||
|
||||
<li><a name="setExtensionsEvent">setExtensionsEvent</a><br>
|
||||
If set, the event will contain the command implemented by SetExtensions
|
||||
(e.g. on-for-timer 10), else the executed command (e.g. on).</li><br>
|
||||
|
||||
<a name="setList"></a>
|
||||
<li>setList cmd [topic|perl-Expression] ...<br>
|
||||
When the FHEM command cmd is issued, publish the topic.
|
||||
|
@ -728,6 +728,7 @@ ZWave_Initialize($)
|
||||
noExplorerFrames:noArg
|
||||
noWakeupForApplicationUpdate:noArg
|
||||
secure_classes
|
||||
setExtensionsEvent:1,0
|
||||
showtime:noArg
|
||||
vclasses
|
||||
useMultiCmd:noArg
|
||||
@ -1128,6 +1129,9 @@ ZWave_Cmd($$@)
|
||||
$cmd .= " ".join(" ", @a) if(@a);
|
||||
my $iohash = $hash->{IODev};
|
||||
my $withSet = ($iohash->{showSetInState} && !$cmdList{$cmd}{ctrlCmd});
|
||||
$cmd = $hash->{SetExtensionsCommand}
|
||||
if($hash->{SetExtensionsCommand} &&
|
||||
AttrVal($name, "setExtensionsEvent", undef));
|
||||
readingsSingleUpdate($hash, "state", $withSet ? "set_$cmd" : $cmd, 1);
|
||||
|
||||
}
|
||||
@ -6456,6 +6460,11 @@ s2Hex($)
|
||||
command. It contains a space seperated list of the the command classes
|
||||
that are supported with SECURITY.
|
||||
</li>
|
||||
|
||||
<li><a name="setExtensionsEvent">setExtensionsEvent</a><br>
|
||||
If set, the event will contain the command implemented by SetExtensions
|
||||
(e.g. on-for-timer 10), else the executed command (e.g. on).</li><br>
|
||||
|
||||
<li><a href="#showtime">showtime</a></li>
|
||||
<li><a name="vclasses">vclasses</a><br>
|
||||
This is the result of the "get DEVICE versionClassAll" command, and
|
||||
|
@ -13,9 +13,18 @@ dummy_Initialize($)
|
||||
|
||||
$hash->{SetFn} = "dummy_Set";
|
||||
$hash->{DefFn} = "dummy_Define";
|
||||
$hash->{AttrList} = "readingList setList useSetExtensions " .
|
||||
"disable disabledForIntervals ".
|
||||
$readingFnAttributes;
|
||||
no warnings 'qw';
|
||||
my @attrList = qw(
|
||||
disable
|
||||
disabledForIntervals
|
||||
readingList
|
||||
setExtensionsEvent:1,0
|
||||
setList
|
||||
useSetExtensions
|
||||
$readingFnAttributes;
|
||||
);
|
||||
use warnings 'qw';
|
||||
$hash->{AttrList} = join(" ", @attrList);
|
||||
}
|
||||
|
||||
###################################
|
||||
@ -60,6 +69,9 @@ dummy_Set($@)
|
||||
my $v = join(" ", @a);
|
||||
Log3 $name, 4, "dummy set $name $v";
|
||||
|
||||
$v = $hash->{SetExtensionsCommand}
|
||||
if($hash->{SetExtensionsCommand} &&
|
||||
AttrVal($name, "setExtensionsEvent", undef));
|
||||
readingsSingleUpdate($hash,"state",$v,1);
|
||||
return undef;
|
||||
}
|
||||
@ -135,6 +147,10 @@ dummy_Define($$)
|
||||
In this case no arbitrary set commands are accepted, only the setList and
|
||||
the set exensions commands.</li>
|
||||
|
||||
<li><a name="setExtensionsEvent">setExtensionsEvent</a><br>
|
||||
If set, the event will contain the command implemented by SetExtensions
|
||||
(e.g. on-for-timer 10), else the executed command (e.g. on).</li>
|
||||
|
||||
<li><a href="#readingFnAttributes">readingFnAttributes</a></li>
|
||||
</ul>
|
||||
<br>
|
||||
@ -198,6 +214,11 @@ dummy_Define($$)
|
||||
diesem Fall werden nur die Befehle aus setList und die set exensions
|
||||
akzeptiert.</li>
|
||||
|
||||
<li><a name="setExtensionsEvent">setExtensionsEvent</a><br>
|
||||
Falls gesetzt, enthält das Event den im SetExtensions
|
||||
implementierten Befehl (z.Bsp. on-for-timer 10), sonst den
|
||||
Ausgefürten (z.Bsp. on).</li>
|
||||
|
||||
<li><a href="#readingFnAttributes">readingFnAttributes</a></li>
|
||||
</ul>
|
||||
<br>
|
||||
|
@ -38,6 +38,7 @@ SE_DoSet(@)
|
||||
$hash->{InSetExtensions} = 1;
|
||||
AnalyzeCommand($hash->{CL}, "set ".join(" ", @_)); # cmdalias (Forum #63896)
|
||||
delete $hash->{InSetExtensions};
|
||||
delete $hash->{SetExtensionsCommand};
|
||||
}
|
||||
|
||||
sub
|
||||
@ -114,6 +115,7 @@ SetExtensions($$@)
|
||||
my $param = $a[0];
|
||||
|
||||
|
||||
$hash->{SetExtensionsCommand} = $cmd.(@a ? " ".join(" ",@a) : "");
|
||||
if($cmd eq "on-for-timer" || $cmd eq "off-for-timer") {
|
||||
return "$cmd requires a number as argument" if($param !~ m/^\d*\.?\d*$/);
|
||||
|
||||
@ -123,7 +125,7 @@ SetExtensions($$@)
|
||||
CMD=>$cmd, NEXTCMD=>$cmd2
|
||||
};
|
||||
SE_DoSet($name, $cmd1);
|
||||
InternalTimer(gettimeofday()+$param,"SetExtensionsFn","SE $name $cmd",0);
|
||||
InternalTimer(gettimeofday()+$param,"SetExtensionsFn",$hash, 0);
|
||||
}
|
||||
|
||||
} elsif($cmd =~ m/^(on|off)-till/) {
|
||||
@ -153,6 +155,7 @@ SetExtensions($$@)
|
||||
if($param !~ m/^\d+$/ || $p2 !~ m/^\d*\.?\d*$/);
|
||||
|
||||
if($param) {
|
||||
delete($hash->{SetExtensionsCommand}) if($param == 1 && $a[2]);
|
||||
SE_DoSet($name, $a[2] ? $offCmd : $onCmd);
|
||||
$param-- if($a[2]);
|
||||
if($param) {
|
||||
@ -160,7 +163,7 @@ SetExtensions($$@)
|
||||
START=>time(), START_FMT=>TimeNow(), DURATION=>$param,
|
||||
CMD=>$cmd, NEXTCMD=>"$cmd $param $p2 ".($a[2] ? "0" : "1")
|
||||
};
|
||||
InternalTimer(gettimeofday()+$p2, "SetExtensionsFn","SE $name $cmd",0);
|
||||
InternalTimer(gettimeofday()+$p2, "SetExtensionsFn",$hash,0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -175,6 +178,7 @@ SetExtensions($$@)
|
||||
my @lt = localtime;
|
||||
my $hms_from = sprintf("%02d:%02d:%02d", $hr, $min, $sec);
|
||||
my $hms_now = sprintf("%02d:%02d:%02d", $lt[2], $lt[1], $lt[0]);
|
||||
delete($hash->{SetExtensionsCommand}); # Will be set by on-till
|
||||
|
||||
if($hms_from le $hms_now) { # By slight delays at will schedule tomorrow.
|
||||
SetExtensions($hash, $list, $name, "on-till", $till);
|
||||
@ -194,6 +198,7 @@ SetExtensions($$@)
|
||||
}
|
||||
|
||||
} elsif($cmd eq "toggle") {
|
||||
delete($hash->{SetExtensionsCommand}); # Need on/off in STATE
|
||||
my $value = Value($name);
|
||||
(undef,$value) = ReplaceEventMap($name, [$name, $value], 0) if($eventMap);
|
||||
|
||||
@ -208,13 +213,12 @@ SetExtensions($$@)
|
||||
sub
|
||||
SetExtensionsFn($)
|
||||
{
|
||||
my (undef, $name, $cmd) = split(" ", shift, 3);
|
||||
my $hash = $defs{$name};
|
||||
my ($hash) = @_;
|
||||
return if(!$hash || !$hash->{TIMED_OnOff});
|
||||
|
||||
my $nextcmd = $hash->{TIMED_OnOff}{NEXTCMD};
|
||||
delete $hash->{TIMED_OnOff};
|
||||
SE_DoSet($name, split(" ",$nextcmd));
|
||||
SE_DoSet($hash->{NAME}, split(" ",$nextcmd));
|
||||
}
|
||||
|
||||
1;
|
||||
|
Loading…
x
Reference in New Issue
Block a user