eventMap changes
git-svn-id: https://fhem.svn.sourceforge.net/svnroot/fhem/trunk/fhem@965 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
1
CHANGED
1
CHANGED
@@ -2,6 +2,7 @@
|
|||||||
- bugfix: applying smallscreen attributes to firefox/opera
|
- bugfix: applying smallscreen attributes to firefox/opera
|
||||||
- feature: CUL_TX added (thanks to Peterp)
|
- feature: CUL_TX added (thanks to Peterp)
|
||||||
- feature: TCM120 / EnOcean parser added
|
- feature: TCM120 / EnOcean parser added
|
||||||
|
- feature: eventMap enhanced
|
||||||
|
|
||||||
- 2011-07-08 (5.1)
|
- 2011-07-08 (5.1)
|
||||||
- feature: smallscreen optimizations for iPhone
|
- feature: smallscreen optimizations for iPhone
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
fw=$1
|
fw=$1
|
||||||
if test ! -f ../../$fw.tar.gz; then
|
if test ! -f ../../$fw.tar.gz; then
|
||||||
echo "usage: makeimage <fhem-VERSION.tar.gz>"
|
echo "usage: makeimage <fhem-VERSION>"
|
||||||
echo "../../<fhem-VERSION>.tar.gz must exist"
|
echo "../../<fhem-VERSION>.tar.gz must exist"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -1318,14 +1318,16 @@ A line ending with \ will be concatenated with the next one, so long lines
|
|||||||
|
|
||||||
<a name="eventMap"></a>
|
<a name="eventMap"></a>
|
||||||
<li>eventMap<br>
|
<li>eventMap<br>
|
||||||
Exchange event or command names to a device specific version. This
|
Replace event names and set arguments. The value of this attribute
|
||||||
will also be used to exchange set arguments (if possible).
|
consists of a list of space separated values, each value is a colon
|
||||||
Example:<ul><code>
|
separated pair. The first part specifies the "old" value, the second
|
||||||
|
the new/desired value. If the first character is slash(/) or komma(,)
|
||||||
|
then split not by space but by this character, enabling to embed spaces.
|
||||||
|
Examples:<ul><code>
|
||||||
attr store eventMap on:open off:closed<br>
|
attr store eventMap on:open off:closed<br>
|
||||||
|
attr store eventMap /on-for-timer 10:open/off:closed/<br>
|
||||||
set store open
|
set store open
|
||||||
</code></ul>
|
</code></ul>
|
||||||
The attribute applies to all set commands, events and to the device
|
|
||||||
state, but not to the other device READINGS.
|
|
||||||
</li><br>
|
</li><br>
|
||||||
|
|
||||||
<li><a href="#do_not_notify">do_not_notify</a></li><br>
|
<li><a href="#do_not_notify">do_not_notify</a></li><br>
|
||||||
|
|||||||
79
fhem.pl
79
fhem.pl
@@ -66,7 +66,7 @@ sub Log($$);
|
|||||||
sub OpenLogfile($);
|
sub OpenLogfile($);
|
||||||
sub PrintHash($$);
|
sub PrintHash($$);
|
||||||
sub ReadingsVal($$$);
|
sub ReadingsVal($$$);
|
||||||
sub ReplaceEventMap($$);
|
sub ReplaceEventMap($$$);
|
||||||
sub ResolveDateWildcards($@);
|
sub ResolveDateWildcards($@);
|
||||||
sub RemoveInternalTimer($);
|
sub RemoveInternalTimer($);
|
||||||
sub SecondsTillTomorrow($);
|
sub SecondsTillTomorrow($);
|
||||||
@@ -167,7 +167,7 @@ my $nextat; # Time when next timer will be triggered.
|
|||||||
my $intAtCnt=0;
|
my $intAtCnt=0;
|
||||||
my %duplicate; # Pool of received msg for multi-fhz/cul setups
|
my %duplicate; # Pool of received msg for multi-fhz/cul setups
|
||||||
my $duplidx=0; # helper for the above pool
|
my $duplidx=0; # helper for the above pool
|
||||||
my $cvsid = '$Id: fhem.pl,v 1.148 2011-07-24 11:53:11 rudolfkoenig Exp $';
|
my $cvsid = '$Id: fhem.pl,v 1.149 2011-07-30 13:22:25 rudolfkoenig Exp $';
|
||||||
my $namedef =
|
my $namedef =
|
||||||
"where <name> is either:\n" .
|
"where <name> is either:\n" .
|
||||||
"- a single device name\n" .
|
"- a single device name\n" .
|
||||||
@@ -1043,16 +1043,8 @@ DoSet(@)
|
|||||||
my $dev = $a[0];
|
my $dev = $a[0];
|
||||||
return "Please define $dev first" if(!$defs{$dev});
|
return "Please define $dev first" if(!$defs{$dev});
|
||||||
return "No set implemented for $dev" if(!$modules{$defs{$dev}{TYPE}}{SetFn});
|
return "No set implemented for $dev" if(!$modules{$defs{$dev}{TYPE}}{SetFn});
|
||||||
if($attr{$dev}{eventMap}) {
|
|
||||||
foreach my $rv (split(" ", $attr{$dev}{eventMap})) {
|
|
||||||
my ($re, $val) = split(":", $rv, 2);
|
|
||||||
if($a[1] =~ m/$val/) {
|
|
||||||
$a[1] =~ s/$val/$re/;
|
|
||||||
last;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
@a = ReplaceEventMap($dev, \@a, 0) if($attr{$dev}{eventMap});
|
||||||
my $ret = CallFn($dev, "SetFn", $defs{$dev}, @a);
|
my $ret = CallFn($dev, "SetFn", $defs{$dev}, @a);
|
||||||
return $ret if($ret);
|
return $ret if($ret);
|
||||||
|
|
||||||
@@ -1724,25 +1716,18 @@ CommandSetstate($$)
|
|||||||
my $d = $defs{$sdev};
|
my $d = $defs{$sdev};
|
||||||
|
|
||||||
# Detailed state with timestamp
|
# Detailed state with timestamp
|
||||||
if($a[1] =~ m/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2} /) {
|
if($a[1] =~ m/^(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}) +([^ ].*)$/) {
|
||||||
my @b = split(" ", $a[1], 4);
|
my ($tim, $nameval) = ($1, $2);
|
||||||
|
my ($sname, $sval) = split(" ", $nameval, 2);
|
||||||
if($defs{$sdev}{TYPE} eq "FS20" && $b[2] ne "state") { # Compatibility
|
my $ret = CallFn($sdev, "StateFn", $d, $tim, $sname, $sval);
|
||||||
$b[3] = $b[2] . ($b[3] ? " $b[3]" : "");
|
|
||||||
$b[2] = "state";
|
|
||||||
}
|
|
||||||
|
|
||||||
my $tim = "$b[0] $b[1]";
|
|
||||||
ReplaceEventMap($sdev, $b[2]);
|
|
||||||
my $ret = CallFn($sdev, "StateFn", $d, $tim, $b[2], $b[3]);
|
|
||||||
if($ret) {
|
if($ret) {
|
||||||
push @rets, $ret;
|
push @rets, $ret;
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$d->{READINGS}{$b[2]} || $d->{READINGS}{$b[2]}{TIME} lt $tim) {
|
if(!$d->{READINGS}{$sname} || $d->{READINGS}{$sname}{TIME} lt $tim) {
|
||||||
$d->{READINGS}{$b[2]}{VAL} = $b[3];
|
$d->{READINGS}{$sname}{VAL} = $sval;
|
||||||
$d->{READINGS}{$b[2]}{TIME} = $tim;
|
$d->{READINGS}{$sname}{TIME} = $tim;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@@ -2068,9 +2053,9 @@ DoTrigger($$)
|
|||||||
if($attr{$dev}{eventMap}) {
|
if($attr{$dev}{eventMap}) {
|
||||||
my $c = $defs{$dev}{CHANGED};
|
my $c = $defs{$dev}{CHANGED};
|
||||||
for(my $i = 0; $i < @{$c}; $i++) {
|
for(my $i = 0; $i < @{$c}; $i++) {
|
||||||
$c->[$i] = ReplaceEventMap($dev, $c->[$i]);
|
$c->[$i] = ReplaceEventMap($dev, $c->[$i], 1);
|
||||||
}
|
}
|
||||||
$defs{$dev}{STATE} = ReplaceEventMap($dev, $defs{$dev}{STATE});
|
$defs{$dev}{STATE} = ReplaceEventMap($dev, $defs{$dev}{STATE}, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
# STATE && {READINGS}{state} should be the same
|
# STATE && {READINGS}{state} should be the same
|
||||||
@@ -2503,19 +2488,43 @@ addToAttrList($)
|
|||||||
}
|
}
|
||||||
|
|
||||||
sub
|
sub
|
||||||
ReplaceEventMap($$)
|
ReplaceEventMap($$$)
|
||||||
{
|
{
|
||||||
my ($dev, $str) = @_;
|
my ($dev, $str, $dir) = @_;
|
||||||
return $str if(!$attr{$dev}{eventMap});
|
my $em = $attr{$dev}{eventMap};
|
||||||
|
return $str if(!$em);
|
||||||
|
|
||||||
foreach my $rv (split(" ", $attr{$dev}{eventMap})) {
|
my $sc = " "; # Split character
|
||||||
|
my $fc = substr($em, 0, 1); # First character of the eventmap
|
||||||
|
if($fc eq "," || $fc eq "/") {
|
||||||
|
$sc = $fc;
|
||||||
|
$em = substr($em, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
my $nstr = join(" ", @{$str}) if(!$dir);
|
||||||
|
my $changed;
|
||||||
|
foreach my $rv (split($sc, $em)) {
|
||||||
my ($re, $val) = split(":", $rv, 2);
|
my ($re, $val) = split(":", $rv, 2);
|
||||||
if($str =~ m/$re/) {
|
next if(!defined($val));
|
||||||
$str =~ s/$re/$val/;
|
if($dir) { # event -> Presentation
|
||||||
last;
|
if($str =~ m/$re/) {
|
||||||
|
$str =~ s/$re/$val/;
|
||||||
|
$changed = 1;
|
||||||
|
last;
|
||||||
|
}
|
||||||
|
|
||||||
|
} else { # Setting event
|
||||||
|
if($nstr =~ m/$val/) {
|
||||||
|
$nstr =~ s/$val/$re/;
|
||||||
|
$changed = 1;
|
||||||
|
last;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $str;
|
return $str if($dir);
|
||||||
|
return split(" ",$nstr) if($changed);
|
||||||
|
return @{$str};
|
||||||
}
|
}
|
||||||
|
|
||||||
sub
|
sub
|
||||||
|
|||||||
Reference in New Issue
Block a user