diff --git a/fhem/configDB.pm b/fhem/configDB.pm index 1701daf31..869d46fa1 100644 --- a/fhem/configDB.pm +++ b/fhem/configDB.pm @@ -116,6 +116,8 @@ # # 2016-07-03 - added support for multiple hosts (experimental) # +# 2016-07-04 - fixed improve config file read +# ############################################################################## # @@ -179,8 +181,16 @@ if(!open(CONFIG, 'configDB.conf')) { Log3('configDB', 1, 'Cannot open database configuration file configDB.conf'); return 0; } -my @config=; -close(CONFIG); +#my @config=; +#close(CONFIG); + +my @config; +while (){ + my $line = $_; + $line =~ s/^\s+|\s+$//g; + push (@config,$line) if($line !~ m/^#/ && length($line) > 0); +} +close CONFIG; use vars qw(%configDB); @@ -197,9 +207,11 @@ my $count = @configs; if ($count > 1) { my $fhemhost = hostname; foreach my $c (@configs) { + next unless $c =~ m/^%dbconfig.*/; eval $c; last if ($dbconfig{fhemhost} eq $fhemhost); } + eval $configs[0] unless (defined($dbconfig{fhemhost}) && length($dbconfig{fhemhost})) } else { eval $configs[0]; }