diff --git a/fhem/FHEM/98_SVG.pm b/fhem/FHEM/98_SVG.pm
index 1382d1a32..cad4f07c7 100755
--- a/fhem/FHEM/98_SVG.pm
+++ b/fhem/FHEM/98_SVG.pm
@@ -116,6 +116,7 @@ SVG_Set($@)
if($cmd ne "copyGplotFile");
my $srcName = "$FW_gplotdir/$hash->{GPLOTFILE}.gplot";
+ my ($og,$od) = ($hash->{GPLOTFILE}, $hash->{DEF});
$hash->{GPLOTFILE} = $hash->{NAME};
my $dstName = "$FW_gplotdir/$hash->{GPLOTFILE}.gplot";
return "this is already a unique gplot file" if($srcName eq $dstName);
@@ -126,6 +127,12 @@ SVG_Set($@)
my ($err,@rows) = FileRead($srcName);
return $err if($err);
$err = FileWrite($dstName, @rows);
+
+ if($err) {
+ $hash->{DEF} = $od; $hash->{GPLOTFILE} = $og;
+ } else {
+ addStructChange("modify", $me, "$me $hash->{DEF}")
+ }
return $err;
}
@@ -469,6 +476,21 @@ SVG_PEdit($$$$)
$ret .= "
";
$ret .= "Example lines for input: $example |
";
+ my %gpf;
+ map {
+ $gpf{$defs{$_}{GPLOTFILE}}{$_} = 1 if($defs{$_}{TYPE} eq "SVG");
+ } sort keys %defs;
+
+ if(int(keys %{$gpf{$defs{$d}{GPLOTFILE}}}) > 1) {
+ $ret .= "| ".
+ "Note:".
+ "The .gplot file ($defs{$d}{GPLOTFILE}) is used by multiple SVG ".
+ "devices (".join(",", sort keys %{$gpf{$defs{$d}{GPLOTFILE}}})."), ".
+ "writing probably will corrupt the other SVGs. ".
+ "Remedy: execute set $d copyGplotFile".
+ " |
";
+ }
+
$ret .= "| ";
$ret .= FW_submit("submit", "Write .gplot file")." ".
FW_submit("showFileLogData", "Show preprocessed input").
@@ -609,13 +631,6 @@ SVG_WriteGplot($)
$maxLines = $1 if($1 > $maxLines);
}
- my $wlName = $FW_webArgs{detail};
- my $hash = $defs{$wlName};
- if($hash->{GPLOTFILE} ne $wlName) {
- Log 1, "WriteGplot: calling set $wlName copyGplotFile";
- SVG_Set($hash, $wlName, "copyGplotFile");
- }
-
my @rows;
push @rows, "# Created by FHEM/98_SVG.pm, ".TimeNow();
push @rows, "set terminal png transparent size crop";
@@ -665,6 +680,7 @@ SVG_WriteGplot($)
push @rows, $r;
}
+ my $hash = $defs{$FW_webArgs{detail}};
my $err = FileWrite("$FW_gplotdir/$hash->{GPLOTFILE}.gplot", @rows);
$FW_RET .= " SVG_WriteGplot: $err " if($err);
diff --git a/fhem/FHEM/98_autocreate.pm b/fhem/FHEM/98_autocreate.pm
index 9a1251246..24ddcae9f 100644
--- a/fhem/FHEM/98_autocreate.pm
+++ b/fhem/FHEM/98_autocreate.pm
@@ -121,7 +121,8 @@ autocreate_Notify($$)
my $temporary;
################
- if($s =~ m/^UNDEFINED -temporary/) { # Special for EnOcean. DO NOT use it elsewhere
+ # Special for EnOcean. DO NOT use it elsewhere
+ if($s =~ m/^UNDEFINED -temporary/) {
$temporary = 1;
$s =~ s/ -temporary//;
}
@@ -135,7 +136,7 @@ autocreate_Notify($$)
my $at = AttrVal($me, "autocreateThreshold", undef);
LoadModule($type) if( !$at );
- if( $at || $modules{$type}{AutoCreate} ) {
+ if($at) {
my @at = split( '[, ]', $at?$at:"" );
my $hash = $defs{$me};
@@ -227,6 +228,7 @@ autocreate_Notify($$)
last;
}
}
+
$hash = $defs{$name};
$nrcreated++;
my $room = replace_wildcards($hash, AttrVal($me, "device_room", "%TYPE"));
@@ -288,12 +290,18 @@ autocreate_Notify($$)
Log3 $me, 2, "autocreate: define $cmd";
$ret = CommandDefine(undef, $cmd);
if($ret) {
- Log3 $me, 1, "ERROR: $ret";
+ Log3 $me, 1, "ERROR: define $cmd: $ret";
last;
}
$attr{$wlname}{room} = $room if($room);
$attr{$wlname}{label} = '"' . $name .
' Min $data{min1}, Max $data{max1}, Last $data{currval1}"';
+
+ $ret = CommandSet(undef, "$wlname copyGplotFile");
+ if($ret) {
+ Log3 $me, 1, "ERROR: set $wlname copyGplotFile: $ret";
+ last;
+ }
}
}
|