2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-04-07 12:58:13 +00:00

FritzBoxUtils.pm: added FB_mail($$$) , FB_WLANswitch($)

git-svn-id: https://svn.fhem.de/fhem/trunk@1899 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
ulimaass 2012-09-28 22:17:03 +00:00
parent f35fc5dba0
commit 8a7f79acba

View File

@ -46,4 +46,45 @@ FB_checkPw($$)
}
}
######## FB_mail ##################################################
# What : Sends a mail
# Call : { FB_mail('empfaenger@mail.de','Subject','text 123') }
# Source: http://www.fhemwiki.de/wiki/E-Mail_senden
# Prereq: - FB7390 needs fhem-installation from fhem.de; installation from AVM will _not_ work (chroot)
# - In FritzBox, Push-Service needs to be active
sub
FB_mail($$$)
{
my ($rcpt, $subject, $text) = @_;
my $tmpfile = "fhem_nachricht.txt";
system("/bin/echo \'$text\' > \'$tmpfile\' ");
system("/sbin/mailer send -i \"$tmpfile\" -s \"$subject\" -t \"$rcpt\"");
system("rm \"$tmpfile\"");
Log 3, "Mail sent."
}
######## FB_WLANswitch ############################################
# What : Switches WLAN on or off
# Call : { FB_WLANswitch("on") }
# Source: http://www.fhemwiki.de/wiki/Fritzbox:_WLAN_ein/ausschalten
sub
FB_WLANswitch($) {
my $cmd = shift;
my $ret = "";
if ($cmd =~ m"on"i) { # on or ON
$ret .= "ATD: " . `echo "ATD#96*1*" | nc 127.0.0.1 1011` ;
sleep 1 ;
$ret .= " ATH: " . `echo "ATH" | nc 127.0.0.1 1011` ;
}
if ($cmd =~ m"off"i) { # off or OFF
$ret .= "ATD: " . `echo "ATD#96*0*" | nc 127.0.0.1 1011` ;
sleep 1 ;
$ret .= " ATH: " . `echo "ATH" | nc 127.0.0.1 1011` ;
}
$ret =~ s,[\r\n]*,,g; # remove CR from return-string
Log 4, "FB_WLANswitch($cmd) returned: $ret";
}
1;