From 2f170fb156d88db3e2380f08743b05a28f819eee Mon Sep 17 00:00:00 2001 From: Schlump <8473452+Schlump@users.noreply.github.com> Date: Sat, 16 Mar 2024 15:34:10 +0100 Subject: [PATCH 1/2] Update config.json --- front/plugins/_publisher_pushover/config.json | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/front/plugins/_publisher_pushover/config.json b/front/plugins/_publisher_pushover/config.json index cec4be3a..e48394d5 100755 --- a/front/plugins/_publisher_pushover/config.json +++ b/front/plugins/_publisher_pushover/config.json @@ -404,6 +404,28 @@ "string": "Your Pushover APP Token." } ] + }, + { + "function": "DEVICE_NAME", + "type": "text", + "default_value": "DEVICE_NAME", + "options": [], + "localized": [ + "name", + "description" + ], + "name": [ + { + "language_code": "en_us", + "string": "Pushover Device name (not required)" + } + ], + "description": [ + { + "language_code": "en_us", + "string": "When specifying a device name, notifications will be exclusively sent to the device." + } + ] } ] -} \ No newline at end of file +} From 195206c6995e25b1355f658f31dd10bc8a456d60 Mon Sep 17 00:00:00 2001 From: Schlump <8473452+Schlump@users.noreply.github.com> Date: Sat, 16 Mar 2024 15:34:22 +0100 Subject: [PATCH 2/2] Update pushover.py --- front/plugins/_publisher_pushover/pushover.py | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/front/plugins/_publisher_pushover/pushover.py b/front/plugins/_publisher_pushover/pushover.py index 78c8c4b3..3cb664dd 100755 --- a/front/plugins/_publisher_pushover/pushover.py +++ b/front/plugins/_publisher_pushover/pushover.py @@ -71,18 +71,28 @@ def send(text): user_key = get_setting_value("PUSHOVER_USER_KEY") app_token = get_setting_value("PUSHOVER_APP_TOKEN") + device_name = ( + None + if get_setting_value("PUSHOVER_DEVICE_NAME") == "DEVICE_NAME" + else get_setting_value("PUSHOVER_DEVICE_NAME") + ) mylog("verbose", f'[{pluginName}] PUSHOVER_USER_KEY: "{hide_string(user_key)}"') mylog("verbose", f'[{pluginName}] PUSHOVER_APP_TOKEN: "{hide_string(app_token)}"') + data = {"token": app_token, "user": user_key, "message": text} + # Add device_name to the data dictionary only if it is not None + if device_name: + data["device"] = device_name + try: - response = requests.post( - "https://api.pushover.net/1/messages.json", - data={"token": app_token, "user": user_key, "message": text}, - ) + response = requests.post("https://api.pushover.net/1/messages.json", data=data) + + # Update response_status_code with the actual status code from the response + response_status_code = response.status_code # Check if the request was successful (status code 200) - if response.status_code == 200: + if response_status_code == 200: response_text = response.text # This captures the response body/message else: response_text = json.dumps(response.text)