From 79e47c7cdda7086ffded056899ddad66b74dcf6d Mon Sep 17 00:00:00 2001 From: markusbloch <> Date: Thu, 27 Oct 2016 19:59:44 +0000 Subject: [PATCH] Pushsafer: optimized picture file error handling (Forum: #59240) git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@12447 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- CHANGED | 1 + FHEM/70_Pushsafer.pm | 23 +++++++++++++++-------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/CHANGED b/CHANGED index fe2eeef84..38043765f 100644 --- a/CHANGED +++ b/CHANGED @@ -1,5 +1,6 @@ # Add changes at the top of the list. Keep it in ASCII, and 80-char wide. # Do not insert empty lines here, update check depends on it. + - changed: Pushsafer: optimized picture file error handling - new: 59_Wunderground: new weather module to fetch data from Weather Underground - bugfix: 50_HP1000: correct default unit for windSpeed/windGust from m/s to diff --git a/FHEM/70_Pushsafer.pm b/FHEM/70_Pushsafer.pm index cf4860adb..af4566b12 100755 --- a/FHEM/70_Pushsafer.pm +++ b/FHEM/70_Pushsafer.pm @@ -203,12 +203,8 @@ sub Pushsafer_createBody($$) if($key =~/^p\d?$/) { - if(-r $val) - { - $val = Pushsafer_createDataUrl($hash, $val); - next unless(defined($val)); - } - elsif($val =~ /^IPCAM:(\S+)$/) + + if($val =~ /^IPCAM:(\S+)$/) { my $ipcam = $1; @@ -218,13 +214,23 @@ sub Pushsafer_createBody($$) next; } - my $path = AttrVal($ipcam, "storage",$attr{global}{modpath}."/www/snapshots"); + my $path = AttrVal($ipcam, "storage",AttrVal("global", "modpath", ".")."/www/snapshots"); $path .= "/" unless($path =~ m,/$,); $path .= ReadingsVal($ipcam, "last", ""); $val = Pushsafer_createDataUrl($hash, $path); + next unless(defined($val)); + } + elsif(-e $val) + { + $val = Pushsafer_createDataUrl($hash, $val); } + else + { + Log3 $name, 3, "Pushsafer ($name) - picture file does not exist: $val - sending message without a picture..."; + next; + } } push @urlParts, $key."=".urlEncode($val); @@ -269,7 +275,8 @@ sub Pushsafer_createDataUrl($$) if(defined($err)) { - Log3 $name, 3, "Pushsafer ($name) - unable to open image file: $file - sending message without picture..."; + Log3 $name, 3, "Pushsafer ($name) - unable to open image file $file: $err"; + Log3 $name, 3, "Pushsafer ($name) - sending message without picture..."; } else {