From 4d3845ed7f7577e70e9498f2685f93c1cc37b465 Mon Sep 17 00:00:00 2001 From: rudolfkoenig Date: Sat, 6 Nov 2010 19:31:38 +0000 Subject: [PATCH] CUL_HM added git-svn-id: https://fhem.svn.sourceforge.net/svnroot/fhem/trunk/fhem@751 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- CHANGED | 1 + FHEM/00_CUL.pm | 87 +++++++++++++++++++++++++++++---------- FHEM/98_autocreate.pm | 1 - docs/commandref.html | 95 +++++++++++++++++++++++++++++++++++-------- fhem.pl | 24 +++++++---- 5 files changed, 161 insertions(+), 47 deletions(-) diff --git a/CHANGED b/CHANGED index 31af1e45a..48ad8fc91 100644 --- a/CHANGED +++ b/CHANGED @@ -7,6 +7,7 @@ - bugfix: S300TH sanity check won't allow negative temperatures. - feature: decode CUL uptime - feature: USB doc changes, FHZ initFS20_02/stopHMS parameters by Andreas. + - feature: CUL_HM (experimental) for HomeMatic devices. - 2010-08-15 (5.0) - **NOTE*: The default installation path is changed to satisfy lintian diff --git a/FHEM/00_CUL.pm b/FHEM/00_CUL.pm index 205495156..5e3bc9515 100755 --- a/FHEM/00_CUL.pm +++ b/FHEM/00_CUL.pm @@ -5,15 +5,15 @@ use strict; use warnings; use Time::HiRes qw(gettimeofday); - +sub CUL_Attr(@); sub CUL_Clear($); -sub CUL_Write($$$); -sub CUL_Read($); -sub CUL_ReadAnswer($$$$); -sub CUL_Ready($); sub CUL_HandleCurRequest($$); sub CUL_HandleWriteQueue($); sub CUL_Parse($$$$$); +sub CUL_Read($); +sub CUL_ReadAnswer($$$$); +sub CUL_Ready($); +sub CUL_Write($$$); sub CUL_OpenDev($$); sub CUL_CloseDev($); @@ -38,7 +38,6 @@ my %sets = ( "bWidth" => "", "rAmpl" => "", "sens" => "", - "verbose" => "X", "led" => "l", "patable" => "x", "file" => "", @@ -47,18 +46,11 @@ my %sets = ( my @ampllist = (24, 27, 30, 33, 36, 38, 40, 42); # rAmpl(dB) -sub -CUL_Initialize($) -{ - my ($hash) = @_; +my $clientsSlowRF = ":FS20:FHT:FHT8V:KS300:USF1000:BS:HMS" . + ":CUL_EM:CUL_WS:CUL_FHTTK:CUL_RFR:CUL_HOERMANN:"; +my $clientsHomeMatic = ":CUL_HM:"; -# Provider - $hash->{ReadFn} = "CUL_Read"; - $hash->{WriteFn} = "CUL_Write"; - $hash->{Clients} = - ":FS20:FHT:KS300:CUL_EM:CUL_WS:USF1000:BS:HMS:CUL_FHTTK:CUL_RFR:FHT8V". - ":CUL_HOERMANN:"; - my %mc = ( +my %matchListSlowRF = ( "1:USF1000" => "^81..(04|0c)..0101a001a5ceaa00....", "2:BS" => "^81..(04|0c)..0101a001a5cf", "3:FS20" => "^81..(04|0c)..0101a001", @@ -70,8 +62,23 @@ CUL_Initialize($) "9:CUL_FHTTK" => "^T........", "A:CUL_RFR" => "^[0-9A-F]{4}U.", "B:CUL_HOERMANN"=> "^R..........", - ); - $hash->{MatchList} = \%mc; +); +my %matchListHomeMatic = ( + "1:CUL_HM" => "^A......................", +); + +sub +CUL_Initialize($) +{ + my ($hash) = @_; + +# Provider + $hash->{ReadFn} = "CUL_Read"; + $hash->{WriteFn} = "CUL_Write"; + $hash->{Clients} = $clientsSlowRF; + $hash->{MatchList} = \%matchListSlowRF; + $hash->{HomeMaticClients} = $clientsHomeMatic; + $hash->{HomeMaticMatchList} = \%matchListHomeMatic; $hash->{ReadyFn} = "CUL_Ready"; # Normal devices @@ -80,9 +87,11 @@ CUL_Initialize($) $hash->{GetFn} = "CUL_Get"; $hash->{SetFn} = "CUL_Set"; $hash->{StateFn} = "CUL_SetState"; + $hash->{AttrFn} = "CUL_Attr"; $hash->{AttrList}= "do_not_notify:1,0 dummy:1,0 " . "showtime:1,0 model:CUL,CUN,CUR loglevel:0,1,2,3,4,5,6 " . - "fhtsoftbuffer:1,0 sendpool addvaltrigger"; + "fhtsoftbuffer:1,0 sendpool addvaltrigger " . + "rfmode:SlowRF,HomeMatic hm_autopair"; $hash->{ShutdownFn} = "CUL_Shutdown"; } @@ -282,7 +291,6 @@ WRITEEND: return "Expecting a 0-padded hex number" if((length($arg)&1) == 1 && $type ne "raw"); - $initstr = "X$arg" if($type eq "verbose"); Log $ll, "set $name $type $arg"; CUL_SimpleWrite($hash, $sets{$type} . $arg); @@ -456,6 +464,7 @@ CUL_DoInit($) Log 1, $msg; return $msg; } + $ver =~ s/[\r\n]//g; $hash->{VERSION} = $ver; if($ver =~ m/CUR/) { @@ -757,7 +766,7 @@ CUL_Parse($$$$$) my $rssi; my $dmsg = $rmsg; - if($initstr =~ m/X2/ && $dmsg =~ m/^[FTKEHR]([A-F0-9][A-F0-9])+$/) { # RSSI + if($dmsg =~ m/^[AFTKEHR]([A-F0-9][A-F0-9])+$/) { # RSSI my $l = length($dmsg); $rssi = hex(substr($dmsg, $l-2, 2)); $dmsg = substr($dmsg, 0, $l-2); @@ -829,6 +838,8 @@ CUL_Parse($$$$$) ; } elsif($fn eq "R" && $len >= 11) { # CUL_EM / Native ; + } elsif($fn eq "A" && $len >= 21) { # AskSin/BidCos/HomeMatic + ; } else { Log GetLogLevel($name,2), "$name: unknown message $dmsg"; return; @@ -1069,4 +1080,36 @@ CUL_Disconnected($) DoTrigger($name, "DISCONNECTED"); } +sub +CUL_Attr(@) +{ + my @a = @_; + + if($a[2] eq "rfmode") { + + my $name = $a[1]; + my $hash = $defs{$name}; + + if($a[3] eq "HomeMatic") { + return if($initstr eq "Ar"); + $hash->{mode} = "HomeMatic"; + $initstr = "Ar"; + CUL_SimpleWrite($hash, $initstr); + + } else { + return if($initstr eq "X21"); + delete($hash->{mode}); + $initstr = "X21"; + CUL_SimpleWrite($hash, "Ax"); + CUL_SimpleWrite($hash, $initstr); + + } + + Log 2, "Switched $name rfmode to $a[3]"; + + } + + return undef; +} + 1; diff --git a/FHEM/98_autocreate.pm b/FHEM/98_autocreate.pm index e3c074744..e32aaa40c 100644 --- a/FHEM/98_autocreate.pm +++ b/FHEM/98_autocreate.pm @@ -172,7 +172,6 @@ autocreate_Notify($$) } } - CommandSave(undef, undef) if(!$ret && $nrcreated && $attr{$me}{autosave}); return $ret; } diff --git a/docs/commandref.html b/docs/commandref.html index dace4f1b9..6a89db8dd 100644 --- a/docs/commandref.html +++ b/docs/commandref.html @@ -76,6 +76,7 @@ CUL   CUL_EM   CUL_FHTTK   + CUL_HM   CUL_HOERMANN   CUL_RFR   CUL_WS   @@ -790,7 +791,8 @@ A line ending with \ will be concatenated with the next one, so long lines
  fhem> xmllist
   <FHZINFO>
           <internal_LIST>
