eventMap added, exchange_on_off removed

git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@782 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2010-12-27 09:42:16 +00:00
parent c8b3d2d81d
commit 064f91824e
4 changed files with 65 additions and 12 deletions

View File

@ -11,6 +11,8 @@
- bugfix: HTML-Syntax check of the pgm2 output and documents (*.html)
- feature: added date alias for FHT80b (Boris)
- feature: attr may be a regexp (for CUL_IR)
- feature: Homepage moved from koeniglich.de/fhem to fhem.de
- feature: eventMap attribute
- 2010-08-15 (5.0)
- **NOTE*: The default installation path is changed to satisfy lintian

9
TODO
View File

@ -1,11 +1,11 @@
FHEM:
- Avoid same firstbyte CUL id for multi-CUL
- HomeMatic signing
- autocreate for HomeMatic
- autodetect physical hardware
- RFR: Error message for uncomplete last message
- fix autocreate rename anomaly (rename filelog only)
- implement PID
- implement wiki decisions
- autodetect physical hardware
- fhem-to-fhem module
- CUR built-in MENU creation support
Webpgm2
- plot data from multiple files in a single picture
@ -13,3 +13,4 @@ Webpgm2
- click on the graph only correct for the day zoom
- integrate weblink details in the SVG
- autocreate: multiple plots
- fancy webkit tranformations

View File

@ -1250,6 +1250,18 @@ A line ending with \ will be concatenated with the next one, so long lines
you attached more than one physical device capable of receiving signals
for this logical device.</li><br>
<a name="eventMap"></a>
<li>eventMap<br>
Exchange event or command names to a device specific version. This
will also be used to exchange set arguments (if possible).
Example:<ul><code>
attr store eventMap on:open off:closed<br>
set store open
</code></ul>
The code applies to all set commands, events and to the device state,
but not to the other device READINGS.
</li><br>
<li><a href="#do_not_notify">do_not_notify</a></li><br>
<a name="attrdummy"></a>
<li>dummy<br>
@ -1304,11 +1316,6 @@ A line ending with \ will be concatenated with the next one, so long lines
"ignored=1" special devspec.
</li><br>
<a name="exchange_on_off"></a>
<li>exchange_on_off<br>
Exchange on and off (and on-for-timer, etc). Both reception and sending
is exchanged.</li>
</ul>
</ul>
@ -1532,6 +1539,7 @@ A line ending with \ will be concatenated with the next one, so long lines
<li><a href="#model">model</a> (fht80b)</li><br>
<li><a href="#showtime">showtime</a></li><br>
<li><a href="#IODev">IODev</a></li><br>
<li><a href="#eventMap">eventMap</a></li><br>
<a name="retrycount"></a>
<li>retrycount<br/>
@ -1636,6 +1644,7 @@ A line ending with \ will be concatenated with the next one, so long lines
<li><a href="#dummy">loglevel</a></li>
<li><a href="#ignore">ignore</a></li>
<li><a href="#loglevel">loglevel</a></li>
<li><a href="#eventMap">eventMap</a></li><br>
</ul>
<br>
</ul>
@ -1764,6 +1773,7 @@ A line ending with \ will be concatenated with the next one, so long lines
<li><a href="#showtime">showtime</a></li><br>
<li><a href="#IODev">IODev</a></li><br>
<li><a href="#ignore">ignore</a></li><br>
<li><a href="#eventMap">eventMap</a></li><br>
</ul>
<br>
@ -1836,6 +1846,7 @@ A line ending with \ will be concatenated with the next one, so long lines
<li><a href="#loglevel">loglevel</a></li><br>
<li><a href="#showtime">showtime</a></li><br>
<li><a href="#IODev">IODev</a></li><br>
<li><a href="#eventMap">eventMap</a></li><br>
<li><a href="#model">model</a> (hms100-t hms100-tf hms100-wd hms100-mg
hms100-co hms100-tfk hms100-fit rm100-2)</li>
</ul>
@ -2060,6 +2071,7 @@ A line ending with \ will be concatenated with the next one, so long lines
<li><a href="#loglevel">loglevel</a></li><br>
<li><a href="#model">model</a> (S300,KS300,WS7000)</li><br>
<li><a href="#IODev">IODev</a></li><br>
<li><a href="#eventMap">eventMap</a></li><br>
</ul>
<br>
</ul>
@ -2126,6 +2138,7 @@ A line ending with \ will be concatenated with the next one, so long lines
<li><a href="#loglevel">loglevel</a></li><br>
<li><a href="#model">model</a> (EMEM,EMWZ,EMGZ)</li><br>
<li><a href="#IODev">IODev</a></li><br>
<li><a href="#eventMap">eventMap</a></li><br>
</ul>
<br>
</ul>
@ -2746,6 +2759,7 @@ A line ending with \ will be concatenated with the next one, so long lines
<ul>
<li><a href="#ignore">ignore</a></li>
<li><a href="#IODev">IODev</a></li>
<li><a href="#eventMap">eventMap</a></li><br>
<li><a href="#do_not_notify">do_not_notify</a></li>
<li><a href="#showtime">showtime</a></li>
<li><a href="#loglevel">loglevel</a></li>
@ -2941,6 +2955,7 @@ A line ending with \ will be concatenated with the next one, so long lines
<li><a href="#model">model</a> (lm12,lm15,am12,tm13)</li>
<li><a href="#loglevel">loglevel</a></li>
<li><a href="#IODev">IODev</a></li><br>
<li><a href="#eventMap">eventMap</a></li><br>
</ul>
<br>
</ul>

