diff --git a/fhem/docs/commandref.html b/fhem/docs/commandref.html index 2c2f6f030..1d0e89d4a 100644 --- a/fhem/docs/commandref.html +++ b/fhem/docs/commandref.html @@ -1012,13 +1012,14 @@ A line ending with \ will be concatenated with the next one, so long lines <a name="rereadcfg"></a> <h3>rereadcfg</h3> <ul> - <code>rereadcfg</code> + <code>rereadcfg [fhem-config-file]</code> <br><br> - Re-read the configuration file. - Note: The statefile will be saved first, then the config file will be read + Re-read the configuration file, or the optionally specified file. + The sequence: the statefile will be saved first, then all devices will be + deleted, then the original config file (or the specified file) will be read (all devices will be initialized again), and at last the statefile will be - reloaded. It triggers upon completion the global:REREADCFG event. - All existing connections up to the one issuing the rereadcfg will be closed. + reloaded. It triggers upon completion the global:REREADCFG event. All + existing connections up to the one issuing the rereadcfg will be closed. <br><br> Example: <ul> diff --git a/fhem/fhem.pl b/fhem/fhem.pl index 23e9ab19e..34162a1e4 100755 --- a/fhem/fhem.pl +++ b/fhem/fhem.pl @@ -235,7 +235,7 @@ $modules{Global}{AttrFn} = "GlobalAttr"; "rename" => { Fn=>"CommandRename", Hlp=>"<old> <new>,rename a definition" }, "rereadcfg" => { Fn=>"CommandRereadCfg", - Hlp=>",reread the config file" }, + Hlp=>"[configfile],read in the config after deleting everything" }, "save" => { Fn=>"CommandSave", Hlp=>"[configfile],write the configfile and the statefile" }, "set" => { Fn=>"CommandSet", @@ -882,7 +882,10 @@ CommandRereadCfg($$) { my ($cl, $param) = @_; my $name = $cl->{NAME} if($cl); + my $cfgfile = ($param ? $param : $attr{global}{configfile}); + return "Cannon open $cfgfile: $!" if(! -f $cfgfile); + $attr{global}{configfile} = $cfgfile; WriteStatefile(); $reread_active=1; @@ -896,7 +899,6 @@ CommandRereadCfg($$) delete $defs{$d}; } - my $cfgfile = $attr{global}{configfile}; %comments = (); %defs = (); %attr = ();