finalized support for Pushover

This commit is contained in:
2024-10-30 15:43:06 -04:00
parent 2849f54932
commit 94db527500
6 changed files with 397 additions and 69 deletions

View File

@@ -1637,40 +1637,48 @@ properties:
priority:
type: integer
description: |
A value of -2, -1, 0 (default), 1 or 2 that
indicates the message priority.
example: "0"
A value of -2, -1, 0 (default), 1 or 2 that indicates the message priority.
example: 0
expire:
type: integer
description: |
he expire parameter specifies how many seconds
your notification will continue to be retried
for (every retry seconds).
example: 1200
retry:
type: integer
description: |
The retry parameter specifies how often
(in seconds) the Pushover servers will send the
same notification to the user.
example: 30
device:
type: string
description: |
The name of one of your devices to send just to that
device instead of all devices.
The name of one of your devices to send just to that device instead of all devices.
example: pixel8
html:
type: integer
description: |
Set to 1 to enable HTML parsing of the message. Set
to 0 for plain text.
Set to 1 to enable HTML parsing of the message. Set to 0 for plain text.
example: 1
sound:
type: string
description: |
The name of a supported sound to override your
default sound choice. All options can be
found here: https://pushover.net/api#sounds
The name of a supported sound to override your default sound choice. All
options can be found here: https://pushover.net/api#sounds
example: bike
title:
type: string
description: |
Your message's title, otherwise your app's
name is used.
Your message's title, otherwise your app's name is used.
example: A backup job has started.
ttl:
type: integer
description: |
The number of seconds that the message will live,
before being deleted automatically. The ttl
parameter is ignored for messages with a priority
The number of seconds that the message will live, before being deleted
automatically. The ttl parameter is ignored for messages with a priority
value of 2.
example: 3600
url:
@@ -1681,8 +1689,8 @@ properties:
url_title:
type: string
description: |
A title for the URL specified as the url parameter,
otherwise just the URL is shown.
A title for the URL specified as the url parameter, otherwise just
the URL is shown.
example: Pushover Link
finish:
type: object
@@ -1696,40 +1704,48 @@ properties:
priority:
type: integer
description: |
A value of -2, -1, 0 (default), 1 or 2 that
indicates the message priority.
example: "0"
A value of -2, -1, 0 (default), 1 or 2 that indicates the message priority.
example: 0
expire:
type: integer
description: |
he expire parameter specifies how many seconds
your notification will continue to be retried
for (every retry seconds).
example: 1200
retry:
type: integer
description: |
The retry parameter specifies how often
(in seconds) the Pushover servers will send the
same notification to the user.
example: 30
device:
type: string
description: |
The name of one of your devices to send just to that
device instead of all devices.
The name of one of your devices to send just to that device instead of all devices.
example: pixel8
html:
type: integer
description: |
Set to 1 to enable HTML parsing of the message. Set
to 0 for plain text.
Set to 1 to enable HTML parsing of the message. Set to 0 for plain text.
example: 1
sound:
type: string
description: |
The name of a supported sound to override your
default sound choice. All options can be
found here: https://pushover.net/api#sounds
The name of a supported sound to override your default sound choice. All
options can be found here: https://pushover.net/api#sounds
example: bike
title:
type: string
description: |
Your message's title, otherwise your app's
name is used.
Your message's title, otherwise your app's name is used.
example: A backup job has started.
ttl:
type: integer
description: |
The number of seconds that the message will live,
before being deleted automatically. The ttl
parameter is ignored for messages with a priority
The number of seconds that the message will live, before being deleted
automatically. The ttl parameter is ignored for messages with a priority
value of 2.
example: 3600
url:
@@ -1740,8 +1756,8 @@ properties:
url_title:
type: string
description: |
A title for the URL specified as the url parameter,
otherwise just the URL is shown.
A title for the URL specified as the url parameter, otherwise just
the URL is shown.
example: Pushover Link
fail:
type: object
@@ -1754,40 +1770,48 @@ properties:
priority:
type: integer
description: |
A value of -2, -1, 0 (default), 1 or 2 that
indicates the message priority.
example: "0"
A value of -2, -1, 0 (default), 1 or 2 that indicates the message priority.
example: 0
expire:
type: integer
description: |
he expire parameter specifies how many seconds
your notification will continue to be retried
for (every retry seconds).
example: 1200
retry:
type: integer
description: |
The retry parameter specifies how often
(in seconds) the Pushover servers will send the
same notification to the user.
example: 30
device:
type: string
description: |
The name of one of your devices to send just to that
device instead of all devices.
The name of one of your devices to send just to that device instead of all devices.
example: pixel8
html:
type: integer
description: |
Set to 1 to enable HTML parsing of the message. Set
to 0 for plain text.
Set to 1 to enable HTML parsing of the message. Set to 0 for plain text.
example: 1
sound:
type: string
description: |
The name of a supported sound to override your
default sound choice. All options can be
found here: https://pushover.net/api#sounds
The name of a supported sound to override your default sound choice. All
options can be found here: https://pushover.net/api#sounds
example: bike
title:
type: string
description: |
Your message's title, otherwise your app's
name is used.
Your message's title, otherwise your app's name is used.
example: A backup job has started.
ttl:
type: integer
description: |
The number of seconds that the message will live,
before being deleted automatically. The ttl
parameter is ignored for messages with a priority
The number of seconds that the message will live, before being deleted
automatically. The ttl parameter is ignored for messages with a priority
value of 2.
example: 3600
url:
@@ -1798,8 +1822,8 @@ properties:
url_title:
type: string
description: |
A title for the URL specified as the url parameter,
otherwise just the URL is shown.
A title for the URL specified as the url parameter, otherwise just
the URL is shown.
example: Pushover Link
states:
type: array

View File

@@ -46,18 +46,25 @@ def ping_monitor(hook_config, config, config_filename, state, monitoring_log_lev
logger.warning(f'{config_filename}: User missing for Pushover')
return
if 'priority' in state_config and state_config['priority'] == 2:
if 'expire' not in state_config:
logger.info(f'{config_filename}: Setting expire to default (10min).')
state_config['expire'] = 1200
if 'retry' not in state_config:
logger.info(f'{config_filename}: Setting retry to default (30sec).')
state_config['retry'] = 30
else:
state_config.pop('expire', None)
state_config.pop('retry', None)
data = {
'token': token,
'user': user,
'message': state.name.lower(), # default to state name. Can be overwritten in state_config loop below.
}
for key in state_config:
data[key] = state_config[key]
if key == 'priority':
if data['priority'] == 2:
data['expire'] = 30
data['retry'] = 30
if not dry_run:
logging.getLogger('urllib3').setLevel(logging.ERROR)