mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-03-03 16:56:54 +00:00
99_msg: add threshold attributes
git-svn-id: https://svn.fhem.de/fhem/trunk@9386 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
5c97f98be8
commit
5611ba3129
@ -87,6 +87,13 @@ sub msg_Initialize($$) {
|
|||||||
msgPriorityText:-2,-1,0,1,2
|
msgPriorityText:-2,-1,0,1,2
|
||||||
msgResidentsDev
|
msgResidentsDev
|
||||||
msgSwitcherDev
|
msgSwitcherDev
|
||||||
|
msgThPrioHigh:-2,-1,0,1,2
|
||||||
|
msgThPrioNormal:-2,-1,0,1,2
|
||||||
|
msgThPrioAudioEmergency:-2,-1,0,1,2
|
||||||
|
msgThPrioAudioHigh:-2,-1,0,1,2
|
||||||
|
msgThPrioTextEmergency:-2,-1,0,1,2
|
||||||
|
msgThPrioTextNormal:-2,-1,0,1,2
|
||||||
|
msgThPrioGwEmergency:-2,-1,0,1,2
|
||||||
msgTitleAudio
|
msgTitleAudio
|
||||||
msgTitleAudioShort
|
msgTitleAudioShort
|
||||||
msgTitleAudioShortPrio
|
msgTitleAudioShortPrio
|
||||||
@ -869,8 +876,100 @@ s/^[\s\t]*\|([\w\süöäß^°!"§$%&\/\\()<>=?´`"+\[\]#*@€]+)\|[\s\t]+//
|
|||||||
###
|
###
|
||||||
if ( $type[$i] eq "text" ) {
|
if ( $type[$i] eq "text" ) {
|
||||||
|
|
||||||
|
# user selected emergency priority text threshold
|
||||||
|
my $prioThresTextEmg =
|
||||||
|
# look for direct
|
||||||
|
AttrVal(
|
||||||
|
$device, "msgThPrioTextEmergency",
|
||||||
|
|
||||||
|
#look for indirect audio
|
||||||
|
AttrVal(
|
||||||
|
AttrVal( $device, "msgRecipient$typeUc", "" ),
|
||||||
|
"msgThPrioTextEmergency",
|
||||||
|
|
||||||
|
#look for indirect general
|
||||||
|
AttrVal(
|
||||||
|
AttrVal( $device, "msgRecipient", "" ),
|
||||||
|
"msgThPrioTextEmergency",
|
||||||
|
|
||||||
|
# look for global direct
|
||||||
|
AttrVal(
|
||||||
|
"global", "msgThPrioTextEmergency",
|
||||||
|
|
||||||
|
#look for global indirect type
|
||||||
|
AttrVal(
|
||||||
|
AttrVal(
|
||||||
|
"global",
|
||||||
|
"msgRecipient$typeUc", ""
|
||||||
|
),
|
||||||
|
"msgThPrioTextEmergency",
|
||||||
|
|
||||||
|
#look for global indirect general
|
||||||
|
AttrVal(
|
||||||
|
AttrVal(
|
||||||
|
"global", "msgRecipient",
|
||||||
|
""
|
||||||
|
),
|
||||||
|
"msgThPrioTextEmergency",
|
||||||
|
|
||||||
|
# default
|
||||||
|
"2"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
;
|
||||||
|
|
||||||
|
# user selected low priority text threshold
|
||||||
|
my $prioThresTextNormal =
|
||||||
|
# look for direct
|
||||||
|
AttrVal(
|
||||||
|
$device, "msgThPrioTextNormal",
|
||||||
|
|
||||||
|
#look for indirect audio
|
||||||
|
AttrVal(
|
||||||
|
AttrVal( $device, "msgRecipient$typeUc", "" ),
|
||||||
|
"msgThPrioTextNormal",
|
||||||
|
|
||||||
|
#look for indirect general
|
||||||
|
AttrVal(
|
||||||
|
AttrVal( $device, "msgRecipient", "" ),
|
||||||
|
"msgThPrioTextNormal",
|
||||||
|
|
||||||
|
# look for global direct
|
||||||
|
AttrVal(
|
||||||
|
"global", "msgThPrioTextNormal",
|
||||||
|
|
||||||
|
#look for global indirect type
|
||||||
|
AttrVal(
|
||||||
|
AttrVal(
|
||||||
|
"global",
|
||||||
|
"msgRecipient$typeUc", ""
|
||||||
|
),
|
||||||
|
"msgThPrioTextNormal",
|
||||||
|
|
||||||
|
#look for global indirect general
|
||||||
|
AttrVal(
|
||||||
|
AttrVal(
|
||||||
|
"global", "msgRecipient",
|
||||||
|
""
|
||||||
|
),
|
||||||
|
"msgThPrioTextNormal",
|
||||||
|
|
||||||
|
# default
|
||||||
|
"-2"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
;
|
||||||
|
|
||||||
# Decide push and/or e-mail destination based on priorities
|
# Decide push and/or e-mail destination based on priorities
|
||||||
if ( $loopPriority >= 2
|
if ( $loopPriority >= $prioThresTextEmg
|
||||||
&& $routes{push} == 1
|
&& $routes{push} == 1
|
||||||
&& $routes{mail} == 1 )
|
&& $routes{mail} == 1 )
|
||||||
{
|
{
|
||||||
@ -882,7 +981,7 @@ s/^[\s\t]*\|([\w\süöäß^°!"§$%&\/\\()<>=?´`"+\[\]#*@€]+)\|[\s\t]+//
|
|||||||
push @type, "push" if !( "push" ~~ @type );
|
push @type, "push" if !( "push" ~~ @type );
|
||||||
push @type, "mail" if !( "mail" ~~ @type );
|
push @type, "mail" if !( "mail" ~~ @type );
|
||||||
}
|
}
|
||||||
elsif ($loopPriority >= 2
|
elsif ($loopPriority >= $prioThresTextEmg
|
||||||
&& $routes{push} == 1
|
&& $routes{push} == 1
|
||||||
&& $routes{mail} == 0 )
|
&& $routes{mail} == 0 )
|
||||||
{
|
{
|
||||||
@ -893,7 +992,7 @@ 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 >= 2
|
elsif ($loopPriority >= $prioThresTextEmg
|
||||||
&& $routes{push} == 0
|
&& $routes{push} == 0
|
||||||
&& $routes{mail} == 1 )
|
&& $routes{mail} == 1 )
|
||||||
{
|
{
|
||||||
@ -904,7 +1003,7 @@ 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 >= -2 && $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 .= ","
|
||||||
@ -912,7 +1011,7 @@ 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 >= -2 && $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 .= ","
|
||||||
@ -981,7 +1080,7 @@ s/^[\s\t]*\|([\w\süöäß^°!"§$%&\/\\()<>=?´`"+\[\]#*@€]+)\|[\s\t]+//
|
|||||||
return "ROUTE_UNAVAILABLE" if ( $return ne "" );
|
return "ROUTE_UNAVAILABLE" if ( $return ne "" );
|
||||||
}
|
}
|
||||||
|
|
||||||
# user selected announcement state
|
# user selected audio-visual announcement state
|
||||||
my $annState = ReadingsVal(
|
my $annState = ReadingsVal(
|
||||||
|
|
||||||
# look for direct
|
# look for direct
|
||||||
@ -1002,7 +1101,7 @@ s/^[\s\t]*\|([\w\süöäß^°!"§$%&\/\\()<>=?´`"+\[\]#*@€]+)\|[\s\t]+//
|
|||||||
AttrVal(
|
AttrVal(
|
||||||
"global", "msgSwitcherDev",
|
"global", "msgSwitcherDev",
|
||||||
|
|
||||||
#look for global indirect audio
|
#look for global indirect type
|
||||||
AttrVal(
|
AttrVal(
|
||||||
AttrVal(
|
AttrVal(
|
||||||
"global",
|
"global",
|
||||||
@ -1030,15 +1129,199 @@ s/^[\s\t]*\|([\w\süöäß^°!"§$%&\/\\()<>=?´`"+\[\]#*@€]+)\|[\s\t]+//
|
|||||||
"long"
|
"long"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
# user selected emergency priority audio threshold
|
||||||
|
my $prioThresAudioEmg =
|
||||||
|
# look for direct
|
||||||
|
AttrVal(
|
||||||
|
$device, "msgThPrioAudioEmergency",
|
||||||
|
|
||||||
|
#look for indirect audio
|
||||||
|
AttrVal(
|
||||||
|
AttrVal( $device, "msgRecipient$typeUc", "" ),
|
||||||
|
"msgThPrioAudioEmergency",
|
||||||
|
|
||||||
|
#look for indirect general
|
||||||
|
AttrVal(
|
||||||
|
AttrVal( $device, "msgRecipient", "" ),
|
||||||
|
"msgThPrioAudioEmergency",
|
||||||
|
|
||||||
|
# look for global direct
|
||||||
|
AttrVal(
|
||||||
|
"global", "msgThPrioAudioEmergency",
|
||||||
|
|
||||||
|
#look for global indirect type
|
||||||
|
AttrVal(
|
||||||
|
AttrVal(
|
||||||
|
"global",
|
||||||
|
"msgRecipient$typeUc", ""
|
||||||
|
),
|
||||||
|
"msgThPrioAudioEmergency",
|
||||||
|
|
||||||
|
#look for global indirect general
|
||||||
|
AttrVal(
|
||||||
|
AttrVal(
|
||||||
|
"global", "msgRecipient",
|
||||||
|
""
|
||||||
|
),
|
||||||
|
"msgThPrioAudioEmergency",
|
||||||
|
|
||||||
|
# default
|
||||||
|
"2"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
;
|
||||||
|
|
||||||
|
# user selected high priority audio threshold
|
||||||
|
my $prioThresAudioHigh =
|
||||||
|
# look for direct
|
||||||
|
AttrVal(
|
||||||
|
$device, "msgThPrioAudioHigh",
|
||||||
|
|
||||||
|
#look for indirect audio
|
||||||
|
AttrVal(
|
||||||
|
AttrVal( $device, "msgRecipient$typeUc", "" ),
|
||||||
|
"msgThPrioAudioHigh",
|
||||||
|
|
||||||
|
#look for indirect general
|
||||||
|
AttrVal(
|
||||||
|
AttrVal( $device, "msgRecipient", "" ),
|
||||||
|
"msgThPrioAudioHigh",
|
||||||
|
|
||||||
|
# look for global direct
|
||||||
|
AttrVal(
|
||||||
|
"global", "msgThPrioAudioHigh",
|
||||||
|
|
||||||
|
#look for global indirect type
|
||||||
|
AttrVal(
|
||||||
|
AttrVal(
|
||||||
|
"global",
|
||||||
|
"msgRecipient$typeUc", ""
|
||||||
|
),
|
||||||
|
"msgThPrioAudioHigh",
|
||||||
|
|
||||||
|
#look for global indirect general
|
||||||
|
AttrVal(
|
||||||
|
AttrVal(
|
||||||
|
"global", "msgRecipient",
|
||||||
|
""
|
||||||
|
),
|
||||||
|
"msgThPrioAudioHigh",
|
||||||
|
|
||||||
|
# default
|
||||||
|
"1"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
;
|
||||||
|
|
||||||
|
# user selected high priority threshold
|
||||||
|
my $prioThresHigh =
|
||||||
|
# look for direct
|
||||||
|
AttrVal(
|
||||||
|
$device, "msgThPrioHigh",
|
||||||
|
|
||||||
|
#look for indirect audio
|
||||||
|
AttrVal(
|
||||||
|
AttrVal( $device, "msgRecipient$typeUc", "" ),
|
||||||
|
"msgThPrioHigh",
|
||||||
|
|
||||||
|
#look for indirect general
|
||||||
|
AttrVal(
|
||||||
|
AttrVal( $device, "msgRecipient", "" ),
|
||||||
|
"msgThPrioHigh",
|
||||||
|
|
||||||
|
# look for global direct
|
||||||
|
AttrVal(
|
||||||
|
"global", "msgThPrioHigh",
|
||||||
|
|
||||||
|
#look for global indirect type
|
||||||
|
AttrVal(
|
||||||
|
AttrVal(
|
||||||
|
"global",
|
||||||
|
"msgRecipient$typeUc", ""
|
||||||
|
),
|
||||||
|
"msgThPrioHigh",
|
||||||
|
|
||||||
|
#look for global indirect general
|
||||||
|
AttrVal(
|
||||||
|
AttrVal(
|
||||||
|
"global", "msgRecipient",
|
||||||
|
""
|
||||||
|
),
|
||||||
|
"msgThPrioHigh",
|
||||||
|
|
||||||
|
# default
|
||||||
|
"2"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
;
|
||||||
|
|
||||||
|
# user selected normal priority threshold
|
||||||
|
my $prioThresNormal =
|
||||||
|
# look for direct
|
||||||
|
AttrVal(
|
||||||
|
$device, "msgThPrioNormal",
|
||||||
|
|
||||||
|
#look for indirect audio
|
||||||
|
AttrVal(
|
||||||
|
AttrVal( $device, "msgRecipient$typeUc", "" ),
|
||||||
|
"msgThPrioNormal",
|
||||||
|
|
||||||
|
#look for indirect general
|
||||||
|
AttrVal(
|
||||||
|
AttrVal( $device, "msgRecipient", "" ),
|
||||||
|
"msgThPrioNormal",
|
||||||
|
|
||||||
|
# look for global direct
|
||||||
|
AttrVal(
|
||||||
|
"global", "msgThPrioNormal",
|
||||||
|
|
||||||
|
#look for global indirect type
|
||||||
|
AttrVal(
|
||||||
|
AttrVal(
|
||||||
|
"global",
|
||||||
|
"msgRecipient$typeUc", ""
|
||||||
|
),
|
||||||
|
"msgThPrioNormal",
|
||||||
|
|
||||||
|
#look for global indirect general
|
||||||
|
AttrVal(
|
||||||
|
AttrVal(
|
||||||
|
"global", "msgRecipient",
|
||||||
|
""
|
||||||
|
),
|
||||||
|
"msgThPrioNormal",
|
||||||
|
|
||||||
|
# default
|
||||||
|
"0"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
;
|
||||||
|
|
||||||
if ( $type[$i] eq "audio" ) {
|
if ( $type[$i] eq "audio" ) {
|
||||||
if ( $annState eq "long"
|
if ( $annState eq "long"
|
||||||
|| $forceType == 1
|
|| $forceType == 1
|
||||||
|| $forceDevice == 1
|
|| $forceDevice == 1
|
||||||
|| $loopPriority >= 2 )
|
|| $loopPriority >= $prioThresAudioEmg )
|
||||||
{
|
{
|
||||||
$priorityCat = "";
|
$priorityCat = "";
|
||||||
}
|
}
|
||||||
elsif ( $loopPriority >= 1 ) {
|
elsif ( $loopPriority >= $prioThresAudioHigh ) {
|
||||||
$priorityCat = "ShortPrio";
|
$priorityCat = "ShortPrio";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -1046,10 +1329,10 @@ s/^[\s\t]*\|([\w\süöäß^°!"§$%&\/\\()<>=?´`"+\[\]#*@€]+)\|[\s\t]+//
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if ( $loopPriority >= 2 ) {
|
if ( $loopPriority >= $prioThresHigh ) {
|
||||||
$priorityCat = "High";
|
$priorityCat = "High";
|
||||||
}
|
}
|
||||||
elsif ( $loopPriority >= 0 ) {
|
elsif ( $loopPriority >= $prioThresNormal ) {
|
||||||
$priorityCat = "";
|
$priorityCat = "";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -1280,6 +1563,52 @@ s/^[\s\t]*\|([\w\süöäß^°!"§$%&\/\\()<>=?´`"+\[\]#*@€]+)\|[\s\t]+//
|
|||||||
### Send message
|
### Send message
|
||||||
###
|
###
|
||||||
|
|
||||||
|
# user selected emergency priority text threshold
|
||||||
|
my $prioThresGwEmg =
|
||||||
|
# look for direct
|
||||||
|
AttrVal(
|
||||||
|
$device, "msgThPrioGwEmergency",
|
||||||
|
|
||||||
|
#look for indirect type
|
||||||
|
AttrVal(
|
||||||
|
AttrVal( $device, "msgRecipient$typeUc", "" ),
|
||||||
|
"msgThPrioGwEmergency",
|
||||||
|
|
||||||
|
#look for indirect general
|
||||||
|
AttrVal(
|
||||||
|
AttrVal( $device, "msgRecipient", "" ),
|
||||||
|
"msgThPrioGwEmergency",
|
||||||
|
|
||||||
|
# look for global direct
|
||||||
|
AttrVal(
|
||||||
|
"global", "msgThPrioGwEmergency",
|
||||||
|
|
||||||
|
#look for global indirect type
|
||||||
|
AttrVal(
|
||||||
|
AttrVal(
|
||||||
|
"global",
|
||||||
|
"msgRecipient$typeUc", ""
|
||||||
|
),
|
||||||
|
"msgThPrioGwEmergency",
|
||||||
|
|
||||||
|
#look for global indirect general
|
||||||
|
AttrVal(
|
||||||
|
AttrVal(
|
||||||
|
"global", "msgRecipient",
|
||||||
|
""
|
||||||
|
),
|
||||||
|
"msgThPrioGwEmergency",
|
||||||
|
|
||||||
|
# default
|
||||||
|
"2"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
;
|
||||||
|
|
||||||
my %gatewaysStatus;
|
my %gatewaysStatus;
|
||||||
|
|
||||||
foreach my $gatewayDevOr ( split /\|/, $gatewayDevs ) {
|
foreach my $gatewayDevOr ( split /\|/, $gatewayDevs ) {
|
||||||
@ -1287,16 +1616,6 @@ s/^[\s\t]*\|([\w\süöäß^°!"§$%&\/\\()<>=?´`"+\[\]#*@€]+)\|[\s\t]+//
|
|||||||
Log3 $logDevice, 5,
|
Log3 $logDevice, 5,
|
||||||
"msg $device: Trying to send message via gateway $gatewayDev";
|
"msg $device: Trying to send message via gateway $gatewayDev";
|
||||||
|
|
||||||
# restricted priority scope for Pushover
|
|
||||||
if ( $type[$i] eq "push"
|
|
||||||
&& $defs{$gatewayDev}{TYPE} eq "Pushover" )
|
|
||||||
{
|
|
||||||
$loopPriority = 2
|
|
||||||
if ( $loopPriority > 2 );
|
|
||||||
$loopPriority = -2
|
|
||||||
if ( $loopPriority < -2 );
|
|
||||||
}
|
|
||||||
|
|
||||||
##############
|
##############
|
||||||
# check for gateway availability and set route status
|
# check for gateway availability and set route status
|
||||||
#
|
#
|
||||||
@ -1374,7 +1693,7 @@ s/^[\s\t]*\|([\w\süöäß^°!"§$%&\/\\()<>=?´`"+\[\]#*@€]+)\|[\s\t]+//
|
|||||||
$routeStatus eq "USER_DISABLED"
|
$routeStatus eq "USER_DISABLED"
|
||||||
|| $routeStatus eq "USER_ABSENT"
|
|| $routeStatus eq "USER_ABSENT"
|
||||||
)
|
)
|
||||||
&& $loopPriority >= 2
|
&& $loopPriority >= $prioThresGwEmg
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
$routeStatus = "OK_EMERGENCY";
|
$routeStatus = "OK_EMERGENCY";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user