From 064f91824ef0c8b865f90ff7442f3747820cddc2 Mon Sep 17 00:00:00 2001 From: rudolfkoenig <> Date: Mon, 27 Dec 2010 09:42:16 +0000 Subject: [PATCH] eventMap added, exchange_on_off removed git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@782 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- CHANGED | 2 ++ TODO | 9 +++++---- docs/commandref.html | 25 ++++++++++++++++++++----- fhem.pl | 41 ++++++++++++++++++++++++++++++++++++++--- 4 files changed, 65 insertions(+), 12 deletions(-) diff --git a/CHANGED b/CHANGED index e5713966a..bf9e68c80 100644 --- a/CHANGED +++ b/CHANGED @@ -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 diff --git a/TODO b/TODO index 4477d4d4a..56b7d4365 100644 --- a/TODO +++ b/TODO @@ -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 diff --git a/docs/commandref.html b/docs/commandref.html index 37643882d..3156bd0db 100644 --- a/docs/commandref.html +++ b/docs/commandref.html @@ -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.
+ +
  • eventMap
    + Exchange event or command names to a device specific version. This + will also be used to exchange set arguments (if possible). + Example: + The code applies to all set commands, events and to the device state, + but not to the other device READINGS. +

  • +
  • do_not_notify

  • dummy
    @@ -1304,11 +1316,6 @@ A line ending with \ will be concatenated with the next one, so long lines "ignored=1" special devspec.

  • - -
  • exchange_on_off
    - Exchange on and off (and on-for-timer, etc). Both reception and sending - is exchanged.
  • - @@ -1532,6 +1539,7 @@ A line ending with \ will be concatenated with the next one, so long lines
  • model (fht80b)

  • showtime

  • IODev

  • +
  • eventMap

  • retrycount
    @@ -1636,6 +1644,7 @@ A line ending with \ will be concatenated with the next one, so long lines
  • loglevel
  • ignore
  • loglevel
  • +
  • eventMap


  • @@ -1764,6 +1773,7 @@ A line ending with \ will be concatenated with the next one, so long lines
  • showtime

  • IODev

  • ignore

  • +
  • eventMap


  • @@ -1836,6 +1846,7 @@ A line ending with \ will be concatenated with the next one, so long lines
  • loglevel

  • showtime

  • IODev

  • +
  • eventMap

  • model (hms100-t hms100-tf hms100-wd hms100-mg hms100-co hms100-tfk hms100-fit rm100-2)
  • @@ -2060,6 +2071,7 @@ A line ending with \ will be concatenated with the next one, so long lines
  • loglevel

  • model (S300,KS300,WS7000)

  • IODev

  • +
  • eventMap


  • @@ -2126,6 +2138,7 @@ A line ending with \ will be concatenated with the next one, so long lines
  • loglevel

  • model (EMEM,EMWZ,EMGZ)

  • IODev

  • +
  • eventMap


  • @@ -2746,6 +2759,7 @@ A line ending with \ will be concatenated with the next one, so long lines
    diff --git a/fhem.pl b/fhem.pl index 3303d5ed1..18cd3be74 100755 --- a/fhem.pl +++ b/fhem.pl @@ -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 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; +}