From 996f7596c8505c40936b5c6e32cc1557b6c83f44 Mon Sep 17 00:00:00 2001 From: nasseeder1 Date: Fri, 29 Jul 2022 10:54:20 +0000 Subject: [PATCH] 49_SSCam: contrib 9.10.7 git-svn-id: https://svn.fhem.de/fhem/trunk@26270 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/contrib/DS_Starter/49_SSCam.pm | 109 +++++++++++++++++++++++----- 1 file changed, 92 insertions(+), 17 deletions(-) diff --git a/fhem/contrib/DS_Starter/49_SSCam.pm b/fhem/contrib/DS_Starter/49_SSCam.pm index 848b0525a..3f9b2a40b 100644 --- a/fhem/contrib/DS_Starter/49_SSCam.pm +++ b/fhem/contrib/DS_Starter/49_SSCam.pm @@ -185,7 +185,7 @@ BEGIN { # Versions History intern my %vNotesIntern = ( - "9.10.7" => "27.07.2022 allow placeholders #CAM, #DATE, #TIME, #FILE, #CTIME ", + "9.10.7" => "29.07.2022 allow placeholders #CAM, #DATE, #TIME, #FILE, #CTIME (also for Email) ", "9.10.6" => "18.07.2022 textField-long property set for recChatTxt, recEmailTxt, recTelegramTxt, snapChatTxt, snapEmailTxt, snapTelegramTxt, ". "set 'part1type' to default => text/html instead of text/plain", "9.10.5" => "01.07.2022 fix noQuotesForSID using in streaming devices type mjpeg ", @@ -10844,6 +10844,7 @@ sub __sendEmailblocking { ## } $subject = decode_utf8($subject); + my $mailmsg = MIME::Lite->new( From => $from, To => $to, @@ -10851,15 +10852,10 @@ sub __sendEmailblocking { ## Type => 'multipart/mixed', #'multipart/mixed', # was 'text/plain' ); - ### Add the text message part: - ### (Note that "attach" has same arguments as "new"): $part1txt = decode_utf8($part1txt); - $mailmsg->attach( - Type => $part1type, - Data => $part1txt, - ); - + ### Add image, Das Image liegt bereits als File vor + #################################################### if($image) { $mailmsg->attach( Type => $part2type, @@ -10886,8 +10882,20 @@ sub __sendEmailblocking { ## Filename => $fname, Disposition => 'attachment', ); + + my $params = { + hash => $hash, + name => $name, + txt => $part1txt, + fname => $fname, + ct => $ct + }; + + $part1txt = __extractForEmail ($params); + Log3($name, 4, "$name - Image data sequence [$key] decoded from internal Cache for Email attachment") if($decoded); } + BlockingInformParent("FHEM::SSCam::subaddFromBlocking", [$name, "-", $tac], 0); } else { @@ -10914,8 +10922,20 @@ sub __sendEmailblocking { ## Filename => $fname, Disposition => 'attachment', ); + + my $params = { + hash => $hash, + name => $name, + txt => $part1txt, + fname => $fname, + ct => $ct + }; + + $part1txt = __extractForEmail ($params); + Log3($name, 4, "$name - Image data sequence [$key] decoded from CHI-Cache for Email attachment"); } + BlockingInformParent("FHEM::SSCam::subaddFromBlocking", [$name, "-", $tac], 0); } } @@ -10935,8 +10955,20 @@ sub __sendEmailblocking { ## Filename => $fname, Disposition => 'attachment', ); + + my $params = { + hash => $hash, + name => $name, + txt => $part1txt, + fname => $fname, + ct => $ct + }; + + $part1txt = __extractForEmail ($params); + Log3($name, 4, "$name - Video data sequence [$key] decoded from internal Cache for Email attachment"); } + BlockingInformParent("FHEM::SSCam::subaddFromBlocking", [$name, "-", $tac], 0); } else { @@ -10963,12 +10995,31 @@ sub __sendEmailblocking { ## Filename => $fname, Disposition => 'attachment', ); + + my $params = { + hash => $hash, + name => $name, + txt => $part1txt, + fname => $fname, + ct => $ct + }; + + $part1txt = __extractForEmail ($params); + Log3($name, 4, "$name - Video data sequence [$key] decoded from CHI-Cache for Email attachment"); } + BlockingInformParent("FHEM::SSCam::subaddFromBlocking", [$name, "-", $tac], 0); } } + ### Add the text message part (Note that "attach" has same arguments as "new") + ############################################################################### + $mailmsg->attach( + Type => $part1type, + Data => $part1txt, + ); + $mailmsg->attr('content-type.charset' => 'UTF-8'); ##### SMTP-Connection ##### @@ -11088,6 +11139,22 @@ sub __sendEmailblocking { ## return "$name|''|$ret"; } +#################################################################################################### +# Daten extrahieren für Email Versand +#################################################################################################### +sub __extractForEmail { + my $paref = shift; + my $txt = $paref->{txt} // qq{}; + my $fname = $paref->{fname} // qq{}; + my $ct = $paref->{ct} // qq{}; + + $txt =~ s/[\$#]FILE/$fname/gx; + $txt =~ s/[\$#]CTIME/$ct/gx; + +return $txt; +} + + #################################################################################################### # Auswertungsroutine nichtblockierendes Send EMail #################################################################################################### @@ -13411,15 +13478,17 @@ attr <name> genericStrmHtmlTag <img $HTMLATTR
  • recEmailTxt subject => <subject text>, body => <message text>
    Activates the Email shipping of recordings after whose creation.
    - The attribute has to be definied in the form as described.
    - You can use the following placeholders in "subject" and "body".

    + The attribute must be defined in the specified form.
    + The following placeholders can be used in the subject or body.


    @@ -13576,8 +13645,8 @@ attr <name> genericStrmHtmlTag <img $HTMLATTR
  • snapEmailTxt subject => <subject text>, body => <message text>
    Activates the Email shipping of snapshots after whose creation.
    - The attribute has to be defined in the form as described.
    - You can use the following placeholders in "subject" and "body".

    + The attribute must be defined in the specified form.
    + The following placeholders can be used in the subject or body.


    @@ -15440,14 +15511,16 @@ attr <name> genericStrmHtmlTag <img $HTMLATTR
  • recEmailTxt subject => <Betreff-Text>, body => <Mitteilung-Text>
    Aktiviert den Emailversand von Aufnahmen nach deren Erstellung.
    Das Attribut muß in der angegebenen Form definiert werden.
    - Es können die folgenden Platzhalter im subject und body verwendet werden.

    + Es können die folgenden Platzhalter im subject bzw. body verwendet werden.


    @@ -15607,14 +15680,16 @@ attr <name> genericStrmHtmlTag <img $HTMLATTR Aktiviert den Emailversand von Schnappschüssen nach deren Erstellung. Wurden mehrere Schnappschüsse ausgelöst, werden sie gemeinsam in einer Mail versendet.
    Das Attribut muß in der angegebenen Form definiert werden.
    - Es können die folgenden Platzhalter im subject und body verwendet werden.

    + Es können die folgenden Platzhalter im subject bzw. body verwendet werden.