From b9c6838db555f19c4b5a8ebed459a74c7148c9d6 Mon Sep 17 00:00:00 2001 From: talkabout <> Date: Tue, 2 Feb 2016 19:23:13 +0000 Subject: [PATCH] 70_Pushalot: added support for TimeToLive parameter. git-svn-id: https://svn.fhem.de/fhem/trunk@10699 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/CHANGED | 1 + fhem/FHEM/70_Pushalot.pm | 41 +++++++++++++++++++++++++++------------- 2 files changed, 29 insertions(+), 13 deletions(-) diff --git a/fhem/CHANGED b/fhem/CHANGED index d7ec67514..bfdcbbdf3 100644 --- a/fhem/CHANGED +++ b/fhem/CHANGED @@ -1,5 +1,6 @@ # Add changes at the top of the list. Keep it in ASCII, and 80-char wide. # Do not insert empty lines here, update check depends on it. + - feature: 70_Pushalot: added support for TimeToLive parameter. - bugfix: 60_allergy: fixed invalid readings names - bugfix: 73_km200: Little Bugfix with the use around Regular Expressions - feature: 91_notify: add readLog attribute diff --git a/fhem/FHEM/70_Pushalot.pm b/fhem/FHEM/70_Pushalot.pm index e8c5364f6..54bd137cb 100644 --- a/fhem/FHEM/70_Pushalot.pm +++ b/fhem/FHEM/70_Pushalot.pm @@ -24,6 +24,7 @@ # set PushNotification message "This is my message." "With Title" "http://www.xyz/image.png" "http://www.xyz.com"" # set PushNotification message "This is my message." "With Title" "http://www.xyz/image.png" "http://www.xyz.com" "Link Title" # set PushNotification message "This is my message." "With Title" "http://www.xyz/image.png" "http://www.xyz.com" "Link Title" True False +# set PushNotification message "This is my message." "With Title" "http://www.xyz/image.png" "http://www.xyz.com" "Link Title" True False 5 # # Explantation: # @@ -34,6 +35,8 @@ # - The fifth parameter is an optional link title for the message # - The sixth parameter defines whether the message should be marked as important # - The seventh parameter defines whether the message should be delivered silently +# - The eigth parameter defines the "time to live" in seconds for the message. After this time the message is automatically purged. Note: The Pushalot service is checking +# messages for purge every 5 minutes # # For further documentation # https://pushalot.com/api: @@ -139,17 +142,18 @@ sub Pushalot_Build_Body($@) my ($hash, @args) = @_; my $string = join(" ", @args); - my @matches = ($string =~ /"[^"]*"| True| False/g); + my @matches = ($string =~ /"[^"]*"| True| False| \d+/g); - my ($message, $title, $image, $link, $linkTitle, $important, $silent) = @matches; + my ($message, $title, $image, $link, $linkTitle, $important, $silent, $timeToLive) = @matches; - $message =~ s/^[\s"]+|[\s"]+$//g; - $title =~ s/^[\s"]+|[\s"]+$//g; - $image =~ s/^[\s"]+|[\s"]+$//g; - $link =~ s/^[\s"]+|[\s"]+$//g; - $linkTitle =~ s/^[\s"]+|[\s"]+$//g; - $important =~ s/^[\s"]+|[\s"]+$//g; - $silent =~ s/^[\s"]+|[\s"]+$//g; + $message =~ s/^[\s"]+|[\s"]+$//g; + $title =~ s/^[\s"]+|[\s"]+$//g; + $image =~ s/^[\s"]+|[\s"]+$//g; + $link =~ s/^[\s"]+|[\s"]+$//g; + $linkTitle =~ s/^[\s"]+|[\s"]+$//g; + $important =~ s/^[\s"]+|[\s"]+$//g; + $silent =~ s/^[\s"]+|[\s"]+$//g; + $timeToLive =~ s/^[\s"]+|[\s"]+$//g; if ($message eq "") { @@ -162,11 +166,12 @@ sub Pushalot_Build_Body($@) . "&Source=" . $hash->{Source} . "&Body=" . uri_escape($message) . "&Title=" . uri_escape($title) - . "&Image=" . uri_escape($image) - . "&Link=" . uri_escape($link) - . "&LinkTitle=" . uri_escape($linkTitle) + . ($image ? "&Image=" . uri_escape($image) : "") + . ($link ? "&Link=" . uri_escape($link) : "") + . ($linkTitle ? "&LinkTitle=" . uri_escape($linkTitle) : "") . "&IsImportant=" . $important - . "&IsSilent=" . $silent; + . "&IsSilent=" . $silent + . "&TimeToLive=" . $timeToLive; } #------------------------------------------------------------------------------ @@ -317,6 +322,10 @@ sub Pushalot_Parse_Result($$$)
set PushNotification message "This is my message." "With Title" "http://www.xyz.com/image.png" "http://www.xyz.com" "Link Title"
set PushNotification message "This is my message." "With Title" "http://www.xyz.com/image.png" "http://www.xyz.com" "Link Title" True
set PushNotification message "This is my message." "With Title" "http://www.xyz.com/image.png" "http://www.xyz.com" "Link Title" True False
set PushNotification message "This is my message." "With Title" "http://www.xyz.com/image.png" "http://www.xyz.com" "Link Title" True False 5
set PushNotification message "Das ist meine Nachricht." "Mit Titel" "http://www.xyz.com/image.png" "http://www.xyz.com" "Link Titel"
set PushNotification message "Das ist meine Nachricht." "Mit Titel" "http://www.xyz.com/image.png" "http://www.xyz.com" "Link Titel" True
set PushNotification message "Das ist meine Nachricht." "Mit Titel" "http://www.xyz.com/image.png" "http://www.xyz.com" "Link Title" True False
set PushNotification message "Das ist meine Nachricht." "Mit Titel" "http://www.xyz.com/image.png" "http://www.xyz.com" "Link Title" True False 5