2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-01-31 12:49:34 +00:00

zwave_jeedomconvert.pl: add pictures from the jeedom project (Forum #54182)

git-svn-id: https://svn.fhem.de/fhem/trunk@11922 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2016-08-08 14:39:02 +00:00
parent f3c698de5a
commit 01ff7334df
3 changed files with 56 additions and 1 deletions

View File

@ -0,0 +1,54 @@
#!/usr/bin/perl
use strict;
use warnings;
# Details in Forum #35416
if(@ARGV != 0) {
print "Usage:\n".
" git clone https://github.com/jeedom/plugin-openzwave".
" cd plugin-openzwave/core/config".
" gzip -d < <fhem>/FHEM/lib/zwave_pepperlinks.csv.gz > zwave_pepperlinks.csv\n".
" perl <fhem>/contrib/zwave_jeedomconvert.pl\n".
" diff zwave_pepperlinks.csv zwave_pepperlinks.csv.NEW\n".
" upload shown *.jpg files to fhem.de/deviceimages\n".
" gzip < zwave_pepperlinks.csv.NEW > <fhem>/FHEM/lib/zwave_pepperlinks.csv.gz\n".
" rm *.jpg\n";
exit 1;
}
open(F1, "<zwave_pepperlinks.csv") || die("zwave_pepperlinks.csv: $!\n");
my %m;
while(my $l = <F1>) {
chomp($l);
my @a = split(/,/,$l);
$m{$a[0]}{L} = $a[1];
$m{$a[0]}{P} = $a[2];
}
close(F1);
open(F1, "find devices -name *.jpg -print|") || die("Cant start find: $!\n");
while(my $l = <F1>) {
chomp($l);
next if($l !~ m,/(\d+)\.(\d+)\.(\d+)_(.*)$,);
my $i = sprintf("%04x-%04x-%04x", $1, $2, $3);
next if($m{$i} && $m{$i}{P});
my $file = "$1.$2.$3_$4";
$file =~ s/ /_/g;
print "WARNING: bogus filename $file\n" if($file =~ m/^[^0-9A-Za-z.]+$/);
$m{$i}{P} = $file;
symlink($l, $file);
}
close(F1);
open(F2, ">zwave_pepperlinks.csv.NEW") || die("zwave_pepperlinks.csv.NEW: $!\n");
for my $i (sort keys %m) {
my ($l,$p) = ($m{$i}{L}, $m{$i}{P});
next if(!$l && !$p);
$l = "" if(!$l);
$p = "" if(!$p);
print F2 "$i,$l,$p\n";
}
close(F2);

View File

@ -3060,7 +3060,8 @@ deviceEvents($$)
if($hash->{READINGS} && $hash->{READINGS}{state}) {
my $ostate = $hash->{READINGS}{state}{VAL};
my $mstate = ReplaceEventMap($hash->{NAME}, $ostate, 1);
@{$cws} = map { $_ eq $mstate ? "state: $ostate" : $_ } @{$hash->{CHANGED}};
@{$cws} = map { $_ eq $mstate ? "state: $ostate" : $_ }
@{$hash->{CHANGED}};
} else {
@{$cws} = @{$hash->{CHANGED}};
}