diff --git a/CHANGED b/CHANGED index 431565284..79e813486 100644 --- a/CHANGED +++ b/CHANGED @@ -526,4 +526,5 @@ - feature: suppress inplausible readings from USF1000 - bugfix: FHZ_ReadAnswer bugfix for Windows (Klaus, 20.8.2009) - feature: CUL: device acces code reorganized, TCP/IP support added - - feature: Pachube module from Axel in contrib + - feature: Pachube module from Axel + - feature: dumpdef module from Axel in contrib diff --git a/FHEM/00_CUL.pm b/FHEM/00_CUL.pm index 6d21b9dc8..bfbb7e0aa 100755 --- a/FHEM/00_CUL.pm +++ b/FHEM/00_CUL.pm @@ -107,7 +107,8 @@ CUL_Define($$) } $hash->{DeviceName} = $dev; - return CUL_OpenDev($hash, 0); + my $ret = CUL_OpenDev($hash, 0); + return $ret; } @@ -466,7 +467,7 @@ CUL_DoInit($) CUL_SimpleWrite($hash, "T01" . $hash->{FHTID}); } - $hash->{STATE} = "Initialized"; + $hash->{STATE} = "Initialized" if(!$hash->{STATE}); # Reset the counter delete($hash->{XMIT_TIME}); @@ -913,16 +914,30 @@ CUL_OpenDev($$) my $name = $hash->{NAME}; my $po; + $hash->{PARTIAL} = ""; Log 3, "CUL opening CUL device $dev" if(!$reopen); if($dev =~ m/^(.+):([0-9]+)$/) { # host:port + + # This part is called every time the timeout (5sec) is expired _OR_ + # somebody is communicating over another TCP connection. As the connect + # for non-existent devices has a delay of 3 sec, we are sitting all the + # time in this connect. NEXT_OPEN tries to avoid this problem. + if($hash->{NEXT_OPEN} && time() < $hash->{NEXT_OPEN}) { + return; + } + my $conn = IO::Socket::INET->new(PeerAddr => $dev); - if(!$conn) { + if($conn) { + delete($hash->{NEXT_OPEN}) + + } else { Log(3, "Can't connect to $dev: $!") if(!$reopen); $readyfnlist{"$name.$dev"} = $hash; $hash->{STATE} = "disconnected"; + $hash->{NEXT_OPEN} = time()+60; return ""; } diff --git a/contrib/95_PachLog.pm b/FHEM/95_PachLog.pm similarity index 100% rename from contrib/95_PachLog.pm rename to FHEM/95_PachLog.pm diff --git a/HISTORY b/HISTORY index 7bbfc02f8..5eebf3bd3 100644 --- a/HISTORY +++ b/HISTORY @@ -419,4 +419,4 @@ - 09_USF1000.pm: new module to support USF1000S devices. - Fri Aug 08 2009 (Boris) - - 09_USF1000.pm: suppress inplausible readings from USF1000 \ No newline at end of file + - 09_USF1000.pm: suppress inplausible readings from USF1000 diff --git a/contrib/99_dumpdef.pm b/contrib/99_dumpdef.pm index 6abc46784..a5ffc1ab2 100644 --- a/contrib/99_dumpdef.pm +++ b/contrib/99_dumpdef.pm @@ -1,55 +1,53 @@ -############################################## -# VarDump for FHEM-Devices -############################################## -# Installation -# 99_dumpdef.pm ins FHEM-Verzeichis kopieren -# dann: "reload 99_dumpdef.pm" -############################################## -# Aufruf: dumpdef "DEVICE-NAME" -############################################## -# Aufruf: dumpdef -# = %modules -# = %selectlist -# = %value -# = %cmds -# = %data -############################################## -package main; -use strict; -use warnings; -use POSIX; -use Data::Dumper; -sub Commanddumpdef($); - -##################################### -sub -dumpdef_Initialize($) -{ - my %lhash = ( Fn=>"Commanddumpdef", - Hlp=>"Dump to FHEMWEB & LOG" ); - $cmds{dumpdef} = \%lhash; -} - - -##################################### -sub Commanddumpdef($) -{ - my ($cl, $d) = @_; -# $d = $a[1]; - return "Usage: dumpdef " if(!$d); - my($package, $filename, $line, $subroutine) = caller(3); - my $r = "CALLER => $package: $filename LINE: $line SUB: $subroutine \n"; - $r .= "

SUB-NAME: " .(caller(0))[3] . "

