2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-04-07 19:04:20 +00:00

10_ZWave.pm: add user_* configuration files (Forum #138451)

git-svn-id: https://svn.fhem.de/fhem/trunk@28978 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2024-06-16 18:22:09 +00:00
parent 7cb2a51e73
commit a7426df238

View File

@ -22,6 +22,7 @@ sub ZWave_secEnd($);
sub ZWave_configParseModel($;$); sub ZWave_configParseModel($;$);
sub ZWave_callbackId($;$); sub ZWave_callbackId($;$);
sub ZWave_setEndpoints($); sub ZWave_setEndpoints($);
sub ZWave_mfsParse($$$$$;$);
our ($FW_ME,$FW_tp,$FW_ss); our ($FW_ME,$FW_tp,$FW_ss);
our %zwave_id2class; our %zwave_id2class;
@ -2576,9 +2577,9 @@ ZWave_mfsAddClasses($$)
} }
sub sub
ZWave_mfsParse($$$$$) ZWave_mfsParse($$$$$;$)
{ {
my ($hash, $mf, $prod, $id, $config) = @_; my ($hash, $mf, $prod, $id, $config, $ozw) = @_;
my $getVal = sub { return $_[0] =~ m/$_[1]\s*=\s*"([^"]*)"/ ? $1 : "unknown"}; my $getVal = sub { return $_[0] =~ m/$_[1]\s*=\s*"([^"]*)"/ ? $1 : "unknown"};
if($config == 2) { if($config == 2) {
@ -2586,8 +2587,8 @@ ZWave_mfsParse($$$$$)
return "modelId:$mf-$prod-$id"; return "modelId:$mf-$prod-$id";
} }
my $xml = $attr{global}{modpath}. my $xml = $attr{global}{modpath}."/FHEM/lib/".
"/FHEM/lib/openzwave_manufacturer_specific.xml"; ($ozw ? "openzwave" : "user_zwave"). "_manufacturer_specific.xml";
($mf, $prod, $id) = (lc($mf), lc($prod), lc($id)); # Just to make it sure ($mf, $prod, $id) = (lc($mf), lc($prod), lc($id)); # Just to make it sure
if(open(FH, $xml)) { if(open(FH, $xml)) {
my ($lastMf, $mName, $ret) = ("",""); my ($lastMf, $mName, $ret) = ("","");
@ -2621,9 +2622,10 @@ ZWave_mfsParse($$$$$)
return $ret if($ret); return $ret if($ret);
} else { } else {
Log 1, "can't open $xml: $!"; Log 1, "can't open $xml: $!" if($ozw);
} }
return ZWave_mfsParse($hash, $mf, $prod, $id, $config, 1) if(!$ozw);
return sprintf("model:0x%s 0x%s 0x%s", $mf, $prod, $id); return sprintf("model:0x%s 0x%s 0x%s", $mf, $prod, $id);
} }
@ -2920,15 +2922,16 @@ ZWave_cleanString($$$)
sub sub
ZWave_configParseModel($;$) ZWave_configParseModel($;$)
{ {
my ($cfg, $my) = @_; my ($cfg, $run) = @_;
return if(!$my && ZWave_configParseModel($cfg, 1)); # first fhem_ then open... $run = 0 if(!$run);
my $fn = $attr{global}{modpath}."/FHEM/lib/".($my ? "fhem_":"open"). my @fList = ("user_", "fhem_", "open");
my $fn = $attr{global}{modpath}."/FHEM/lib/".$fList[$run].
"zwave_deviceconfig.xml.gz"; "zwave_deviceconfig.xml.gz";
my $gz = gzopen($fn, "rb"); my $gz = gzopen($fn, "rb");
if(!$gz) { if(!$gz) {
Log 3, "Can't open $fn: $!" if(!$my); Log 3, "Can't open $fn: $!" if($run == 2); # user_
return 0; return $run < 2 ? ZWave_configParseModel($cfg, $run+1) : 0;
} }
my ($ret, $line, $class, %hash, $cmdName, %classInfo, %group, $origName); my ($ret, $line, $class, %hash, $cmdName, %classInfo, %group, $origName);
@ -3005,7 +3008,9 @@ ZWave_configParseModel($;$)
} }
if($line =~ m+<Help>(.*)</Help>+s) { if($line =~ m+<Help>(.*)</Help>+s) {
$hash{$cmdName}{Help} .= "$bsHelp$1<br>"; my $h = $1;
$h =~ s/ {9}/<br>/g; #138451
$hash{$cmdName}{Help} .= "$bsHelp$h<br>";
$bsHelp=""; $bsHelp="";
} }
@ -3050,9 +3055,11 @@ ZWave_configParseModel($;$)
} }
$zwave_modelConfig{$cfg} = \%mc; $zwave_modelConfig{$cfg} = \%mc;
Log 3, "ZWave got config for $cfg from $fn, found ".keys(%hash)." commands" if($ret) {
if($ret); Log 3, "ZWave got config for $cfg from $fn, found ".keys(%hash)." commands";
return $ret; } elsif($run < 2) {
return ZWave_configParseModel($cfg, $run+1);
}
} }
################################### ###################################
@ -7139,9 +7146,8 @@ ZWave_tmSet($)
return the manufacturer specific id (16bit), return the manufacturer specific id (16bit),
the product type (16bit) the product type (16bit)
and the product specific id (16bit).<br> and the product specific id (16bit).<br>
Note: if the openzwave xml files are installed, then return the name of the Note: if the id combination is found in the user_, fhem_ or openzwave files,
manufacturer and of the product. This call is also necessary to decode more more descriptive config commands and help for these commands is available.
model specific configuration commands and parameters.
</li> </li>
<br><br><b>Class METER</b> <br><br><b>Class METER</b>