41
fhem.pl
View File

@ -64,6 +64,7 @@ sub Log($$);
sub OpenLogfile($);
sub PrintHash($$);
sub ReadingsVal($$$);
sub ReplaceEventMap($$);
sub ResolveDateWildcards($@);
sub RemoveInternalTimer($);
sub SecondsTillTomorrow($);
@ -162,7 +163,7 @@ my $nextat; # Time when next timer will be triggered.
my $intAtCnt=0;
my %duplicate; # Pool of received msg for multi-fhz/cul setups
my $duplidx=0; # helper for the above pool
my $cvsid = '$Id: fhem.pl,v 1.119 2010-12-21 07:45:28 rudolfkoenig Exp $';
my $cvsid = '$Id: fhem.pl,v 1.120 2010-12-27 09:42:16 rudolfkoenig Exp $';
my $namedef =
"where <name> is either:\n" .
"- a single device name\n" .
@ -183,6 +184,7 @@ $modules{_internal_}{AttrList} =
"verbose:1,2,3,4,5 mseclog version nofork logdir holiday2we " .
"autoload_undefined_devices";
$modules{_internal_}{AttrFn} = "GlobalAttr";
my $commonAttr = "eventMap";
%cmds = (
@ -997,6 +999,16 @@ DoSet(@)
my $dev = $a[0];
return "Please define $dev first" if(!$defs{$dev});
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;
}
}
}
my $ret = CallFn($dev, "SetFn", $defs{$dev}, @a);
return $ret if($ret);
@ -1452,6 +1464,7 @@ getAllAttr($)
if($modules{$defs{$d}{TYPE}}{AttrList});
$list .= " " . $attr{global}{userattr}
if($attr{global}{userattr});
$list .= " " . $commonAttr;
return $list;
}
@ -1958,8 +1971,13 @@ DoTrigger($$)
return "";
}
# Done by the modules to be able to ignore unimportant messages
#$defs{$dev}{STATE} = $defs{$dev}{CHANGED}[0];
if($attr{$dev}{eventMap}) {
my $c = $defs{$dev}{CHANGED};
for(my $i = 0; $i < @{$c}; $i++) {
$c->[$i] = ReplaceEventMap($dev, $c->[$i]);
}
$defs{$dev}{STATE} = ReplaceEventMap($dev, $defs{$dev}{STATE});
}
# STATE && {READINGS}{state} should be the same
my $r = $defs{$dev}{READINGS};
@ -2344,6 +2362,7 @@ AttrVal($$$)
return $default;
}
# Add an attribute to the userattr list, if not yet present
sub
addToAttrList($)
{
@ -2359,3 +2378,19 @@ addToAttrList($)
$hash{$arg} = 1;
$attr{global}{userattr} = join(" ", sort keys %hash);
}
sub
ReplaceEventMap($$)
{
my ($dev, $str) = @_;
return $str if(!$attr{$dev}{eventMap});
foreach my $rv (split(" ", $attr{$dev}{eventMap})) {
my ($re, $val) = split(":", $rv, 2);
if($str =~ m/$re/) {
$str =~ s/$re/$val/;
last;
}
}
return $str;
}