\n"; - if($d eq "CMD") {$r .= Dumper(%cmds) . "\n"; return $r; } - if($d eq "DAT") {$r .= Dumper(%data) . "\n"; return $r; } - if($d eq "MOD") {$r .= Dumper(%modules) . "\n"; return $r; } - if($d eq "SEL") {$r .= Dumper(%selectlist) . "\n"; return $r; } - if(!defined($defs{$d})) { - return "Unkown Device";} - $r .= "DUMP-DEVICE: $d \n"; - $r .= Dumper($defs{$d}) . "\n"; - $r .= "DUMP-DEVICE-ATTR \n"; - $r .= Dumper($attr{$d}) . "\n"; - return $r; -} -1; +############################################## +# VarDump for FHEM-Devices +############################################## +# Installation +# 99_dumpdef.pm ins FHEM-Verzeichis kopieren +# dann: "reload 99_dumpdef.pm" +############################################## +# Aufruf: dumpdef "DEVICE-NAME" +############################################## +# Aufruf: dumpdef +# = %modules +# = %selectlist +# = %cmds +# = %data +############################################## +package main; +use strict; +use warnings; +use POSIX; +use Data::Dumper; +sub Commanddumpdef($); + +##################################### +sub +dumpdef_Initialize($) +{ + my %lhash = ( Fn=>"Commanddumpdef", + Hlp=>"Dump to FHEMWEB & LOG" ); + $cmds{dumpdef} = \%lhash; +} + + +##################################### +sub Commanddumpdef($) +{ + my ($cl, $d) = @_; + return "Usage: dumpdef " if(!$d); + my($package, $filename, $line, $subroutine) = caller(3); + my $r = "CALLER => $package: $filename LINE: $line SUB: $subroutine \n"; + $r .= "SUB-NAME: " .(caller(0))[3] . "\n"; + if($d eq "CMD") {$r .= Dumper(%cmds) . "\n"; return $r; } + if($d eq "DAT") {$r .= Dumper(%data) . "\n"; return $r; } + if($d eq "MOD") {$r .= Dumper(%modules) . "\n"; return $r; } + if($d eq "SEL") {$r .= Dumper(%selectlist) . "\n"; return $r; } + if(!defined($defs{$d})) { + return "Unkown Device";} + $r .= "DUMP-DEVICE: $d \n"; + $r .= Dumper($defs{$d}) . "\n"; + $r .= "DUMP-DEVICE-ATTR \n"; + $r .= Dumper($attr{$d}) . "\n"; + return $r; +} +1; diff --git a/docs/commandref.html b/docs/commandref.html index f2910708b..f5cace4c6 100644 --- a/docs/commandref.html +++ b/docs/commandref.html @@ -84,9 +84,11 @@ Helper modules
    FileLog   + PachLog   SUNRISE_EL   at   dummy   + dumpdef   holiday   notify   watchdog   @@ -1537,11 +1539,13 @@ A line ending with \ will be concatenated with the next one, so long lines

    CUL

      - The CUL is an USB device sold by busware.de - . With the opensource firmware (see this link) it is - capable to receive and send different 868MHz protocols - (FS20/FHT/S300/EM/HMS).
      + The CUL/CUR/CUN is a family of RF devices sold by busware.de. + + With the opensource firmware (see this link) they are capable + to receive and send different 868MHz protocols (FS20/FHT/S300/EM/HMS).
      +
      Some protocols (FS20/FHT) are converted by this module so that the same logical device can be used, irrespective if the radio telegram is received by @@ -1554,17 +1558,24 @@ A line ending with \ will be concatenated with the next one, so long lines Define
        - define <name> CUL <serial-device> <housecode> [mobile]
        + define <name> CUL <device> <housecode>

        - Specifies the serial port to communicate with the CUL or CUR. - The name(s) of the serial-device(s) depends on your distribution, + USB-connected devices (CUL/CUR/CUN):
          + <device> specifies the serial port to communicate with the CUL or CUR. + The name of the serial-device depends on your distribution, under linux the cdc_acm kernel module is responsible, and usually a - /dev/ttyACM0 device will be created. + /dev/ttyACM0 device will be created. If your distribution does not have a + cdc_acm module, you can force usbserial to handle the CUL by the following + command:
            modprobe usbserial vendor=0x03eb product=0x204b
          In this + case the device is most probably /dev/ttyUSB0.
          +
        + Network-connected devices (CUN):
          + <device> specifies the host:port of the device. E.g. 192.168.0.244:2323 +

        - If the serial-device is called none, then no device will be opened, so you + If the device is called none, then no device will be opened, so you can experiment without hardware attached.
        - If you specify the "mobile" parameter, then fhem.pl won't block if the - device is removed. This is mainly intended for the CUR.
        + The housecode is a 4 digit hex number, and it is used when the CUL/CUR talks to FHT devices or when CUR requests data.
      @@ -3786,6 +3797,92 @@ isday, sunrise_coord
    + +

    PachLog

    +
      + The PachLog module logs sensor data like temperature and humidity to www.pachube.com.
      +
      + + Define +
        +
        define <name> PachLog <Pachube-API-Key>
        +
        + <Pachube-API-Key>:
        + You need the Pachube-API-Key to authenticate your application to the + Pachube service.
        + Don't share this with anyone: it's just like a password.
        +
      +
      + + + Set +
        +
        + Add a new device for logging to www.pachube.com

        + set <NAME> ADD <FHEM-DEVICENAME> FEED-NR:ID:READING:ID:READING

        + Example: KS300 weather data

        + READING: temperature humidity wind rain

        + 1. Generate input feed on www.pachube.com => You get your + FEED-NR: 1234
        + 2. Add datastreams to the feed:
        +
          + + + + +
          ID0temperature
          ID1humidity
          ID2wind
          ID3rain

          +
        + 3. Add the KS300 to your PachLog device

        + set <NAME> ADD <My-KS300> 1234:0temperature:1:humidity:2:wind:3:rain

        + Delete a device form logging to www.pachube.com

        + set <NAME> DEL <FHEM-DEVICENAME>

        +
      +
      + + Get
        N/A

      + Attributes
        N/A

      +
    + + + +

    dumpdef

    +
      + dumpdef <options> +

      + Data::Dumper for FHEM-Devices/Hashes

      + Dumps the content of <options> to FHEMWEB

      + Options:

      +
        + + + + + + +
        FHEM-DEVICENAME=>%defs{FHEM-DEVICENAME}+%attr{FHEM-DEVICENAME}
        MOD=>%modules
        SEL=>%selectlist
        DAT=>%data
        CMD=>%cmd
        +
      +

      + Example: +

        + dumpdef TEST

        +
          CALLER => main: /opt/fhz/FHEM/01_FHEMWEB.pm LINE: 194 SUB: main::FW_AnswerCall
          + SUB-NAME: main::Commanddumpdef
          + DUMP-DEVICE: TEST
          + $VAR1 = {
            + 'IODev' => {},
            + 'NAME' => 'TEST',
            + 'NR' => 64,
            + 'STATE' => '???',
            + 'TYPE' => 'dummy'
            + };
          + DUMP-DEVICE-ATTR
          + $VAR1 = {
            + 'room' => 'DEF_DUMMY,GRP.TEST'
            + };
          +

        +
      +

    Perl specials

    diff --git a/fhem.pl b/fhem.pl index 808fae5d9..cb1ea7b1e 100755 --- a/fhem.pl +++ b/fhem.pl @@ -151,7 +151,7 @@ my %defaultattr; # Default attributes my %intAt; # Internal at timer hash. my $nextat; # Time when next timer will be triggered. my $intAtCnt=0; -my $cvsid = '$Id: fhem.pl,v 1.79 2009-08-12 08:08:14 rudolfkoenig Exp $'; +my $cvsid = '$Id: fhem.pl,v 1.80 2009-09-11 07:34:12 rudolfkoenig Exp $'; my $namedef = "where is either:\n" . "- a single device name\n" . @@ -287,7 +287,7 @@ Log 0, "Server started (version $attr{global}{version}, pid $$)"; ################################################ # Main Loop -sub MAIN {MAIN:};#Dummy +sub MAIN {MAIN:}; #Dummy while (1) { my ($rout, $rin) = ('', ''); @@ -825,7 +825,9 @@ WriteStatefile() print SFH "define $d $defs{$d}{TYPE} $defs{$d}{DEF}\n" if($defs{$d}{VOLATILE}); print SFH "setstate $d $defs{$d}{STATE}\n" - if($defs{$d}{STATE} && $defs{$d}{STATE} ne "unknown"); + if($defs{$d}{STATE} && + $defs{$d}{STATE} ne "unknown" && + $defs{$d}{STATE} ne "Initialized"); ############# # Now the detailed list