mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-05-07 22:29:19 +00:00
FRITZBOX: new feature: sendMail
git-svn-id: https://svn.fhem.de/fhem/trunk@7190 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
a2cf159dfa
commit
357eb6624a
@ -45,6 +45,7 @@ sub FRITZBOX_Log($$$);
|
|||||||
sub FRITZBOX_Init($);
|
sub FRITZBOX_Init($);
|
||||||
sub FRITZBOX_Ring_Start($@);
|
sub FRITZBOX_Ring_Start($@);
|
||||||
sub FRITZBOX_Exec($$);
|
sub FRITZBOX_Exec($$);
|
||||||
|
sub FRITZBOX_Send_Mail($@);
|
||||||
|
|
||||||
our $telnet;
|
our $telnet;
|
||||||
|
|
||||||
@ -249,6 +250,7 @@ FRITZBOX_Set($$@)
|
|||||||
. " guestWlan:on,off"
|
. " guestWlan:on,off"
|
||||||
. " message"
|
. " message"
|
||||||
. " ring"
|
. " ring"
|
||||||
|
. " sendMail"
|
||||||
. " startRadio"
|
. " startRadio"
|
||||||
. " tam"
|
. " tam"
|
||||||
. " update:noArg"
|
. " update:noArg"
|
||||||
@ -320,11 +322,9 @@ FRITZBOX_Set($$@)
|
|||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elsif( lc $cmd eq 'update' )
|
elsif ( lc $cmd eq 'sendmail')
|
||||||
{
|
{
|
||||||
$hash->{fhem}{LOCAL}=1;
|
FRITZBOX_Send_Mail $hash, @val;
|
||||||
FRITZBOX_Readout_Start($hash);
|
|
||||||
$hash->{fhem}{LOCAL}=0;
|
|
||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
elsif ( lc $cmd eq 'startradio')
|
elsif ( lc $cmd eq 'startradio')
|
||||||
@ -347,6 +347,13 @@ FRITZBOX_Set($$@)
|
|||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
elsif( lc $cmd eq 'update' )
|
||||||
|
{
|
||||||
|
$hash->{fhem}{LOCAL}=1;
|
||||||
|
FRITZBOX_Readout_Start($hash);
|
||||||
|
$hash->{fhem}{LOCAL}=0;
|
||||||
|
return undef;
|
||||||
|
}
|
||||||
elsif ( lc $cmd eq 'wlan')
|
elsif ( lc $cmd eq 'wlan')
|
||||||
{
|
{
|
||||||
if (int @val == 1 && $val[0] =~ /^(on|off)$/)
|
if (int @val == 1 && $val[0] =~ /^(on|off)$/)
|
||||||
@ -855,6 +862,9 @@ FRITZBOX_Ring_Start($@)
|
|||||||
$val[1] = 5
|
$val[1] = 5
|
||||||
unless defined $val[1];
|
unless defined $val[1];
|
||||||
|
|
||||||
|
$val[1] = 5
|
||||||
|
unless $val[1] =~/^\d+$/;
|
||||||
|
|
||||||
if ( exists( $hash->{helper}{RING_RUNNING_PID} ) )
|
if ( exists( $hash->{helper}{RING_RUNNING_PID} ) )
|
||||||
{
|
{
|
||||||
FRITZBOX_Log $hash, 1, "Old process still running. Killing old process ".$hash->{helper}{RING_RUNNING_PID};
|
FRITZBOX_Log $hash, 1, "Old process still running. Killing old process ".$hash->{helper}{RING_RUNNING_PID};
|
||||||
@ -900,13 +910,11 @@ FRITZBOX_Ring_Run($)
|
|||||||
|
|
||||||
|
|
||||||
my $duration = 5;
|
my $duration = 5;
|
||||||
if ($val[0] !~ /^msg:/i)
|
if (defined $val[0])
|
||||||
{
|
{
|
||||||
$duration = $val[0]
|
$duration = $val[0]
|
||||||
if defined $val[0];
|
if ($val[0] =~ /^\d+$/);
|
||||||
shift @val;
|
shift @val;
|
||||||
return $name."|0|Error: Duration '".$val[0]."' not a positiv integer"
|
|
||||||
unless $duration =~ /^\d+$/;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
my $ringTone;
|
my $ringTone;
|
||||||
@ -1376,6 +1384,47 @@ FRITZBOX_Exec_Local($$)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#####################################
|
||||||
|
sub FRITZBOX_Send_Mail($@)
|
||||||
|
{
|
||||||
|
my ($hash,@val) = @_;
|
||||||
|
my $lastField;
|
||||||
|
my %field;
|
||||||
|
my @cmdArray;
|
||||||
|
|
||||||
|
foreach (@val)
|
||||||
|
{
|
||||||
|
if ($_ =~ /^(to|subject|body):/i)
|
||||||
|
{
|
||||||
|
$lastField = $1;
|
||||||
|
$_ =~ s/^$1://;
|
||||||
|
}
|
||||||
|
$field{$lastField} .= $_." "
|
||||||
|
if $lastField;
|
||||||
|
}
|
||||||
|
|
||||||
|
my $cmd = "/sbin/mailer send";
|
||||||
|
if ($field{body})
|
||||||
|
{
|
||||||
|
push @cmdArray, "/bin/echo \"".$field{body}."\" > /var/tmp/fhem_nachricht.txt";
|
||||||
|
$cmd .= " -i '/var/tmp/fhem_nachricht.txt'";
|
||||||
|
}
|
||||||
|
|
||||||
|
$field{subject} = "Message from FHEM"
|
||||||
|
unless $field{subject};
|
||||||
|
$cmd .= " -s \"".$field{subject}."\"";
|
||||||
|
|
||||||
|
$cmd .= " -t \"".$field{to}."\""
|
||||||
|
if $field{to} ne "";
|
||||||
|
push @cmdArray, $cmd;
|
||||||
|
push @cmdArray, "rm /var/tmp/fhem_nachricht.txt"
|
||||||
|
if $field{body};
|
||||||
|
|
||||||
|
FRITZBOX_Exec( $hash, \@cmdArray );
|
||||||
|
|
||||||
|
return undef;
|
||||||
|
}
|
||||||
|
|
||||||
#####################################
|
#####################################
|
||||||
sub FRITZBOX_fritztris($)
|
sub FRITZBOX_fritztris($)
|
||||||
{
|
{
|
||||||
@ -1513,6 +1562,12 @@ sub FRITZBOX_fritztris($)
|
|||||||
<br>
|
<br>
|
||||||
If the call is taken the callee hears the "music on hold" which can be used to transmit messages.
|
If the call is taken the callee hears the "music on hold" which can be used to transmit messages.
|
||||||
</li><br>
|
</li><br>
|
||||||
|
<li><code>set <name> sendMail [to:emailAddress] [subject:emailSubject] [body:emailText]</code>
|
||||||
|
<br>
|
||||||
|
Sends an email via the email notification service that is configured in push service of the Fritz!Box.
|
||||||
|
All parameters can be omitted. Make sure the messages are not classified as junk by your email client.
|
||||||
|
<br>
|
||||||
|
</li><br>
|
||||||
<li><code>set <name> startradio <internalNumber> [name]</code>
|
<li><code>set <name> startradio <internalNumber> [name]</code>
|
||||||
<br>
|
<br>
|
||||||
<i>Not implemented yet.</i> Starts the internet radio on the given Fritz!Fon
|
<i>Not implemented yet.</i> Starts the internet radio on the given Fritz!Fon
|
||||||
|
Loading…
x
Reference in New Issue
Block a user