From 61d0461aec92bf7389c6c56e512807a155601235 Mon Sep 17 00:00:00 2001 From: rudolfkoenig <> Date: Sun, 15 Jul 2012 08:04:35 +0000 Subject: [PATCH] eventMap fixes: EnOcean and translation both should work with the on:off toggle git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@1727 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem.pl | 3 ++- webfrontend/pgm2/01_FHEMWEB.pm | 40 +++++++++++++++++++--------------- 2 files changed, 24 insertions(+), 19 deletions(-) diff --git a/fhem.pl b/fhem.pl index 9c8105697..ed7e018af 100755 --- a/fhem.pl +++ b/fhem.pl @@ -2542,7 +2542,8 @@ ReplaceEventMap($$$) { my ($dev, $str, $dir) = @_; my $em = $attr{$dev}{eventMap}; - return $str if(!$em || (!$dir && $str->[1] eq "?")); + return $str if($dir && !$em); + return @{$str} if(!$dir && (!$em || $str->[1] eq "?")); my $dname = shift @{$str} if(!$dir); my $nstr = join(" ", @{$str}) if(!$dir); diff --git a/webfrontend/pgm2/01_FHEMWEB.pm b/webfrontend/pgm2/01_FHEMWEB.pm index 6a99e88b2..dc71d04f1 100755 --- a/webfrontend/pgm2/01_FHEMWEB.pm +++ b/webfrontend/pgm2/01_FHEMWEB.pm @@ -653,8 +653,7 @@ FW_doDetail($) FW_pO ""; foreach my $cmd (split(":", $webCmd)) { FW_pO ""; - FW_pH "cmd.$d=set $d $cmd&detail=$d", - ReplaceEventMap($d,$cmd,1), 1, "col1"; + FW_pH "cmd.$d=set $d $cmd&detail=$d", $cmd, 1, "col1"; FW_pO ""; } FW_pO "
"; @@ -903,7 +902,6 @@ FW_showRoom() FW_pO ""; if($cmdlist) { my @cList = split(":", $cmdlist); - my @rList = map { ReplaceEventMap($d,$_,1) } @cList; my $firstIdx = 0; # Special handling (slider, dropdown) @@ -952,8 +950,7 @@ FW_showRoom() } for(my $idx=$firstIdx; $idx < @cList; $idx++) { - FW_pH "cmd.$d=set $d $cList[$idx]$rf", - ReplaceEventMap($d,$cList[$idx],1),1,"col3"; + FW_pH "cmd.$d=set $d $cList[$idx]$rf", $cList[$idx], 1,"col3"; } @@ -1879,18 +1876,24 @@ sub FW_dev2image($) { my ($name) = @_; - my $icon = ""; - return $icon if(!$name || !$defs{$name}); + my $d = $defs{$name}; + return "" if(!$name || !$d); - my ($type, $state) = ($defs{$name}{TYPE}, $defs{$name}{STATE}); - return $icon if(!$type || !defined($state)); + my ($type, $state) = ($d->{TYPE}, $d->{STATE}); + return "" if(!$type || !$state); + my (undef, $rstate) = ReplaceEventMap($name, [undef, $state], 0); $state =~ s/ .*//; # Want to be able to have icons for "on-for-timer xxx" - $icon = $FW_icons{$state} if(defined($FW_icons{$state}));# on.png - $icon = $FW_icons{$type} if($FW_icons{$type}); # FS20.png - $icon = $FW_icons{"$type.$state"} if($FW_icons{"$type.$state"}); # FS20.on.png - $icon = $FW_icons{$name} if($FW_icons{$name}); # lamp.png - $icon = $FW_icons{"$name.$state"} if($FW_icons{"$name.$state"}); # lamp.on.png + + my $icon; + $icon = $FW_icons{"$name.$state"} if(!$icon); # lamp.Aus.png + $icon = $FW_icons{"$name.$rstate"} if(!$icon); # lamp.on.png + $icon = $FW_icons{$name} if(!$icon); # lamp.png + $icon = $FW_icons{"$type.$state"} if(!$icon); # FS20.Aus.png + $icon = $FW_icons{"$type.$rstate"} if(!$icon); # FS20.on.png + $icon = $FW_icons{$type} if(!$icon); # FS20.png + $icon = $FW_icons{$state} if(!$icon); # Aus.png + $icon = $FW_icons{$rstate} if(!$icon); # on.png return $icon; } @@ -2068,10 +2071,11 @@ FW_devState($$) $cmdlist = $webCmd; } elsif($hasOnOff && !$cmdlist) { - my (undef, $nstate) = ReplaceEventMap($d, [$d, $state], 0); - $nstate = $state if(!defined($nstate)); - $link = "cmd.$d=set $d " . ($nstate eq "on" ? "off" : "on"); - $cmdlist = "on:off"; + # Have to cover: "on:An off:Aus", "A0:Aus AI:An Aus:off An:on" + my $on = ReplaceEventMap($d, "on", 1); + my $off = ReplaceEventMap($d, "off", 1); + $link = "cmd.$d=set $d " . ($state eq $on ? $off : $on); + $cmdlist = "$on:$off"; }