diff --git a/fhem/CHANGED b/fhem/CHANGED index 9e94b7567..ab25f6d37 100644 --- a/fhem/CHANGED +++ b/fhem/CHANGED @@ -489,4 +489,5 @@ - feature: Common Module calling for CUL/FHZ/CM11 - feature: Store CUL sensitivity info - feature: avoid the "unknown/help me" message for unloaded devices + - feature: structure module for big installations - feature: Cost Control in 15_CUL_EM (CostPerUnit, BasisFeePerMonth) diff --git a/fhem/FHEM/00_CUL.pm b/fhem/FHEM/00_CUL.pm index 8f5d4ce11..665194a80 100755 --- a/fhem/FHEM/00_CUL.pm +++ b/fhem/FHEM/00_CUL.pm @@ -498,9 +498,8 @@ CUL_Read($) my $dev = $hash->{DeviceName}; Log 1, "USB device $dev disconnected, waiting to reappear"; $hash->{PortObj}->close(); - DoTrigger($name, "DISCONNECTED"); - delete($hash->{PortObj}); + delete($hash->{FD}); delete($selectlist{"$name.$dev"}); $readyfnlist{"$name.$dev"} = $hash; # Start polling $hash->{STATE} = "disconnected"; @@ -509,6 +508,7 @@ CUL_Read($) # and following opens block infinitely. Only a reboot helps. sleep(5); + DoTrigger($name, "DISCONNECTED"); return ""; } diff --git a/fhem/FHEM/00_FHZ.pm b/fhem/FHEM/00_FHZ.pm index f135a39a5..dcd7e6e35 100755 --- a/fhem/FHEM/00_FHZ.pm +++ b/fhem/FHEM/00_FHZ.pm @@ -364,6 +364,8 @@ FHZ_Undef($$) } } $hash->{PortObj}->close() if($hash->{PortObj}); + delete($hash->{PortObj}); + delete($hash->{FD}); return undef; } @@ -618,9 +620,8 @@ FHZ_Read($) Log 1, "USB device $dev disconnected, waiting to reappear"; delete($hash->{FD}); $hash->{PortObj}->close(); - DoTrigger($name, "DISCONNECTED"); - delete($hash->{PortObj}); + delete($hash->{FD}); delete($selectlist{"$name.$dev"}); $readyfnlist{"$name.$dev"} = $hash; # Start polling $hash->{STATE} = "disconnected"; @@ -628,6 +629,8 @@ FHZ_Read($) # Without the following sleep the open of the device causes a SIGSEGV, # and following opens block infinitely. Only a reboot helps. sleep(5); + + DoTrigger($name, "DISCONNECTED"); } diff --git a/fhem/FHEM/14_CUL_WS.pm b/fhem/FHEM/14_CUL_WS.pm index 4a30c9e65..61079c554 100755 --- a/fhem/FHEM/14_CUL_WS.pm +++ b/fhem/FHEM/14_CUL_WS.pm @@ -27,6 +27,7 @@ CUL_WS_Initialize($) $hash->{Match} = "^K....."; $hash->{DefFn} = "CUL_WS_Define"; $hash->{UndefFn} = "CUL_WS_Undef"; + $hash->{AttrFn} = "CUL_WS_Attr"; $hash->{ParseFn} = "CUL_WS_Parse"; $hash->{AttrList} = "IODev do_not_notify:0,1 showtime:0,1 model:S300TH,KS300 loglevel"; } @@ -70,7 +71,6 @@ sub CUL_WS_Parse($$) { my ($hash,$msg) = @_; - my $name = $hash->{NAME}; my %tlist = ("0"=>"temp", "1"=>"temp/hum", "2"=>"rain", @@ -87,17 +87,18 @@ CUL_WS_Parse($$) my $cde = ($firstbyte&7) + 1; my $type = $tlist{$a[2]} ? $tlist{$a[2]} : "unknown"; - my $def = $defptr{$cde}; + my $def = $defptr{$hash->{NAME} . "." . $cde}; + $def = $defptr{$cde} if(!$def); return "" if($def->{IODev} && $def->{IODev}{NAME} ne $hash->{NAME}); - if(!$defptr{$cde}) + if(!$def) { Log 1, "CUL_WS UNDEFINED $type sensor detected, code $cde"; # return "UNDEFINED CUL_WS: $cde"; } my $tm=TimeNow(); - $hash = $defptr{$cde}; + $hash = $def; my $typbyte = hex($a[2]) & 7; my $sfirstbyte = $firstbyte & 7; @@ -226,7 +227,7 @@ else my $rain = sprintf("%0.1f", hex("$a[14]$a[11]$a[12]") * $c / 1000); my $wnd = sprintf("%0.1f", "$a[9]$a[10].$a[7]" + $hash->{corr3}); my $hum = sprintf( "%02d", "$a[8]$a[5]" + $hash->{corr2}); - my $tmp = sprintf("%0.1f", ("$a[6]$a[3].$a[4]"+$hash->{corr1}) * + my $tmp = sprintf("%0.1f", ("$a[6]$a[3].$a[4]"+ $hash->{corr1}), (($a[1] & 0xC) ? -1 : 1)); my $ir = ((hex($a[1]) & 2)) ? "yes" : "no"; @@ -243,7 +244,8 @@ else } } -Log GetLogLevel($name,3), "CUL_WS $devtype $name: $val"; +my $name = $hash->{NAME}; +Log GetLogLevel($name,4), "CUL_WS $devtype $name: $val"; $hash->{STATE} = $val; # List overview $hash->{READINGS}{state}{TIME} = TimeNow(); # For list @@ -255,4 +257,21 @@ $hash->{READINGS}{$devtype}{TIME}=$tm; return $name; } +sub +CUL_WS_Attr(@) +{ + my @a = @_; + + # Make possible to use the same code for different logical devices when they + # are received through different physical devices. + return if($a[0] ne "set" || $a[2] ne "IODev"); + my $hash = $defs{$a[1]}; + my $iohash = $defs{$a[3]}; + my $cde = $hash->{CODE}; + delete($defptr{$cde}); + $defptr{$iohash->{NAME} . "." . $cde} = $hash; + return undef; +} + + 1; diff --git a/fhem/FHEM/70_SCIVT.pm b/fhem/FHEM/70_SCIVT.pm index 134f1e286..4587f0733 100644 --- a/fhem/FHEM/70_SCIVT.pm +++ b/fhem/FHEM/70_SCIVT.pm @@ -66,6 +66,7 @@ SCIVT_Define($$) $init_done = $oid; return undef; } + ##################################### sub SCIVT_Set($@) diff --git a/fhem/Makefile b/fhem/Makefile index 8a7006fb5..5b3470a3f 100644 --- a/fhem/Makefile +++ b/fhem/Makefile @@ -15,7 +15,8 @@ install:install-base cp examples/sample_fhem $(VARDIR)/fhem.cfg @echo @echo - @echo Edit $(VARDIR)/fhem.cfg then type perl $(BINDIR)/fhem.pl $(VARDIR)/fhem.cfg + @echo Edit $(VARDIR)/fhem.cfg then type + @echo perl $(BINDIR)/fhem.pl $(VARDIR)/fhem.cfg install-pgm2:install-base cp webfrontend/pgm2/* $(MODDIR)/FHEM @@ -25,9 +26,11 @@ install-pgm2:install-base cd examples; for i in *; do cp $$i $(MODDIR)/FHEM/example.$$i; done @echo @echo - @echo Edit $(VARDIR)/fhem.cfg then start perl $(BINDIR)/fhem.pl $(VARDIR)/fhem.cfg + @echo Edit $(VARDIR)/fhem.cfg then type + @echo perl $(BINDIR)/fhem.pl $(VARDIR)/fhem.cfg install-base: + mkdir -p $(BINDIR) $(MODDIR) $(VARDIR) cp fhem.pl $(BINDIR) cp -r FHEM $(MODDIR) mkdir -p $(VARDIR) diff --git a/fhem/TODO b/fhem/TODO index 6d09af22c..bd0367cd0 100644 --- a/fhem/TODO +++ b/fhem/TODO @@ -1,8 +1,8 @@ FHEM: +- Remote serial device via IP (for the FHZ1300 WLAN) - Common buffer for parallel use of two devices: CUL+FHZ, (WS300/EM1000PC?) - holiday database - fhem-to-fhem module -- Remote serial device via IP - CUR built-in MENU creation support Webpgm2 diff --git a/fhem/contrib/README b/fhem/contrib/README index 0dd736d98..fe3df5897 100755 --- a/fhem/contrib/README +++ b/fhem/contrib/README @@ -30,7 +30,7 @@ - JsonList 99_JsonList.pm adds a jsonlist command, which is list in JSON format. See JsonList/README.JsonList for more. By Martin. -- fhem2speech +- fhem-speech Martins instructions on how to make FHEM talk using the MBROLA speech synthesizer - init-scripts diff --git a/fhem/docs/HOWTO.html b/fhem/docs/HOWTO.html index a12d95e70..05173c164 100644 --- a/fhem/docs/HOWTO.html +++ b/fhem/docs/HOWTO.html @@ -26,7 +26,7 @@
make install-pgm2
- perl /usr/local/bin/fhem.pl fhem.cfg
+ perl /usr/local/bin/fhem.pl /var/log/fhem/fhem.cfg
The logfile should look like:
2008.06.15 16:17:03 2: FHEMWEB port 8083 opened
diff --git a/fhem/fhem.pl b/fhem/fhem.pl
index 8cd279ecc..d95270626 100755
--- a/fhem/fhem.pl
+++ b/fhem/fhem.pl
@@ -135,6 +135,8 @@ use vars qw(%cmds); # Global command name hash. To be expanded
use vars qw($reread_active);
+my $AttrList = "room comment";
+
my $server; # Server socket
my $currlogfile; # logfile, without wildcards
my $logopened = 0; # logfile opened or using stdout
@@ -148,8 +150,7 @@ my %defaultattr; # Default attributes
my %intAt; # Internal at timer hash.
my $nextat; # Time when next timer will be triggered.
my $intAtCnt=0;
-my $AttrList = "room comment";
-my $cvsid = '$Id: fhem.pl,v 1.68 2009-01-27 08:01:34 rudolfkoenig Exp $';
+my $cvsid = '$Id: fhem.pl,v 1.69 2009-02-11 12:58:22 rudolfkoenig Exp $';
my $namedef =
"where is either:\n" .
"- a single device name\n" .