mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-01-31 12:49:34 +00:00
fhem.pl: $cmds->ModuleName: autoload commands even if they are defined in a "foreign" file (Forum #33916)
git-svn-id: https://svn.fhem.de/fhem/trunk@8115 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
f69c101bdf
commit
0a7aea82a4
19
fhem/fhem.pl
19
fhem/fhem.pl
@ -265,6 +265,7 @@ $readingFnAttributes = "event-on-change-reading event-on-update-reading ".
|
|||||||
"?" => { ReplacedBy => "help" },
|
"?" => { ReplacedBy => "help" },
|
||||||
"attr" => { Fn=>"CommandAttr",
|
"attr" => { Fn=>"CommandAttr",
|
||||||
Hlp=>"<devspec> <attrname> [<attrval>],set attribute for <devspec>"},
|
Hlp=>"<devspec> <attrname> [<attrval>],set attribute for <devspec>"},
|
||||||
|
"createlog"=> { ModuleName => "autocreate" },
|
||||||
"define" => { Fn=>"CommandDefine",
|
"define" => { Fn=>"CommandDefine",
|
||||||
Hlp=>"<name> <type> <options>,define a device/at/notify entity" },
|
Hlp=>"<name> <type> <options>,define a device/at/notify entity" },
|
||||||
"deleteattr" => { Fn=>"CommandDeleteAttr",
|
"deleteattr" => { Fn=>"CommandDeleteAttr",
|
||||||
@ -323,6 +324,7 @@ $readingFnAttributes = "event-on-change-reading event-on-update-reading ".
|
|||||||
Hlp => "[<fileName>|all|check|force] ".
|
Hlp => "[<fileName>|all|check|force] ".
|
||||||
"[http://.../controlfile],update FHEM" },
|
"[http://.../controlfile],update FHEM" },
|
||||||
"updatefhem" => { ReplacedBy => "update" },
|
"updatefhem" => { ReplacedBy => "update" },
|
||||||
|
"usb" => { ModuleName => "autocreate" },
|
||||||
"version" => { Fn => "CommandVersion",
|
"version" => { Fn => "CommandVersion",
|
||||||
Hlp=>"[filter],print SVN version of loaded modules" },
|
Hlp=>"[filter],print SVN version of loaded modules" },
|
||||||
);
|
);
|
||||||
@ -968,11 +970,16 @@ AnalyzeCommand($$;$)
|
|||||||
|
|
||||||
#############
|
#############
|
||||||
# autoload commands.
|
# autoload commands.
|
||||||
|
my $lcfn = lc($fn);
|
||||||
|
$fn = $lcfn if(defined($cmds{$lcfn}));
|
||||||
if(!defined($cmds{$fn}) || !defined($cmds{$fn}{Fn})) {
|
if(!defined($cmds{$fn}) || !defined($cmds{$fn}{Fn})) {
|
||||||
map { $fn = $_ if(lc($fn) eq lc($_)); } keys %modules;
|
my $modName;
|
||||||
$fn = LoadModule($fn);
|
map { $modName = $_ if($lcfn eq lc($_)); } keys %modules;
|
||||||
$fn = lc($fn) if(defined($cmds{lc($fn)}));
|
$modName = $cmds{$lcfn}{ModuleName}
|
||||||
return "Unknown command $fn, try help." if(!defined($cmds{$fn}));
|
if($cmds{$lcfn} && $cmds{$lcfn}{ModuleName});
|
||||||
|
LoadModule($modName) if($modName);
|
||||||
|
$fn = $lcfn if($cmds{$lcfn});
|
||||||
|
return "Unknown command $fn, try help." if(!$cmds{$fn} || !$cmds{$fn}{Fn});
|
||||||
}
|
}
|
||||||
|
|
||||||
if($cl && $cmds{$fn}{ClientFilter} &&
|
if($cl && $cmds{$fn}{ClientFilter} &&
|
||||||
@ -1539,7 +1546,9 @@ CommandDefine($$)
|
|||||||
my ($cl, $def) = @_;
|
my ($cl, $def) = @_;
|
||||||
my @a = split("[ \t][ \t]*", $def, 3);
|
my @a = split("[ \t][ \t]*", $def, 3);
|
||||||
my $ignoreErr;
|
my $ignoreErr;
|
||||||
if($a[0] eq "-ignoreErr") { # RSS in fhem.cfg.demo, with no GD installed
|
|
||||||
|
# used by RSS in fhem.cfg.demo, with no GD installed
|
||||||
|
if($a[0] && $a[0] eq "-ignoreErr") {
|
||||||
$def =~ s/\s*-ignoreErr\s*//;
|
$def =~ s/\s*-ignoreErr\s*//;
|
||||||
@a = split("[ \t][ \t]*", $def, 3);
|
@a = split("[ \t][ \t]*", $def, 3);
|
||||||
$ignoreErr = 1;
|
$ignoreErr = 1;
|
||||||
|
Loading…
Reference in New Issue
Block a user