2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-03 16:56:54 +00:00

SetExtensions.pm: fix the EnOcean on/off eventMap (Forum #95589)

git-svn-id: https://svn.fhem.de/fhem/trunk@18197 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2019-01-09 20:50:34 +00:00
parent 79376fdcc0
commit 12ab1e3b0a

View File

@ -68,10 +68,11 @@ SetExtensions($$@)
($list =~ m/(^| )$uCmd\b/ ? $uCmd : ""));
}
# Must work with EnOceans "attr x eventMap BI:off B0:on"
sub
getReplCmd($$)
{
my ($name, $cmd);
my ($name, $cmd) = @_;
my (undef,$value) = ReplaceEventMap($name, [$name, $cmd], 0);
return $cmd if($value ne $cmd);
@ -85,15 +86,19 @@ SetExtensions($$@)
my $offCmd = getCmd($list, "off");
my $eventMap = AttrVal($name, "eventMap", undef);
my $fixedIt;
if((!$onCmd || !$offCmd) && $eventMap) {
$onCmd = getReplCmd($name, "on") if(!$onCmd);
$offCmd = getReplCmd($name, "off") if(!$offCmd && $onCmd);
$fixedIt = 1;
}
if(!$onCmd || !$offCmd) { # No extension
return AttrTemplate_Set($hash, $list, $name, $cmd, @a);
}
$cmd = ReplaceEventMap($name, $cmd, 1) if($fixedIt);
if(!defined($se_list{$cmd})) {
# Add only "new" commands
my @mylist = grep { $list !~ m/\b$_\b/ } keys %se_list;