mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-01-31 18:59:33 +00:00
FRITZBOX: umlaute in email body
git-svn-id: https://svn.fhem.de/fhem/trunk@8450 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
6dd36c396d
commit
222c1e271f
@ -33,6 +33,8 @@
|
||||
# parser for the weather data
|
||||
package MyProplantaParser;
|
||||
use base qw(HTML::Parser);
|
||||
use Time::HiRes qw(usleep nanosleep);
|
||||
|
||||
our @texte = ();
|
||||
my $lookupTag = "span|b";
|
||||
my $curTag = "";
|
||||
@ -163,6 +165,8 @@ sub text
|
||||
my ( $self, $text ) = @_;
|
||||
my $found = 0;
|
||||
my $readingName;
|
||||
# Wait 1ms to reduce CPU load and hence blocking of FHEM by it (workaround until a better solution is available)
|
||||
usleep (1000);
|
||||
if ( $curTag =~ $lookupTag )
|
||||
{
|
||||
$curTextPos++;
|
||||
@ -391,6 +395,7 @@ my $missingModul;
|
||||
eval "use LWP::UserAgent;1" or $missingModul .= "LWP::UserAgent ";
|
||||
eval "use HTTP::Request;1" or $missingModul .= "HTTP::Request ";
|
||||
eval "use HTML::Parser;1" or $missingModul .= "HTML::Parser ";
|
||||
eval "use MIME::Base64;1" or $missingModul .= "MIME::Base64 ";
|
||||
|
||||
require 'Blocking.pm';
|
||||
require 'HttpUtils.pm';
|
||||
@ -469,8 +474,8 @@ sub PROPLANTA_Define($$)
|
||||
|
||||
RemoveInternalTimer($hash);
|
||||
|
||||
#Get first data after 12 seconds
|
||||
InternalTimer( gettimeofday() + 12, "PROPLANTA_Start", $hash, 0 );
|
||||
#Get first data after 32 seconds
|
||||
InternalTimer( gettimeofday() + 32, "PROPLANTA_Start", $hash, 0 );
|
||||
|
||||
return undef;
|
||||
}
|
||||
@ -557,11 +562,11 @@ sub PROPLANTA_Start($)
|
||||
|
||||
$hash->{INTERVAL} = AttrVal( $name, "INTERVAL", $hash->{INTERVAL} );
|
||||
|
||||
if(!$hash->{fhem}{LOCAL} && $hash->{INTERVAL} > 0) {
|
||||
# set up timer if automatically call
|
||||
if($hash->{INTERVAL} > 0) {
|
||||
# reset timer if interval is defined
|
||||
RemoveInternalTimer( $hash );
|
||||
InternalTimer(gettimeofday() + $hash->{INTERVAL}, "PROPLANTA_Start", $hash, 1 );
|
||||
return undef if( AttrVal($name, "disable", 0 ) == 1 );
|
||||
return undef if AttrVal($name, "disable", 0 ) == 1 && !$hash->{fhem}{LOCAL};
|
||||
}
|
||||
|
||||
if ( AttrVal( $name, 'URL', '') eq '' && not defined( $hash->{URL} ) )
|
||||
@ -570,6 +575,16 @@ sub PROPLANTA_Start($)
|
||||
return;
|
||||
}
|
||||
|
||||
# "Set update"-action will kill a running update child process
|
||||
if (defined ($hash->{helper}{RUNNING_PID}) && $hash->{fhem}{LOCAL})
|
||||
{
|
||||
BlockingKill($hash->{helper}{RUNNING_PID});
|
||||
delete( $hash->{helper}{RUNNING_PID} );
|
||||
PROPLANTA_Log $hash, 4, "Killing old forked process";
|
||||
}
|
||||
|
||||
unless (defined ($hash->{helper}{RUNNING_PID}))
|
||||
{
|
||||
$hash->{helper}{RUNNING_PID} =
|
||||
BlockingCall(
|
||||
"PROPLANTA_Run", # callback worker task
|
||||
@ -578,11 +593,18 @@ sub PROPLANTA_Start($)
|
||||
120, # timeout seconds
|
||||
"PROPLANTA_Aborted", # callback for abortion
|
||||
$hash ); # parameter for abortion
|
||||
PROPLANTA_Log $hash, 4, "Start forked process to capture html";
|
||||
}
|
||||
else
|
||||
{
|
||||
PROPLANTA_Log $hash, 1, "Could not start forked process, old process still running";
|
||||
}
|
||||
}
|
||||
|
||||
#####################################
|
||||
sub PROPLANTA_Run($)
|
||||
{
|
||||
setpriority( 0, 0, 10);
|
||||
my ($name) = @_;
|
||||
my $ptext=$name;
|
||||
my $URL;
|
||||
@ -656,6 +678,7 @@ sub PROPLANTA_Run($)
|
||||
|
||||
return $ptext;
|
||||
}
|
||||
|
||||
#####################################
|
||||
# asyncronous callback by blocking
|
||||
sub PROPLANTA_Done($)
|
||||
@ -668,9 +691,12 @@ sub PROPLANTA_Done($)
|
||||
my $hash = $defs{$name};
|
||||
return unless ( defined($hash->{NAME}) );
|
||||
|
||||
PROPLANTA_Log $hash, 4, "Forked process successfully finished";
|
||||
|
||||
# delete the marker for RUNNING_PID process
|
||||
delete( $hash->{helper}{RUNNING_PID} );
|
||||
|
||||
|
||||
# Wetterdaten speichern
|
||||
readingsBeginUpdate($hash);
|
||||
|
||||
@ -718,11 +744,13 @@ sub PROPLANTA_Done($)
|
||||
}
|
||||
readingsEndUpdate( $hash, 1 );
|
||||
}
|
||||
|
||||
#####################################
|
||||
sub PROPLANTA_Aborted($)
|
||||
{
|
||||
my ($hash) = @_;
|
||||
delete( $hash->{helper}{RUNNING_PID} );
|
||||
PROPLANTA_Log $hash, 4, "Forked process timed out";
|
||||
}
|
||||
|
||||
##### noch nicht fertig ###########
|
||||
@ -789,6 +817,8 @@ PROPLANTA_Html($)
|
||||
<br>
|
||||
The website provides a forecast for 12 days, for the first 7 days in a 3-hours-interval.
|
||||
<br>
|
||||
This modul causes a high CPU load. It is recommended to reduce the number of captured forecast days.
|
||||
<br>
|
||||
It uses the perl moduls HTTP::Request, LWP::UserAgent and HTML::Parse.
|
||||
<br/><br/>
|
||||
<a name="PROPLANTAdefine"></a>
|
||||
@ -894,6 +924,8 @@ PROPLANTA_Html($)
|
||||
<br/>
|
||||
Es stellt eine Vorhersage für 12 Tage zur Verfügung - während der ersten 7 Tage im 3-Stunden-Intervall.
|
||||
<br>
|
||||
Dieses Modul erzeugt eine hohe CPU-Last. Es wird deshalb empfohlen, die auszulesenden Vorhersagetage zu reduzieren.
|
||||
<br>
|
||||
<i>Es nutzt die Perl-Module HTTP::Request, LWP::UserAgent und HTML::Parse</i>.
|
||||
<br/><br/>
|
||||
<b>Define</b>
|
||||
|
@ -2383,6 +2383,15 @@ sub FRITZBOX_SendMail($@)
|
||||
{
|
||||
chop $field{body};
|
||||
$field{body} =~ s/"/\\"/g;
|
||||
# change none ASCII chars in octal code for ISO-8859-1 (acc. http://www.pjb.com.au/comp/diacritics.html)
|
||||
$field{body} =~ s/Ä|Ä/\\304/g;
|
||||
$field{body} =~ s/Ö|Ö/\\326/g;
|
||||
$field{body} =~ s/Ü|Ãœ/\\334/g;
|
||||
$field{body} =~ s/ß|ß/\\337/g;
|
||||
$field{body} =~ s/ä|ä/\\344/g;
|
||||
$field{body} =~ s/ö|ö/\\366/g;
|
||||
$field{body} =~ s/ü|ü/\\374/g;
|
||||
|
||||
push @cmdArray, '/bin/echo -e "'.$field{body}.'" >/var/tmp/fhem_nachricht.txt';
|
||||
$cmd .= " -i '/var/tmp/fhem_nachricht.txt'";
|
||||
}
|
||||
@ -2405,8 +2414,8 @@ sub FRITZBOX_SendMail($@)
|
||||
return undef;
|
||||
}
|
||||
|
||||
sub ##########################################
|
||||
FRITZBOX_StartRadio($@)
|
||||
##########################################
|
||||
sub FRITZBOX_StartRadio($@)
|
||||
{
|
||||
my ($hash, @val) = @_;
|
||||
my @cmdArray;
|
||||
|
Loading…
Reference in New Issue
Block a user