zwavealliance.images.parse: patch from krikan (Forum #115717)

git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@23129 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2020-11-09 20:14:04 +00:00
parent 2930f7841b
commit 7ee578d21d

View File

@ -1,11 +1,14 @@
#/usr/bin/perl #/usr/bin/perl
use strict;
use warnings;
# Creates the FHEM file from the raw data # Creates the FHEM file from the raw data
# Usage: zwavealliance.images.parse downloaddir # Usage: zwavealliance.images.parse downloaddir
# Downloaddir is filled with the following script: # Downloaddir is filled with the following script:
# i=1 # i=1
# while test $i -lt 3000 # while test $i -lt 4034
# do # do
# echo $i # echo $i
# wget -O $i -q http://products.z-wavealliance.org/products/$i/XML # wget -O $i -q http://products.z-wavealliance.org/products/$i/XML
@ -26,7 +29,7 @@ for my $fn (sort { $a <=> $b } @files) {
next if (! -f $path); next if (! -f $path);
print("$fn\n"); print("$fn\n");
open(FH, $path) || die("Cant open $path\n"); open(FH, $path) || die("Cant open $path\n");
my ($bn,$mi,$pti,$pi,$pic,$em) = ('','','','','',''); my ($bn,$mi,$pti,$pi,$pic,$em,$ppi) = ('','','','','','','');
while(my $l = <FH>) { while(my $l = <FH>) {
chomp($l); chomp($l);
@ -35,10 +38,15 @@ for my $fn (sort { $a <=> $b } @files) {
$mi = $1 if($l =~ m,<ManufacturerId>0x(....)</ManufacturerId>,); $mi = $1 if($l =~ m,<ManufacturerId>0x(....)</ManufacturerId>,);
$pti = $1 if($l =~ m,<ProductTypeId>0x(....)</ProductTypeId>,); $pti = $1 if($l =~ m,<ProductTypeId>0x(....)</ProductTypeId>,);
$pi = $1 if($l =~ m,<ProductId>0x(....)</ProductId>,); $pi = $1 if($l =~ m,<ProductId>0x(....)</ProductId>,);
$pic = $1 if($l =~ m,<Image>.*productName=(.*)</Image>,); $pic = $1 if($l =~ m,<CertificationNumber>(.*)</CertificationNumber>,);
$ppi = $1 if($l =~ m,<value>product_pictures/(.*)\.(.*)</value>,);
} }
close(FH); close(FH);
if($pic ne $ppi) {
printf "Problem: $pic vs. $ppi\n";
# just to see new problems with pictures
}
if($em eq 'empty') { if($em eq 'empty') {
printf "No data for $fn, deleting the file\n"; printf "No data for $fn, deleting the file\n";
# in the hope that somebody will fix the file # in the hope that somebody will fix the file