mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-23 20:52:13 +00:00
Added possibility for emergency priority to pushover module.
git-svn-id: https://svn.fhem.de/fhem/trunk@4309 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
beb17f49ce
commit
923c454c69
@ -14,14 +14,16 @@
|
|||||||
#
|
#
|
||||||
#
|
#
|
||||||
# You can send messages via the following command:
|
# You can send messages via the following command:
|
||||||
# set <Pushover_device> msg <title> <msg> <device> <priority> <sound>
|
# set <Pushover_device> msg <title> <msg> <device> <priority> <sound> [<retry> <expire>]
|
||||||
#
|
#
|
||||||
# Example:
|
# Examples:
|
||||||
# set Pushover1 msg 'Titel' 'This is a text.' '' 0 ''
|
# set Pushover1 msg 'Titel' 'This is a text.' '' 0 ''
|
||||||
|
# set Pushover1 msg 'Emergency' 'Security issue in living room.' '' 2 'siren' 30 3600
|
||||||
#
|
#
|
||||||
# Explantation:
|
# Explantation:
|
||||||
# If device is empty, the message will be sent to all devices.
|
# If device is empty, the message will be sent to all devices.
|
||||||
# If sound is empty, the default setting in the app will be used.
|
# If sound is empty, the default setting in the app will be used.
|
||||||
|
# If priority is higher or equal 2, retry and expire must be defined.
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# For further documentation of these parameters:
|
# For further documentation of these parameters:
|
||||||
@ -84,13 +86,40 @@ sub Pushover_Set_Message
|
|||||||
my $hash = shift;
|
my $hash = shift;
|
||||||
|
|
||||||
my $attr = join(" ", @_);
|
my $attr = join(" ", @_);
|
||||||
$attr =~ /(".*"|'.*')\s*(".*"|'.*')\s*(".*"|'.*')\s*(\d+)\s*(".*"|'.*')\s*$/s;
|
|
||||||
|
|
||||||
my $title = $1;
|
my $shortExpressionMatched = 0;
|
||||||
my $message = $2;
|
my $longExpressionMatched = 0;
|
||||||
my $device = $3;
|
|
||||||
my $priority = $4;
|
if($attr =~ /(".*"|'.*')\s*(".*"|'.*')\s*(".*"|'.*')\s*(\d+)\s*(".*"|'.*')\s*(\d+)\s*(\d+)\s*$/s)
|
||||||
my $sound = $5;
|
{
|
||||||
|
$longExpressionMatched = 1;
|
||||||
|
}
|
||||||
|
elsif($attr =~ /(".*"|'.*')\s*(".*"|'.*')\s*(".*"|'.*')\s*(\d+)\s*(".*"|'.*')\s*$/s)
|
||||||
|
{
|
||||||
|
$shortExpressionMatched = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
my $title = "";
|
||||||
|
my $message = "";
|
||||||
|
my $device = "";
|
||||||
|
my $priority = "";
|
||||||
|
my $sound = "";
|
||||||
|
my $retry = "";
|
||||||
|
my $expire = "";
|
||||||
|
|
||||||
|
if(($shortExpressionMatched == 1) || ($longExpressionMatched == 1))
|
||||||
|
{
|
||||||
|
$title = $1;
|
||||||
|
$message = $2;
|
||||||
|
$device = $3;
|
||||||
|
$priority = $4;
|
||||||
|
$sound = $5;
|
||||||
|
|
||||||
|
if($longExpressionMatched == 1)
|
||||||
|
{
|
||||||
|
$retry = $6;
|
||||||
|
$expire = $7;
|
||||||
|
}
|
||||||
|
|
||||||
if($title =~ /^['"](.*)['"]$/s)
|
if($title =~ /^['"](.*)['"]$/s)
|
||||||
{
|
{
|
||||||
@ -117,7 +146,18 @@ sub Pushover_Set_Message
|
|||||||
$sound = $1;
|
$sound = $1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(($title ne "") && ($message ne ""))
|
if($retry =~ /^['"](.*)['"]$/s)
|
||||||
|
{
|
||||||
|
$retry = $1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($expire =~ /^['"](.*)['"]$/s)
|
||||||
|
{
|
||||||
|
$expire = $1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if((($title ne "") && ($message ne "")) && ((($retry ne "") && ($expire ne "")) || ($priority < 2)))
|
||||||
{
|
{
|
||||||
my $body = "token=" . $hash->{Token} . "&" .
|
my $body = "token=" . $hash->{Token} . "&" .
|
||||||
"user=" . $hash->{User} . "&" .
|
"user=" . $hash->{User} . "&" .
|
||||||
@ -139,11 +179,21 @@ sub Pushover_Set_Message
|
|||||||
$body = $body . "&" . "sound=" . $sound;
|
$body = $body . "&" . "sound=" . $sound;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($retry ne "")
|
||||||
|
{
|
||||||
|
$body = $body . "&" . "retry=" . $retry;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($expire ne "")
|
||||||
|
{
|
||||||
|
$body = $body . "&" . "expire=" . $expire;
|
||||||
|
}
|
||||||
|
|
||||||
return Pushover_HTTP_Call($hash, $body);
|
return Pushover_HTTP_Call($hash, $body);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return "Syntax: set <Pushover_device> msg <title> <msg> <device> <priority> <sound>";
|
return "Syntax: set <Pushover_device> msg <title> <msg> <device> <priority> <sound> [<retry> <expire>]";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user