From a2e0461637aeb9158647902943c0a2621f01f5ab Mon Sep 17 00:00:00 2001 From: Byte09 <> Date: Mon, 31 Dec 2018 08:03:12 +0000 Subject: [PATCH] 98_MSwitch.pm:Fix - perlwarning if incoming event json formated git-svn-id: https://svn.fhem.de/fhem/trunk@18102 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/98_MSwitch.pm | 46 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 42 insertions(+), 4 deletions(-) diff --git a/fhem/FHEM/98_MSwitch.pm b/fhem/FHEM/98_MSwitch.pm index 454b295c9..d3b76b642 100644 --- a/fhem/FHEM/98_MSwitch.pm +++ b/fhem/FHEM/98_MSwitch.pm @@ -2452,8 +2452,28 @@ sub MSwitch_Notify($$) { my $anzahl; EVENT: foreach my $event (@eventscopy) { - #MSwitch_LOG( $ownName, 0, "$ownName: event -> $event " ); + MSwitch_LOG( $ownName, 5, "$ownName: event -> $event " ); + + if( $event =~ m/(.*)(\{.*\})(.*)/ ) + { + + MSwitch_LOG( $ownName, 5, "$ownName: changedevent1 -> $1 " ); + MSwitch_LOG( $ownName, 5, "$ownName: changedevent2 -> $2 " ); + MSwitch_LOG( $ownName, 5, "$ownName: changedevent3 -> $3 " ); + my $p1 = $1; + my $json = $2; + my $p3 = $3; + $json =~ s/:/[dp]/g; + $json =~ s/\"/[dst]/g; + + $event = $p1.$json.$p3; + MSwitch_LOG( $ownName, 5, "$ownName: changedevent -> $event " ); + #next EVENT; + } + + + $own_hash->{eventsave} = 'unsaved'; MSwitch_LOG( $ownName, 5, "$ownName: eingehendes Event -> " @@ -4610,7 +4630,7 @@ sub MSwitch_fhemwebFn($$$$) { $ret = $ret . "Trigger Device Global Whitelist: - "; @@ -6886,11 +6906,16 @@ m/(.*?)(\[\[[a-zA-Z][a-zA-Z0-9_]{0,30}:[a-zA-Z0-9_]{0,30}\]-\[[a-zA-Z][a-zA-Z0-9 MSwitch_LOG( $name, 6, "$name: Checkcondition - finalstring -> " . $finalstring ); + + #MSwitch_LOG( $name, 0,"name $name "); + + + my $ret = eval $finalstring; MSwitch_LOG( $name, 6, "$name: Checkcondition - return -> " . $ret ); if ($@) { - MSwitch_LOG( $name, 1, "ERROR: $@ " . __LINE__ ); - MSwitch_LOG( $name, 1, "$finalstring " . __LINE__ ); + MSwitch_LOG( $name, 1, "$name ERROR: $@ " . __LINE__ ); + MSwitch_LOG( $name, 1, "$name $finalstring " . __LINE__ ); $hash->{helper}{conditionerror} = $@; return 'false'; @@ -8529,6 +8554,19 @@ sub MSwitch_EventBulk($$$$) { my $evtfull = join( ':', @evtparts ); $evtparts[2] = '' if !defined $evtparts[2]; + + + $event =~ s/\[dp\]/:/g; + $evtfull =~ s/\[dp\]/:/g; + $evtparts[1] =~ s/\[dp\]/:/g if $evtparts[1]; + $evtparts[2] =~ s/\[dp\]/:/g if $evtparts[2]; + + $event =~ s/\[dst\]/"/g; + $evtfull =~ s/\[dst\]/"/g; + $evtparts[1] =~ s/\[dst\]/"/g if $evtparts[1]; + $evtparts[2] =~ s/\[dst\]/"/g if $evtparts[2]; + + $event =~ s/\[#dp\]/:/g; $evtfull =~ s/\[#dp\]/:/g; $evtparts[1] =~ s/\[#dp\]/:/g if $evtparts[1];