2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-01-31 18:59:33 +00:00
fhem-mirror/fhem/contrib/zwave_alliance2open.pl
rudolfkoenig 6793cb95c6 contrib/zwave_alliance2open.pl: first version
git-svn-id: https://svn.fhem.de/fhem/trunk@28607 2b470e98-0d58-463d-a4d8-8e2adae1ed80
2024-03-06 17:31:25 +00:00

38 lines
1.3 KiB
Perl

#!/usr/bin/perl
# convert ZWAVE-Alliance XML description file into openzwacve format, which can
# be digested by the FHEM ZWave module. Note: only the config parameters are converted.
if($#ARGV != -1) {
print STDERR "Usage: perl zwave_alliance2open.pl < zwavealliance.xml > openzwave.xml\n";
exit(1);
}
my ($inTag, $name,$desc,$pnum,$size,$dflt,$min,$max);
print "<Product sourceFile=\"changeme\">\n";
print " <CommandClass id=\"112\">\n";
while(my $l = <>) {
$inTag = 1 if($l =~ /<ConfigurationParameterExport>/);
$inTag = 0 if($l =~ /<ConfigurationParameterValues>/);
if($inTag) {
$name = $1 if($l =~ m/<Name>(.*)<\/Name>/);
$desc = $1 if($l =~ m/<Description>(.*)<\/Description>/);
$pnum = $1 if($l =~ m/<ParameterNumber>(.*)<\/ParameterNumber>/);
$size = $1 if($l =~ m/<Size>(.*)<\/Size>/);
$dflt = $1 if($l =~ m/<DefaultValue>(.*)<\/DefaultValue>/);
$min = $1 if($l =~ m/<minValue>(.*)<\/minValue>/);
$max = $1 if($l =~ m/<maxValue>(.*)<\/maxValue>/);
}
if($l =~ /<\/ConfigurationParameterExport>/) {
print " <Value genre=\"config\" index=\"$pnum\" label=\"$name\" size=\"$size\" type=\"byte\" value=\"$dflt\" min=\"$min\" max=\"$max\">\n";
print " <Help>$desc</Help>\n";
print " </Value>\n";
$inTag = 0;
}
}
print " </CommandClass>\n";
print "</Product>\n";