75_MSG,msgSchema: move default title to msgSchema and remove default title for modules without explicit title support

git-svn-id: https://svn.fhem.de/fhem/trunk@10393 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
jpawlowski 2016-01-07 01:21:48 +00:00
parent 4a5306d13c
commit 58e4aa5b68
2 changed files with 864 additions and 675 deletions

View File

@ -62,15 +62,16 @@ sub CommandMsg($$;$$) {
my $globalDevName = "globalMsg"; 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 {
fhem "define $globalDevName msgConfig"; fhem "define $globalDevName msgConfig";
$return .= "Global configuration device $globalDevName was created.\n\n"; $return .=
"Global configuration device $globalDevName was created.\n\n";
} }
if ( $msg eq "" || $msg =~ /^\?[\s\t]*$/ || $msg eq "help" ) { if ( $msg eq "" || $msg =~ /^\?[\s\t]*$/ || $msg eq "help" ) {
return return $return
$return . . "Usage: msg [<type>] [<\@device>|<e-mail address>] [<priority>] [|<title>|] <message>";
"Usage: msg [<type>] [<\@device>|<e-mail address>] [<priority>] [|<title>|] <message>";
} }
# default settings # default settings
@ -83,7 +84,6 @@ $return .
'residentGone' => 'text', 'residentGone' => 'text',
'residentAbsent' => 'text', 'residentAbsent' => 'text',
}, },
'title' => 'Announcement',
}, },
'light' => { 'light' => {
@ -93,11 +93,6 @@ $return .
'residentGone' => 'audio', 'residentGone' => 'audio',
'residentAbsent' => 'audio', 'residentAbsent' => 'audio',
}, },
'title' => 'Announcement',
},
'mail' => {
'title' => 'System Message',
}, },
'push' => { 'push' => {
@ -105,7 +100,6 @@ $return .
'gwUnavailable' => 'mail', 'gwUnavailable' => 'mail',
'emergency' => 'mail', 'emergency' => 'mail',
}, },
'title' => 'System Message',
}, },
'screen' => { 'screen' => {
@ -115,7 +109,6 @@ $return .
'residentGone' => 'light', 'residentGone' => 'light',
'residentAbsent' => 'light', 'residentAbsent' => 'light',
}, },
'title' => 'Info',
}, },
}; };
@ -161,15 +154,18 @@ s/^[\s\t]*\|([\w\süöäß^°!"§$%&\/\\()<>=?´`"+\[\]#*@€]+)\|[\s\t]+//
} }
# check for advanced options # check for advanced options
if ( $msg =~ s/[\s\t]*O(\[\{.*\}\])[\s\t]*$// ) if ( $msg =~ s/[\s\t]*O(\[\{.*\}\])[\s\t]*$// ) {
{
# Use JSON module if possible # Use JSON module if possible
eval 'use JSON qw( decode_json ); 1'; eval 'use JSON qw( decode_json ); 1';
if ( !$@ ) { if ( !$@ ) {
$advanced = decode_json( Encode::encode_utf8($1) ); $advanced = decode_json( Encode::encode_utf8($1) );
Log3 $globalDevName, 5, "msg: Advanced options\n" . Dumper($advanced); Log3 $globalDevName, 5,
} else { "msg: Advanced options\n" . Dumper($advanced);
Log3 $globalDevName, 3, "msg: To use advanced options, please install Perl::JSON."; }
else {
Log3 $globalDevName, 3,
"msg: To use advanced options, please install Perl::JSON.";
} }
} }
@ -251,7 +247,8 @@ s/^[\s\t]*\|([\w\süöäß^°!"§$%&\/\\()<>=?´`"+\[\]#*@€]+)\|[\s\t]+//
my @recipient = split( /,/, $recipientsOr[$iRecipOr] ); my @recipient = split( /,/, $recipientsOr[$iRecipOr] );
foreach my $device (@recipient) { foreach my $device (@recipient) {
Log3 $globalDevName, 5, "msg: running loop for device $device" Log3 $globalDevName, 5,
"msg: running loop for device $device"
if ( $testMode ne "1" ); if ( $testMode ne "1" );
my $msgSentDev = 0; my $msgSentDev = 0;
@ -286,7 +283,8 @@ s/^[\s\t]*\|([\w\süöäß^°!"§$%&\/\\()<>=?´`"+\[\]#*@€]+)\|[\s\t]+//
&& $deviceType eq "device" ) && $deviceType eq "device" )
{ {
$return .= "Device $device does not exist\n"; $return .= "Device $device does not exist\n";
Log3 $globalDevName, 5, "msg $device: Device does not exist" Log3 $globalDevName, 5,
"msg $device: Device does not exist"
if ( $testMode ne "1" ); if ( $testMode ne "1" );
my $regex1 = my $regex1 =
@ -308,8 +306,13 @@ s/^[\s\t]*\|([\w\süöäß^°!"§$%&\/\\()<>=?´`"+\[\]#*@€]+)\|[\s\t]+//
} }
# next type loop if device is an email address and this is not the mail type loop run # 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" && $type[$i] ne "text") { if ( $deviceType eq "email"
Log3 $globalDevName, 5, "msg $device: Skipping loop for device type 'email' with unmatched message type '" . $type[$i] . "'"; && $type[$i] ne "mail"
&& $type[$i] ne "text" )
{
Log3 $globalDevName, 5,
"msg $device: Skipping loop for device type 'email' with unmatched message type '"
. $type[$i] . "'";
next; next;
} }
@ -373,14 +376,16 @@ s/^[\s\t]*\|([\w\süöäß^°!"§$%&\/\\()<>=?´`"+\[\]#*@€]+)\|[\s\t]+//
AttrVal( AttrVal(
AttrVal( AttrVal(
$globalDevName, $globalDevName,
"msgRecipient$typeUc", "" "msgRecipient$typeUc",
""
), ),
"msgLocationDevs", "msgLocationDevs",
# look for global indirect general # look for global indirect general
AttrVal( AttrVal(
AttrVal( AttrVal(
$globalDevName, "msgRecipient", $globalDevName,
"msgRecipient",
"" ""
), ),
"msgLocationDevs", "msgLocationDevs",
@ -421,7 +426,8 @@ s/^[\s\t]*\|([\w\süöäß^°!"§$%&\/\\()<>=?´`"+\[\]#*@€]+)\|[\s\t]+//
); );
my $locationDev = ""; my $locationDev = "";
if ( $deviceLocation ne "" && $deviceType eq "device" ) { if ( $deviceLocation ne "" && $deviceType eq "device" )
{
# lookup matching location # lookup matching location
foreach (@locationDevs) { foreach (@locationDevs) {
@ -476,8 +482,7 @@ s/^[\s\t]*\|([\w\süöäß^°!"§$%&\/\\()<>=?´`"+\[\]#*@€]+)\|[\s\t]+//
$gatewayDevOr ) $gatewayDevOr )
{ {
my $tmpSubRecipient; my $tmpSubRecipient;
if ( $gatewayDev =~ s/:(.*)//) if ( $gatewayDev =~ s/:(.*)// ) {
{
$tmpSubRecipient = $1; $tmpSubRecipient = $1;
} }
@ -579,22 +584,44 @@ s/^[\s\t]*\|([\w\süöäß^°!"§$%&\/\\()<>=?´`"+\[\]#*@€]+)\|[\s\t]+//
### given device name is already a gateway device itself ### given device name is already a gateway device itself
### ###
my $deviceType2 = defined($defs{$device}) ? $defs{$device}{TYPE} : ""; my $deviceType2 =
defined( $defs{$device} ) ? $defs{$device}{TYPE} : "";
if ( if (
$gatewayDevs eq "" $gatewayDevs eq ""
&& $deviceType eq "device" && $deviceType eq "device"
&& $deviceType2 ne "" && $deviceType2 ne ""
&& ( && (
( $type[$i] eq "audio" && defined($cmdSchema->{ $type[$i] }{$deviceType2}) ) || (
( $type[$i] eq "light" && defined($cmdSchema->{ $type[$i] }{$deviceType2}) ) || $type[$i] eq "audio" && defined(
( $type[$i] eq "push" && defined($cmdSchema->{ $type[$i] }{$deviceType2}) ) || $cmdSchema->{ $type[$i] }{$deviceType2}
( $type[$i] eq "screen" && defined($cmdSchema->{ $type[$i] }{$deviceType2}) ) )
)
|| (
$type[$i] eq "light"
&& defined(
$cmdSchema->{ $type[$i] }{$deviceType2}
)
)
|| (
$type[$i] eq "push"
&& defined(
$cmdSchema->{ $type[$i] }{$deviceType2}
)
)
|| (
$type[$i] eq "screen"
&& defined(
$cmdSchema->{ $type[$i] }{$deviceType2}
)
)
) )
) )
{ {
Log3 $logDevice, 4, Log3 $logDevice, 4,
"msg $device: Recipient type $deviceType2 is a gateway device itself for message type ".$type[$i].". Still checking for any delegates ..." "msg $device: Recipient type $deviceType2 is a gateway device itself for message type "
. $type[$i]
. ". Still checking for any delegates ..."
if ( $testMode ne "1" ); if ( $testMode ne "1" );
$gatewayDevs = $gatewayDevs =
@ -669,13 +696,17 @@ s/^[\s\t]*\|([\w\süöäß^°!"§$%&\/\\()<>=?´`"+\[\]#*@€]+)\|[\s\t]+//
#look for indirect #look for indirect
AttrVal( AttrVal(
AttrVal( AttrVal(
$globalDevName, "msgRecipient$typeUc", "" $globalDevName, "msgRecipient$typeUc",
""
), ),
"msgContact$typeUc", "msgContact$typeUc",
#look for indirect general #look for indirect general
AttrVal( AttrVal(
AttrVal( $globalDevName, "msgRecipient", "" ), AttrVal(
$globalDevName, "msgRecipient",
""
),
"msgContact$typeUc", "msgContact$typeUc",
# no contact found # no contact found
@ -711,7 +742,8 @@ s/^[\s\t]*\|([\w\süöäß^°!"§$%&\/\\()<>=?´`"+\[\]#*@€]+)\|[\s\t]+//
#look for global indirect #look for global indirect
AttrVal( AttrVal(
AttrVal( AttrVal(
$globalDevName, "msgRecipient$typeUc", $globalDevName,
"msgRecipient$typeUc",
"" ""
), ),
"msgPriority$typeUc", "msgPriority$typeUc",
@ -719,7 +751,8 @@ s/^[\s\t]*\|([\w\süöäß^°!"§$%&\/\\()<>=?´`"+\[\]#*@€]+)\|[\s\t]+//
#look for global indirect general #look for global indirect general
AttrVal( AttrVal(
AttrVal( AttrVal(
$globalDevName, "msgRecipient", $globalDevName,
"msgRecipient",
"" ""
), ),
"msgPriority$typeUc", "msgPriority$typeUc",
@ -822,6 +855,7 @@ s/^[\s\t]*\|([\w\süöäß^°!"§$%&\/\\()<>=?´`"+\[\]#*@€]+)\|[\s\t]+//
# user selected emergency priority text threshold # user selected emergency priority text threshold
my $prioThresTextEmg = my $prioThresTextEmg =
# look for direct # look for direct
AttrVal( AttrVal(
$device, "msgThPrioTextEmergency", $device, "msgThPrioTextEmergency",
@ -838,20 +872,23 @@ s/^[\s\t]*\|([\w\süöäß^°!"§$%&\/\\()<>=?´`"+\[\]#*@€]+)\|[\s\t]+//
# look for global direct # look for global direct
AttrVal( AttrVal(
$globalDevName, "msgThPrioTextEmergency", $globalDevName,
"msgThPrioTextEmergency",
#look for global indirect type #look for global indirect type
AttrVal( AttrVal(
AttrVal( AttrVal(
$globalDevName, $globalDevName,
"msgRecipient$typeUc", "" "msgRecipient$typeUc",
""
), ),
"msgThPrioTextEmergency", "msgThPrioTextEmergency",
#look for global indirect general #look for global indirect general
AttrVal( AttrVal(
AttrVal( AttrVal(
$globalDevName, "msgRecipient", $globalDevName,
"msgRecipient",
"" ""
), ),
"msgThPrioTextEmergency", "msgThPrioTextEmergency",
@ -863,11 +900,11 @@ s/^[\s\t]*\|([\w\süöäß^°!"§$%&\/\\()<>=?´`"+\[\]#*@€]+)\|[\s\t]+//
) )
) )
) )
) );
;
# user selected low priority text threshold # user selected low priority text threshold
my $prioThresTextNormal = my $prioThresTextNormal =
# look for direct # look for direct
AttrVal( AttrVal(
$device, "msgThPrioTextNormal", $device, "msgThPrioTextNormal",
@ -890,14 +927,16 @@ s/^[\s\t]*\|([\w\süöäß^°!"§$%&\/\\()<>=?´`"+\[\]#*@€]+)\|[\s\t]+//
AttrVal( AttrVal(
AttrVal( AttrVal(
$globalDevName, $globalDevName,
"msgRecipient$typeUc", "" "msgRecipient$typeUc",
""
), ),
"msgThPrioTextNormal", "msgThPrioTextNormal",
#look for global indirect general #look for global indirect general
AttrVal( AttrVal(
AttrVal( AttrVal(
$globalDevName, "msgRecipient", $globalDevName,
"msgRecipient",
"" ""
), ),
"msgThPrioTextNormal", "msgThPrioTextNormal",
@ -909,8 +948,7 @@ s/^[\s\t]*\|([\w\süöäß^°!"§$%&\/\\()<>=?´`"+\[\]#*@€]+)\|[\s\t]+//
) )
) )
) )
) );
;
# Decide push and/or e-mail destination based on priorities # Decide push and/or e-mail destination based on priorities
if ( $loopPriority >= $prioThresTextEmg if ( $loopPriority >= $prioThresTextEmg
@ -947,7 +985,9 @@ s/^[\s\t]*\|([\w\süöäß^°!"§$%&\/\\()<>=?´`"+\[\]#*@€]+)\|[\s\t]+//
$forwarded .= "text>mail"; $forwarded .= "text>mail";
push @type, "mail" if !( "mail" ~~ @type ); push @type, "mail" if !( "mail" ~~ @type );
} }
elsif ( $loopPriority >= $prioThresTextNormal && $routes{push} == 1 ) { elsif ($loopPriority >= $prioThresTextNormal
&& $routes{push} == 1 )
{
Log3 $logDevice, 4, Log3 $logDevice, 4,
"msg $device: Text routing decision: push(4)"; "msg $device: Text routing decision: push(4)";
$forwarded .= "," $forwarded .= ","
@ -955,7 +995,9 @@ s/^[\s\t]*\|([\w\süöäß^°!"§$%&\/\\()<>=?´`"+\[\]#*@€]+)\|[\s\t]+//
$forwarded .= "text>push"; $forwarded .= "text>push";
push @type, "push" if !( "push" ~~ @type ); push @type, "push" if !( "push" ~~ @type );
} }
elsif ( $loopPriority >= $prioThresTextNormal && $routes{mail} == 1 ) { elsif ($loopPriority >= $prioThresTextNormal
&& $routes{mail} == 1 )
{
Log3 $logDevice, 4, Log3 $logDevice, 4,
"msg $device: Text routing decision: mail(5)"; "msg $device: Text routing decision: mail(5)";
$forwarded .= "," $forwarded .= ","
@ -1049,14 +1091,16 @@ s/^[\s\t]*\|([\w\süöäß^°!"§$%&\/\\()<>=?´`"+\[\]#*@€]+)\|[\s\t]+//
AttrVal( AttrVal(
AttrVal( AttrVal(
$globalDevName, $globalDevName,
"msgRecipient$typeUc", "" "msgRecipient$typeUc",
""
), ),
"msgSwitcherDev", "msgSwitcherDev",
#look for global indirect general #look for global indirect general
AttrVal( AttrVal(
AttrVal( AttrVal(
$globalDevName, "msgRecipient", $globalDevName,
"msgRecipient",
"" ""
), ),
"msgSwitcherDev", "msgSwitcherDev",
@ -1075,6 +1119,7 @@ s/^[\s\t]*\|([\w\süöäß^°!"§$%&\/\\()<>=?´`"+\[\]#*@€]+)\|[\s\t]+//
# user selected emergency priority audio threshold # user selected emergency priority audio threshold
my $prioThresAudioEmg = my $prioThresAudioEmg =
# look for direct # look for direct
AttrVal( AttrVal(
$device, "msgThPrioAudioEmergency", $device, "msgThPrioAudioEmergency",
@ -1097,14 +1142,16 @@ s/^[\s\t]*\|([\w\süöäß^°!"§$%&\/\\()<>=?´`"+\[\]#*@€]+)\|[\s\t]+//
AttrVal( AttrVal(
AttrVal( AttrVal(
$globalDevName, $globalDevName,
"msgRecipient$typeUc", "" "msgRecipient$typeUc",
""
), ),
"msgThPrioAudioEmergency", "msgThPrioAudioEmergency",
#look for global indirect general #look for global indirect general
AttrVal( AttrVal(
AttrVal( AttrVal(
$globalDevName, "msgRecipient", $globalDevName,
"msgRecipient",
"" ""
), ),
"msgThPrioAudioEmergency", "msgThPrioAudioEmergency",
@ -1116,11 +1163,11 @@ s/^[\s\t]*\|([\w\süöäß^°!"§$%&\/\\()<>=?´`"+\[\]#*@€]+)\|[\s\t]+//
) )
) )
) )
) );
;
# user selected high priority audio threshold # user selected high priority audio threshold
my $prioThresAudioHigh = my $prioThresAudioHigh =
# look for direct # look for direct
AttrVal( AttrVal(
$device, "msgThPrioAudioHigh", $device, "msgThPrioAudioHigh",
@ -1143,14 +1190,16 @@ s/^[\s\t]*\|([\w\süöäß^°!"§$%&\/\\()<>=?´`"+\[\]#*@€]+)\|[\s\t]+//
AttrVal( AttrVal(
AttrVal( AttrVal(
$globalDevName, $globalDevName,
"msgRecipient$typeUc", "" "msgRecipient$typeUc",
""
), ),
"msgThPrioAudioHigh", "msgThPrioAudioHigh",
#look for global indirect general #look for global indirect general
AttrVal( AttrVal(
AttrVal( AttrVal(
$globalDevName, "msgRecipient", $globalDevName,
"msgRecipient",
"" ""
), ),
"msgThPrioAudioHigh", "msgThPrioAudioHigh",
@ -1162,11 +1211,11 @@ s/^[\s\t]*\|([\w\süöäß^°!"§$%&\/\\()<>=?´`"+\[\]#*@€]+)\|[\s\t]+//
) )
) )
) )
) );
;
# user selected high priority threshold # user selected high priority threshold
my $prioThresHigh = my $prioThresHigh =
# look for direct # look for direct
AttrVal( AttrVal(
$device, "msgThPrioHigh", $device, "msgThPrioHigh",
@ -1189,14 +1238,16 @@ s/^[\s\t]*\|([\w\süöäß^°!"§$%&\/\\()<>=?´`"+\[\]#*@€]+)\|[\s\t]+//
AttrVal( AttrVal(
AttrVal( AttrVal(
$globalDevName, $globalDevName,
"msgRecipient$typeUc", "" "msgRecipient$typeUc",
""
), ),
"msgThPrioHigh", "msgThPrioHigh",
#look for global indirect general #look for global indirect general
AttrVal( AttrVal(
AttrVal( AttrVal(
$globalDevName, "msgRecipient", $globalDevName,
"msgRecipient",
"" ""
), ),
"msgThPrioHigh", "msgThPrioHigh",
@ -1208,11 +1259,11 @@ s/^[\s\t]*\|([\w\süöäß^°!"§$%&\/\\()<>=?´`"+\[\]#*@€]+)\|[\s\t]+//
) )
) )
) )
) );
;
# user selected normal priority threshold # user selected normal priority threshold
my $prioThresNormal = my $prioThresNormal =
# look for direct # look for direct
AttrVal( AttrVal(
$device, "msgThPrioNormal", $device, "msgThPrioNormal",
@ -1235,14 +1286,16 @@ s/^[\s\t]*\|([\w\süöäß^°!"§$%&\/\\()<>=?´`"+\[\]#*@€]+)\|[\s\t]+//
AttrVal( AttrVal(
AttrVal( AttrVal(
$globalDevName, $globalDevName,
"msgRecipient$typeUc", "" "msgRecipient$typeUc",
""
), ),
"msgThPrioNormal", "msgThPrioNormal",
#look for global indirect general #look for global indirect general
AttrVal( AttrVal(
AttrVal( AttrVal(
$globalDevName, "msgRecipient", $globalDevName,
"msgRecipient",
"" ""
), ),
"msgThPrioNormal", "msgThPrioNormal",
@ -1254,8 +1307,7 @@ s/^[\s\t]*\|([\w\süöäß^°!"§$%&\/\\()<>=?´`"+\[\]#*@€]+)\|[\s\t]+//
) )
) )
) )
) );
;
if ( $type[$i] eq "audio" ) { if ( $type[$i] eq "audio" ) {
if ( $annState eq "long" if ( $annState eq "long"
@ -1369,20 +1421,27 @@ s/^[\s\t]*\|([\w\süöäß^°!"§$%&\/\\()<>=?´`"+\[\]#*@€]+)\|[\s\t]+//
|| $residentDevPresence eq "" || $residentDevPresence eq ""
) )
&& ReadingsVal( && ReadingsVal(
AttrVal( $globalDevName, "msgRecipient$typeUc", "" ), AttrVal(
"presence", "-" ) ne "-" $globalDevName, "msgRecipient$typeUc", ""
),
"presence",
"-"
) ne "-"
) )
{ {
$residentDevState = $residentDevState = ReadingsVal(
ReadingsVal( AttrVal(
AttrVal( $globalDevName, "msgRecipient$typeUc", "" ), $globalDevName, "msgRecipient$typeUc", ""
"state", "" ) ),
if ( $residentDevState eq "" ); "state", ""
$residentDevPresence = ) if ( $residentDevState eq "" );
ReadingsVal( $residentDevPresence = ReadingsVal(
AttrVal( $globalDevName, "msgRecipient$typeUc", "" ), AttrVal(
"presence", "" ) $globalDevName, "msgRecipient$typeUc", ""
if ( $residentDevPresence eq "" ); ),
"presence",
""
) if ( $residentDevPresence eq "" );
} }
# global indirect general # global indirect general
@ -1391,16 +1450,19 @@ s/^[\s\t]*\|([\w\süöäß^°!"§$%&\/\\()<>=?´`"+\[\]#*@€]+)\|[\s\t]+//
$residentDevState eq "" $residentDevState eq ""
|| $residentDevPresence eq "" || $residentDevPresence eq ""
) )
&& ReadingsVal( AttrVal( $globalDevName, "msgRecipient", "" ), && ReadingsVal(
AttrVal( $globalDevName, "msgRecipient", "" ),
"presence", "-" ) ne "-" "presence", "-" ) ne "-"
) )
{ {
$residentDevState = $residentDevState =
ReadingsVal( AttrVal( $globalDevName, "msgRecipient", "" ), ReadingsVal(
AttrVal( $globalDevName, "msgRecipient", "" ),
"state", "" ) "state", "" )
if ( $residentDevState eq "" ); if ( $residentDevState eq "" );
$residentDevPresence = $residentDevPresence =
ReadingsVal( AttrVal( $globalDevName, "msgRecipient", "" ), ReadingsVal(
AttrVal( $globalDevName, "msgRecipient", "" ),
"presence", "" ) "presence", "" )
if ( $residentDevPresence eq "" ); if ( $residentDevPresence eq "" );
} }
@ -1434,6 +1496,7 @@ s/^[\s\t]*\|([\w\süöäß^°!"§$%&\/\\()<>=?´`"+\[\]#*@€]+)\|[\s\t]+//
# user selected emergency priority text threshold # user selected emergency priority text threshold
my $prioThresGwEmg = my $prioThresGwEmg =
# look for direct # look for direct
AttrVal( AttrVal(
$device, "msgThPrioGwEmergency", $device, "msgThPrioGwEmergency",
@ -1456,14 +1519,16 @@ s/^[\s\t]*\|([\w\süöäß^°!"§$%&\/\\()<>=?´`"+\[\]#*@€]+)\|[\s\t]+//
AttrVal( AttrVal(
AttrVal( AttrVal(
$globalDevName, $globalDevName,
"msgRecipient$typeUc", "" "msgRecipient$typeUc",
""
), ),
"msgThPrioGwEmergency", "msgThPrioGwEmergency",
#look for global indirect general #look for global indirect general
AttrVal( AttrVal(
AttrVal( AttrVal(
$globalDevName, "msgRecipient", $globalDevName,
"msgRecipient",
"" ""
), ),
"msgThPrioGwEmergency", "msgThPrioGwEmergency",
@ -1475,16 +1540,14 @@ s/^[\s\t]*\|([\w\süöäß^°!"§$%&\/\\()<>=?´`"+\[\]#*@€]+)\|[\s\t]+//
) )
) )
) )
) );
;
my %gatewaysStatus; my %gatewaysStatus;
foreach my $gatewayDevOr ( split /\|/, $gatewayDevs ) { foreach my $gatewayDevOr ( split /\|/, $gatewayDevs ) {
foreach my $gatewayDev ( split /,/, $gatewayDevOr ) { foreach my $gatewayDev ( split /,/, $gatewayDevOr ) {
if ( $gatewayDev =~ s/:(.*)//) if ( $gatewayDev =~ s/:(.*)// ) {
{
$subRecipient = $1 if ( $subRecipient eq "" ); $subRecipient = $1 if ( $subRecipient eq "" );
} }
@ -1511,50 +1574,30 @@ s/^[\s\t]*\|([\w\süöäß^°!"§$%&\/\\()<>=?´`"+\[\]#*@€]+)\|[\s\t]+//
elsif ( elsif (
$type[$i] ne "mail" $type[$i] ne "mail"
&& ( && (
ReadingsVal( ReadingsVal( $gatewayDev, "power", "on" )
$gatewayDev, "power", eq "off"
"on" || ReadingsVal( $gatewayDev, "presence",
) eq "off" "present" ) eq "absent"
|| ReadingsVal( $gatewayDev, "presence",
"appeared" ) eq "disappeared"
|| ReadingsVal( $gatewayDev, "state",
"present" ) eq "absent"
|| ReadingsVal( $gatewayDev, "state",
"connected" ) eq "unauthorized"
|| ReadingsVal( $gatewayDev, "state",
"connected" ) eq "disconnected"
|| ReadingsVal( $gatewayDev, "state",
"reachable" ) eq "unreachable"
|| ReadingsVal( || ReadingsVal(
$gatewayDev, "presence", $gatewayDev, "available", "1"
"present"
) eq "absent"
|| ReadingsVal(
$gatewayDev, "presence",
"appeared"
) eq "disappeared"
|| ReadingsVal(
$gatewayDev, "state",
"present"
) eq "absent"
|| ReadingsVal(
$gatewayDev, "state",
"connected"
) eq "unauthorized"
|| ReadingsVal(
$gatewayDev, "state",
"connected"
) eq "disconnected"
|| ReadingsVal(
$gatewayDev, "state",
"reachable"
) eq "unreachable"
|| ReadingsVal(
$gatewayDev, "available",
"1"
) eq "0" ) eq "0"
|| ReadingsVal( $gatewayDev, "available",
"yes" ) eq "no"
|| ReadingsVal( || ReadingsVal(
$gatewayDev, "available", $gatewayDev, "reachable", "1"
"yes"
) eq "no"
|| ReadingsVal(
$gatewayDev, "reachable",
"1"
) eq "0" ) eq "0"
|| ReadingsVal( || ReadingsVal( $gatewayDev, "reachable",
$gatewayDev, "reachable", "yes" ) eq "no"
"yes"
) eq "no"
) )
) )
@ -1618,18 +1661,39 @@ s/^[\s\t]*\|([\w\süöäß^°!"§$%&\/\\()<>=?´`"+\[\]#*@€]+)\|[\s\t]+//
$routeStatus .= "+LOCATION"; $routeStatus .= "+LOCATION";
} }
my $gatewayType =
$type[$i] eq "mail"
? "fhemMsgMail"
: $defs{$gatewayDev}{TYPE};
my $gatewayType = $type[$i] eq "mail" ? "fhemMsgMail" : $defs{$gatewayDev}{TYPE}; my $defTitle;
$defTitle =
$cmdSchema->{ $type[$i] }{$gatewayType}
{defaultValues}{$priorityCat}{TITLE}
if (
defined(
$cmdSchema->{ $type[$i] }{$gatewayType}
{defaultValues}{$priorityCat}{TITLE}
)
&& $priorityCat ne ""
);
$defTitle =
$cmdSchema->{ $type[$i] }{$gatewayType}
{defaultValues}{Normal}{TITLE}
if (
defined(
$cmdSchema->{ $type[$i] }{$gatewayType}
{defaultValues}{Normal}{TITLE}
)
&& $priorityCat eq ""
);
my $defTitle = defined($settings->{ $type[$i] }{title}) ? $settings->{ $type[$i] }{title} : "System Message"; Log3 $logDevice, 5,
$defTitle = $cmdSchema->{ $type[$i] }{$gatewayType}{defaultValues}{$priorityCat}{TITLE} "msg $device: Determined default title: $defTitle";
if ( defined($cmdSchema->{ $type[$i] }{$gatewayType}{defaultValues}{$priorityCat}{TITLE}) && $priorityCat ne "" );
$defTitle = $cmdSchema->{ $type[$i] }{$gatewayType}{defaultValues}{Normal}{TITLE}
if ( defined($cmdSchema->{ $type[$i] }{$gatewayType}{defaultValues}{Normal}{TITLE}) && $priorityCat eq "" );
# use title from device, global or internal default # use title from device, global or internal default
my $loopTitle; my $loopTitle;
$loopTitle = $title if ( $title ne "-" ); $loopTitle = $title;
$loopTitle = $loopTitle =
# look for direct high # look for direct high
@ -1638,7 +1702,9 @@ s/^[\s\t]*\|([\w\süöäß^°!"§$%&\/\\()<>=?´`"+\[\]#*@€]+)\|[\s\t]+//
# look for indirect high # look for indirect high
AttrVal( AttrVal(
AttrVal( $device, "msgRecipient$typeUc", "" ), AttrVal(
$device, "msgRecipient$typeUc", ""
),
"msgTitle$typeUc$priorityCat", "msgTitle$typeUc$priorityCat",
#look for indirect general high #look for indirect general high
@ -1648,12 +1714,14 @@ s/^[\s\t]*\|([\w\süöäß^°!"§$%&\/\\()<>=?´`"+\[\]#*@€]+)\|[\s\t]+//
# look for global direct high # look for global direct high
AttrVal( AttrVal(
$globalDevName, "msgTitle$typeUc$priorityCat", $globalDevName,
"msgTitle$typeUc$priorityCat",
# look for global indirect high # look for global indirect high
AttrVal( AttrVal(
AttrVal( AttrVal(
$globalDevName, "msgRecipient$typeUc", $globalDevName,
"msgRecipient$typeUc",
"" ""
), ),
"msgTitle$typeUc$priorityCat", "msgTitle$typeUc$priorityCat",
@ -1661,7 +1729,8 @@ s/^[\s\t]*\|([\w\süöäß^°!"§$%&\/\\()<>=?´`"+\[\]#*@€]+)\|[\s\t]+//
#look for global indirect general high #look for global indirect general high
AttrVal( AttrVal(
AttrVal( AttrVal(
$globalDevName, "msgRecipient", $globalDevName,
"msgRecipient",
"" ""
), ),
"msgTitle$typeUc$priorityCat", "msgTitle$typeUc$priorityCat",
@ -1674,16 +1743,23 @@ s/^[\s\t]*\|([\w\süöäß^°!"§$%&\/\\()<>=?´`"+\[\]#*@€]+)\|[\s\t]+//
) )
) )
) if ( $title eq "-" ); ) if ( $title eq "-" );
$loopTitle = undef
if ( $loopTitle eq ""
|| $loopTitle eq "none"
|| $loopTitle eq "-" );
my $loopMsg = $msg; my $loopMsg = $msg;
if ( $catchall == 1 ) { if ( $catchall == 1 ) {
$loopTitle = "Fw: $loopTitle"; $loopTitle = "Fw: $loopTitle" if ($loopTitle);
$loopMsg = "Forwarded Message: $loopMsg"
if ( !$loopTitle );
if ( $type[$i] eq "mail" ) { if ( $type[$i] eq "mail" ) {
$loopMsg .= $loopMsg .=
"\n\n-- \nMail catched from device $device"; "\n\n-- \nMail catched from device $device";
} }
else { else {
$loopMsg .= " ### (Catched from device $device)"; $loopMsg .=
" ### (Catched from device $device)";
} }
} }
@ -1691,15 +1767,30 @@ s/^[\s\t]*\|([\w\süöäß^°!"§$%&\/\\()<>=?´`"+\[\]#*@€]+)\|[\s\t]+//
# #
$loopMsg =~ s/\n/<br \/>/gi; $loopMsg =~ s/\n/<br \/>/gi;
$loopMsg =~ s/((|(\d+)| )\|\w+\|( |))/\n\n/gi $loopMsg =~ s/((|(\d+)| )\|\w+\|( |))/\n\n/gi
if ( $type[$i] ne "audio" ); # Remove Sonos Speak commands if ( $type[$i] ne "audio" )
; # Remove Sonos Speak commands
# use command from device, global or internal default # use command from device, global or internal default
my $defCmd = ""; my $defCmd = "";
$defCmd = $cmdSchema->{ $type[$i] }{$gatewayType}{$priorityCat} $defCmd =
if ( defined($cmdSchema->{ $type[$i] }{$gatewayType}{$priorityCat}) && $priorityCat ne "" ); $cmdSchema->{ $type[$i] }{$gatewayType}
$defCmd = $cmdSchema->{ $type[$i] }{$gatewayType}{Normal} {$priorityCat}
if ( defined($cmdSchema->{ $type[$i] }{$gatewayType}{Normal}) && $priorityCat eq "" ); if (
defined(
$cmdSchema->{ $type[$i] }{$gatewayType}
{$priorityCat}
)
&& $priorityCat ne ""
);
$defCmd =
$cmdSchema->{ $type[$i] }{$gatewayType}{Normal}
if (
defined(
$cmdSchema->{ $type[$i] }{$gatewayType}
{Normal}
)
&& $priorityCat eq ""
);
my $cmd = my $cmd =
# gateway device # gateway device
@ -1759,17 +1850,20 @@ s/^[\s\t]*\|([\w\süöäß^°!"§$%&\/\\()<>=?´`"+\[\]#*@€]+)\|[\s\t]+//
); );
if ( $cmd eq "" ) { if ( $cmd eq "" ) {
Log3 $logDevice, 4, "$gatewayDev: Unknown command schema for gateway device type $gatewayType. Use manual definition by userattr msgCmd*"; Log3 $logDevice, 4,
$return .= "$gatewayDev: Unknown command schema for gateway device type $gatewayType. Use manual definition by userattr msgCmd*\n"; "$gatewayDev: Unknown command schema for gateway device type $gatewayType. Use manual definition by userattr msgCmd*";
$return .=
"$gatewayDev: Unknown command schema for gateway device type $gatewayType. Use manual definition by userattr msgCmd*\n";
next; next;
} }
$cmd =~ s/%DEVICE%/$gatewayDev/gi; $cmd =~ s/%DEVICE%/$gatewayDev/gi;
$cmd =~ s/%PRIORITY%/$loopPriority/gi; $cmd =~ s/%PRIORITY%/$loopPriority/gi;
$cmd =~ s/%TITLE%/$loopTitle/gi; $cmd =~ s/%TITLE%/$loopTitle/gi if ($loopTitle);
$cmd =~ s/%MSG%/$loopMsg/gi; $cmd =~ s/%MSG%/$loopMsg/gi;
$cmd =~ s/%RECIPIENT%/$subRecipient/gi if ($subRecipient ne ""); $cmd =~ s/%RECIPIENT%/$subRecipient/gi
if ( $subRecipient ne "" );
# advanced options from message # advanced options from message
if ( ref($advanced) eq "ARRAY" ) { if ( ref($advanced) eq "ARRAY" ) {
@ -1782,9 +1876,19 @@ s/^[\s\t]*\|([\w\süöäß^°!"§$%&\/\\()<>=?´`"+\[\]#*@€]+)\|[\s\t]+//
} }
# advanced options from command schema hash # advanced options from command schema hash
if ($priorityCat ne "" && defined( $cmdSchema->{ $type[$i] }{$gatewayType}{defaultValues}{$priorityCat} )) { if (
$priorityCat ne ""
&& defined(
$cmdSchema->{ $type[$i] }{$gatewayType}
{defaultValues}{$priorityCat}
)
)
{
for my $item ($cmdSchema->{ $type[$i] }{$gatewayType}{defaultValues}{$priorityCat}) { for my $item (
$cmdSchema->{ $type[$i] }{$gatewayType}
{defaultValues}{$priorityCat} )
{
for my $key ( keys(%$item) ) { for my $key ( keys(%$item) ) {
my $val = $item->{$key}; my $val = $item->{$key};
$cmd =~ s/%$key%/$val/gi; $cmd =~ s/%$key%/$val/gi;
@ -1792,9 +1896,19 @@ s/^[\s\t]*\|([\w\süöäß^°!"§$%&\/\\()<>=?´`"+\[\]#*@€]+)\|[\s\t]+//
} }
} }
elsif ($priorityCat eq "" && defined( $cmdSchema->{ $type[$i] }{$gatewayType}{defaultValues}{Normal} )) { elsif (
$priorityCat eq ""
&& defined(
$cmdSchema->{ $type[$i] }{$gatewayType}
{defaultValues}{Normal}
)
)
{
for my $item ($cmdSchema->{ $type[$i] }{$gatewayType}{defaultValues}{Normal}) { for my $item (
$cmdSchema->{ $type[$i] }{$gatewayType}
{defaultValues}{Normal} )
{
for my $key ( keys(%$item) ) { for my $key ( keys(%$item) ) {
my $val = $item->{$key}; my $val = $item->{$key};
$cmd =~ s/%$key%/$val/gi; $cmd =~ s/%$key%/$val/gi;
@ -1834,46 +1948,65 @@ s/^[\s\t]*\|([\w\süöäß^°!"§$%&\/\\()<>=?´`"+\[\]#*@€]+)\|[\s\t]+//
Log3 $logDevice, 3, Log3 $logDevice, 3,
"msg $device: ID=$msgID.$sentCounter TYPE=$type[$i] ROUTE=$gatewayDev RECIPIENT=$subRecipient STATUS=$routeStatus PRIORITY=$loopPriority($priorityCat) TITLE='$loopTitle' MSG='$msg'" "msg $device: ID=$msgID.$sentCounter TYPE=$type[$i] ROUTE=$gatewayDev RECIPIENT=$subRecipient STATUS=$routeStatus PRIORITY=$loopPriority($priorityCat) TITLE='$loopTitle' MSG='$msg'"
if ( $priorityCat ne "" && $subRecipient ne ""); if ( $priorityCat ne ""
&& $subRecipient ne "" );
Log3 $logDevice, 3, Log3 $logDevice, 3,
"msg $device: ID=$msgID.$sentCounter TYPE=$type[$i] ROUTE=$gatewayDev RECIPIENT=$subRecipient STATUS=$routeStatus PRIORITY=$loopPriority TITLE='$loopTitle' MSG='$msg'" "msg $device: ID=$msgID.$sentCounter TYPE=$type[$i] ROUTE=$gatewayDev RECIPIENT=$subRecipient STATUS=$routeStatus PRIORITY=$loopPriority TITLE='$loopTitle' MSG='$msg'"
if ( $priorityCat eq "" && $subRecipient ne ""); if ( $priorityCat eq ""
&& $subRecipient ne "" );
Log3 $logDevice, 3, Log3 $logDevice, 3,
"msg $device: ID=$msgID.$sentCounter TYPE=$type[$i] ROUTE=$gatewayDev STATUS=$routeStatus PRIORITY=$loopPriority($priorityCat) TITLE='$loopTitle' MSG='$msg'" "msg $device: ID=$msgID.$sentCounter TYPE=$type[$i] ROUTE=$gatewayDev STATUS=$routeStatus PRIORITY=$loopPriority($priorityCat) TITLE='$loopTitle' MSG='$msg'"
if ( $priorityCat ne "" && $subRecipient eq ""); if ( $priorityCat ne ""
&& $subRecipient eq "" );
Log3 $logDevice, 3, Log3 $logDevice, 3,
"msg $device: ID=$msgID.$sentCounter TYPE=$type[$i] ROUTE=$gatewayDev STATUS=$routeStatus PRIORITY=$loopPriority TITLE='$loopTitle' MSG='$msg'" "msg $device: ID=$msgID.$sentCounter TYPE=$type[$i] ROUTE=$gatewayDev STATUS=$routeStatus PRIORITY=$loopPriority TITLE='$loopTitle' MSG='$msg'"
if ( $priorityCat eq "" && $subRecipient eq ""); if ( $priorityCat eq ""
&& $subRecipient eq "" );
$msgSent = 1 if ( $error == 0 ); $msgSent = 1 if ( $error == 0 );
$msgSentDev = 1 if ( $error == 0 ); $msgSentDev = 1 if ( $error == 0 );
if ( $subRecipient ne "" ) { if ( $subRecipient ne "" ) {
$gatewaysStatus{"$gatewayDev:$subRecipient"} = $routeStatus if ($globalDevName ne $gatewayDev); $gatewaysStatus{"$gatewayDev:$subRecipient"}
$gatewaysStatus{"$device:$subRecipient"} = $routeStatus if ($globalDevName eq $gatewayDev); = $routeStatus
} else { if ( $globalDevName ne $gatewayDev );
$gatewaysStatus{$gatewayDev} = $routeStatus if ($globalDevName ne $gatewayDev); $gatewaysStatus{"$device:$subRecipient"} =
$gatewaysStatus{$device} = $routeStatus if ($globalDevName eq $gatewayDev); $routeStatus
if ( $globalDevName eq $gatewayDev );
}
else {
$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" )
{ {
Log3 $logDevice, 3, Log3 $logDevice, 3,
"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'"
$gatewaysStatus{$gatewayDev} = $routeStatus if ($globalDevName ne $gatewayDev); if ( $subRecipient eq "" );
$gatewaysStatus{$device} = $routeStatus if ($globalDevName eq $gatewayDev); $gatewaysStatus{$gatewayDev} = $routeStatus
if ( $globalDevName ne $gatewayDev );
$gatewaysStatus{$device} = $routeStatus
if ( $globalDevName eq $gatewayDev );
} }
else { else {
Log3 $logDevice, 3, Log3 $logDevice, 3,
"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 "" );
$msgSent = 2 if ( $msgSent != 1 ); $msgSent = 2 if ( $msgSent != 1 );
$msgSentDev = 2 if ( $msgSentDev != 1 ); $msgSentDev = 2 if ( $msgSentDev != 1 );
$gatewaysStatus{$gatewayDev} = $routeStatus if ($globalDevName ne $gatewayDev); $gatewaysStatus{$gatewayDev} = $routeStatus
$gatewaysStatus{$device} = $routeStatus if ($globalDevName eq $gatewayDev); if ( $globalDevName ne $gatewayDev );
$gatewaysStatus{$device} = $routeStatus
if ( $globalDevName eq $gatewayDev );
} }
} }
@ -1906,7 +2039,8 @@ 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 || $deviceType eq "email" ); $readingsDev = $defs{$globalDevName}
if ( $catchall == 1 || $deviceType eq "email" );
readingsBeginUpdate($readingsDev); readingsBeginUpdate($readingsDev);
readingsBulkUpdate( $readingsDev, "fhemMsg" . $typeUc, readingsBulkUpdate( $readingsDev, "fhemMsg" . $typeUc,
@ -1928,8 +2062,7 @@ s/^[\s\t]*\|([\w\süöäß^°!"§$%&\/\\()<>=?´`"+\[\]#*@€]+)\|[\s\t]+//
readingsBulkUpdate( $readingsDev, readingsBulkUpdate( $readingsDev,
"fhemMsg" . $typeUc . "Gw", $gwStates ); "fhemMsg" . $typeUc . "Gw", $gwStates );
readingsBulkUpdate( $readingsDev, readingsBulkUpdate( $readingsDev,
"fhemMsg" . $typeUc . "State", "fhemMsg" . $typeUc . "State", $msgSentDev );
$msgSentDev );
################################################################ ################################################################
### Implicit forwards based on priority or presence ### Implicit forwards based on priority or presence
@ -2068,10 +2201,28 @@ s/^[\s\t]*\|([\w\süöäß^°!"§$%&\/\\()<>=?´`"+\[\]#*@€]+)\|[\s\t]+//
if ( $residentDevPresence ne "" if ( $residentDevPresence ne ""
|| $residentDevState ne "" ); || $residentDevState ne "" );
my $fw_gwUnavailable = defined($settings->{ $type[$i] }{typeEscalation}{gwUnavailable}) ? $settings->{ $type[$i] }{typeEscalation}{gwUnavailable} : ""; my $fw_gwUnavailable =
my $fw_emergency = defined($settings->{ $type[$i] }{typeEscalation}{emergency}) ? $settings->{ $type[$i] }{typeEscalation}{emergency} : ""; defined(
my $fw_residentAbsent = defined($settings->{ $type[$i] }{typeEscalation}{residentAbsent}) ? $settings->{ $type[$i] }{typeEscalation}{residentAbsent} : ""; $settings->{ $type[$i] }{typeEscalation}{gwUnavailable}
my $fw_residentGone = defined($settings->{ $type[$i] }{typeEscalation}{residentGone}) ? $settings->{ $type[$i] }{typeEscalation}{residentGone} : ""; )
? $settings->{ $type[$i] }{typeEscalation}{gwUnavailable}
: "";
my $fw_emergency =
defined(
$settings->{ $type[$i] }{typeEscalation}{emergency} )
? $settings->{ $type[$i] }{typeEscalation}{emergency}
: "";
my $fw_residentAbsent =
defined(
$settings->{ $type[$i] }{typeEscalation}{residentAbsent}
)
? $settings->{ $type[$i] }{typeEscalation}{residentAbsent}
: "";
my $fw_residentGone =
defined(
$settings->{ $type[$i] }{typeEscalation}{residentGone} )
? $settings->{ $type[$i] }{typeEscalation}{residentGone}
: "";
# Forward message # Forward message
# if no gateway device for this type was available # if no gateway device for this type was available
@ -2164,7 +2315,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.-]*))$/ ); $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 "" );

View File

@ -56,33 +56,42 @@ my $db = {
'ShortPrio' => 'set %DEVICE% talk |%TITLE%| %MSGSH%', 'ShortPrio' => 'set %DEVICE% talk |%TITLE%| %MSGSH%',
'Short' => 'set %DEVICE% talk |%TITLE%| %MSGSH%', 'Short' => 'set %DEVICE% talk |%TITLE%| %MSGSH%',
'defaultValues' => { 'defaultValues' => {
'Normal' => {
'TITLE' => 'Announcement',
},
'ShortPrio' => { 'ShortPrio' => {
'MSGSH' => 'Achtung!', 'MSGSH' => 'Achtung!',
'TITLE' => 'Announcement',
}, },
'Short' => { 'Short' => {
'MSGSH' => '', 'MSGSH' => '',
'TITLE' => 'Announcement',
}, },
}, },
}, },
'SONOSPLAYER' => { 'SONOSPLAYER' => {
'Normal' => 'set %DEVICE% Speak %VOLUME% %LANG% |%TITLE%| %MSG%', 'Normal' => 'set %DEVICE% Speak %VOLUME% %LANG% |%TITLE%| %MSG%',
'ShortPrio' => 'set %DEVICE% Speak %VOLUME% %LANG% |%TITLE%| %MSGSH%', 'ShortPrio' =>
'set %DEVICE% Speak %VOLUME% %LANG% |%TITLE%| %MSGSH%',
'Short' => 'set %DEVICE% Speak %VOLUME% %LANG% |%TITLE%| %MSGSH%', 'Short' => 'set %DEVICE% Speak %VOLUME% %LANG% |%TITLE%| %MSGSH%',
'defaultValues' => { 'defaultValues' => {
'Normal' => { 'Normal' => {
'VOLUME' => 38, 'VOLUME' => 38,
'LANG' => 'de', 'LANG' => 'de',
'TITLE' => 'Announcement',
}, },
'ShortPrio' => { 'ShortPrio' => {
'VOLUME' => 33, 'VOLUME' => 33,
'LANG' => 'de', 'LANG' => 'de',
'MSGSH' => 'Achtung!', 'MSGSH' => 'Achtung!',
'TITLE' => 'Announcement',
}, },
'Short' => { 'Short' => {
'VOLUME' => 28, 'VOLUME' => 28,
'LANG' => 'de', 'LANG' => 'de',
'MSGSH' => '', 'MSGSH' => '',
'TITLE' => 'Announcement',
}, },
}, },
}, },
@ -106,8 +115,10 @@ my $db = {
'light' => { 'light' => {
'HUEDevice' => { 'HUEDevice' => {
'Normal' => '{ my $dev=\'%DEVICE%\'; my $state=ReadingsVal($dev,"state","off"); fhem "set $dev blink 2 1"; fhem "sleep 4.25; set $dev:FILTER=state!=$state $state"; }', 'Normal' =>
'High' => '{ my $dev=\'%DEVICE%\'; my $state=ReadingsVal($dev,"state","off"); fhem "set $dev blink 10 1"; fhem "sleep 20.25; set $dev:FILTER=state!=$state $state"; }', '{ my $dev=\'%DEVICE%\'; my $state=ReadingsVal($dev,"state","off"); fhem "set $dev blink 2 1"; fhem "sleep 4.25; set $dev:FILTER=state!=$state $state"; }',
'High' =>
'{ my $dev=\'%DEVICE%\'; my $state=ReadingsVal($dev,"state","off"); fhem "set $dev blink 10 1"; fhem "sleep 20.25; set $dev:FILTER=state!=$state $state"; }',
'Low' => 'set %DEVICE% alert select', 'Low' => 'set %DEVICE% alert select',
}, },
@ -116,19 +127,33 @@ my $db = {
'mail' => { 'mail' => {
'fhemMsgMail' => { 'fhemMsgMail' => {
'Normal' => '{ my $dev=\'%DEVICE%\'; my $title=\'%TITLE%\'; my $msg=\'%MSG%\'; system("echo \'$msg\' | /usr/bin/mail -s \'$title\' \'$dev\'"); }', 'Normal' =>
'High' => '{ my $dev=\'%DEVICE%\'; my $title=\'%TITLE%\'; my $msg=\'%MSG%\'; system("echo \'$msg\' | /usr/bin/mail -s \'$title\' \'$dev\'"); }', '{ my $dev=\'%DEVICE%\'; my $title=\'%TITLE%\'; my $msg=\'%MSG%\'; system("echo \'$msg\' | /usr/bin/mail -s \'$title\' \'$dev\'"); }',
'Low' => '{ my $dev=\'%DEVICE%\'; my $title=\'%TITLE%\'; my $msg=\'%MSG%\'; system("echo \'$msg\' | /usr/bin/mail -s \'$title\' \'$dev\'"); }', 'High' =>
'{ my $dev=\'%DEVICE%\'; my $title=\'%TITLE%\'; my $msg=\'%MSG%\'; system("echo \'$msg\' | /usr/bin/mail -s \'$title\' \'$dev\'"); }',
'Low' =>
'{ my $dev=\'%DEVICE%\'; my $title=\'%TITLE%\'; my $msg=\'%MSG%\'; system("echo \'$msg\' | /usr/bin/mail -s \'$title\' \'$dev\'"); }',
'defaultValues' => {
'Normal' => {
'TITLE' => 'System Message',
},
'High' => {
'TITLE' => 'System Message',
},
'Low' => {
'TITLE' => 'System Message',
},
}, },
}, },
},
'push' => { 'push' => {
'Fhemapppush' => { 'Fhemapppush' => {
'Normal' => 'set %DEVICE% message \'%TITLE%: %MSG%\' %ACTION%', 'Normal' => 'set %DEVICE% message \'%MSG%\' %ACTION%',
'High' => 'set %DEVICE% message \'%TITLE%: %MSG%\' %ACTION%', 'High' => 'set %DEVICE% message \'%MSG%\' %ACTION%',
'Low' => 'set %DEVICE% message \'%TITLE%: %MSG%\' %ACTION%', 'Low' => 'set %DEVICE% message \'%MSG%\' %ACTION%',
'defaultValues' => { 'defaultValues' => {
'Normal' => { 'Normal' => {
'ACTION' => '', 'ACTION' => '',
@ -143,9 +168,9 @@ my $db = {
}, },
'Jabber' => { 'Jabber' => {
'Normal' => 'set %DEVICE% msg %RECIPIENT% %TITLE%: %MSG%', 'Normal' => 'set %DEVICE% msg %RECIPIENT% %MSG%',
'High' => 'set %DEVICE% msg %RECIPIENT% %TITLE%: %MSG%', 'High' => 'set %DEVICE% msg %RECIPIENT% %MSG%',
'Low' => 'set %DEVICE% msg %RECIPIENT% %TITLE%: %MSG%', 'Low' => 'set %DEVICE% msg %RECIPIENT% %MSG%',
}, },
'Pushbullet' => { 'Pushbullet' => {
@ -155,26 +180,32 @@ my $db = {
'defaultValues' => { 'defaultValues' => {
'Normal' => { 'Normal' => {
'RECIPIENT' => '', 'RECIPIENT' => '',
'TITLE' => '',
}, },
'High' => { 'High' => {
'RECIPIENT' => '', 'RECIPIENT' => '',
'TITLE' => '',
}, },
'Low' => { 'Low' => {
'RECIPIENT' => '', 'RECIPIENT' => '',
'TITLE' => '',
}, },
}, },
}, },
'PushNotifier' => { 'PushNotifier' => {
'Normal' => 'set %DEVICE% message %TITLE%: %MSG%', 'Normal' => 'set %DEVICE% message %MSG%',
'High' => 'set %DEVICE% message %TITLE%: %MSG%', 'High' => 'set %DEVICE% message %MSG%',
'Low' => 'set %DEVICE% message %TITLE%: %MSG%', 'Low' => 'set %DEVICE% message %MSG%',
}, },
'Pushover' => { 'Pushover' => {
'Normal' => 'set %DEVICE% msg \'%TITLE%\' \'%MSG%\' \'%RECIPIENT%\' %PRIORITY% \'%Pushover_SOUND%\' %RETRY% %EXPIRE% %URLTITLE% %ACTION%', 'Normal' =>
'High' => 'set %DEVICE% msg \'%TITLE%\' \'%MSG%\' \'%RECIPIENT%\' %PRIORITY% \'%Pushover_SOUND%\' %RETRY% %EXPIRE% %URLTITLE% %ACTION%', 'set %DEVICE% msg \'%TITLE%\' \'%MSG%\' \'%RECIPIENT%\' %PRIORITY% \'%Pushover_SOUND%\' %RETRY% %EXPIRE% %URLTITLE% %ACTION%',
'Low' => 'set %DEVICE% msg \'%TITLE%\' \'%MSG%\' \'%RECIPIENT%\' %PRIORITY% \'%Pushover_SOUND%\' %RETRY% %EXPIRE% %URLTITLE% %ACTION%', 'High' =>
'set %DEVICE% msg \'%TITLE%\' \'%MSG%\' \'%RECIPIENT%\' %PRIORITY% \'%Pushover_SOUND%\' %RETRY% %EXPIRE% %URLTITLE% %ACTION%',
'Low' =>
'set %DEVICE% msg \'%TITLE%\' \'%MSG%\' \'%RECIPIENT%\' %PRIORITY% \'%Pushover_SOUND%\' %RETRY% %EXPIRE% %URLTITLE% %ACTION%',
'defaultValues' => { 'defaultValues' => {
'Normal' => { 'Normal' => {
'RECIPIENT' => '', 'RECIPIENT' => '',
@ -182,6 +213,7 @@ my $db = {
'EXPIRE' => '', 'EXPIRE' => '',
'URLTITLE' => '', 'URLTITLE' => '',
'ACTION' => '', 'ACTION' => '',
'TITLE' => 'System Message',
'Pushover_SOUND' => '', 'Pushover_SOUND' => '',
}, },
'High' => { 'High' => {
@ -190,6 +222,7 @@ my $db = {
'EXPIRE' => '600', 'EXPIRE' => '600',
'URLTITLE' => '', 'URLTITLE' => '',
'ACTION' => '', 'ACTION' => '',
'TITLE' => 'System Message',
'Pushover_SOUND' => '', 'Pushover_SOUND' => '',
}, },
'Low' => { 'Low' => {
@ -198,15 +231,16 @@ my $db = {
'EXPIRE' => '', 'EXPIRE' => '',
'URLTITLE' => '', 'URLTITLE' => '',
'ACTION' => '', 'ACTION' => '',
'TITLE' => 'System Message',
'Pushover_SOUND' => '', 'Pushover_SOUND' => '',
}, },
}, },
}, },
'TelegramBot' => { 'TelegramBot' => {
'Normal' => 'set %DEVICE% message %RECIPIENT% %TITLE%: %MSG%', 'Normal' => 'set %DEVICE% message %RECIPIENT% %MSG%',
'High' => 'set %DEVICE% message %RECIPIENT% %TITLE%: %MSG%', 'High' => 'set %DEVICE% message %RECIPIENT% %MSG%',
'Low' => 'set %DEVICE% message %RECIPIENT% %TITLE%: %MSG%', 'Low' => 'set %DEVICE% message %RECIPIENT% %MSG%',
'defaultValues' => { 'defaultValues' => {
'Normal' => { 'Normal' => {
'RECIPIENT' => '', 'RECIPIENT' => '',
@ -221,9 +255,9 @@ my $db = {
}, },
'yowsup' => { 'yowsup' => {
'Normal' => 'set %DEVICE% send %RECIPIENT% %TITLE%: %MSG%', 'Normal' => 'set %DEVICE% send %RECIPIENT% %MSG%',
'High' => 'set %DEVICE% send %RECIPIENT% %TITLE%: %MSG%', 'High' => 'set %DEVICE% send %RECIPIENT% %MSG%',
'Low' => 'set %DEVICE% send %RECIPIENT% %TITLE%: %MSG%', 'Low' => 'set %DEVICE% send %RECIPIENT% %MSG%',
}, },
}, },
@ -231,9 +265,9 @@ my $db = {
'screen' => { 'screen' => {
'AMAD' => { 'AMAD' => {
'Normal' => 'set %DEVICE% screenMsg %TITLE%: %MSG%', 'Normal' => 'set %DEVICE% screenMsg %MSG%',
'High' => 'set %DEVICE% screenMsg %TITLE%: %MSG%', 'High' => 'set %DEVICE% screenMsg %MSG%',
'Low' => 'set %DEVICE% screenMsg %TITLE%: %MSG%', 'Low' => 'set %DEVICE% screenMsg %MSG%',
}, },
'ENIGMA2' => { 'ENIGMA2' => {
@ -257,9 +291,12 @@ my $db = {
}, },
'XBMC' => { 'XBMC' => {
'Normal' => '{ my $dev=\'%DEVICE%\'; my $title=\'%TITLE%\'; my $msg=\'%MSG%\'; $timeout=%TIMEOUT%*1000; fhem "set $dev msg $msg $timeout %XBMC_ICON%"; }', 'Normal' =>
'High' => '{ my $dev=\'%DEVICE%\'; my $title=\'%TITLE%\'; my $msg=\'%MSG%\'; $timeout=%TIMEOUT%*1000; fhem "set $dev msg $msg $timeout %XBMC_ICON%"; }', '{ my $dev=\'%DEVICE%\'; my $msg=\'%MSG%\'; $timeout=%TIMEOUT%*1000; fhem "set $dev msg $msg $timeout %XBMC_ICON%"; }',
'Low' => '{ my $dev=\'%DEVICE%\'; my $title=\'%TITLE%\'; my $msg=\'%MSG%\'; $timeout=%TIMEOUT%*1000; fhem "set $dev msg $msg $timeout %XBMC_ICON%"; }', 'High' =>
'{ my $dev=\'%DEVICE%\'; my $msg=\'%MSG%\'; $timeout=%TIMEOUT%*1000; fhem "set $dev msg $msg $timeout %XBMC_ICON%"; }',
'Low' =>
'{ my $dev=\'%DEVICE%\'; my $msg=\'%MSG%\'; $timeout=%TIMEOUT%*1000; fhem "set $dev msg $msg $timeout %XBMC_ICON%"; }',
'defaultValues' => { 'defaultValues' => {
'Normal' => { 'Normal' => {
'TIMEOUT' => 8, 'TIMEOUT' => 8,