From 3d5d62afe0de716684a337bc8c9e89aa914d72db Mon Sep 17 00:00:00 2001 From: tpoitzsch Date: Wed, 31 Dec 2014 10:05:34 +0000 Subject: [PATCH] FRITZBOX: sendmail bugfix, show: adapted to old dect, docu git-svn-id: svn://svn.code.sf.net/p/fhem/code/trunk@7374 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/72_FRITZBOX.pm | 43 +++++++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/fhem/FHEM/72_FRITZBOX.pm b/fhem/FHEM/72_FRITZBOX.pm index 38a2770f9..f0a13dd8d 100644 --- a/fhem/FHEM/72_FRITZBOX.pm +++ b/fhem/FHEM/72_FRITZBOX.pm @@ -608,7 +608,7 @@ FRITZBOX_Readout_Run($) # 5 Radio Name push @readoutArray, [ "dect".$_."_radio", "ctlmgr_ctl r telcfg settings/Foncontrol/User".$_."/RadioRingID", "radio" ]; # 6 Background image - push @readoutArray, [ "dect".$_."_imagePath ", "ctlmgr_ctl r telcfg settings/Foncontrol/User".$_."/ImagePath " ]; + push @readoutArray, [ "dect".$_."_imagePath", "ctlmgr_ctl r telcfg settings/Foncontrol/User".$_."/ImagePath" ]; # 7 Customer Ring Tone push @readoutArray, [ "dect".$_."_custRingTone", "ctlmgr_ctl r telcfg settings/Foncontrol/User".$_."/G722RingTone" ]; # 8 Customer Ring Tone Name @@ -666,7 +666,7 @@ FRITZBOX_Readout_Run($) for (0..$tamCount-1) { $rName = "tam".($_+1); - if ($resultArray->[$_] == 1 || defined $hash->{READINGS}{$rName} ) + if ($resultArray->[$_] eq "1" || defined $hash->{READINGS}{$rName} ) { push @readoutArray, [ $rName, "ctlmgr_ctl r tam settings/TAM". $_ ."/Name" ]; push @readoutArray, [ $rName."_state", "ctlmgr_ctl r tam settings/TAM".$_."/Active", "onoff" ]; @@ -890,9 +890,9 @@ sub FRITZBOX_Readout_Format($$$) unless $readout ne "" && $format ne "" ; if ($format eq "aldays") { - if ($readout == 0) { + if ($readout eq "0") { $readout = "once"; - } elsif ($readout == 127) { + } elsif ($readout eq "127") { $readout = "daily"; } else { my $bitStr = $readout; @@ -1090,7 +1090,7 @@ FRITZBOX_Ring_Run($) $intNo =~ s/,/#/g; #Preparing 2nd command array to ring and reset everything - FRITZBOX_Log $hash, 3, "Ringing $intNo for $duration seconds"; + FRITZBOX_Log $hash, 4, "Ringing $intNo for $duration seconds"; push @cmdArray, "ctlmgr_ctl w telcfg command/Dial **".$intNo; push @cmdArray, "ctlmgr_ctl w telcfg settings/DialPort 50" if $ringWithIntern != 0 ; @@ -1099,11 +1099,11 @@ FRITZBOX_Ring_Run($) { push @cmdArray, "ctlmgr_ctl w telcfg settings/Foncontrol/User".$FritzFons[$_]."/IntRingTone ".$result->[2*$_]; } + push @cmdArray, "sleep ".$duration; # Reset name of calling number push @cmdArray, "ctlmgr_ctl w telcfg settings/MSN/Port".($ringWithIntern-1)."/Name '".$result->[2*int(@FritzFons)]."'" if $ringWithIntern =~ /^([1-4])$/; - push @cmdArray, "sleep ".$duration; push @cmdArray, "ctlmgr_ctl w telcfg command/Hangup **".$intNo; # Execute command array @@ -1222,7 +1222,7 @@ sub FRITZBOX_SetMOH($@) # Execute command array $result = FRITZBOX_Exec ( $hash, \@cmdArray ); return "Could not access '$inFile'" - unless $result->[3] == 1; + unless $result->[3] eq "1"; #Prepare 2nd command array push @cmdArray, 'ffmpegconv -i "'.$uploadFile.'" -o "'.$mohFile.'" --limit 32 --type 7'; @@ -1230,7 +1230,7 @@ sub FRITZBOX_SetMOH($@) # Execute 2nd command array $result = FRITZBOX_Exec ( $hash, \@cmdArray ); return "Could not convert '$inFile'" - unless $result->[1] == 1; + unless $result->[1] eq "1"; #Prepare 3rd command array push @cmdArray, 'cat "'.$mohFile.'" >/var/flash/fx_moh'; @@ -1642,16 +1642,21 @@ sub FRITZBOX_Send_Mail($@) my $cmd = "/sbin/mailer send"; if ($field{body}) { - push @cmdArray, "/bin/echo \"".$field{body}."\" > /var/tmp/fhem_nachricht.txt"; + chop $field{body}; + $field{body} =~ s/"/\\"/g; + push @cmdArray, '/bin/echo -e "'.$field{body}.'" >/var/tmp/fhem_nachricht.txt'; $cmd .= " -i '/var/tmp/fhem_nachricht.txt'"; } - $field{subject} = "Message from FHEM" - unless $field{subject}; + chop $field{subject} if $field{subject}; + $field{subject} = "Message from FHEM " unless $field{subject}; $cmd .= " -s \"".$field{subject}."\""; - $cmd .= " -t \"".$field{to}."\"" - if $field{to} ne ""; + if ($field{to}) + { + chop $field{to}; + $cmd .= " -t \"".$field{to}."\"" + } push @cmdArray, $cmd; push @cmdArray, "rm /var/tmp/fhem_nachricht.txt" if $field{body}; @@ -1788,9 +1793,9 @@ sub FRITZBOX_fritztris($)

