Skip to content

Commit

Permalink
pushover: add ttl parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
stoepf committed Nov 22, 2023
1 parent 3ac1457 commit 7d25c2b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
8 changes: 6 additions & 2 deletions pushover/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ Pushover is one out of many push services, which is compatible with Android, IOS

---
## Changelog
__2023-11-22__:
* add ttl parameter

__2018-10-04__:

* Use new lib.network
Expand Down Expand Up @@ -40,7 +43,7 @@ Description of the attributes:
---
## Usage:

### sh.po(title, message [, priority] [, retry] [, expire] [, sound] [, url] [, url_title] [, device] [, userKey] [, apiKey])
### sh.po(title, message [, priority] [, retry] [, expire] [, ttl] [, sound] [, url] [, url_title] [, device] [, userKey] [, apiKey])
Send a message to your device.

#### Parameters
Expand All @@ -49,6 +52,7 @@ Send a message to your device.
* __priority__: Priority of the message - read https://pushover.net/api#priority
* __retry__: when Emergency priority set, this specifies how often (in seconds) the Pushover servers will send the same notification to the user - read https://pushover.net/api#priority
* __expire__: when Emergency priority set, this specifies how many seconds your notification will continue to be retried for (every retry seconds) - read https://pushover.net/api#priority
* __ttl__: specifies the time to live in seconds (ignored for priority 2 messages) - read https://pushover.net/api#ttl
* __sound__: override a user's default tone choice on a per-notification basis - read https://pushover.net/api#sounds
* __url__: adds a supplementary URL that is not included in the message text, but available for the user to click on - read https://pushover.net/api#urls
* __url_title__: the title for the a supplementary URL - read https://pushover.net/api#urls
Expand All @@ -72,7 +76,7 @@ sh.po("Simple Test", "This is my test message.")
sh.po("Warning", "Your door is not locked!", 1)

# send simple message to device with id: e6653
sh.po("Simple Test", "This is my test message", None, None, None, None, None, None, "e6653")
sh.po("Simple Test", "This is my test message", device="e6653")

# send a message with an attached image (camera snapshot for example)
sh.po(title="Simple Test", message="This is my test message", attachment="/tmp/snapshot.jpg")
Expand Down
7 changes: 5 additions & 2 deletions pushover/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

class Pushover(SmartPlugin):

PLUGIN_VERSION = "1.6.1"
PLUGIN_VERSION = "1.6.2"

_url = "https://api.pushover.net/1/messages.json"

Expand All @@ -49,7 +49,7 @@ def run(self):
def stop(self):
self.alive = False

def __call__(self, title=None, message='', priority=None, retry=None, expire=None, sound=None, url=None, url_title=None, device=None, userKey=None, apiKey=None, attachment=None):
def __call__(self, title=None, message='', priority=None, retry=None, expire=None, ttl=None, sound=None, url=None, url_title=None, device=None, userKey=None, apiKey=None, attachment=None):
data = {}

data['timestamp'] = int(time.time())
Expand Down Expand Up @@ -93,6 +93,9 @@ def __call__(self, title=None, message='', priority=None, retry=None, expire=Non
else:
self.logger.error("Pushover message priority need to be a number between -2 and 2!")

if ttl:
data['ttl'] = ttl

if sound:
data['sound'] = sound

Expand Down
2 changes: 1 addition & 1 deletion pushover/plugin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ plugin:
maintainer: 'Thomas Creutz'
tester: None
state: ready
version: 1.6.1 # Plugin version
version: 1.6.2 # Plugin version
sh_minversion: 1.5 # minimum shNG version to use this plugin
multi_instance: True # plugin supports multi instance
restartable: unknown
Expand Down

0 comments on commit 7d25c2b

Please sign in to comment.