-                  <internal name="global" state="internal" sets="" attrs="room configfile logfile modpath pidfilename port statefile userattr verbose version">
+                  <internal name="global" state="internal" sets=""
+                            attrs="room configfile logfile ...">
                           <INT key="DEF" value="<no definition>"/>
                           <INT key="NR" value="0"/>
                           <INT key="STATE" value="internal"/>
@@ -1102,7 +1104,6 @@ A line ending with \ will be concatenated with the next one, so long lines
 
     
     
  • fhtsoftbuffer
    - Can be applied to FHZ devices.
    As the FHZ command buffer for FHT devices is limited (see fhtbuf), and commands are only sent to the FHT device every 120 seconds, the hardware buffer may overflow and FHT commands get lost. @@ -1899,11 +1900,6 @@ A line ending with \ will be concatenated with the next one, so long lines Set
      -
    • verbose
      - Set a CUL "verbose" level. See the CUL firmware README document for - details. Note: only X00/X01/X21/X25 is supported by the fhem CUL - module, the other flags may crash fhem. -

    • raw
      Issue a CUL firmware command. See the CUL firmware README document for details on CUL commands. @@ -1973,7 +1969,7 @@ A line ending with \ will be concatenated with the next one, so long lines
    • showtime

    • loglevel

    • model (CUL,CUN,CUR)

    • -
    • sendpool
      +
    • sendpool
      If using more than one CUL/CUN for covering a large area, sending different events by the different CUL's might disturb each other. This phenomenon is also known as the Palm-Beach-Resort effect. @@ -1984,17 +1980,28 @@ A line ending with \ will be concatenated with the next one, so long lines attr CUN2 sendpool CUN1,CUN2,CUN3
      attr CUN3 sendpool CUN1,CUN2,CUN3

    • -
    • fhtsoftbuffer
      - As the CUL command buffer for FHT devices is limited (see fhtbuf), - and commands are only sent to the FHT device every 120 seconds, - the hardware buffer may overflow and FHT commands get lost or errors - may occur. - Setting this attribute implements an "unlimited" software buffer.
      - Default is disabled (i.e. not set or set to 0).

    • -
    • addvaltrigger
      +
    • addvaltrigger
      Create triggers for additional device values. Right now these are RSSI and RAWMSG for the CUL family and RAWMSG for the FHZ.

    • +
    • rfmode
      + Configure the RF Transceiver of the CUL (the CC1101). Available + arguments are: +
        +
      • SlowRF
        + To communicate with FS20/FHT/HMS/EM1010/S300/Hoermann devices @1kHz + datarate. This is the default. + +
      • HomeMatic
        + To communicate with HomeMatic type of devices @20kHz datarate + +
      +

    • + +
    • hm_autopair
      + Only useful in HomeMatic mode, see rfmode above. The CUL_HM Module will + try to pair any device requesting a pairing. +


    @@ -2103,6 +2110,62 @@ A line ending with \ will be concatenated with the next one, so long lines
    + +

    CUL_HM

    +
      + Support for eQ-3 HomeMatic devices via the CUL. Note: The rfmode attribute of at least one attache CUL/CUN device + must be set to HomeMatic. Note: The protocoll used by HomeMatic devices + (BidCos, known as AskSin in the culfw) must be enabled in the culfw firmware. + This is the default for all CUN and for newer CUL (i.e. V3.0 and greater) + devices. Note: This module is experimental! +

      + + + Define +
        + define <name> CUL_HM <6-digit-hex-code> +

        + Best to avoid this command with the autocreate + module enabled, and the hm_autopair attribute + set for the corresponding CUL device. Now set the physical device in + pairing mode (Anlernmodus), the rest should happen automatically. +

      + + + Set +
        + Depends on the subType of the device. +
      • switch +
          +
        • on - set the switch on
        • +
        • off - set the switch off
        • +
        +
      • +

      + + + Get
        N/A

      + + + Attributes +
        +
      • do_not_notify
      • +
      • ignore
      • +
      • showtime
      • +
      • loglevel
      • +
      • name
        + This attribute is set automatically after a successful pairing. + It is not supposed to be set by hand.
      • +
      • subType
        + This attribute is set automatically after a successful pairing. + It is not supposed to be set by hand. It is necessary to be set + in order to use the set command.
      • +
      +
      +
    + +

    CUL_HOERMANN

      diff --git a/fhem.pl b/fhem.pl index 2068e4c0d..8eb55c99e 100755 --- a/fhem.pl +++ b/fhem.pl @@ -162,7 +162,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.115 2010-10-27 16:51:32 rudolfkoenig Exp $'; +my $cvsid = '$Id: fhem.pl,v 1.116 2010-11-06 19:31:38 rudolfkoenig Exp $'; my $namedef = "where is either:\n" . "- a single device name\n" . @@ -1169,8 +1169,9 @@ AssignIoPort($) # Set the I/O device, search for the last compatible one. for my $p (sort { $defs{$b}{NR} <=> $defs{$a}{NR} } keys %defs) { - my $cl = $modules{$defs{$p}{TYPE}}{Clients}; - my $re = $modules{$defs{$p}{TYPE}}{regexpClients}; + my $mode = ($defs{$p}{mode} ? $defs{$p}{mode} : ""); + my $cl = $modules{$defs{$p}{TYPE}}{"${mode}Clients"}; + my $re = $modules{$defs{$p}{TYPE}}{"${mode}regexpClients"}; if(((defined($cl) && $cl =~ m/:$hash->{TYPE}:/) || (defined($re) && $hash->{TYPE} =~ m/$re/)) && $defs{$p}{NAME} ne $hash->{NAME}) { # e.g. RFR @@ -2157,11 +2158,12 @@ Dispatch($$$) } my @found; + my $mode = ($hash->{mode} ? $hash->{mode} : ""); foreach my $m (sort { $modules{$a}{ORDER} cmp $modules{$b}{ORDER} } grep {defined($modules{$_}{ORDER})} keys %modules) { - my $cl = $iohash->{Clients}; - my $re = $iohash->{regexpClients}; + my $cl = $iohash->{"${mode}Clients"}; + my $re = $iohash->{"${mode}regexpClients"}; next if(!(defined($cl) && $cl =~ m/:$m:/) || (defined($re) && $m =~ m/$re/)); @@ -2175,10 +2177,9 @@ Dispatch($$$) } if(!int(@found)) { - my $h = $iohash->{MatchList}; + my $h = $iohash->{"${mode}MatchList"}; if(defined($h)) { foreach my $m (sort keys %{$h}) { - if($dmsg =~ m/$h->{$m}/) { my ($order, $mname) = split(":", $m); @@ -2318,6 +2319,14 @@ ReadingsVal($$$) return $default; } +sub +AttrVal($$$) +{ + my ($d,$n,$default) = @_; + return $attr{$d}{$n} if(defined($attr{$d}) && defined($attr{$d}{$n})); + return $default; +} + sub addToAttrList($) { @@ -2333,4 +2342,3 @@ addToAttrList($) $hash{$arg} = 1; $attr{global}{userattr} = join(" ", sort keys %hash); } -