The modul switches in local mode if FHEM runs on a Fritz!Box (as root user!). Otherwise, it tries to open a telnet connection to "fritz.box", so telnet (#96*7*) has to be enabled on the Fritz!Box. For remote access the password must be stored in the file 'fb_pwd.txt' in the root directory of FHEM.

- Check also the other Fritz!Box moduls: SYSMON and FB_CALLMONITOR. + The commands are directly executed on the Fritz!Box shell. That means, no official API is used but mainly the internal interface program that links web interface and firmware. On update of FritzOS might hence lead to modul errors if AVM changes the interface.
- So fare, the module has been tested on Fritz!Box 7390 and 7490 and Fritz!Fon MT-F and C4. + Check also the other Fritz!Box moduls: SYSMON and FB_CALLMONITOR.
The modul uses the Perl modul 'Net::Telnet' for remote access.

@@ -1886,7 +1891,8 @@ sub FRITZBOX_fritztris($)
  • set <name> sendMail [to:<Address>] [subject:<Subject>] [body:<Text>]
    - Sends an email via the email notification service that is configured in push service of the Fritz!Box. + Sends an email via the email notification service that is configured in push service of the Fritz!Box. + Use "\n" for line breaks in the body. All parameters can be omitted. Make sure the messages are not classified as junk by your email client.

  • @@ -2044,9 +2050,9 @@ sub FRITZBOX_fritztris($)

    Das Modul schaltet in den lokalen Modus, wenn FHEM auf einer Fritz!Box läuft (als root-Benutzer!). Ansonsten versucht es eine Telnet Verbindung zu "fritz.box" zu öffnen. D.h. Telnet (#96*7*) muss auf der Fritz!Box erlaubt sein. Für diesen Fernzugriff muss das Passwort in der Datei 'fb_pwd.txt' im Wurzelverzeichnis von FHEM gespeichert sein.

    - Bitte auch die anderen Fritz!Box-Module beachten: SYSMON und FB_CALLMONITOR. + Die Steuerung erfolgt direkt über die Fritz!Box Shell. D.h. es wird keine offizielle API genutzt sondern vor allem die interne Schnittstelle der Box zwischen Webinterface und Firmware. Eine Aktualisierung des FritzOS kann also zu Modul-Fehlern führen, wenn AVM diese Schnittstelle ändert.
    - Bisher wurde das Modul auf einer Fritz!Box 7390 und 7490 und auf den Fritz!Fon MT-F und C4 getestet. + Bitte auch die anderen Fritz!Box-Module beachten: SYSMON und FB_CALLMONITOR.
    Das Modul nutzt das Perlmodule 'Net::Telnet' für den Fernzugriff.

    @@ -2141,6 +2147,7 @@ sub FRITZBOX_fritztris($)
  • set <name> sendMail [to:<Address>] [subject:<Subject>] [body:<Text>]
    Sendet eine Email über den Emailbenachrichtigungsservice der als Push Service auf der Fritz!Box konfiguriert wurde. + Mit "\n" kann einen Zeilenumbruch im Textkörper erzeut werden. Alle Parameter können ausgelassen werden. Bitte kontrolliert, dass die Email nicht im Junk-Verzeichnis landet.