2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-13 23:36:37 +00:00

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

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

View File

@ -1,11 +1,14 @@
#/usr/bin/perl
use strict;
use warnings;
# Creates the FHEM file from the raw data
# Usage: zwavealliance.images.parse downloaddir
# Downloaddir is filled with the following script:
# i=1
# while test $i -lt 3000
# while test $i -lt 4034
# do
# echo $i
# 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);
print("$fn\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>) {
chomp($l);
@ -35,10 +38,15 @@ for my $fn (sort { $a <=> $b } @files) {
$mi = $1 if($l =~ m,<ManufacturerId>0x(....)</ManufacturerId>,);
$pti = $1 if($l =~ m,<ProductTypeId>0x(....)</ProductTypeId>,);
$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);
if($pic ne $ppi) {
printf "Problem: $pic vs. $ppi\n";
# just to see new problems with pictures
}
if($em eq 'empty') {
printf "No data for $fn, deleting the file\n";
# in the hope that somebody will fix the file