mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-01-31 18:59:33 +00:00
10_ZWave.pm: more flexible parsing of manufacturer_specific.xml (Forum #100280)
git-svn-id: https://svn.fhem.de/fhem/trunk@19855 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
7a83730ead
commit
7a810ece69
@ -2343,6 +2343,7 @@ sub
|
||||
ZWave_mfsParse($$$$$)
|
||||
{
|
||||
my ($hash, $mf, $prod, $id, $config) = @_;
|
||||
sub getVal { return $_[0] =~ m/$_[1]\s*=\s*"([^"]*)"/ ? $1 : "unknown" }
|
||||
|
||||
if($config == 2) {
|
||||
setReadingsVal($hash, "modelId", "$mf-$prod-$id", TimeNow());
|
||||
@ -2355,16 +2356,18 @@ ZWave_mfsParse($$$$$)
|
||||
if(open(FH, $xml)) {
|
||||
my ($lastMf, $mName, $ret) = ("","");
|
||||
while(my $l = <FH>) {
|
||||
if($l =~ m/<Manufacturer.*id="([^"]*)".*name="([^"]*)"/) {
|
||||
$lastMf = lc($1);
|
||||
$mName = $2;
|
||||
if($l =~ m/<Manufacturer/) {
|
||||
$lastMf = lc(getVal($l, "id"));
|
||||
$mName = getVal($l, "name");
|
||||
next;
|
||||
}
|
||||
|
||||
if($l =~ m/<Product type\s*=\s*"([^"]*)".*id\s*=\s*"([^"]*)".*name\s*=\s*"([^"]*)"/) {
|
||||
if($mf eq $lastMf && $prod eq lc($1) && $id eq lc($2)) {
|
||||
if($l =~ m/<Product/) {
|
||||
my $lId = lc(getVal($l, "id"));
|
||||
my $lProd = lc(getVal($l, "type"));
|
||||
if($mf eq $lastMf && $prod eq $lProd && $id eq $lId) {
|
||||
if($config) {
|
||||
$ret = (($l =~ m/config\s*=\s*"([^"]*)"/) ? $1 : "unknown");
|
||||
$ret = getVal($l, "config");
|
||||
ZWave_mfsAddClasses($hash, $1);
|
||||
# execInits needs the modelId
|
||||
setReadingsVal($hash, "modelId", "$mf-$prod-$id", TimeNow());
|
||||
|
Loading…
Reference in New Issue
Block a user