mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-05-04 22:19:38 +00:00
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:
parent
4a5306d13c
commit
58e4aa5b68
@ -62,15 +62,16 @@ sub CommandMsg($$;$$) {
|
||||
my $globalDevName = "globalMsg";
|
||||
if ( defined( $modules{msgConfig}{defptr} ) ) {
|
||||
$globalDevName = $modules{msgConfig}{defptr}{NAME};
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
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" ) {
|
||||
return
|
||||
$return .
|
||||
"Usage: msg [<type>] [<\@device>|<e-mail address>] [<priority>] [|<title>|] <message>";
|
||||
return $return
|
||||
. "Usage: msg [<type>] [<\@device>|<e-mail address>] [<priority>] [|<title>|] <message>";
|
||||
}
|
||||
|
||||
# default settings
|
||||
@ -83,7 +84,6 @@ $return .
|
||||
'residentGone' => 'text',
|
||||
'residentAbsent' => 'text',
|
||||
},
|
||||
'title' => 'Announcement',
|
||||
},
|
||||
|
||||
'light' => {
|
||||
@ -93,11 +93,6 @@ $return .
|
||||
'residentGone' => 'audio',
|
||||
'residentAbsent' => 'audio',
|
||||
},
|
||||
'title' => 'Announcement',
|
||||
},
|
||||
|
||||
'mail' => {
|
||||
'title' => 'System Message',
|
||||
},
|
||||
|
||||
'push' => {
|
||||
@ -105,7 +100,6 @@ $return .
|
||||
'gwUnavailable' => 'mail',
|
||||
'emergency' => 'mail',
|
||||
},
|
||||
'title' => 'System Message',
|
||||
},
|
||||
|
||||
'screen' => {
|
||||
@ -115,7 +109,6 @@ $return .
|
||||
'residentGone' => 'light',
|
||||
'residentAbsent' => 'light',
|
||||
},
|
||||
'title' => 'Info',
|
||||
},
|
||||
};
|
||||
|
||||
@ -161,15 +154,18 @@ s/^[\s\t]*\|([\w\süöäß^°!"§$%&\/\\()<>=?´`"+\[\]#*@€]+)\|[\s\t]+//
|
||||
}
|
||||
|
||||
# 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
|
||||
eval 'use JSON qw( decode_json ); 1';
|
||||
if ( !$@ ) {
|
||||
$advanced = decode_json( Encode::encode_utf8($1) );
|
||||
Log3 $globalDevName, 5, "msg: Advanced options\n" . Dumper($advanced);
|
||||
} else {
|
||||
Log3 $globalDevName, 3, "msg: To use advanced options, please install Perl::JSON.";
|
||||
Log3 $globalDevName, 5,
|
||||
"msg: Advanced options\n" . Dumper($advanced);
|
||||
}
|
||||
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] );
|
||||
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" );
|
||||
|
||||
my $msgSentDev = 0;
|
||||
@ -286,7 +283,8 @@ s/^[\s\t]*\|([\w\süöäß^°!"§$%&\/\\()<>=?´`"+\[\]#*@€]+)\|[\s\t]+//
|
||||
&& $deviceType eq "device" )
|
||||
{
|
||||
$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" );
|
||||
|
||||
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
|
||||
if ($deviceType eq "email" && $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] . "'";
|
||||
if ( $deviceType eq "email"
|
||||
&& $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;
|
||||
}
|
||||
|
||||
@ -373,14 +376,16 @@ s/^[\s\t]*\|([\w\süöäß^°!"§$%&\/\\()<>=?´`"+\[\]#*@€]+)\|[\s\t]+//
|
||||
AttrVal(
|
||||
AttrVal(
|
||||
$globalDevName,
|
||||
"msgRecipient$typeUc", ""
|
||||
"msgRecipient$typeUc",
|
||||
""
|
||||
),
|
||||
"msgLocationDevs",
|
||||
|
||||
# look for global indirect general
|
||||
AttrVal(
|
||||
AttrVal(
|
||||
$globalDevName, "msgRecipient",
|
||||
$globalDevName,
|
||||
"msgRecipient",
|
||||
""
|
||||
),
|
||||
"msgLocationDevs",
|
||||
@ -421,7 +426,8 @@ s/^[\s\t]*\|([\w\süöäß^°!"§$%&\/\\()<>=?´`"+\[\]#*@€]+)\|[\s\t]+//
|
||||
);
|
||||
|
||||
my $locationDev = "";
|
||||
if ( $deviceLocation ne "" && $deviceType eq "device" ) {
|
||||
if ( $deviceLocation ne "" && $deviceType eq "device" )
|
||||
{
|
||||
|
||||
# lookup matching location
|
||||
foreach (@locationDevs) {
|
||||
@ -476,8 +482,7 @@ s/^[\s\t]*\|([\w\süöäß^°!"§$%&\/\\()<>=?´`"+\[\]#*@€]+)\|[\s\t]+//
|
||||
$gatewayDevOr )
|
||||
{
|
||||
my $tmpSubRecipient;
|
||||
if ( $gatewayDev =~ s/:(.*)//)
|
||||
{
|
||||
if ( $gatewayDev =~ s/:(.*)// ) {
|
||||
$tmpSubRecipient = $1;
|
||||
}
|
||||
|
||||
@ -579,22 +584,44 @@ s/^[\s\t]*\|([\w\süöäß^°!"§$%&\/\\()<>=?´`"+\[\]#*@€]+)\|[\s\t]+//
|
||||
### 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 (
|
||||
$gatewayDevs eq ""
|
||||
&& $deviceType eq "device"
|
||||
&& $deviceType2 ne ""
|
||||
&& (
|
||||
( $type[$i] eq "audio" && 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}) )
|
||||
(
|
||||
$type[$i] eq "audio" && 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,
|
||||
"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" );
|
||||
|
||||
$gatewayDevs =
|
||||
@ -669,13 +696,17 @@ s/^[\s\t]*\|([\w\süöäß^°!"§$%&\/\\()<>=?´`"+\[\]#*@€]+)\|[\s\t]+//
|
||||
#look for indirect
|
||||
AttrVal(
|
||||
AttrVal(
|
||||
$globalDevName, "msgRecipient$typeUc", ""
|
||||
$globalDevName, "msgRecipient$typeUc",
|
||||
""
|
||||
),
|
||||
"msgContact$typeUc",
|
||||
|
||||
#look for indirect general
|
||||
AttrVal(
|
||||
AttrVal( $globalDevName, "msgRecipient", "" ),
|
||||
AttrVal(
|
||||
$globalDevName, "msgRecipient",
|
||||
""
|
||||
),
|
||||
"msgContact$typeUc",
|
||||
|
||||
# no contact found
|
||||
@ -711,7 +742,8 @@ s/^[\s\t]*\|([\w\süöäß^°!"§$%&\/\\()<>=?´`"+\[\]#*@€]+)\|[\s\t]+//
|
||||
#look for global indirect
|
||||
AttrVal(
|
||||
AttrVal(
|
||||
$globalDevName, "msgRecipient$typeUc",
|
||||
$globalDevName,
|
||||
"msgRecipient$typeUc",
|
||||
""
|
||||
),
|
||||
"msgPriority$typeUc",
|
||||
@ -719,7 +751,8 @@ s/^[\s\t]*\|([\w\süöäß^°!"§$%&\/\\()<>=?´`"+\[\]#*@€]+)\|[\s\t]+//
|
||||
#look for global indirect general
|
||||
AttrVal(
|
||||
AttrVal(
|
||||
$globalDevName, "msgRecipient",
|
||||
$globalDevName,
|
||||
"msgRecipient",
|
||||
""
|
||||
),
|
||||
"msgPriority$typeUc",
|
||||
@ -822,6 +855,7 @@ s/^[\s\t]*\|([\w\süöäß^°!"§$%&\/\\()<>=?´`"+\[\]#*@€]+)\|[\s\t]+//
|
||||
|
||||
# user selected emergency priority text threshold
|
||||
my $prioThresTextEmg =
|
||||
|
||||
# look for direct
|
||||
AttrVal(
|
||||
$device, "msgThPrioTextEmergency",
|
||||
@ -838,20 +872,23 @@ s/^[\s\t]*\|([\w\süöäß^°!"§$%&\/\\()<>=?´`"+\[\]#*@€]+)\|[\s\t]+//
|
||||
|
||||
# look for global direct
|
||||
AttrVal(
|
||||
$globalDevName, "msgThPrioTextEmergency",
|
||||
$globalDevName,
|
||||
"msgThPrioTextEmergency",
|
||||
|
||||
#look for global indirect type
|
||||
AttrVal(
|
||||
AttrVal(
|
||||
$globalDevName,
|
||||
"msgRecipient$typeUc", ""
|
||||
"msgRecipient$typeUc",
|
||||
""
|
||||
),
|
||||
"msgThPrioTextEmergency",
|
||||
|
||||
#look for global indirect general
|
||||
AttrVal(
|
||||
AttrVal(
|
||||
$globalDevName, "msgRecipient",
|
||||
$globalDevName,
|
||||
"msgRecipient",
|
||||
""
|
||||
),
|
||||
"msgThPrioTextEmergency",
|
||||
@ -863,11 +900,11 @@ s/^[\s\t]*\|([\w\süöäß^°!"§$%&\/\\()<>=?´`"+\[\]#*@€]+)\|[\s\t]+//
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
;
|
||||
);
|
||||
|
||||
# user selected low priority text threshold
|
||||
my $prioThresTextNormal =
|
||||
|
||||
# look for direct
|
||||
AttrVal(
|
||||
$device, "msgThPrioTextNormal",
|
||||
@ -890,14 +927,16 @@ s/^[\s\t]*\|([\w\süöäß^°!"§$%&\/\\()<>=?´`"+\[\]#*@€]+)\|[\s\t]+//
|
||||
AttrVal(
|
||||
AttrVal(
|
||||
$globalDevName,
|
||||
"msgRecipient$typeUc", ""
|
||||
"msgRecipient$typeUc",
|
||||
""
|
||||
),
|
||||
"msgThPrioTextNormal",
|
||||
|
||||
#look for global indirect general
|
||||
AttrVal(
|
||||
AttrVal(
|
||||
$globalDevName, "msgRecipient",
|
||||
$globalDevName,
|
||||
"msgRecipient",
|
||||
""
|
||||
),
|
||||
"msgThPrioTextNormal",
|
||||
@ -909,8 +948,7 @@ s/^[\s\t]*\|([\w\süöäß^°!"§$%&\/\\()<>=?´`"+\[\]#*@€]+)\|[\s\t]+//
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
;
|
||||
);
|
||||
|
||||
# Decide push and/or e-mail destination based on priorities
|
||||
if ( $loopPriority >= $prioThresTextEmg
|
||||
@ -947,7 +985,9 @@ s/^[\s\t]*\|([\w\süöäß^°!"§$%&\/\\()<>=?´`"+\[\]#*@€]+)\|[\s\t]+//
|
||||
$forwarded .= "text>mail";
|
||||
push @type, "mail" if !( "mail" ~~ @type );
|
||||
}
|
||||
elsif ( $loopPriority >= $prioThresTextNormal && $routes{push} == 1 ) {
|
||||
elsif ($loopPriority >= $prioThresTextNormal
|
||||
&& $routes{push} == 1 )
|
||||
{
|
||||
Log3 $logDevice, 4,
|
||||
"msg $device: Text routing decision: push(4)";
|
||||
$forwarded .= ","
|
||||
@ -955,7 +995,9 @@ s/^[\s\t]*\|([\w\süöäß^°!"§$%&\/\\()<>=?´`"+\[\]#*@€]+)\|[\s\t]+//
|
||||
$forwarded .= "text>push";
|
||||
push @type, "push" if !( "push" ~~ @type );
|
||||
}
|
||||
elsif ( $loopPriority >= $prioThresTextNormal && $routes{mail} == 1 ) {
|
||||
elsif ($loopPriority >= $prioThresTextNormal
|
||||
&& $routes{mail} == 1 )
|
||||
{
|
||||
Log3 $logDevice, 4,
|
||||
"msg $device: Text routing decision: mail(5)";
|
||||
$forwarded .= ","
|
||||
@ -1049,14 +1091,16 @@ s/^[\s\t]*\|([\w\süöäß^°!"§$%&\/\\()<>=?´`"+\[\]#*@€]+)\|[\s\t]+//
|
||||
AttrVal(
|
||||
AttrVal(
|
||||
$globalDevName,
|
||||
"msgRecipient$typeUc", ""
|
||||
"msgRecipient$typeUc",
|
||||
""
|
||||
),
|
||||
"msgSwitcherDev",
|
||||
|
||||
#look for global indirect general
|
||||
AttrVal(
|
||||
AttrVal(
|
||||
$globalDevName, "msgRecipient",
|
||||
$globalDevName,
|
||||
"msgRecipient",
|
||||
""
|
||||
),
|
||||
"msgSwitcherDev",
|
||||
@ -1075,6 +1119,7 @@ s/^[\s\t]*\|([\w\süöäß^°!"§$%&\/\\()<>=?´`"+\[\]#*@€]+)\|[\s\t]+//
|
||||
|
||||
# user selected emergency priority audio threshold
|
||||
my $prioThresAudioEmg =
|
||||
|
||||
# look for direct
|
||||
AttrVal(
|
||||
$device, "msgThPrioAudioEmergency",
|
||||
@ -1097,14 +1142,16 @@ s/^[\s\t]*\|([\w\süöäß^°!"§$%&\/\\()<>=?´`"+\[\]#*@€]+)\|[\s\t]+//
|
||||
AttrVal(
|
||||
AttrVal(
|
||||
$globalDevName,
|
||||
"msgRecipient$typeUc", ""
|
||||
"msgRecipient$typeUc",
|
||||
""
|
||||
),
|
||||
"msgThPrioAudioEmergency",
|
||||
|
||||
#look for global indirect general
|
||||
AttrVal(
|
||||
AttrVal(
|
||||
$globalDevName, "msgRecipient",
|
||||
$globalDevName,
|
||||
"msgRecipient",
|
||||
""
|
||||
),
|
||||
"msgThPrioAudioEmergency",
|
||||
@ -1116,11 +1163,11 @@ s/^[\s\t]*\|([\w\süöäß^°!"§$%&\/\\()<>=?´`"+\[\]#*@€]+)\|[\s\t]+//
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
;
|
||||
);
|
||||
|
||||
# user selected high priority audio threshold
|
||||
my $prioThresAudioHigh =
|
||||
|
||||
# look for direct
|
||||
AttrVal(
|
||||
$device, "msgThPrioAudioHigh",
|
||||
@ -1143,14 +1190,16 @@ s/^[\s\t]*\|([\w\süöäß^°!"§$%&\/\\()<>=?´`"+\[\]#*@€]+)\|[\s\t]+//
|
||||
AttrVal(
|
||||
AttrVal(
|
||||
$globalDevName,
|
||||
"msgRecipient$typeUc", ""
|
||||
"msgRecipient$typeUc",
|
||||
""
|
||||
),
|
||||
"msgThPrioAudioHigh",
|
||||
|
||||
#look for global indirect general
|
||||
AttrVal(
|
||||
AttrVal(
|
||||
$globalDevName, "msgRecipient",
|
||||
$globalDevName,
|
||||
"msgRecipient",
|
||||
""
|
||||
),
|
||||
"msgThPrioAudioHigh",
|
||||
@ -1162,11 +1211,11 @@ s/^[\s\t]*\|([\w\süöäß^°!"§$%&\/\\()<>=?´`"+\[\]#*@€]+)\|[\s\t]+//
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
;
|
||||
);
|
||||
|
||||
# user selected high priority threshold
|
||||
my $prioThresHigh =
|
||||
|
||||
# look for direct
|
||||
AttrVal(
|
||||
$device, "msgThPrioHigh",
|
||||
@ -1189,14 +1238,16 @@ s/^[\s\t]*\|([\w\süöäß^°!"§$%&\/\\()<>=?´`"+\[\]#*@€]+)\|[\s\t]+//
|
||||
AttrVal(
|
||||
AttrVal(
|
||||
$globalDevName,
|
||||
"msgRecipient$typeUc", ""
|
||||
"msgRecipient$typeUc",
|
||||
""
|
||||
),
|
||||
"msgThPrioHigh",
|
||||
|
||||
#look for global indirect general
|
||||
AttrVal(
|
||||
AttrVal(
|
||||
$globalDevName, "msgRecipient",
|
||||
$globalDevName,
|
||||
"msgRecipient",
|
||||
""
|
||||
),
|
||||
"msgThPrioHigh",
|
||||
@ -1208,11 +1259,11 @@ s/^[\s\t]*\|([\w\süöäß^°!"§$%&\/\\()<>=?´`"+\[\]#*@€]+)\|[\s\t]+//
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
;
|
||||
);
|
||||
|
||||
# user selected normal priority threshold
|
||||
my $prioThresNormal =
|
||||
|
||||
# look for direct
|
||||
AttrVal(
|
||||
$device, "msgThPrioNormal",
|
||||
@ -1235,14 +1286,16 @@ s/^[\s\t]*\|([\w\süöäß^°!"§$%&\/\\()<>=?´`"+\[\]#*@€]+)\|[\s\t]+//
|
||||
AttrVal(
|
||||
AttrVal(
|
||||
$globalDevName,
|
||||
"msgRecipient$typeUc", ""
|
||||
"msgRecipient$typeUc",
|
||||
""
|
||||
),
|
||||
"msgThPrioNormal",
|
||||
|
||||
#look for global indirect general
|
||||
AttrVal(
|
||||
AttrVal(
|
||||
$globalDevName, "msgRecipient",
|
||||
$globalDevName,
|
||||
"msgRecipient",
|
||||
""
|
||||
),
|
||||
"msgThPrioNormal",
|
||||
@ -1254,8 +1307,7 @@ s/^[\s\t]*\|([\w\süöäß^°!"§$%&\/\\()<>=?´`"+\[\]#*@€]+)\|[\s\t]+//
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
;
|
||||
);
|
||||
|
||||
if ( $type[$i] eq "audio" ) {
|
||||
if ( $annState eq "long"
|
||||
@ -1369,20 +1421,27 @@ s/^[\s\t]*\|([\w\süöäß^°!"§$%&\/\\()<>=?´`"+\[\]#*@€]+)\|[\s\t]+//
|
||||
|| $residentDevPresence eq ""
|
||||
)
|
||||
&& ReadingsVal(
|
||||
AttrVal( $globalDevName, "msgRecipient$typeUc", "" ),
|
||||
"presence", "-" ) ne "-"
|
||||
AttrVal(
|
||||
$globalDevName, "msgRecipient$typeUc", ""
|
||||
),
|
||||
"presence",
|
||||
"-"
|
||||
) ne "-"
|
||||
)
|
||||
{
|
||||
$residentDevState =
|
||||
ReadingsVal(
|
||||
AttrVal( $globalDevName, "msgRecipient$typeUc", "" ),
|
||||
"state", "" )
|
||||
if ( $residentDevState eq "" );
|
||||
$residentDevPresence =
|
||||
ReadingsVal(
|
||||
AttrVal( $globalDevName, "msgRecipient$typeUc", "" ),
|
||||
"presence", "" )
|
||||
if ( $residentDevPresence eq "" );
|
||||
$residentDevState = ReadingsVal(
|
||||
AttrVal(
|
||||
$globalDevName, "msgRecipient$typeUc", ""
|
||||
),
|
||||
"state", ""
|
||||
) if ( $residentDevState eq "" );
|
||||
$residentDevPresence = ReadingsVal(
|
||||
AttrVal(
|
||||
$globalDevName, "msgRecipient$typeUc", ""
|
||||
),
|
||||
"presence",
|
||||
""
|
||||
) if ( $residentDevPresence eq "" );
|
||||
}
|
||||
|
||||
# global indirect general
|
||||
@ -1391,16 +1450,19 @@ s/^[\s\t]*\|([\w\süöäß^°!"§$%&\/\\()<>=?´`"+\[\]#*@€]+)\|[\s\t]+//
|
||||
$residentDevState eq ""
|
||||
|| $residentDevPresence eq ""
|
||||
)
|
||||
&& ReadingsVal( AttrVal( $globalDevName, "msgRecipient", "" ),
|
||||
&& ReadingsVal(
|
||||
AttrVal( $globalDevName, "msgRecipient", "" ),
|
||||
"presence", "-" ) ne "-"
|
||||
)
|
||||
{
|
||||
$residentDevState =
|
||||
ReadingsVal( AttrVal( $globalDevName, "msgRecipient", "" ),
|
||||
ReadingsVal(
|
||||
AttrVal( $globalDevName, "msgRecipient", "" ),
|
||||
"state", "" )
|
||||
if ( $residentDevState eq "" );
|
||||
$residentDevPresence =
|
||||
ReadingsVal( AttrVal( $globalDevName, "msgRecipient", "" ),
|
||||
ReadingsVal(
|
||||
AttrVal( $globalDevName, "msgRecipient", "" ),
|
||||
"presence", "" )
|
||||
if ( $residentDevPresence eq "" );
|
||||
}
|
||||
@ -1434,6 +1496,7 @@ s/^[\s\t]*\|([\w\süöäß^°!"§$%&\/\\()<>=?´`"+\[\]#*@€]+)\|[\s\t]+//
|
||||
|
||||
# user selected emergency priority text threshold
|
||||
my $prioThresGwEmg =
|
||||
|
||||
# look for direct
|
||||
AttrVal(
|
||||
$device, "msgThPrioGwEmergency",
|
||||
@ -1456,14 +1519,16 @@ s/^[\s\t]*\|([\w\süöäß^°!"§$%&\/\\()<>=?´`"+\[\]#*@€]+)\|[\s\t]+//
|
||||
AttrVal(
|
||||
AttrVal(
|
||||
$globalDevName,
|
||||
"msgRecipient$typeUc", ""
|
||||
"msgRecipient$typeUc",
|
||||
""
|
||||
),
|
||||
"msgThPrioGwEmergency",
|
||||
|
||||
#look for global indirect general
|
||||
AttrVal(
|
||||
AttrVal(
|
||||
$globalDevName, "msgRecipient",
|
||||
$globalDevName,
|
||||
"msgRecipient",
|
||||
""
|
||||
),
|
||||
"msgThPrioGwEmergency",
|
||||
@ -1475,16 +1540,14 @@ s/^[\s\t]*\|([\w\süöäß^°!"§$%&\/\\()<>=?´`"+\[\]#*@€]+)\|[\s\t]+//
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
;
|
||||
);
|
||||
|
||||
my %gatewaysStatus;
|
||||
|
||||
foreach my $gatewayDevOr ( split /\|/, $gatewayDevs ) {
|
||||
foreach my $gatewayDev ( split /,/, $gatewayDevOr ) {
|
||||
|
||||
if ( $gatewayDev =~ s/:(.*)//)
|
||||
{
|
||||
if ( $gatewayDev =~ s/:(.*)// ) {
|
||||
$subRecipient = $1 if ( $subRecipient eq "" );
|
||||
}
|
||||
|
||||
@ -1511,50 +1574,30 @@ s/^[\s\t]*\|([\w\süöäß^°!"§$%&\/\\()<>=?´`"+\[\]#*@€]+)\|[\s\t]+//
|
||||
elsif (
|
||||
$type[$i] ne "mail"
|
||||
&& (
|
||||
ReadingsVal(
|
||||
$gatewayDev, "power",
|
||||
"on"
|
||||
) eq "off"
|
||||
ReadingsVal( $gatewayDev, "power", "on" )
|
||||
eq "off"
|
||||
|| ReadingsVal( $gatewayDev, "presence",
|
||||
"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, "presence",
|
||||
"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"
|
||||
$gatewayDev, "available", "1"
|
||||
) eq "0"
|
||||
|| ReadingsVal( $gatewayDev, "available",
|
||||
"yes" ) eq "no"
|
||||
|| ReadingsVal(
|
||||
$gatewayDev, "available",
|
||||
"yes"
|
||||
) eq "no"
|
||||
|| ReadingsVal(
|
||||
$gatewayDev, "reachable",
|
||||
"1"
|
||||
$gatewayDev, "reachable", "1"
|
||||
) eq "0"
|
||||
|| ReadingsVal(
|
||||
$gatewayDev, "reachable",
|
||||
"yes"
|
||||
) eq "no"
|
||||
|| ReadingsVal( $gatewayDev, "reachable",
|
||||
"yes" ) eq "no"
|
||||
|
||||
)
|
||||
)
|
||||
@ -1618,18 +1661,39 @@ s/^[\s\t]*\|([\w\süöäß^°!"§$%&\/\\()<>=?´`"+\[\]#*@€]+)\|[\s\t]+//
|
||||
$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";
|
||||
$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 "" );
|
||||
Log3 $logDevice, 5,
|
||||
"msg $device: Determined default title: $defTitle";
|
||||
|
||||
# use title from device, global or internal default
|
||||
my $loopTitle;
|
||||
$loopTitle = $title if ( $title ne "-" );
|
||||
$loopTitle = $title;
|
||||
$loopTitle =
|
||||
|
||||
# look for direct high
|
||||
@ -1638,7 +1702,9 @@ s/^[\s\t]*\|([\w\süöäß^°!"§$%&\/\\()<>=?´`"+\[\]#*@€]+)\|[\s\t]+//
|
||||
|
||||
# look for indirect high
|
||||
AttrVal(
|
||||
AttrVal( $device, "msgRecipient$typeUc", "" ),
|
||||
AttrVal(
|
||||
$device, "msgRecipient$typeUc", ""
|
||||
),
|
||||
"msgTitle$typeUc$priorityCat",
|
||||
|
||||
#look for indirect general high
|
||||
@ -1648,12 +1714,14 @@ s/^[\s\t]*\|([\w\süöäß^°!"§$%&\/\\()<>=?´`"+\[\]#*@€]+)\|[\s\t]+//
|
||||
|
||||
# look for global direct high
|
||||
AttrVal(
|
||||
$globalDevName, "msgTitle$typeUc$priorityCat",
|
||||
$globalDevName,
|
||||
"msgTitle$typeUc$priorityCat",
|
||||
|
||||
# look for global indirect high
|
||||
AttrVal(
|
||||
AttrVal(
|
||||
$globalDevName, "msgRecipient$typeUc",
|
||||
$globalDevName,
|
||||
"msgRecipient$typeUc",
|
||||
""
|
||||
),
|
||||
"msgTitle$typeUc$priorityCat",
|
||||
@ -1661,7 +1729,8 @@ s/^[\s\t]*\|([\w\süöäß^°!"§$%&\/\\()<>=?´`"+\[\]#*@€]+)\|[\s\t]+//
|
||||
#look for global indirect general high
|
||||
AttrVal(
|
||||
AttrVal(
|
||||
$globalDevName, "msgRecipient",
|
||||
$globalDevName,
|
||||
"msgRecipient",
|
||||
""
|
||||
),
|
||||
"msgTitle$typeUc$priorityCat",
|
||||
@ -1674,16 +1743,23 @@ s/^[\s\t]*\|([\w\süöäß^°!"§$%&\/\\()<>=?´`"+\[\]#*@€]+)\|[\s\t]+//
|
||||
)
|
||||
)
|
||||
) if ( $title eq "-" );
|
||||
$loopTitle = undef
|
||||
if ( $loopTitle eq ""
|
||||
|| $loopTitle eq "none"
|
||||
|| $loopTitle eq "-" );
|
||||
|
||||
my $loopMsg = $msg;
|
||||
if ( $catchall == 1 ) {
|
||||
$loopTitle = "Fw: $loopTitle";
|
||||
$loopTitle = "Fw: $loopTitle" if ($loopTitle);
|
||||
$loopMsg = "Forwarded Message: $loopMsg"
|
||||
if ( !$loopTitle );
|
||||
if ( $type[$i] eq "mail" ) {
|
||||
$loopMsg .=
|
||||
"\n\n-- \nMail catched from device $device";
|
||||
}
|
||||
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/((|(\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
|
||||
my $defCmd = "";
|
||||
$defCmd = $cmdSchema->{ $type[$i] }{$gatewayType}{$priorityCat}
|
||||
if ( defined($cmdSchema->{ $type[$i] }{$gatewayType}{$priorityCat}) && $priorityCat ne "" );
|
||||
$defCmd = $cmdSchema->{ $type[$i] }{$gatewayType}{Normal}
|
||||
if ( defined($cmdSchema->{ $type[$i] }{$gatewayType}{Normal}) && $priorityCat eq "" );
|
||||
$defCmd =
|
||||
$cmdSchema->{ $type[$i] }{$gatewayType}
|
||||
{$priorityCat}
|
||||
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 =
|
||||
|
||||
# gateway device
|
||||
@ -1759,17 +1850,20 @@ s/^[\s\t]*\|([\w\süöäß^°!"§$%&\/\\()<>=?´`"+\[\]#*@€]+)\|[\s\t]+//
|
||||
);
|
||||
|
||||
if ( $cmd eq "" ) {
|
||||
Log3 $logDevice, 4, "$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";
|
||||
Log3 $logDevice, 4,
|
||||
"$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;
|
||||
}
|
||||
|
||||
$cmd =~ s/%DEVICE%/$gatewayDev/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/%RECIPIENT%/$subRecipient/gi if ($subRecipient ne "");
|
||||
$cmd =~ s/%RECIPIENT%/$subRecipient/gi
|
||||
if ( $subRecipient ne "" );
|
||||
|
||||
# advanced options from message
|
||||
if ( ref($advanced) eq "ARRAY" ) {
|
||||
@ -1782,9 +1876,19 @@ s/^[\s\t]*\|([\w\süöäß^°!"§$%&\/\\()<>=?´`"+\[\]#*@€]+)\|[\s\t]+//
|
||||
}
|
||||
|
||||
# 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) ) {
|
||||
my $val = $item->{$key};
|
||||
$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) ) {
|
||||
my $val = $item->{$key};
|
||||
$cmd =~ s/%$key%/$val/gi;
|
||||
@ -1834,46 +1948,65 @@ s/^[\s\t]*\|([\w\süöäß^°!"§$%&\/\\()<>=?´`"+\[\]#*@€]+)\|[\s\t]+//
|
||||
|
||||
Log3 $logDevice, 3,
|
||||
"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,
|
||||
"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,
|
||||
"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,
|
||||
"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 );
|
||||
$msgSentDev = 1 if ( $error == 0 );
|
||||
if ( $subRecipient ne "" ) {
|
||||
$gatewaysStatus{"$gatewayDev:$subRecipient"} = $routeStatus if ($globalDevName ne $gatewayDev);
|
||||
$gatewaysStatus{"$device:$subRecipient"} = $routeStatus if ($globalDevName eq $gatewayDev);
|
||||
} else {
|
||||
$gatewaysStatus{$gatewayDev} = $routeStatus if ($globalDevName ne $gatewayDev);
|
||||
$gatewaysStatus{$device} = $routeStatus if ($globalDevName eq $gatewayDev);
|
||||
$gatewaysStatus{"$gatewayDev:$subRecipient"}
|
||||
= $routeStatus
|
||||
if ( $globalDevName ne $gatewayDev );
|
||||
$gatewaysStatus{"$device:$subRecipient"} =
|
||||
$routeStatus
|
||||
if ( $globalDevName eq $gatewayDev );
|
||||
}
|
||||
else {
|
||||
$gatewaysStatus{$gatewayDev} = $routeStatus
|
||||
if ( $globalDevName ne $gatewayDev );
|
||||
$gatewaysStatus{$device} = $routeStatus
|
||||
if ( $globalDevName eq $gatewayDev );
|
||||
}
|
||||
}
|
||||
elsif ($routeStatus eq "UNAVAILABLE"
|
||||
|| $routeStatus eq "UNDEFINED" )
|
||||
{
|
||||
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,
|
||||
"msg $device: ID=$msgID.$sentCounter TYPE=$type[$i] ROUTE=$gatewayDev STATUS=$routeStatus PRIORITY=$loopPriority TITLE='$loopTitle' '$msg'" if ($subRecipient eq "");
|
||||
$gatewaysStatus{$gatewayDev} = $routeStatus if ($globalDevName ne $gatewayDev);
|
||||
$gatewaysStatus{$device} = $routeStatus if ($globalDevName eq $gatewayDev);
|
||||
"msg $device: ID=$msgID.$sentCounter TYPE=$type[$i] ROUTE=$gatewayDev STATUS=$routeStatus PRIORITY=$loopPriority TITLE='$loopTitle' '$msg'"
|
||||
if ( $subRecipient eq "" );
|
||||
$gatewaysStatus{$gatewayDev} = $routeStatus
|
||||
if ( $globalDevName ne $gatewayDev );
|
||||
$gatewaysStatus{$device} = $routeStatus
|
||||
if ( $globalDevName eq $gatewayDev );
|
||||
}
|
||||
else {
|
||||
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,
|
||||
"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 );
|
||||
$msgSentDev = 2 if ( $msgSentDev != 1 );
|
||||
$gatewaysStatus{$gatewayDev} = $routeStatus if ($globalDevName ne $gatewayDev);
|
||||
$gatewaysStatus{$device} = $routeStatus if ($globalDevName eq $gatewayDev);
|
||||
$gatewaysStatus{$gatewayDev} = $routeStatus
|
||||
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
|
||||
my $readingsDev = $defs{$device};
|
||||
$readingsDev = $defs{$globalDevName} if ( $catchall == 1 || $deviceType eq "email" );
|
||||
$readingsDev = $defs{$globalDevName}
|
||||
if ( $catchall == 1 || $deviceType eq "email" );
|
||||
readingsBeginUpdate($readingsDev);
|
||||
|
||||
readingsBulkUpdate( $readingsDev, "fhemMsg" . $typeUc,
|
||||
@ -1928,8 +2062,7 @@ s/^[\s\t]*\|([\w\süöäß^°!"§$%&\/\\()<>=?´`"+\[\]#*@€]+)\|[\s\t]+//
|
||||
readingsBulkUpdate( $readingsDev,
|
||||
"fhemMsg" . $typeUc . "Gw", $gwStates );
|
||||
readingsBulkUpdate( $readingsDev,
|
||||
"fhemMsg" . $typeUc . "State",
|
||||
$msgSentDev );
|
||||
"fhemMsg" . $typeUc . "State", $msgSentDev );
|
||||
|
||||
################################################################
|
||||
### Implicit forwards based on priority or presence
|
||||
@ -2068,10 +2201,28 @@ s/^[\s\t]*\|([\w\süöäß^°!"§$%&\/\\()<>=?´`"+\[\]#*@€]+)\|[\s\t]+//
|
||||
if ( $residentDevPresence ne ""
|
||||
|| $residentDevState ne "" );
|
||||
|
||||
my $fw_gwUnavailable = defined($settings->{ $type[$i] }{typeEscalation}{gwUnavailable}) ? $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} : "";
|
||||
my $fw_gwUnavailable =
|
||||
defined(
|
||||
$settings->{ $type[$i] }{typeEscalation}{gwUnavailable}
|
||||
)
|
||||
? $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
|
||||
# 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
|
||||
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 )
|
||||
if ( $forwarded eq "" );
|
||||
|
@ -56,33 +56,42 @@ my $db = {
|
||||
'ShortPrio' => 'set %DEVICE% talk |%TITLE%| %MSGSH%',
|
||||
'Short' => 'set %DEVICE% talk |%TITLE%| %MSGSH%',
|
||||
'defaultValues' => {
|
||||
'Normal' => {
|
||||
'TITLE' => 'Announcement',
|
||||
},
|
||||
'ShortPrio' => {
|
||||
'MSGSH' => 'Achtung!',
|
||||
'TITLE' => 'Announcement',
|
||||
},
|
||||
'Short' => {
|
||||
'MSGSH' => '',
|
||||
'TITLE' => 'Announcement',
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
'SONOSPLAYER' => {
|
||||
'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%',
|
||||
'defaultValues' => {
|
||||
'Normal' => {
|
||||
'VOLUME' => 38,
|
||||
'LANG' => 'de',
|
||||
'TITLE' => 'Announcement',
|
||||
},
|
||||
'ShortPrio' => {
|
||||
'VOLUME' => 33,
|
||||
'LANG' => 'de',
|
||||
'MSGSH' => 'Achtung!',
|
||||
'TITLE' => 'Announcement',
|
||||
},
|
||||
'Short' => {
|
||||
'VOLUME' => 28,
|
||||
'LANG' => 'de',
|
||||
'MSGSH' => '',
|
||||
'TITLE' => 'Announcement',
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -106,8 +115,10 @@ my $db = {
|
||||
'light' => {
|
||||
|
||||
'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"; }',
|
||||
'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"; }',
|
||||
'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"; }',
|
||||
'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',
|
||||
},
|
||||
|
||||
@ -116,19 +127,33 @@ my $db = {
|
||||
'mail' => {
|
||||
|
||||
'fhemMsgMail' => {
|
||||
'Normal' => '{ 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\'"); }',
|
||||
'Normal' =>
|
||||
'{ 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' => {
|
||||
|
||||
'Fhemapppush' => {
|
||||
'Normal' => 'set %DEVICE% message \'%TITLE%: %MSG%\' %ACTION%',
|
||||
'High' => 'set %DEVICE% message \'%TITLE%: %MSG%\' %ACTION%',
|
||||
'Low' => 'set %DEVICE% message \'%TITLE%: %MSG%\' %ACTION%',
|
||||
'Normal' => 'set %DEVICE% message \'%MSG%\' %ACTION%',
|
||||
'High' => 'set %DEVICE% message \'%MSG%\' %ACTION%',
|
||||
'Low' => 'set %DEVICE% message \'%MSG%\' %ACTION%',
|
||||
'defaultValues' => {
|
||||
'Normal' => {
|
||||
'ACTION' => '',
|
||||
@ -143,9 +168,9 @@ my $db = {
|
||||
},
|
||||
|
||||
'Jabber' => {
|
||||
'Normal' => 'set %DEVICE% msg %RECIPIENT% %TITLE%: %MSG%',
|
||||
'High' => 'set %DEVICE% msg %RECIPIENT% %TITLE%: %MSG%',
|
||||
'Low' => 'set %DEVICE% msg %RECIPIENT% %TITLE%: %MSG%',
|
||||
'Normal' => 'set %DEVICE% msg %RECIPIENT% %MSG%',
|
||||
'High' => 'set %DEVICE% msg %RECIPIENT% %MSG%',
|
||||
'Low' => 'set %DEVICE% msg %RECIPIENT% %MSG%',
|
||||
},
|
||||
|
||||
'Pushbullet' => {
|
||||
@ -155,26 +180,32 @@ my $db = {
|
||||
'defaultValues' => {
|
||||
'Normal' => {
|
||||
'RECIPIENT' => '',
|
||||
'TITLE' => '',
|
||||
},
|
||||
'High' => {
|
||||
'RECIPIENT' => '',
|
||||
'TITLE' => '',
|
||||
},
|
||||
'Low' => {
|
||||
'RECIPIENT' => '',
|
||||
'TITLE' => '',
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
'PushNotifier' => {
|
||||
'Normal' => 'set %DEVICE% message %TITLE%: %MSG%',
|
||||
'High' => 'set %DEVICE% message %TITLE%: %MSG%',
|
||||
'Low' => 'set %DEVICE% message %TITLE%: %MSG%',
|
||||
'Normal' => 'set %DEVICE% message %MSG%',
|
||||
'High' => 'set %DEVICE% message %MSG%',
|
||||
'Low' => 'set %DEVICE% message %MSG%',
|
||||
},
|
||||
|
||||
'Pushover' => {
|
||||
'Normal' => '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%',
|
||||
'Normal' =>
|
||||
'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' => {
|
||||
'Normal' => {
|
||||
'RECIPIENT' => '',
|
||||
@ -182,6 +213,7 @@ my $db = {
|
||||
'EXPIRE' => '',
|
||||
'URLTITLE' => '',
|
||||
'ACTION' => '',
|
||||
'TITLE' => 'System Message',
|
||||
'Pushover_SOUND' => '',
|
||||
},
|
||||
'High' => {
|
||||
@ -190,6 +222,7 @@ my $db = {
|
||||
'EXPIRE' => '600',
|
||||
'URLTITLE' => '',
|
||||
'ACTION' => '',
|
||||
'TITLE' => 'System Message',
|
||||
'Pushover_SOUND' => '',
|
||||
},
|
||||
'Low' => {
|
||||
@ -198,15 +231,16 @@ my $db = {
|
||||
'EXPIRE' => '',
|
||||
'URLTITLE' => '',
|
||||
'ACTION' => '',
|
||||
'TITLE' => 'System Message',
|
||||
'Pushover_SOUND' => '',
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
'TelegramBot' => {
|
||||
'Normal' => 'set %DEVICE% message %RECIPIENT% %TITLE%: %MSG%',
|
||||
'High' => 'set %DEVICE% message %RECIPIENT% %TITLE%: %MSG%',
|
||||
'Low' => 'set %DEVICE% message %RECIPIENT% %TITLE%: %MSG%',
|
||||
'Normal' => 'set %DEVICE% message %RECIPIENT% %MSG%',
|
||||
'High' => 'set %DEVICE% message %RECIPIENT% %MSG%',
|
||||
'Low' => 'set %DEVICE% message %RECIPIENT% %MSG%',
|
||||
'defaultValues' => {
|
||||
'Normal' => {
|
||||
'RECIPIENT' => '',
|
||||
@ -221,9 +255,9 @@ my $db = {
|
||||
},
|
||||
|
||||
'yowsup' => {
|
||||
'Normal' => 'set %DEVICE% send %RECIPIENT% %TITLE%: %MSG%',
|
||||
'High' => 'set %DEVICE% send %RECIPIENT% %TITLE%: %MSG%',
|
||||
'Low' => 'set %DEVICE% send %RECIPIENT% %TITLE%: %MSG%',
|
||||
'Normal' => 'set %DEVICE% send %RECIPIENT% %MSG%',
|
||||
'High' => 'set %DEVICE% send %RECIPIENT% %MSG%',
|
||||
'Low' => 'set %DEVICE% send %RECIPIENT% %MSG%',
|
||||
},
|
||||
|
||||
},
|
||||
@ -231,9 +265,9 @@ my $db = {
|
||||
'screen' => {
|
||||
|
||||
'AMAD' => {
|
||||
'Normal' => 'set %DEVICE% screenMsg %TITLE%: %MSG%',
|
||||
'High' => 'set %DEVICE% screenMsg %TITLE%: %MSG%',
|
||||
'Low' => 'set %DEVICE% screenMsg %TITLE%: %MSG%',
|
||||
'Normal' => 'set %DEVICE% screenMsg %MSG%',
|
||||
'High' => 'set %DEVICE% screenMsg %MSG%',
|
||||
'Low' => 'set %DEVICE% screenMsg %MSG%',
|
||||
},
|
||||
|
||||
'ENIGMA2' => {
|
||||
@ -257,9 +291,12 @@ my $db = {
|
||||
},
|
||||
|
||||
'XBMC' => {
|
||||
'Normal' => '{ 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 $title=\'%TITLE%\'; 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%"; }',
|
||||
'Normal' =>
|
||||
'{ my $dev=\'%DEVICE%\'; 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' => {
|
||||
'Normal' => {
|
||||
'TIMEOUT' => 8,
|
||||
|
Loading…
x
Reference in New Issue
Block a user