mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-03-03 16:56:54 +00:00
msg: fix for sending emails directly
git-svn-id: https://svn.fhem.de/fhem/trunk@9761 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
96951c11c7
commit
de34c65c64
@ -59,7 +59,7 @@ sub CommandMsg($$;$$) {
|
|||||||
my $return = "";
|
my $return = "";
|
||||||
|
|
||||||
# find existing msgConfig device or create a new instance
|
# find existing msgConfig device or create a new instance
|
||||||
my $globalDevName = "msgConfig";
|
my $globalDevName = "globalMsg";
|
||||||
if (defined ($modules{msgConfig}{defptr})) {
|
if (defined ($modules{msgConfig}{defptr})) {
|
||||||
$globalDevName = $modules{msgConfig}{defptr}{NAME};
|
$globalDevName = $modules{msgConfig}{defptr}{NAME};
|
||||||
} else {
|
} else {
|
||||||
@ -263,7 +263,7 @@ s/^[\s\t]*\|([\w\süöäß^°!"§$%&\/\\()<>=?´`"+\[\]#*@€]+)\|[\s\t]+//
|
|||||||
if ( $device =~
|
if ( $device =~
|
||||||
/^(([A-Za-z0-9%+._-])+[@]+([%+a-z0-9A-Z.-]*))$/ )
|
/^(([A-Za-z0-9%+._-])+[@]+([%+a-z0-9A-Z.-]*))$/ )
|
||||||
{
|
{
|
||||||
$gatewayDevs = $1;
|
$gatewayDevs = $globalDevName;
|
||||||
$deviceType = "email";
|
$deviceType = "email";
|
||||||
}
|
}
|
||||||
elsif ( $device =~ s/^@?(.*)![\s\t]*$// ) {
|
elsif ( $device =~ s/^@?(.*)![\s\t]*$// ) {
|
||||||
@ -300,6 +300,12 @@ s/^[\s\t]*\|([\w\süöäß^°!"§$%&\/\\()<>=?´`"+\[\]#*@€]+)\|[\s\t]+//
|
|||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# next type loop if device is an email address and this is not the mail type loop run
|
||||||
|
if ($deviceType eq "email" && $type[$i] ne "mail") {
|
||||||
|
Log3 $globalDevName, 5, "msg $device: Skipping loop for device type 'email' with unmatched message type '" . $type[$i] . "'";
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
|
||||||
my $typeUc = ucfirst( $type[$i] );
|
my $typeUc = ucfirst( $type[$i] );
|
||||||
my $catchall = 0;
|
my $catchall = 0;
|
||||||
my $useLocation = 0;
|
my $useLocation = 0;
|
||||||
@ -408,7 +414,7 @@ s/^[\s\t]*\|([\w\süöäß^°!"§$%&\/\\()<>=?´`"+\[\]#*@€]+)\|[\s\t]+//
|
|||||||
);
|
);
|
||||||
|
|
||||||
my $locationDev = "";
|
my $locationDev = "";
|
||||||
if ( $deviceLocation ne "" ) {
|
if ( $deviceLocation ne "" && $deviceType eq "device" ) {
|
||||||
|
|
||||||
# lookup matching location
|
# lookup matching location
|
||||||
foreach (@locationDevs) {
|
foreach (@locationDevs) {
|
||||||
@ -570,6 +576,7 @@ s/^[\s\t]*\|([\w\süöäß^°!"§$%&\/\\()<>=?´`"+\[\]#*@€]+)\|[\s\t]+//
|
|||||||
|
|
||||||
if (
|
if (
|
||||||
$gatewayDevs eq ""
|
$gatewayDevs eq ""
|
||||||
|
&& $deviceType eq "device"
|
||||||
&& $deviceType2 ne ""
|
&& $deviceType2 ne ""
|
||||||
&& (
|
&& (
|
||||||
( $type[$i] eq "audio" && defined($cmdSchema->{ $type[$i] }{$deviceType2}) ) ||
|
( $type[$i] eq "audio" && defined($cmdSchema->{ $type[$i] }{$deviceType2}) ) ||
|
||||||
@ -782,6 +789,9 @@ s/^[\s\t]*\|([\w\süöäß^°!"§$%&\/\\()<>=?´`"+\[\]#*@€]+)\|[\s\t]+//
|
|||||||
$routes{text} = 1;
|
$routes{text} = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$routes{mail} = 1
|
||||||
|
if ($deviceType eq "email");
|
||||||
|
|
||||||
Log3 $logDevice, 4,
|
Log3 $logDevice, 4,
|
||||||
"msg $device: Available routes: screen="
|
"msg $device: Available routes: screen="
|
||||||
. $routes{screen}
|
. $routes{screen}
|
||||||
@ -989,7 +999,7 @@ s/^[\s\t]*\|([\w\süöäß^°!"§$%&\/\\()<>=?´`"+\[\]#*@€]+)\|[\s\t]+//
|
|||||||
# FATAL ERROR: we could not find any targets at all
|
# FATAL ERROR: we could not find any targets at all
|
||||||
elsif ( $gatewayDevs eq "" ) {
|
elsif ( $gatewayDevs eq "" ) {
|
||||||
$return .=
|
$return .=
|
||||||
"ERROR: No global $typeUc contact defined. Please specify a destination device or set global attributes: msgContact$typeUc | msgRecipient$typeUc | msgRecipient\n";
|
"ERROR: Could not find any general $typeUc contact. Please specify a destination device or set attributes in general msg configuration device $globalDevName : msgContact$typeUc | msgRecipient$typeUc | msgRecipient\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
#####################
|
#####################
|
||||||
@ -1835,7 +1845,8 @@ s/^[\s\t]*\|([\w\süöäß^°!"§$%&\/\\()<>=?´`"+\[\]#*@€]+)\|[\s\t]+//
|
|||||||
|
|
||||||
$msgSent = 1 if ($error == 0);
|
$msgSent = 1 if ($error == 0);
|
||||||
$msgSentDev = 1 if ($error == 0);
|
$msgSentDev = 1 if ($error == 0);
|
||||||
$gatewaysStatus{$gatewayDev} = $routeStatus;
|
$gatewaysStatus{$gatewayDev} = $routeStatus if ($globalDevName ne $gatewayDev);
|
||||||
|
$gatewaysStatus{$device} = $routeStatus if ($globalDevName eq $gatewayDev);
|
||||||
}
|
}
|
||||||
elsif ($routeStatus eq "UNAVAILABLE"
|
elsif ($routeStatus eq "UNAVAILABLE"
|
||||||
|| $routeStatus eq "UNDEFINED" )
|
|| $routeStatus eq "UNDEFINED" )
|
||||||
@ -1844,7 +1855,8 @@ s/^[\s\t]*\|([\w\süöäß^°!"§$%&\/\\()<>=?´`"+\[\]#*@€]+)\|[\s\t]+//
|
|||||||
"msg $device: ID=$msgID.$sentCounter TYPE=$type[$i] ROUTE=$gatewayDev RECIPIENT=$subRecipient STATUS=$routeStatus PRIORITY=$loopPriority TITLE='$loopTitle' '$msg'" if ($subRecipient ne "");
|
"msg $device: ID=$msgID.$sentCounter TYPE=$type[$i] ROUTE=$gatewayDev RECIPIENT=$subRecipient STATUS=$routeStatus PRIORITY=$loopPriority TITLE='$loopTitle' '$msg'" if ($subRecipient ne "");
|
||||||
Log3 $logDevice, 3,
|
Log3 $logDevice, 3,
|
||||||
"msg $device: ID=$msgID.$sentCounter TYPE=$type[$i] ROUTE=$gatewayDev STATUS=$routeStatus PRIORITY=$loopPriority TITLE='$loopTitle' '$msg'" if ($subRecipient eq "");
|
"msg $device: ID=$msgID.$sentCounter TYPE=$type[$i] ROUTE=$gatewayDev STATUS=$routeStatus PRIORITY=$loopPriority TITLE='$loopTitle' '$msg'" if ($subRecipient eq "");
|
||||||
$gatewaysStatus{$gatewayDev} = $routeStatus;
|
$gatewaysStatus{$gatewayDev} = $routeStatus if ($globalDevName ne $gatewayDev);
|
||||||
|
$gatewaysStatus{$device} = $routeStatus if ($globalDevName eq $gatewayDev);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Log3 $logDevice, 3,
|
Log3 $logDevice, 3,
|
||||||
@ -1853,7 +1865,8 @@ s/^[\s\t]*\|([\w\süöäß^°!"§$%&\/\\()<>=?´`"+\[\]#*@€]+)\|[\s\t]+//
|
|||||||
"msg $device: ID=$msgID.$sentCounter TYPE=$type[$i] ROUTE=$gatewayDev STATUS=$routeStatus PRIORITY=$loopPriority TITLE='$loopTitle' '$msg'" if ($subRecipient eq "");
|
"msg $device: ID=$msgID.$sentCounter TYPE=$type[$i] ROUTE=$gatewayDev STATUS=$routeStatus PRIORITY=$loopPriority TITLE='$loopTitle' '$msg'" if ($subRecipient eq "");
|
||||||
$msgSent = 2 if ( $msgSent != 1 );
|
$msgSent = 2 if ( $msgSent != 1 );
|
||||||
$msgSentDev = 2 if ( $msgSentDev != 1 );
|
$msgSentDev = 2 if ( $msgSentDev != 1 );
|
||||||
$gatewaysStatus{$gatewayDev} = $routeStatus;
|
$gatewaysStatus{$gatewayDev} = $routeStatus if ($globalDevName ne $gatewayDev);
|
||||||
|
$gatewaysStatus{$device} = $routeStatus if ($globalDevName eq $gatewayDev);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -1886,7 +1899,7 @@ s/^[\s\t]*\|([\w\süöäß^°!"§$%&\/\\()<>=?´`"+\[\]#*@€]+)\|[\s\t]+//
|
|||||||
|
|
||||||
# update device readings
|
# update device readings
|
||||||
my $readingsDev = $defs{$device};
|
my $readingsDev = $defs{$device};
|
||||||
$readingsDev = $defs{$globalDevName} if ( $catchall == 1 );
|
$readingsDev = $defs{$globalDevName} if ( $catchall == 1 || $deviceType eq "email" );
|
||||||
readingsBeginUpdate($readingsDev);
|
readingsBeginUpdate($readingsDev);
|
||||||
|
|
||||||
readingsBulkUpdate( $readingsDev, "fhemMsg" . $typeUc,
|
readingsBulkUpdate( $readingsDev, "fhemMsg" . $typeUc,
|
||||||
@ -1897,11 +1910,12 @@ s/^[\s\t]*\|([\w\süöäß^°!"§$%&\/\\()<>=?´`"+\[\]#*@€]+)\|[\s\t]+//
|
|||||||
"fhemMsg" . $typeUc . "Prio",
|
"fhemMsg" . $typeUc . "Prio",
|
||||||
$loopPriority );
|
$loopPriority );
|
||||||
|
|
||||||
my $gwStates = "";
|
my $gwStates = "-";
|
||||||
|
|
||||||
while ( ( my $gwName, my $gwState ) = each %gatewaysStatus )
|
while ( ( my $gwName, my $gwState ) = each %gatewaysStatus )
|
||||||
{
|
{
|
||||||
$gwStates .= " " if $gwStates ne "";
|
$gwStates = "" if $gwStates eq "-";
|
||||||
|
$gwStates .= " " if $gwStates ne "-";
|
||||||
$gwStates .= "$gwName:$gwState";
|
$gwStates .= "$gwName:$gwState";
|
||||||
}
|
}
|
||||||
readingsBulkUpdate( $readingsDev,
|
readingsBulkUpdate( $readingsDev,
|
||||||
@ -2143,6 +2157,8 @@ my $fw_residentGone = defined($settings->{ $type[$i] }{typeEscalation}{residentG
|
|||||||
|
|
||||||
# finalize device readings
|
# finalize device readings
|
||||||
while ( ( my $device, my $types ) = each %sentTypesPerDevice ) {
|
while ( ( my $device, my $types ) = each %sentTypesPerDevice ) {
|
||||||
|
$device = $globalDevName if ( $device =~ /^(([A-Za-z0-9%+._-])+[@]+([%+a-z0-9A-Z.-]*))$/ );
|
||||||
|
|
||||||
readingsBulkUpdate( $defs{$device}, "fhemMsgStateTypes", $types )
|
readingsBulkUpdate( $defs{$device}, "fhemMsgStateTypes", $types )
|
||||||
if ( $forwarded eq "" );
|
if ( $forwarded eq "" );
|
||||||
readingsBulkUpdate( $defs{$device}, "fhemMsgStateTypes",
|
readingsBulkUpdate( $defs{$device}, "fhemMsgStateTypes",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user